perf: 设置子任务时间时,如果主任务没有时间则自动设置
This commit is contained in:
parent
95ac9aac14
commit
e4b9383e96
@ -1218,15 +1218,11 @@ class ProjectController extends AbstractController
|
|||||||
//
|
//
|
||||||
$task = ProjectTask::userTask($task_id, true, 2);
|
$task = ProjectTask::userTask($task_id, true, 2);
|
||||||
// 更新任务
|
// 更新任务
|
||||||
$updateProject = false;
|
$updateMarking = [];
|
||||||
$updateContent = false;
|
$task->updateTask($data, $updateMarking);
|
||||||
$updateSubTask = false;
|
|
||||||
$task->updateTask($data, $updateProject, $updateContent, $updateSubTask);
|
|
||||||
//
|
//
|
||||||
$data = ProjectTask::oneTask($task->id)->toArray();
|
$data = ProjectTask::oneTask($task->id)->toArray();
|
||||||
$data['is_update_project'] = $updateProject;
|
$data['update_marking'] = $updateMarking ?: json_decode('{}');
|
||||||
$data['is_update_content'] = $updateContent;
|
|
||||||
$data['is_update_subtask'] = $updateSubTask;
|
|
||||||
$task->pushMsg('update', $data);
|
$task->pushMsg('update', $data);
|
||||||
//
|
//
|
||||||
return Base::retSuccess('修改成功', $data);
|
return Base::retSuccess('修改成功', $data);
|
||||||
|
@ -478,14 +478,16 @@ class ProjectTask extends AbstractModel
|
|||||||
/**
|
/**
|
||||||
* 修改任务
|
* 修改任务
|
||||||
* @param $data
|
* @param $data
|
||||||
* @param bool $updateProject 是否更新项目数据(项目统计)
|
* @param array $updateMarking 更新的标记
|
||||||
* @param bool $updateContent 是否更新任务详情
|
* - is_update_project 是否更新项目数据(项目统计)
|
||||||
* @param bool $updateSubTask 是否更新子任务
|
* - is_update_content 是否更新任务详情
|
||||||
|
* - is_update_maintask 是否更新主任务
|
||||||
|
* - is_update_subtask 是否更新子任务
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function updateTask($data, &$updateProject = false, &$updateContent = false, &$updateSubTask = false)
|
public function updateTask($data, &$updateMarking = [])
|
||||||
{
|
{
|
||||||
AbstractModel::transaction(function () use ($data, &$updateProject, &$updateContent, &$updateSubTask) {
|
AbstractModel::transaction(function () use ($data, &$updateMarking) {
|
||||||
// 工作流
|
// 工作流
|
||||||
if (Arr::exists($data, 'flow_item_id')) {
|
if (Arr::exists($data, 'flow_item_id')) {
|
||||||
if ($this->flow_item_id == $data['flow_item_id']) {
|
if ($this->flow_item_id == $data['flow_item_id']) {
|
||||||
@ -540,7 +542,7 @@ class ProjectTask extends AbstractModel
|
|||||||
}
|
}
|
||||||
$this->completeTask(null);
|
$this->completeTask(null);
|
||||||
}
|
}
|
||||||
$updateProject = true;
|
$updateMarking['is_update_project'] = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 标题
|
// 标题
|
||||||
@ -592,7 +594,7 @@ class ProjectTask extends AbstractModel
|
|||||||
$row->delete();
|
$row->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$updateProject = true;
|
$updateMarking['is_update_project'] = true;
|
||||||
$this->syncDialogUser();
|
$this->syncDialogUser();
|
||||||
}
|
}
|
||||||
// 计划时间
|
// 计划时间
|
||||||
@ -608,8 +610,16 @@ class ProjectTask extends AbstractModel
|
|||||||
list($start, $end) = is_string($times) ? explode(",", $times) : (is_array($times) ? $times : []);
|
list($start, $end) = is_string($times) ? explode(",", $times) : (is_array($times) ? $times : []);
|
||||||
if (Base::isDate($start) && Base::isDate($end) && $start != $end) {
|
if (Base::isDate($start) && Base::isDate($end) && $start != $end) {
|
||||||
if ($this->parent_id > 0 && $data['skipTimesCheck'] !== true) {
|
if ($this->parent_id > 0 && $data['skipTimesCheck'] !== true) {
|
||||||
// 如果是子任务,则不能超过主任务时间
|
// 子任务时间判断
|
||||||
$mainTask = self::find($this->parent_id);
|
$mainTask = self::find($this->parent_id);
|
||||||
|
if (empty($mainTask->end_at)) {
|
||||||
|
// 如果主任务没有时间则自动设置
|
||||||
|
$mainTask->start_at = Carbon::parse($start);
|
||||||
|
$mainTask->end_at = Carbon::parse($end);
|
||||||
|
$mainTask->save();
|
||||||
|
$updateMarking['is_update_maintask'] = true;
|
||||||
|
} else {
|
||||||
|
// 限制不能超过主任务时间
|
||||||
if (Carbon::parse($start)->lt($mainTask->start_at)) {
|
if (Carbon::parse($start)->lt($mainTask->start_at)) {
|
||||||
throw new ApiException('子任务开始时间不能小于主任务开始时间');
|
throw new ApiException('子任务开始时间不能小于主任务开始时间');
|
||||||
}
|
}
|
||||||
@ -617,16 +627,17 @@ class ProjectTask extends AbstractModel
|
|||||||
throw new ApiException('子任务结束时间不能大于主任务结束时间');
|
throw new ApiException('子任务结束时间不能大于主任务结束时间');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$this->start_at = Carbon::parse($start);
|
$this->start_at = Carbon::parse($start);
|
||||||
$this->end_at = Carbon::parse($end);
|
$this->end_at = Carbon::parse($end);
|
||||||
}
|
}
|
||||||
if ($this->parent_id == 0) {
|
if ($this->parent_id == 0) {
|
||||||
// 如果是主任务,则同步跟主任务相同时间的子任务
|
// 如果是主任务,则同步跟主任务相同时间的子任务
|
||||||
self::where($originalWhere)->chunk(100, function($list) use ($times, &$updateSubTask) {
|
self::where($originalWhere)->chunk(100, function($list) use ($times, &$updateMarking) {
|
||||||
foreach ($list as $item) {
|
foreach ($list as $item) {
|
||||||
$item->updateTask(['times' => $times, 'skipTimesCheck' => true]);
|
$item->updateTask(['times' => $times, 'skipTimesCheck' => true]);
|
||||||
}
|
}
|
||||||
$updateSubTask = true;
|
$updateMarking['is_update_subtask'] = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$this->addLog("修改{任务}时间");
|
$this->addLog("修改{任务}时间");
|
||||||
@ -691,7 +702,7 @@ class ProjectTask extends AbstractModel
|
|||||||
]);
|
]);
|
||||||
$this->desc = Base::getHtml($data['content'], 100);
|
$this->desc = Base::getHtml($data['content'], 100);
|
||||||
$this->addLog("修改{任务}详细描述");
|
$this->addLog("修改{任务}详细描述");
|
||||||
$updateContent = true;
|
$updateMarking['is_update_content'] = true;
|
||||||
}
|
}
|
||||||
// 优先级
|
// 优先级
|
||||||
$p = false;
|
$p = false;
|
||||||
|
18
resources/assets/js/store/actions.js
vendored
18
resources/assets/js/store/actions.js
vendored
@ -857,6 +857,13 @@ export default {
|
|||||||
if (data.flow_item_name && data.flow_item_name.indexOf("|") !== -1) {
|
if (data.flow_item_name && data.flow_item_name.indexOf("|") !== -1) {
|
||||||
[data.flow_item_status, data.flow_item_name] = data.flow_item_name.split("|")
|
[data.flow_item_status, data.flow_item_name] = data.flow_item_name.split("|")
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
let updateMarking = {};
|
||||||
|
if (typeof data.update_marking !== "undefined") {
|
||||||
|
updateMarking = $A.isJson(data.update_marking) ? data.update_marking : {};
|
||||||
|
delete data.update_marking;
|
||||||
|
}
|
||||||
|
//
|
||||||
let index = state.cacheTasks.findIndex(({id}) => id == data.id);
|
let index = state.cacheTasks.findIndex(({id}) => id == data.id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.cacheTasks.splice(index, 1, Object.assign({}, state.cacheTasks[index], data));
|
state.cacheTasks.splice(index, 1, Object.assign({}, state.cacheTasks[index], data));
|
||||||
@ -864,19 +871,16 @@ export default {
|
|||||||
state.cacheTasks.push(data);
|
state.cacheTasks.push(data);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (data.parent_id > 0 && state.cacheTasks.findIndex(({id}) => id == data.parent_id) === -1) {
|
if (updateMarking.is_update_maintask === true || (data.parent_id > 0 && state.cacheTasks.findIndex(({id}) => id == data.parent_id) === -1)) {
|
||||||
dispatch("getTaskOne", data.parent_id);
|
dispatch("getTaskOne", data.parent_id);
|
||||||
}
|
}
|
||||||
if (data.is_update_project) {
|
if (updateMarking.is_update_project === true) {
|
||||||
data.is_update_project = false;
|
|
||||||
dispatch("getProjectOne", data.project_id);
|
dispatch("getProjectOne", data.project_id);
|
||||||
}
|
}
|
||||||
if (data.is_update_content) {
|
if (updateMarking.is_update_content === true) {
|
||||||
data.is_update_content = false;
|
|
||||||
dispatch("getTaskContent", data.id);
|
dispatch("getTaskContent", data.id);
|
||||||
}
|
}
|
||||||
if (data.is_update_subtask) {
|
if (updateMarking.is_update_subtask === true) {
|
||||||
data.is_update_subtask = false;
|
|
||||||
dispatch("getTaskForParent", data.id);
|
dispatch("getTaskForParent", data.id);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user