修复2D布局: 时间戳判定串行/并行 — created_at>parent.completed_at才是串行,否则并行同Y

This commit is contained in:
2026-08-06 11:45:56 +08:00
parent 8f0f725e26
commit c92e7bd931

View File

@ -66,8 +66,12 @@ export default {
const layout = (tasks, parentRowIdx, parentX) => {
if (!tasks || !tasks.length) return;
tasks.forEach(t => {
// 判定parent COMPLETED → 串行 Y+1parent WIP/PENDING → 并行同Y偏右
const isSerial = !t.parent_task_id || (this.taskStatusMap[t.parent_task_id] === 'COMPLETED');
// 时间戳判定:子任务创建于父任务完成之后 → 串行(下一行);否则 → 并行(同Y偏右)
const parentNode = this.taskDataMap[t.parent_task_id];
const isSerial = !t.parent_task_id || (
parentNode && parentNode.completed_at &&
new Date(t.created_at) > new Date(parentNode.completed_at)
);
const rowIdx = isSerial ? (parentRowIdx >= 0 ? parentRowIdx + 1 : rows.length) : parentRowIdx;
while (rows.length <= rowIdx) rows.push({ y: 0, tasks: [] });
@ -100,9 +104,9 @@ export default {
return nodes;
},
taskStatusMap() {
taskDataMap() {
const map = {};
const walk = (tasks) => { if (!tasks) return; tasks.forEach(t => { map[t.id] = t.status; walk(t.child_tasks); }); };
const walk = (tasks) => { if (!tasks) return; tasks.forEach(t => { map[t.id] = t; walk(t.child_tasks); }); };
if (this.product) walk(this.product.task_tree);
return map;
},