mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-15 13:22:49 +00:00
perf: 优化移动任务
This commit is contained in:
parent
9e522091c6
commit
a5cb958398
@ -2417,6 +2417,11 @@ class ProjectController extends AbstractController
|
||||
* @apiParam {Number} flow_item_id 工作流id
|
||||
* @apiParam {Array} owner 负责人
|
||||
* @apiParam {Array} assist 协助人
|
||||
* @apiParam {String} [completed] 是否已完成
|
||||
* - 没有 工作流id 时此参数才生效
|
||||
* - 有值表示已完成
|
||||
* - 空值表示未完成
|
||||
* - 不存在不改变状态
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
@ -2433,7 +2438,7 @@ class ProjectController extends AbstractController
|
||||
$flow_item_id = intval(Request::input('flow_item_id'));
|
||||
$owner = Request::input('owner', []);
|
||||
$assist = Request::input('assist', []);
|
||||
$completeAt = trim(Request::input('complete_at', ''));
|
||||
$completed = Request::exists('completed') ? (bool)Request::input('completed') : null;
|
||||
//
|
||||
$task = ProjectTask::userTask($task_id);
|
||||
//
|
||||
@ -2454,13 +2459,13 @@ class ProjectController extends AbstractController
|
||||
if (empty($flowItem)) {
|
||||
return Base::retError('任务状态不存在');
|
||||
}
|
||||
} else if (!$flow_item_id && !$completeAt) {
|
||||
} else {
|
||||
if (projectFlowItem::whereProjectId($project->id)->count() > 0) {
|
||||
return Base::retError('请选择移动后状态', [], 102);
|
||||
}
|
||||
}
|
||||
//
|
||||
$task->moveTask($project_id, $column_id, $flow_item_id, $owner, $assist, $completeAt);
|
||||
$task->moveTask($project_id, $column_id, $flow_item_id, $owner, $assist, $completed);
|
||||
//
|
||||
$data = [];
|
||||
$mainTask = ProjectTask::userTask($task_id)?->toArray();
|
||||
|
||||
@ -1851,12 +1851,12 @@ class ProjectTask extends AbstractModel
|
||||
* @param int $flowItemId
|
||||
* @param array $owner
|
||||
* @param array $assist
|
||||
* @param string $completeAt
|
||||
* @param string|null $completed
|
||||
* @return bool
|
||||
*/
|
||||
public function moveTask(int $projectId, int $columnId,int $flowItemId = 0,array $owner = [], array $assist = [], string $completeAt='')
|
||||
public function moveTask(int $projectId, int $columnId, int $flowItemId = 0, array $owner = [], array $assist = [], ?string $completed = null)
|
||||
{
|
||||
AbstractModel::transaction(function () use ($projectId, $columnId, $flowItemId, $owner, $assist, $completeAt) {
|
||||
AbstractModel::transaction(function () use ($projectId, $columnId, $flowItemId, $owner, $assist, $completed) {
|
||||
$newTaskUser = array_merge($owner, $assist);
|
||||
//
|
||||
$oldProject = Project::find($this->project_id);
|
||||
@ -1867,6 +1867,14 @@ class ProjectTask extends AbstractModel
|
||||
//
|
||||
$this->project_id = $projectId;
|
||||
$this->column_id = $columnId;
|
||||
// 日志
|
||||
$log = $this->addLog("移动{任务}", [
|
||||
'change' => [$oldProject->name, $newProject->name]
|
||||
]);
|
||||
if ($this->dialog_id) {
|
||||
$notice = $oldProject->id != $newProject->id ? "「{$oldProject->name}」移动至「{$newProject->name}」" : $log->detail;
|
||||
WebSocketDialogMsg::sendMsg(null, $this->dialog_id, 'notice', ['notice' => $notice], User::userid(), true, true);
|
||||
}
|
||||
// 任务内容
|
||||
if ($this->content) {
|
||||
$this->content->project_id = $projectId;
|
||||
@ -1913,22 +1921,12 @@ class ProjectTask extends AbstractModel
|
||||
// 没有流程只更新状态
|
||||
$this->flow_item_id = 0;
|
||||
$this->flow_item_name = '';
|
||||
if ($completeAt) {
|
||||
$this->completeTask(Carbon::parse($completeAt));
|
||||
} else {
|
||||
$this->completeTask(null);
|
||||
if ($completed !== null) {
|
||||
$this->completeTask($completed ? Carbon::now(): null);
|
||||
}
|
||||
}
|
||||
//
|
||||
$this->save();
|
||||
//
|
||||
$log = $this->addLog("移动{任务}", [
|
||||
'change' => [$oldProject->name, $newProject->name]
|
||||
]);
|
||||
if ($this->dialog_id) {
|
||||
$notice = $oldProject->id != $newProject->id ? "「{$oldProject->name}」移动至「{$newProject->name}」" : $log->detail;
|
||||
WebSocketDialogMsg::sendMsg(null, $this->dialog_id, 'notice', ['notice' => $notice], User::userid(), true, true);
|
||||
}
|
||||
});
|
||||
$this->pushMsg('update');
|
||||
return true;
|
||||
|
||||
@ -256,17 +256,21 @@ export default {
|
||||
return;
|
||||
}
|
||||
this.loadIng++;
|
||||
const callData = {
|
||||
task_id: this.task.id,
|
||||
project_id: this.cascader[0],
|
||||
column_id: this.cascader[1],
|
||||
flow_item_id: this.updateData.flow.flow_item_id || 0,
|
||||
owner: this.updateData.owner_userids,
|
||||
assist: this.updateData.assist_userids,
|
||||
};
|
||||
if (!this.updateData.flow.flow_item_id && this.updateData.flow.flow_item_status) {
|
||||
// 没有工作流 但是有状态
|
||||
callData.completed = this.updateData.flow.complete_at ? 1 : 0;
|
||||
}
|
||||
this.$store.dispatch("call", {
|
||||
url: "project/task/move",
|
||||
data: {
|
||||
task_id: this.task.id,
|
||||
project_id: this.cascader[0],
|
||||
column_id: this.cascader[1],
|
||||
flow_item_id: this.updateData.flow.flow_item_id || 0,
|
||||
complete_at: this.updateData.flow.complete_at || '',
|
||||
owner: this.updateData.owner_userids,
|
||||
assist: this.updateData.assist_userids,
|
||||
}
|
||||
data: callData
|
||||
}).then(({data, msg}) => {
|
||||
this.loadIng--;
|
||||
this.$store.dispatch("saveTask", data);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user