fix: 三致命Bug—macro_status预计算+排除已完工脏读+flush落盘+递归深度限制10
This commit is contained in:
@ -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>
|
||||
))}
|
||||
|
||||
@ -81,15 +81,18 @@ export default function AdminTasksPage() {
|
||||
loadProducts(keyword);
|
||||
}
|
||||
|
||||
/** 🔧 本地计算产品综合状态(与表格列渲染逻辑100%统一) */
|
||||
/** 🔧 产品综合状态:优先后端预计算的 macro_status,兜底本地 taskTree */
|
||||
function calcProductStatus(p: ProductResponse): string {
|
||||
// 后端已批量预计算 macro_status(WIP/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;
|
||||
}
|
||||
|
||||
// ---- 按订单分组 + 本地状态过滤 ----
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user