import { useEffect } from "react"; import { bomLines, newBomAssumption, productMaster, steelCoils } from "../mock/bom"; import { yuan } from "../engine/format"; /** 新品 BOM 详细弹窗:展示 BL95A-58 多层 BOM(含下展层与失效件标识) */ export function BomModal({ open, onClose }: { open: boolean; onClose: () => void }) { useEffect(() => { if (!open) return; const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [open, onClose]); if (!open) return null; const coilCost = steelCoils.reduce((s, c) => s + c.kgPerUnit * c.unitPrice, 0); return (
| 序号 | 元件品号 / 品名 | 规格 | 用量 | 单价 | 总价 | 状态 |
|---|---|---|---|---|---|---|
| {l.level === 2 ? "└" : l.seq} | {l.itemName} {l.itemCode} | {l.spec} | {l.level === 2 ? l.qtyDisplay : l.qtyPerUnit} | {l.unitPrice ? l.unitPrice.toFixed(2) : "—"} | {l.totalPrice ? l.totalPrice.toFixed(2) : "—"} | {l.status} |
钢卷用量汇总(复算口径):{steelCoils.map((c) => `${c.material} ${c.kgPerUnit} kg/台 × ${c.unitPrice} 元`).join(" + ")} ={" "} {yuan(coilCost)} 元/台;{newBomAssumption.basis}。失效件 2220160034 仅做状态识别展示,不计用量与金额。