子任务默认时间与主任务相同
This commit is contained in:
parent
bae5afc0da
commit
ba5f635687
@ -873,6 +873,8 @@ class ProjectController extends AbstractController
|
|||||||
'parent_id' => $task->id,
|
'parent_id' => $task->id,
|
||||||
'project_id' => $task->project_id,
|
'project_id' => $task->project_id,
|
||||||
'column_id' => $task->column_id,
|
'column_id' => $task->column_id,
|
||||||
|
'start_at' => $task->start_at,
|
||||||
|
'end_at' => $task->end_at,
|
||||||
'owner' => [User::userid()]
|
'owner' => [User::userid()]
|
||||||
]);
|
]);
|
||||||
$data = [
|
$data = [
|
||||||
@ -918,6 +920,7 @@ class ProjectController extends AbstractController
|
|||||||
//
|
//
|
||||||
$updateComplete = false;
|
$updateComplete = false;
|
||||||
$updateContent = false;
|
$updateContent = false;
|
||||||
|
$updateSubTask = false;
|
||||||
if (Base::isDate($data['complete_at'])) {
|
if (Base::isDate($data['complete_at'])) {
|
||||||
// 标记已完成
|
// 标记已完成
|
||||||
if ($task->complete_at) {
|
if ($task->complete_at) {
|
||||||
@ -934,11 +937,12 @@ class ProjectController extends AbstractController
|
|||||||
$updateComplete = true;
|
$updateComplete = true;
|
||||||
} else {
|
} else {
|
||||||
// 更新任务
|
// 更新任务
|
||||||
$task->updateTask($data, $updateContent);
|
$task->updateTask($data, $updateContent, $updateSubTask);
|
||||||
}
|
}
|
||||||
$data = ProjectTask::with(['taskUser', 'taskTag'])->find($task->id);
|
$data = ProjectTask::with(['taskUser', 'taskTag'])->find($task->id)->toArray();
|
||||||
$data->is_update_complete = $task->parent_id == 0 && $updateComplete;
|
$data['is_update_complete'] = $task->parent_id == 0 && $updateComplete;
|
||||||
$data->is_update_content = $updateContent;
|
$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);
|
||||||
}
|
}
|
||||||
|
@ -381,11 +381,9 @@ class ProjectTask extends AbstractModel
|
|||||||
// 时间
|
// 时间
|
||||||
if ($times) {
|
if ($times) {
|
||||||
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)) {
|
if (Base::isDate($start) && Base::isDate($end) && $start != $end) {
|
||||||
if ($start != $end) {
|
$task->start_at = Carbon::parse($start);
|
||||||
$task->start_at = Carbon::parse($start);
|
$task->end_at = Carbon::parse($end);
|
||||||
$task->end_at = Carbon::parse($end);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 负责人
|
// 负责人
|
||||||
@ -408,7 +406,7 @@ class ProjectTask extends AbstractModel
|
|||||||
$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;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
return AbstractModel::transaction(function() use ($subtasks, $content, $owner, $task) {
|
return AbstractModel::transaction(function() use ($times, $subtasks, $content, $owner, $task) {
|
||||||
$task->save();
|
$task->save();
|
||||||
foreach ($owner as $uid) {
|
foreach ($owner as $uid) {
|
||||||
ProjectTaskUser::createInstance([
|
ProjectTaskUser::createInstance([
|
||||||
@ -428,6 +426,17 @@ class ProjectTask extends AbstractModel
|
|||||||
}
|
}
|
||||||
if ($task->parent_id == 0 && $subtasks && is_array($subtasks)) {
|
if ($task->parent_id == 0 && $subtasks && is_array($subtasks)) {
|
||||||
foreach ($subtasks as $subtask) {
|
foreach ($subtasks as $subtask) {
|
||||||
|
list($start, $end) = is_string($subtask['times']) ? explode(",", $subtask['times']) : (is_array($subtask['times']) ? $subtask['times'] : []);
|
||||||
|
if (Base::isDate($start) && Base::isDate($end) && $start != $end) {
|
||||||
|
if (Carbon::parse($start)->lt($task->start_at)) {
|
||||||
|
throw new ApiException('子任务开始时间不能小于主任务开始时间');
|
||||||
|
}
|
||||||
|
if (Carbon::parse($end)->gt($task->end_at)) {
|
||||||
|
throw new ApiException('子任务结束时间不能大于主任务结束时间');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$subtask['times'] = $times;
|
||||||
|
}
|
||||||
$subtask['parent_id'] = $task->id;
|
$subtask['parent_id'] = $task->id;
|
||||||
$subtask['project_id'] = $task->project_id;
|
$subtask['project_id'] = $task->project_id;
|
||||||
$subtask['column_id'] = $task->column_id;
|
$subtask['column_id'] = $task->column_id;
|
||||||
@ -443,11 +452,12 @@ class ProjectTask extends AbstractModel
|
|||||||
* 修改任务
|
* 修改任务
|
||||||
* @param $data
|
* @param $data
|
||||||
* @param $updateContent
|
* @param $updateContent
|
||||||
|
* @param $updateSubTask
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function updateTask($data, &$updateContent)
|
public function updateTask($data, &$updateContent = false, &$updateSubTask = false)
|
||||||
{
|
{
|
||||||
AbstractModel::transaction(function () use ($data, &$updateContent) {
|
AbstractModel::transaction(function () use ($data, &$updateContent, &$updateSubTask) {
|
||||||
// 标题
|
// 标题
|
||||||
if (Arr::exists($data, 'name') && $this->name != $data['name']) {
|
if (Arr::exists($data, 'name') && $this->name != $data['name']) {
|
||||||
if (empty($data['name'])) {
|
if (empty($data['name'])) {
|
||||||
@ -498,15 +508,37 @@ class ProjectTask extends AbstractModel
|
|||||||
}
|
}
|
||||||
// 计划时间
|
// 计划时间
|
||||||
if (Arr::exists($data, 'times')) {
|
if (Arr::exists($data, 'times')) {
|
||||||
|
$originalWhere = [
|
||||||
|
'parent_id' => $this->id,
|
||||||
|
'start_at' => $this->start_at,
|
||||||
|
'end_at' => $this->end_at,
|
||||||
|
];
|
||||||
$this->start_at = null;
|
$this->start_at = null;
|
||||||
$this->end_at = null;
|
$this->end_at = null;
|
||||||
$times = $data['times'];
|
$times = $data['times'];
|
||||||
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)) {
|
if (Base::isDate($start) && Base::isDate($end) && $start != $end) {
|
||||||
if ($start != $end) {
|
if ($this->parent_id > 0 && $data['skipTimesCheck'] !== true) {
|
||||||
$this->start_at = Carbon::parse($start);
|
// 如果是子任务,则不能超过主任务时间
|
||||||
$this->end_at = Carbon::parse($end);
|
$mainTask = self::find($this->parent_id);
|
||||||
|
if (Carbon::parse($start)->lt($mainTask->start_at)) {
|
||||||
|
throw new ApiException('子任务开始时间不能小于主任务开始时间');
|
||||||
|
}
|
||||||
|
if (Carbon::parse($end)->gt($mainTask->end_at)) {
|
||||||
|
throw new ApiException('子任务结束时间不能大于主任务结束时间');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$this->start_at = Carbon::parse($start);
|
||||||
|
$this->end_at = Carbon::parse($end);
|
||||||
|
}
|
||||||
|
if ($this->parent_id == 0) {
|
||||||
|
// 如果是主任务,则同步跟主任务相同时间的子任务
|
||||||
|
self::where($originalWhere)->chunk(100, function($list) use ($times, &$updateSubTask) {
|
||||||
|
foreach ($list as $item) {
|
||||||
|
$item->updateTask(['times' => $times, 'skipTimesCheck' => true]);
|
||||||
|
}
|
||||||
|
$updateSubTask = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
$this->addLog("修改{任务}时间");
|
$this->addLog("修改{任务}时间");
|
||||||
}
|
}
|
||||||
@ -525,7 +557,7 @@ class ProjectTask extends AbstractModel
|
|||||||
'userid' => $uid,
|
'userid' => $uid,
|
||||||
], [
|
], [
|
||||||
'project_id' => $this->project_id,
|
'project_id' => $this->project_id,
|
||||||
'task_pid' => $this->parent_id ?: $this->id,
|
'task_pid' => $this->id,
|
||||||
'owner' => 0,
|
'owner' => 0,
|
||||||
]);
|
]);
|
||||||
$array[] = $uid;
|
$array[] = $uid;
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
@on-ok="timeOk"
|
@on-ok="timeOk"
|
||||||
transfer>
|
transfer>
|
||||||
<div @click="openTime" :class="['time', taskDetail.today ? 'today' : '', taskDetail.overdue ? 'overdue' : '']">
|
<div @click="openTime" :class="['time', taskDetail.today ? 'today' : '', taskDetail.overdue ? 'overdue' : '']">
|
||||||
{{taskDetail.end_at ? expiresFormat(taskDetail.end_at) : ' '}}
|
{{taskDetail.end_at && taskDetail.end_at != mainEndAt ? expiresFormat(taskDetail.end_at) : ' '}}
|
||||||
</div>
|
</div>
|
||||||
</DatePicker>
|
</DatePicker>
|
||||||
<Poptip
|
<Poptip
|
||||||
@ -315,7 +315,7 @@
|
|||||||
<i class="taskfont"></i>{{$L('子任务')}}
|
<i class="taskfont"></i>{{$L('子任务')}}
|
||||||
</div>
|
</div>
|
||||||
<ul class="item-content subtask">
|
<ul class="item-content subtask">
|
||||||
<TaskDetail v-for="(task, key) in subList" :key="key" :task-id="task.id" :open-task="task"/>
|
<TaskDetail v-for="(task, key) in subList" :key="key" :task-id="task.id" :open-task="task" :main-end-at="taskDetail.end_at"/>
|
||||||
</ul>
|
</ul>
|
||||||
<ul :class="['item-content', subList.length === 0 ? 'nosub' : '']">
|
<ul :class="['item-content', subList.length === 0 ? 'nosub' : '']">
|
||||||
<li>
|
<li>
|
||||||
@ -427,6 +427,9 @@ export default {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mainEndAt: {
|
||||||
|
default: null
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
6
resources/assets/js/store/actions.js
vendored
6
resources/assets/js/store/actions.js
vendored
@ -863,11 +863,17 @@ export default {
|
|||||||
dispatch("getTaskOne", data.parent_id);
|
dispatch("getTaskOne", data.parent_id);
|
||||||
}
|
}
|
||||||
if (data.is_update_complete) {
|
if (data.is_update_complete) {
|
||||||
|
data.is_update_complete = false;
|
||||||
dispatch("getProjectOne", data.project_id);
|
dispatch("getProjectOne", data.project_id);
|
||||||
}
|
}
|
||||||
if (data.is_update_content) {
|
if (data.is_update_content) {
|
||||||
|
data.is_update_content = false;
|
||||||
dispatch("getTaskContent", data.id);
|
dispatch("getTaskContent", data.id);
|
||||||
}
|
}
|
||||||
|
if (data.is_update_subtask) {
|
||||||
|
data.is_update_subtask = false;
|
||||||
|
dispatch("getTasks", {parent_id: data.id});
|
||||||
|
}
|
||||||
//
|
//
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
state.method.setStorage("cacheTasks", state.cacheTasks = state.tasks);
|
state.method.setStorage("cacheTasks", state.cacheTasks = state.tasks);
|
||||||
|
@ -312,8 +312,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.subtask-avatar {
|
.subtask-avatar {
|
||||||
height: 26px;
|
height: 20px;
|
||||||
line-height: 26px;
|
margin-top: 3px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.ivu-icon-ios-loading {
|
.ivu-icon-ios-loading {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user