mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-28 04:40:37 +00:00
perf: 离职移交部门
This commit is contained in:
parent
0e71efd714
commit
0cc1469589
@ -766,30 +766,6 @@ class UsersController extends AbstractController
|
||||
]);
|
||||
$userTransfer->save();
|
||||
$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') {
|
||||
// 取消离职重新加入全员群组
|
||||
if (Base::settingFind('system', 'all_group_autoin', 'yes') === 'yes') {
|
||||
|
||||
@ -132,4 +132,22 @@ class UserDepartment extends AbstractModel
|
||||
//
|
||||
$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()
|
||||
{
|
||||
// 移交部门
|
||||
UserDepartment::transfer($this->original_userid, $this->new_userid);
|
||||
// 移交项目身份
|
||||
ProjectUser::transfer($this->original_userid, $this->new_userid);
|
||||
// 移交任务身份
|
||||
ProjectTaskUser::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>
|
||||
<FormItem :label="$L('离职时间')">
|
||||
<DatePicker
|
||||
ref="disableTime"
|
||||
v-model="disableData.disable_time"
|
||||
:editable="false"
|
||||
:placeholder="$L('选择离职时间')"
|
||||
:options="disableOptions"
|
||||
style="width:100%"
|
||||
format="yyyy/MM/dd HH:mm"
|
||||
type="datetime"/>
|
||||
</FormItem>
|
||||
<FormItem :label="$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>
|
||||
</Form>
|
||||
<div slot="footer" class="adaption">
|
||||
@ -279,6 +281,55 @@ export default {
|
||||
disableShow: false,
|
||||
disableLoading: 0,
|
||||
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,
|
||||
departmentLoading: 0,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user