添加任务自动上工作流状态
This commit is contained in:
parent
b895eec69c
commit
95ac9aac14
@ -1438,13 +1438,12 @@ class ProjectController extends AbstractController
|
|||||||
if ($projectFlowItem?->projectFlow) {
|
if ($projectFlowItem?->projectFlow) {
|
||||||
$projectFlow = $projectFlowItem->projectFlow;
|
$projectFlow = $projectFlowItem->projectFlow;
|
||||||
} else {
|
} else {
|
||||||
$projectFlow = ProjectFlow::whereProjectId($projectTask->project_id)->first();
|
$projectFlow = ProjectFlow::whereProjectId($projectTask->project_id)->orderByDesc('id')->first();
|
||||||
}
|
}
|
||||||
if (empty($projectFlow)) {
|
if (empty($projectFlow)) {
|
||||||
return Base::retSuccess('success', [
|
return Base::retSuccess('success', [
|
||||||
'task_id' => $projectTask->id,
|
'task_id' => $projectTask->id,
|
||||||
'flow_item_id' => 0,
|
'flow_item_id' => 0,
|
||||||
'flow_item_name' => '',
|
|
||||||
'turns' => [],
|
'turns' => [],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -1454,22 +1453,20 @@ class ProjectController extends AbstractController
|
|||||||
$data = [
|
$data = [
|
||||||
'task_id' => $projectTask->id,
|
'task_id' => $projectTask->id,
|
||||||
'flow_item_id' => 0,
|
'flow_item_id' => 0,
|
||||||
'flow_item_name' => '',
|
|
||||||
'turns' => $turns,
|
'turns' => $turns,
|
||||||
];
|
];
|
||||||
$assign = null;
|
|
||||||
if ($projectTask->complete_at) {
|
if ($projectTask->complete_at) {
|
||||||
// 赋一个结束状态
|
// 赋一个结束状态
|
||||||
foreach ($turns as $turn) {
|
foreach ($turns as $turn) {
|
||||||
if ($turn->status == 'end' || preg_match("/complete|done|完成/i", $turn->name)) {
|
if ($turn->status == 'end' || preg_match("/complete|done|完成/i", $turn->name)) {
|
||||||
$assign = $turn;
|
$data['flow_item_id'] = $turn->id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($data['flow_item_id'])) {
|
if (empty($data['flow_item_id'])) {
|
||||||
foreach ($turns as $turn) {
|
foreach ($turns as $turn) {
|
||||||
if ($turn->status == 'end') {
|
if ($turn->status == 'end') {
|
||||||
$assign = $turn;
|
$data['flow_item_id'] = $turn->id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1478,20 +1475,15 @@ class ProjectController extends AbstractController
|
|||||||
// 赋一个开始状态
|
// 赋一个开始状态
|
||||||
foreach ($turns as $turn) {
|
foreach ($turns as $turn) {
|
||||||
if ($turn->status == 'start') {
|
if ($turn->status == 'start') {
|
||||||
$assign = $turn;
|
$data['flow_item_id'] = $turn->id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($assign) {
|
|
||||||
$data['flow_item_id'] = $assign->id;
|
|
||||||
$data['flow_item_name'] = $assign->name;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$data = [
|
$data = [
|
||||||
'task_id' => $projectTask->id,
|
'task_id' => $projectTask->id,
|
||||||
'flow_item_id' => $projectFlowItem->id,
|
'flow_item_id' => $projectFlowItem->id,
|
||||||
'flow_item_name' => $projectFlowItem->name,
|
|
||||||
'turns' => $turns,
|
'turns' => $turns,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -419,6 +419,19 @@ class ProjectTask extends AbstractModel
|
|||||||
} else {
|
} else {
|
||||||
$task->sort = intval(self::whereColumnId($task->column_id)->orderByDesc('sort')->value('sort')) + 1;
|
$task->sort = intval(self::whereColumnId($task->column_id)->orderByDesc('sort')->value('sort')) + 1;
|
||||||
}
|
}
|
||||||
|
// 工作流
|
||||||
|
$projectFlow = ProjectFlow::whereProjectId($project_id)->orderByDesc('id')->first();
|
||||||
|
if ($projectFlow) {
|
||||||
|
$turns = ProjectFlowItem::select(['id', 'name', 'status', 'turns'])->whereFlowId($projectFlow->id)->orderBy('sort')->get();
|
||||||
|
// 赋一个开始状态
|
||||||
|
foreach ($turns as $turn) {
|
||||||
|
if ($turn->status == 'start') {
|
||||||
|
$task->flow_item_id = $turn->id;
|
||||||
|
$task->flow_item_name = $turn->status . "|" . $turn->name;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
return AbstractModel::transaction(function() use ($times, $subtasks, $content, $owner, $task) {
|
return AbstractModel::transaction(function() use ($times, $subtasks, $content, $owner, $task) {
|
||||||
$task->save();
|
$task->save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user