排序铁律: 主分支强制置顶(parent_task_id为空优先)+子分支按created_at正序

This commit is contained in:
2026-08-06 12:06:38 +08:00
parent 7c7b72cadd
commit df42250725
2 changed files with 14 additions and 1 deletions

View File

@ -132,6 +132,13 @@ export default {
} }
}; };
if (this.product) walk(this.product.task_tree); if (this.product) walk(this.product.task_tree);
result.sort((a, b) => {
const aIsMain = !a.parent_task_id;
const bIsMain = !b.parent_task_id;
if (aIsMain && !bIsMain) return -1;
if (!aIsMain && bIsMain) return 1;
return new Date(a.created_at) - new Date(b.created_at);
});
return result; return result;
}, },
lockedTask() { return this.focusTasks.find(t => t.id === this.lockedTaskId) || null; }, lockedTask() { return this.focusTasks.find(t => t.id === this.lockedTaskId) || null; },

View File

@ -100,7 +100,13 @@ export default {
try { try {
const username = this.currentUser?.username || ""; const username = this.currentUser?.username || "";
const res = await get("/tasks/", { assignee_id: username, limit: 100 }); const res = await get("/tasks/", { assignee_id: username, limit: 100 });
this.tasks = res.tasks || []; this.tasks = (res.tasks || []).sort((a, b) => {
const aIsMain = !a.parent_task_id;
const bIsMain = !b.parent_task_id;
if (aIsMain && !bIsMain) return -1;
if (!aIsMain && bIsMain) return 1;
return new Date(a.created_at) - new Date(b.created_at);
});
} catch { this.tasks = []; } } catch { this.tasks = []; }
finally { this.loading = false; } finally { this.loading = false; }
}, },