perf: 优化修改任务时间记录

This commit is contained in:
kuaifan 2022-02-17 19:11:23 +08:00
parent e5ddf5616a
commit 54e4ed27ae
2 changed files with 12 additions and 5 deletions

View File

@ -661,6 +661,7 @@ class ProjectTask extends AbstractModel
// 计划时间(原则:子任务时间在主任务时间内) // 计划时间(原则:子任务时间在主任务时间内)
if (Arr::exists($data, 'times')) { if (Arr::exists($data, 'times')) {
$oldAt = [Carbon::parse($this->start_at), Carbon::parse($this->end_at)]; $oldAt = [Carbon::parse($this->start_at), Carbon::parse($this->end_at)];
$oldStringAt = $this->start_at ? ($oldAt[0]->toDateTimeString() . '~' . $oldAt[1]->toDateTimeString()) : '';
$this->start_at = null; $this->start_at = null;
$this->end_at = null; $this->end_at = null;
$times = $data['times']; $times = $data['times'];
@ -724,7 +725,10 @@ class ProjectTask extends AbstractModel
} }
}); });
} }
$this->addLog("修改{任务}时间"); $newStringAt = $this->start_at ? ($oldAt[0]->toDateTimeString() . '~' . $oldAt[1]->toDateTimeString()) : '';
$this->addLog("修改{任务}时间", [
'change' => [$oldStringAt, $newStringAt]
]);
} }
// 以下紧顶级任务可修改 // 以下紧顶级任务可修改
if ($this->parent_id === 0) { if ($this->parent_id === 0) {
@ -794,6 +798,7 @@ class ProjectTask extends AbstractModel
} }
// 优先级 // 优先级
$p = false; $p = false;
$oldPName = $this->p_name;
if (Arr::exists($data, 'p_level') && $this->p_level != $data['p_level']) { if (Arr::exists($data, 'p_level') && $this->p_level != $data['p_level']) {
$this->p_level = intval($data['p_level']); $this->p_level = intval($data['p_level']);
$p = true; $p = true;
@ -807,7 +812,9 @@ class ProjectTask extends AbstractModel
$p = true; $p = true;
} }
if ($p) { if ($p) {
$this->addLog("修改{任务}优先级"); $this->addLog("修改{任务}优先级", [
'change' => [$oldPName, $this->p_name]
]);
} }
} }
$this->save(); $this->save();

View File

@ -171,10 +171,10 @@ export default {
if ($A.isArray(record.change)) { if ($A.isArray(record.change)) {
let [before, now] = record.change let [before, now] = record.change
vNode.push(h('span', ': ')) vNode.push(h('span', ': '))
if (before) { if (before && before != now) {
vNode.push(h('span', `${before} => ${now}`)) vNode.push(h('span', `${before || '-'} => ${now || '-'}`))
} else { } else {
vNode.push(h('span', now)) vNode.push(h('span', now || '-'))
} }
} }
if (record.userid) { if (record.userid) {