mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 19:23:26 +00:00
perf: 离职移交部门
This commit is contained in:
parent
0e71efd714
commit
0cc1469589
@ -766,30 +766,6 @@ class UsersController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
$userTransfer->save();
|
$userTransfer->save();
|
||||||
$userTransfer->start();
|
$userTransfer->start();
|
||||||
// 离职移出群组
|
|
||||||
WebSocketDialog::select(['web_socket_dialogs.*'])
|
|
||||||
->join('web_socket_dialog_users as u', 'web_socket_dialogs.id', '=', 'u.dialog_id')
|
|
||||||
->where('web_socket_dialogs.type', 'group')
|
|
||||||
->where('u.userid', $userInfo->userid)
|
|
||||||
->orderByDesc('web_socket_dialogs.id')
|
|
||||||
->chunk(100, function($list) use ($transferUser, $userInfo) {
|
|
||||||
/** @var WebSocketDialog $dialog */
|
|
||||||
foreach ($list as $dialog) {
|
|
||||||
// 离职员工退出群
|
|
||||||
$dialog->exitGroup($userInfo->userid, 'remove', false, false);
|
|
||||||
if ($dialog->owner_id === $userInfo->userid) {
|
|
||||||
// 如果是群主则把交接人设为群主
|
|
||||||
$dialog->owner_id = $transferUser->userid;
|
|
||||||
if ($dialog->save()) {
|
|
||||||
$dialog->joinGroup($transferUser->userid, 0);
|
|
||||||
$dialog->pushMsg("groupUpdate", [
|
|
||||||
'id' => $dialog->id,
|
|
||||||
'owner_id' => $dialog->owner_id,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} elseif ($type === 'cleardisable') {
|
} elseif ($type === 'cleardisable') {
|
||||||
// 取消离职重新加入全员群组
|
// 取消离职重新加入全员群组
|
||||||
if (Base::settingFind('system', 'all_group_autoin', 'yes') === 'yes') {
|
if (Base::settingFind('system', 'all_group_autoin', 'yes') === 'yes') {
|
||||||
|
|||||||
@ -132,4 +132,22 @@ class UserDepartment extends AbstractModel
|
|||||||
//
|
//
|
||||||
$this->delete();
|
$this->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移交部门身份
|
||||||
|
* @param $originalUserid
|
||||||
|
* @param $newUserid
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function transfer($originalUserid, $newUserid)
|
||||||
|
{
|
||||||
|
self::whereOwnerUserid($originalUserid)->chunkById(100, function ($list) use ($originalUserid, $newUserid) {
|
||||||
|
/** @var self $item */
|
||||||
|
foreach ($list as $item) {
|
||||||
|
$item->saveDepartment([
|
||||||
|
'owner_userid' => $newUserid,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,11 +35,37 @@ class UserTransfer extends AbstractModel
|
|||||||
*/
|
*/
|
||||||
public function start()
|
public function start()
|
||||||
{
|
{
|
||||||
|
// 移交部门
|
||||||
|
UserDepartment::transfer($this->original_userid, $this->new_userid);
|
||||||
// 移交项目身份
|
// 移交项目身份
|
||||||
ProjectUser::transfer($this->original_userid, $this->new_userid);
|
ProjectUser::transfer($this->original_userid, $this->new_userid);
|
||||||
// 移交任务身份
|
// 移交任务身份
|
||||||
ProjectTaskUser::transfer($this->original_userid, $this->new_userid);
|
ProjectTaskUser::transfer($this->original_userid, $this->new_userid);
|
||||||
// 移交文件
|
// 移交文件
|
||||||
File::transfer($this->original_userid, $this->new_userid);
|
File::transfer($this->original_userid, $this->new_userid);
|
||||||
|
// 离职移出群组
|
||||||
|
WebSocketDialog::select(['web_socket_dialogs.*'])
|
||||||
|
->join('web_socket_dialog_users as u', 'web_socket_dialogs.id', '=', 'u.dialog_id')
|
||||||
|
->where('web_socket_dialogs.type', 'group')
|
||||||
|
->where('u.userid', $this->original_userid)
|
||||||
|
->orderByDesc('web_socket_dialogs.id')
|
||||||
|
->chunk(100, function($list) {
|
||||||
|
/** @var WebSocketDialog $dialog */
|
||||||
|
foreach ($list as $dialog) {
|
||||||
|
// 离职员工退出群
|
||||||
|
$dialog->exitGroup($this->original_userid, 'remove', false, false);
|
||||||
|
if ($dialog->owner_id === $this->original_userid) {
|
||||||
|
// 如果是群主则把交接人设为群主
|
||||||
|
$dialog->owner_id = $this->new_userid;
|
||||||
|
if ($dialog->save()) {
|
||||||
|
$dialog->joinGroup($this->new_userid, 0);
|
||||||
|
$dialog->pushMsg("groupUpdate", [
|
||||||
|
'id' => $dialog->id,
|
||||||
|
'owner_id' => $dialog->owner_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -221,16 +221,18 @@
|
|||||||
<Alert type="error" style="margin-bottom:18px">{{$L(`正在进行帐号【ID:${disableData.userid},${disableData.nickname}】离职操作。`)}}</Alert>
|
<Alert type="error" style="margin-bottom:18px">{{$L(`正在进行帐号【ID:${disableData.userid},${disableData.nickname}】离职操作。`)}}</Alert>
|
||||||
<FormItem :label="$L('离职时间')">
|
<FormItem :label="$L('离职时间')">
|
||||||
<DatePicker
|
<DatePicker
|
||||||
|
ref="disableTime"
|
||||||
v-model="disableData.disable_time"
|
v-model="disableData.disable_time"
|
||||||
:editable="false"
|
:editable="false"
|
||||||
:placeholder="$L('选择离职时间')"
|
:placeholder="$L('选择离职时间')"
|
||||||
|
:options="disableOptions"
|
||||||
style="width:100%"
|
style="width:100%"
|
||||||
format="yyyy/MM/dd HH:mm"
|
format="yyyy/MM/dd HH:mm"
|
||||||
type="datetime"/>
|
type="datetime"/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem :label="$L('交接人')">
|
<FormItem :label="$L('交接人')">
|
||||||
<UserInput v-model="disableData.transfer_userid" :disabled-choice="[disableData.userid]" :multiple-max="1" max-hidden-select :placeholder="$L('选择交接人')"/>
|
<UserInput v-model="disableData.transfer_userid" :disabled-choice="[disableData.userid]" :multiple-max="1" max-hidden-select :placeholder="$L('选择交接人')"/>
|
||||||
<div class="form-tip">{{ $L(`${disableData.nickname} 负责的项目、任务和文件将移交给交接人;同时退出所有群(如果是群主则转让给交接人)`) }}</div>
|
<div class="form-tip">{{ $L(`${disableData.nickname} 负责的部门、项目、任务和文件将移交给交接人;同时退出所有群(如果是群主则转让给交接人)`) }}</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Form>
|
</Form>
|
||||||
<div slot="footer" class="adaption">
|
<div slot="footer" class="adaption">
|
||||||
@ -279,6 +281,55 @@ export default {
|
|||||||
disableShow: false,
|
disableShow: false,
|
||||||
disableLoading: 0,
|
disableLoading: 0,
|
||||||
disableData: {},
|
disableData: {},
|
||||||
|
disableOptions: {
|
||||||
|
shortcuts: [
|
||||||
|
{
|
||||||
|
text: this.$L('12:00'),
|
||||||
|
value () {
|
||||||
|
return $A.Date($A.formatDate("Y-m-d 12:00:00"));
|
||||||
|
},
|
||||||
|
onClick: (picker) => {
|
||||||
|
picker.handlePickSuccess();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: this.$L('17:00'),
|
||||||
|
value () {
|
||||||
|
return $A.Date($A.formatDate("Y-m-d 17:00:00"));
|
||||||
|
},
|
||||||
|
onClick: (picker) => {
|
||||||
|
picker.handlePickSuccess();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: this.$L('18:00'),
|
||||||
|
value () {
|
||||||
|
return $A.Date($A.formatDate("Y-m-d 18:00:00"));
|
||||||
|
},
|
||||||
|
onClick: (picker) => {
|
||||||
|
picker.handlePickSuccess();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: this.$L('19:00'),
|
||||||
|
value () {
|
||||||
|
return $A.Date($A.formatDate("Y-m-d 19:00:00"));
|
||||||
|
},
|
||||||
|
onClick: (picker) => {
|
||||||
|
picker.handlePickSuccess();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: this.$L('现在'),
|
||||||
|
value () {
|
||||||
|
return new Date();
|
||||||
|
},
|
||||||
|
onClick: (picker) => {
|
||||||
|
picker.handlePickSuccess();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
departmentShow: false,
|
departmentShow: false,
|
||||||
departmentLoading: 0,
|
departmentLoading: 0,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user