新增模块

This commit is contained in:
2026-10-18 15:27:02 +08:00
parent 5b7d1e8f64
commit f2e6d2b3f1
228 changed files with 46089 additions and 11 deletions
@@ -0,0 +1,77 @@
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 (
<div className="modal-backdrop" onClick={onClose} role="presentation">
<div
className="modal"
role="dialog"
aria-modal="true"
aria-label="新品 BOM 详细"
onClick={(e) => e.stopPropagation()}
>
<div className="modal-head">
<span>新品 BOM 详细 · {productMaster.itemName}</span>
<button type="button" className="icon-btn" onClick={onClose} aria-label="关闭">
✕
</button>
</div>
<dl className="kv-grid modal-kv">
<dt>品号</dt><dd>{productMaster.itemCode}</dd>
<dt>品名</dt><dd>{productMaster.itemName}</dd>
<dt>规格</dt><dd>{productMaster.spec}</dd>
<dt>品号类型</dt><dd>{productMaster.makeType}</dd>
<dt>工厂</dt><dd>{productMaster.plant}</dd>
<dt>图号</dt><dd>{productMaster.drawingNo}</dd>
<dt>BOM 日期</dt><dd>{productMaster.bomDate}</dd>
<dt>版次</dt><dd>{productMaster.revision}</dd>
</dl>
<table className="bom-table">
<thead>
<tr>
<th>序号</th>
<th>元件品号 / 品名</th>
<th>规格</th>
<th>用量</th>
<th>单价</th>
<th>总价</th>
<th>状态</th>
</tr>
</thead>
<tbody>
{bomLines.map((l) => (
<tr key={l.seq} className={l.level === 2 ? "lvl2" : l.status === "失效" ? "invalid" : ""}>
<td>{l.level === 2 ? "└" : l.seq}</td>
<td>
{l.itemName} <span className="sub">{l.itemCode}</span>
</td>
<td>{l.spec}</td>
<td>{l.level === 2 ? l.qtyDisplay : l.qtyPerUnit}</td>
<td>{l.unitPrice ? l.unitPrice.toFixed(2) : "—"}</td>
<td>{l.totalPrice ? l.totalPrice.toFixed(2) : "—"}</td>
<td>{l.status}</td>
</tr>
))}
</tbody>
</table>
<p className="modal-note">
钢卷用量汇总(复算口径):{steelCoils.map((c) => `${c.material} ${c.kgPerUnit} kg/台 × ${c.unitPrice} 元`).join(" + ")} ={" "}
<b>{yuan(coilCost)} 元/台</b>;{newBomAssumption.basis}。失效件 2220160034 仅做状态识别展示,不计用量与金额。
</p>
</div>
</div>
);
}