// 7 个业务视图(对应原 home/demand/lists/inquiry/cost/strategy/quote 渲染函数) import React from 'react' import { ENGINEERING_DRAWING } from './drawing-assets' import { money, quoteHTML, strategies, issues as calcIssues, calc as calcCost } from './logic' import { SAMPLE, TITLES, offers } from './data' import type { State } from './types' import { useApp } from './store' import { Audit, Btn, Metric, Notice, NumInput, Table } from './components' const aiIsSample = (s: State) => s.project.code === SAMPLE.code && JSON.stringify(s.project.materials) === JSON.stringify(SAMPLE.materials) // ============ 0 项目工作台 ============ export function Home() { const { s, go } = useApp() const c = calcCost(s) const depts = ['技术部', '技术部', '物供 · 生产 · 经营', '经营部', '经营 · 审批', '经营部'] const descs = ['上传需求与模拟图纸,提取并核对', '补全BOM、用量与工时', '比较交期与价格,识别遗漏', '全成本汇总,生成可追溯报告', '历史案例辅助,生成A/B/C策略', '审批后生成,打印与导出'] return ( <>
ENGINEERING TO QUOTATION
从一张图纸,到一份可信报价

围绕技术、物供、生产与经营的协同流程,让每一项成本有来源,每一次决策有依据。

go(1)} cls="primary" /> go(4)} />
{TITLES.slice(1).map((t, i) => ( ))}

项目动态 / 审核追溯

) } // ============ 1 需求与图纸解析 ============ function AiPanel() { const { s, flows, aiSheet, parse, clarify, go } = useApp() const aiRun = flows.aiRun if (!aiRun.visible) return null const running = aiRun.running const done = !running && s.parsed const len = s.project.materials.length const t = done ? len + 7 : aiRun.tick const phase = done ? 4 : t < 2 ? 0 : t < 3 ? 1 : t < len + 3 ? 2 : 3 const found = done ? len : Math.max(0, Math.min(len, t - 2)) const warnings = done || t >= len + 3 const sample = aiIsSample(s) const sheet = aiRun.sheet const points = sheet ? [[3, 10, 28, 44, 25], [4, 11, 22, 6, 37]] : [[0, 14, 29, 39, 24], [1, 10, 22, 6, 37], [2, 45, 25, 5, 32]] const status = ['图纸解析 Agent · 读取图框与视图', '语义理解 Agent · 拆解组件与装配关系', '多模态 Agent + OCR Agent · 交叉核对物料', '校核 Agent · 检查遗漏与规格冲突', '解析完成 · 等待人工确认'][phase] return (

✦ AI 协同图纸解析

{running ? '协同处理中' : done ? '待人工确认' : '准备就绪'}

离线流程演示 · 多模态大模型 + OCR 协同概念,未调用真实模型

{['图纸解析', '理解与拆解', '多模态 + OCR', '遗漏校核'].map((name, i) => (
i ? 'done' : phase === i && (running || done) ? 'active' : '')}> {phase > i ? '✓' : '0' + (i + 1)} {name} {['图框 / 视图定位', '组件 / 信息关联', '逐项识别 / 核对', '缺项 / 人工确认'][i]}
))}
{!running && !done ? '等待启动解析' : status}{found} / {len} 项
{sample ? ( <>
{['内套 · SIM-IS-01', '外套 · SIM-OS-01'].map((name, i) => ( ))}
用于识别动画的模拟机械图 {running &&
} {points.filter((p) => p[0] < found).map((p, i) => (
✓ {s.project.materials[p[0]].name}
))} {warnings && (
! 焊材未覆盖 / 配合与焊缝要求待确认
)}
绿色:模拟图示物料定位 橙色虚线:信息缺失区域 · 可切换图纸查看
) : (
结构化需求映射
当前按 JSON 来源字段展示候选信息;无对应图纸坐标,不生成定位标记。
)} {(running || done) && (
{s.project.materials.slice(0, found).map((m, i) => (
✓ {m.id} · {m.name} {m.qty} {m.unit} {m.ref}{sample && i >= 5 ? ' · 需求文本补充,非图纸直接识别' : ''}
)).reverse()}
)} {warnings && ( )} {done && (

识别总结 / 人工确认

候选数据来源:{sample ? '内置模拟图与需求书,尺寸和净重均为演示假设。' : '上传的结构化需求,需人工对照原始图纸核验。'}

go(2)} disabled={!s.clarified} cls="primary" />
)} ) } export function Demand() { const { s, flows, loadSample, uploadFiles, parse } = useApp() return (

01 / 上传客户需求与图纸

支持结构化JSON、UTF-8 Markdown/TXT需求;PDF、图像及SVG可预览归档,离线模式不做通用OCR。

{ uploadFiles(e.target.files); e.currentTarget.value = '' }} />
{s.files.length ? s.files.map((f, i) =>
{f.name}{f.size} KB · {f.type}
) :
暂无本次上传文件,可直接载入样例开始。
}
{s.fileText || s.project.scope}
) } // ============ 2 物量与资源清单 ============ function KbBanner() { const { s, flows, startKnowledge } = useApp() const kb = flows.kb const total = s.materials.length + s.resources.length const shown = Math.min(total, Math.max(0, kb.tick - 2)) const phase = !kb.running ? 3 : kb.tick < 2 ? 0 : shown < s.materials.length ? 1 : 2 return (
✦ AI 知识库检索与来源匹配
{(kb.running ? ['检索本地索引,定位可引用的依据…', '逐项关联物料、图纸序号与需求条款…', '匹配工艺记录、工时与计价依据…'][phase] + ' ' + shown + ' / ' + total : '检索展示完成 · 可打开图谱逐项核对来源')}
{['检索索引', '物料映射', '工艺关联', '来源核对'].map((n, i) => {i + 1} {n})}
离线知识库演示:检索内置模拟需求 / 工艺记录;未连接企业真实历史库。候选值按来源映射呈现,未匹配记录标为人工补充。
) } export function Lists() { const { s, flows, go, editM, editR, addMissing, deleteListRow, confirmTech, startMaterialNetwork, openModal } = useApp() const kb = flows.kb if (!kb.shown) return null if (!s.parsed) { return <> go(1)} /> } const busy = kb.running const mc = busy ? Math.min(s.materials.length, Math.max(0, kb.tick - 2)) : s.materials.length const rc = busy ? Math.min(s.resources.length, Math.max(0, kb.tick - 2 - s.materials.length)) : s.resources.length return (

物量清单 / BOM

startMaterialNetwork(0, 'material')} cls="primary" /> m.id === 'M009')} /> openModal('newMaterial', '新增人工补充物料')} disabled={busy} />
[ <>{m.id}
{m.ref}, m.name, busy ? m.qty : editM(i, 'qty', v)} ariaLabel={m.name + '用量'} />, m.unit, money(m.qty), deleteListRow('material', i)} disabled={busy} cls="row-delete" />, ])} /> {busy && mc === 0 &&
正在检索图纸物料索引与需求条款…
}

资源清单 / 制造工艺路线

openModal('newResource', '手工添加工序')} disabled={busy} /> startMaterialNetwork(0, 'resource')} cls="primary" />
[ <>{r.name}
{r.note}, r.ref, busy ? r.qty : editR(i, 'qty', v)} ariaLabel={r.name + '计划工时'} />, deleteListRow('resource', i)} disabled={busy} cls="row-delete" />, ])} /> {busy && rc === 0 &&
等待物料关系匹配,随后检索工序与工时依据…
}
m.id === 'M009')} /> go(3)} disabled={busy} />
) } // ============ 3 跨部门询价与审核 ============ function AiInquiryPanel() { const { s, flows } = useApp() const a = flows.aiInquiry if (!a.visible) return null const phase = a.tick < 1 ? 0 : a.tick < 2 ? 1 : a.tick < 3 ? 2 : a.running ? 3 : 4 const valid = s.materials.filter((r) => !!s.quotes[r.id] && Number.isFinite(r.price) && r.price > 0) const amount = valid.reduce((sum, r) => sum + Math.round(r.qty * r.price * 100) / 100, 0) const pending = s.materials.length - valid.length return (
✦ AI Agent 协同询价 {a.running ? '处理中' : a.cancelled ? '已暂停' : a.failed ? '部分物料待人工询价' : '推荐完成'}
{['需求核对 Agent', '报价检索 Agent', '交期比价 Agent', '推荐回填 Agent'].map((n, i) => (
i ? 'done' : phase === i ? 'active' : ''}> {phase > i ? '✓' : i + 1} {n} {['读取物料与采购数量', '检索内置供应商报价', '过滤超期 / 比较单价', '逐项填写并说明理由'][i]}
))}
{a.running ? ['正在核对物料清单与项目交付要求…', '正在检索每项物料的模拟供应商报价…', '正在检查最迟到料时间并比较合规报价…'][Math.min(a.tick, 2)] + (a.tick >= 3 ? ` 已处理 ${a.done} / ${s.materials.length} 项。` : '') : a.cancelled ? '处理已暂停,可重新点击 AI询价。' : `已处理 ${a.done} 项;` + (a.failed ? `${a.failed} 项无交期合规报价,需人工处理。` : '推荐结果已回填,可手工调整后提交审核。')}
离线规则演示:基于内置模拟报价,先满足交期,再选合规最低价;不向供应商发送询价,不自动提交审核。
采购总金额(不含税){pending ? ' · 已回填小计' : ''} ¥ {money(amount)} {pending ? {pending} 项待核价 : null}
) } function ProductionAIFlow() { const { s, flows } = useApp() const a = flows.productionAI if (!a.visible) return null const phase = a.running ? Math.min(3, a.tick) : 4 const valid = s.resources.filter((r) => r.rate != null && Number.isFinite(r.rate) && r.rate > 0) const amount = valid.reduce((sum, r) => sum + Math.round(r.qty * (r.rate || 0) * 100) / 100, 0) const pending = s.resources.length - valid.length return (
✦ AI Agent 协同工序核价 {a.running ? '处理中' : a.cancelled ? '已暂停' : a.failed ? '部分待人工核价' : '推荐完成'}
{['工序理解 Agent', '费率检索 Agent', '口径校核 Agent', '推荐回填 Agent'].map((name, i) => (
i ? 'done' : phase === i ? 'active' : ''}> {phase > i ? '✓' : i + 1} {name} {['核对工序与工时范围', '查找可追溯费率记录', '核对人工 / 设备 / 能耗', '逐项填写费率与理由'][i]}
))}
{a.running ? ['正在理解工序范围与计划工时…', '正在检索本地工艺费率记录…', '正在校核综合费率与费用归集口径…', '正在逐项回填推荐综合费率…'][Math.min(3, a.tick)] + ` 已处理 ${a.done} / ${s.resources.length} 项。` : a.cancelled ? '处理已暂停,可重新点击 AI询价。' : `已处理 ${a.done} 项,${a.failed} 项待人工核价;请核对后提交。`}
离线规则演示:依据内置模拟工艺费率或上传需求中的费率记录;未连接企业实际历史库,不自动提交审核。
工序总金额{pending ? ' · 已回填小计' : ''} ¥ {money(amount)} {pending ? {pending} 项待核价 : null}
) } function ProductionPricing() { const { s, flows, editR, startProductionAI, submitProduction } = useApp() const ai = flows.productionAI return ( <>
[ r.name, ai.running ? r.qty : editR(i, 'qty', v)} ariaLabel={r.name + '计划工时'} />, 0 ? r.rate : ''} key={r.id + '-' + (r.rate ?? '')} disabled={ai.running || undefined} onChange={(e) => editR(i, 'rate', e.target.value)} />, r.aiRateReason ?
{r.aiRateReason}
: ai.unmatched?.includes(r.id) ? 未匹配可靠费率依据,请人工核价。 : 待询价 / 人工核价, r.rate && r.rate > 0 ? money(r.qty * r.rate) : 待核价, ])} />
r.rate == null || !Number.isFinite(r.rate) || r.rate <= 0)} />
) } export function Inquiry() { const { s, sub, setSub, pick, pickAll, submitSupply, returnSupply, returnProduction, confirmReview, flows, startAIInquiry } = useApp() if (!s.parsed) return const iss = calcIssues(s) return ( <>

三部门并行核价 / 统一经营确认

当前演示:{['物供部', '生产部', '经营部'][sub]}
{['物供询价', '生产核价', '经营审核'].map((x, i) => ( setSub(i)} cls={sub === i ? 'primary' : ''} /> ))}
{sub === 0 && ( <>
{ const q = s.quotes[m.id] const over = q && q.days > s.project.delivery - 30 return [ <>{m.name}
{m.id} / {m.unit}, <>
{q?.quality || '待回填供应商报价'} , q?.aiReason ?
✦ AI推荐理由
{q.aiReason}
: '', money(m.qty), money(m.qty * m.price), ] })} /> )} {sub === 1 && } {sub === 2 && (

✦ 经营审核提示(规则扫描)

{iss.length ? iss.map((x, i) => ) : }

部门确认状态

)}

修改与审核记录

) } // ============ 4 全成本测算报告 ============ export function Cost() { const { s, editOther, editParam, generateReport, downloadReport, go } = useApp() const c = calcCost(s) const parts: [string, number][] = [['物料成本', c.material], ['制造资源', c.process], ['专项直接费', c.other], ['项目间接费', c.overhead], ['风险准备', c.risk]] return ( <>

成本构成与归集

{parts.map(([n, v]) => (
{n}
{money(v)}
))}

补充成本与参数

{Object.entries(s.other).map(([k, v]) => (
editOther(k, nv)} ariaLabel={k} />
))}
间接费率% editParam('overhead', v)} ariaLabel="间接费率" /> {' '}风险准备% editParam('risk', v)} ariaLabel="风险准备" />
{!s.review && } {' '}
{s.report && (

✦ 初步测算结论

项目全成本为 {money(c.total)}元,{s.project.sets}套平均成本 {money(c.total / s.project.sets)}元/套。制造资源占比 {((c.process / c.total) * 100).toFixed(1)}%。 {s.floor}%利润率要求对应不含税报价不低于 {money(c.total / (1 - s.floor / 100))}元。

主要敏感项:焊接和精加工工时、材料用量、外购件规格。建议完成技术澄清并锁定采购交期后承诺交付。

go(5)} cls="primary" />
)} ) } // ============ 5 AI报价策略 ============ function CompetitorQuoteForm() { const { s, cqPresetCleared, saveCompetitorQuote, clearCompetitorQuote, flows } = useApp() const preset = !s.competitorQuote && !cqPresetCleared const q: any = preset ? { ...(s.competitorQuote || { name: '', price: null, taxMode: 'exclusive', taxRate: s.tax, sets: s.project.sets, days: s.project.delivery, position: 'balanced', comparable: false, source: '' }), name: '江城重装设备有限公司(模拟)', price: 220000, source: '演示预设报价,仅供模拟比较,非真实友商数据' } : s.competitorQuote || { name: '', price: null, taxMode: 'exclusive', taxRate: s.tax, sets: s.project.sets, days: s.project.delivery, position: 'balanced', comparable: false, source: '' } const [form, setForm] = React.useState(q) const [compChecked, setCompChecked] = React.useState(q.comparable) // 状态切换(预设/清空/项目更换)时同步表单 React.useEffect(() => { setForm(q); setCompChecked(q.comparable) }, [preset, s.competitorQuote, s.project]) const q0 = s.competitorQuote const refUsed = !!(q0 && Number.isFinite(q0.price) && q0.price > 0 && q0.comparable && q0.sets === s.project.sets && q0.days === s.project.delivery && Number.isFinite(q0.taxMode === 'inclusive' ? q0.price / (1 + q0.taxRate / 100) : q0.price) && (q0.taxMode === 'inclusive' ? q0.price / (1 + q0.taxRate / 100) : q0.price) > 0) const statusText = preset ? '已预填可编辑的模拟报价,核对供货范围后保存,即可参与AI策略判定。' : !s.competitorQuote ? '尚未录入友商报价,沿用利润目标生成方案。' : !(Number.isFinite(s.competitorQuote.price) && s.competitorQuote.price > 0) ? '尚未录入友商报价,沿用利润目标生成方案。' : !s.competitorQuote.comparable ? '友商供货范围尚未确认,仅展示信息,不用于调价。' : s.competitorQuote.sets !== s.project.sets || s.competitorQuote.days !== s.project.delivery ? '友商数量或交期与当前项目不一致,仅供参考,不直接参与同口径定价。' : `已按同范围、${s.competitorQuote.sets}套、${s.competitorQuote.days}天比较;友商不含税总价 ${money(s.competitorQuote.taxMode === 'inclusive' ? s.competitorQuote.price / (1 + s.competitorQuote.taxRate / 100) : s.competitorQuote.price)} 元。` const busy = flows.strategyRun.running const set = (k: string, v: any) => setForm((f: any) => ({ ...f, [k]: v })) return (

友商报价参考

{preset ? '模拟预设 · 可修改' : '手工录入'}
saveCompetitorQuote({ ...form, comparable: compChecked })} disabled={busy} cls="primary" />

{statusText}

) } function StrategyAIFlow() { const { flows } = useApp() const a = flows.strategyRun if (!a.visible) return null const phase = a.running ? Math.min(3, Math.floor(a.tick / 2)) : 4 return (
✦ 多 Agent 协同报价决策 {a.running ? '协同处理中' : a.cancelled ? '已暂停' : '策略生成完成'}
{['案例与友商检索 Agent', '成本校核 Agent', '方案推演 Agent', '审批整理 Agent'].map((n, i) => (
i ? 'done' : phase === i ? 'active' : ''}> {phase > i ? '✓' : i + 1} {n} {['检索模拟案例与项目背景', '核对成本、底线与友商口径', '综合利润与友商生成方案', '整理依据与人工审批项'][i]}
))}
{a.running ? ['正在读取成本版本与项目要求…', '正在检索模拟历史案例…', '案例依据已匹配,正在校核成本与利润底线…', '正在结合利润底线与可比友商报价推演方案…', '已生成 A · 竞争优先方案…', '已生成 B · 综合平衡方案…', '已生成 C · 价值保障方案…', '正在整理内部审批资料…'][Math.min(a.tick, 7)] : a.cancelled ? '生成已暂停,可点击 AI报价策略 重新开始。' : '三种策略及审批资料已准备,请人工选择并确认。'}
离线规则演示 · 多 Agent 协同动画,未调用外部模型;报价仍按项目成本与利润约束计算。
) } export function Strategy() { const { s, flows, setFloor, startStrategyAI, setTarget, selectStrategy, approve, rejectStrategy, go, setContext, openModal } = useApp() const st = strategies(s) const reveal = flows.strategyRun.reveal const running = flows.strategyRun.running const cases: [string, string, string][] = [ ['历史案例 H01', '相似内外套组件 / 8套', '历史成交利润率18%,交期100天'], ['历史案例 H02', '高精度导向套 / 12套', '历史成交利润率22%,交期90天'], ['当前项目', `10套 / 交期${s.project.delivery}天`, '以本次已审批成本为报价基准'], ] return ( <>

✦ 报价策略模拟 / 以利润底线约束决策

历史案例用于解释,不直接替换本项目成本。三个方案供货范围、交期相同,仅利润与商业定位不同。

硬性利润率底线%