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