fix: 三致命Bug—macro_status预计算+排除已完工脏读+flush落盘+递归深度限制10

This commit is contained in:
2026-08-09 18:23:55 +08:00
parent d8623df7de
commit 45b5376537
6 changed files with 49 additions and 5 deletions

View File

@ -271,12 +271,24 @@ interface CommonProps {
onViewRecords: (t: TaskResponse) => void;
}
const MAX_DEPTH = 10; // 🔧 防爆栈:递归深度上限
const TaskNode = memo(function TaskNode({
task, isBranch, common,
task, isBranch, common, depth = 0,
}: {
task: TaskResponse; isBranch: boolean;
common: CommonProps;
common: CommonProps; depth?: number;
}) {
// 🔧 防循环引用/脏数据导致死循环
if (depth > MAX_DEPTH) {
return (
<div className="w-56 shrink-0 rounded-xl border-2 border-red-300 bg-red-50 p-3 text-center">
<p className="text-[10px] font-bold text-red-500"> </p>
<p className="mt-1 text-[9px] text-red-400"></p>
</div>
);
}
const isActive = task.status?.toUpperCase() === TASK_STATUS.PENDING
|| task.status?.toUpperCase() === TASK_STATUS.WIP;
@ -320,7 +332,7 @@ const TaskNode = memo(function TaskNode({
{/* 横线连接 */}
<div className="absolute left-[108px] top-6 w-6 h-0.5 bg-gray-200" />
<div className="ml-6">
<TaskNode task={child} isBranch={false} common={common} />
<TaskNode task={child} isBranch={false} common={common} depth={depth + 1} />
</div>
</div>
))}

View File

@ -81,15 +81,18 @@ export default function AdminTasksPage() {
loadProducts(keyword);
}
/** 🔧 本地计算产品综合状态与表格列渲染逻辑100%统一) */
/** 🔧 产品综合状态:优先后端预计算的 macro_status兜底本地 taskTree */
function calcProductStatus(p: ProductResponse): string {
// 后端已批量预计算 macro_statusWIP/PENDING/COMPLETED
if (p.macro_status) return p.macro_status;
// 兜底:展开过的流转树
const tree = taskTrees[p.serial_number];
if (tree?.task_tree?.length) {
if (tree.task_tree.some(t => t.status === "WIP")) return "WIP";
if (tree.task_tree.every(t => t.status === "COMPLETED" || t.status === "ARCHIVED")) return "COMPLETED";
return tree.task_tree[0].status;
}
return p.status; // 未展开流转树时兜底产品状态
return p.status;
}
// ---- 按订单分组 + 本地状态过滤 ----

View File

@ -14,6 +14,7 @@ export interface ProductResponse {
parent_product_id: string | null;
current_location_id: string | null;
current_location_name: string | null;
macro_status: string | null;
overall_status: string | null;
status: string;
created_at: string;