perf: 任务日志显示子任务关联

This commit is contained in:
kuaifan 2024-10-27 18:12:51 +08:00
parent 2edbe4fb3f
commit 7a457e4364
3 changed files with 60 additions and 11 deletions

View File

@ -769,6 +769,7 @@ class ProjectTask extends AbstractModel
if (Arr::exists($data, 'times')) {
$oldAt = [Carbon::parse($this->start_at), Carbon::parse($this->end_at)];
$oldStringAt = $this->start_at ? ($oldAt[0]->toDateTimeString() . '~' . $oldAt[1]->toDateTimeString()) : '';
$clearSubTaskTime = false;
$this->start_at = null;
$this->end_at = null;
$times = $data['times'];
@ -802,6 +803,7 @@ class ProjectTask extends AbstractModel
// 清空子任务时间(子任务时间等于主任务时间)
$this->start_at = $mainTask->start_at;
$this->end_at = $mainTask->end_at;
$clearSubTaskTime = true;
}
}
if ($this->parent_id == 0) {
@ -832,7 +834,7 @@ class ProjectTask extends AbstractModel
}
});
}
$newStringAt = $this->start_at ? ($this->start_at->toDateTimeString() . '~' . $this->end_at->toDateTimeString()) : '';
$newStringAt = $this->start_at && !$clearSubTaskTime ? ($this->start_at->toDateTimeString() . '~' . $this->end_at->toDateTimeString()) : '';
$newDesc = $desc ? "(备注:{$desc}" : "";
$this->addLog("修改{任务}时间" . $newDesc, [
'change' => [$oldStringAt, $newStringAt]
@ -1426,7 +1428,11 @@ class ProjectTask extends AbstractModel
'detail' => $detail,
];
if ($this->parent_id) {
$record['subtitle'] = $this->name;
$record['subtask'] = [
'id' => $this->id,
'parent_id' => $this->parent_id,
'name' => $this->name,
];
}
if ($record) {
$array['record'] = $record;

View File

@ -25,6 +25,10 @@
<div v-if="log.project_task" class="log-task">
<em @click="openTask(log.project_task)">{{$L('关联任务')}}: {{log.project_task.name}}</em>
</div>
<div v-if="hasRecordSubtask(log.record)" class="log-task">
<em @click="posSubTask(log.record.subtask)">{{$L('关联子任务')}}: {{log.record.subtask.name}}</em>
</div>
<div class="log-bottom"></div>
</template>
</TimelineItem>
</Timeline>
@ -159,6 +163,15 @@ export default {
this.getLists();
},
/**
* 是否有子任务
* @param record
* @returns {boolean}
*/
hasRecordSubtask(record) {
return $A.isJson(record) && $A.isJson(record.subtask)
},
/**
* 日志详情
* @param h
@ -305,6 +318,28 @@ export default {
openTask(task) {
this.$store.dispatch("openTask", task)
},
posSubTask(subtask) {
const el = this.$parent.$refs[`subTask_${subtask.id}`]
if (el && el[0]) {
const $e = el[0].$el
if ($e.classList.contains("common-shake")) {
return
}
$A.scrollIntoViewIfNeeded($e)
requestAnimationFrame(_ => {
$e.classList.add("common-shake")
setTimeout(_ => {
$e.classList.remove("common-shake")
}, 600)
})
} else {
if (subtask.parent_id == this.taskId) {
return
}
this.$store.dispatch("openTask", subtask)
}
}
}
}

View File

@ -126,6 +126,11 @@
}
}
.subtitle-value {
padding-left: 12px;
color: rgba(0, 0, 0, .36);
}
.detail-user {
display: inline-block;
vertical-align: top;
@ -157,16 +162,9 @@
}
.log-task {
display: flex;
margin-left: 12px;
margin-bottom: 6px;
opacity: 0.6;
cursor: pointer;
&:hover {
opacity: 1;
> em {
color: $primary-color;
}
}
padding-bottom: 4px;
> em {
display: inline-block;
font-style: normal;
@ -179,8 +177,18 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
opacity: 0.6;
&:hover {
opacity: 1;
color: $primary-color;
}
}
}
.log-bottom {
width: 100%;
height: 6px;
}
}
}
}