diff --git a/scripts/test_prescreen_ui.cjs b/scripts/test_prescreen_ui.cjs index 2d01923..d729948 100644 --- a/scripts/test_prescreen_ui.cjs +++ b/scripts/test_prescreen_ui.cjs @@ -35,7 +35,11 @@ for (const [name, source] of [["panel", panel], ["lib", lib]]) { assert.match(panel, /simulation\.probability_view/, "情景数值必须取自服务端响应"); // 4. 演示值只在演示域显示,且紧邻"人工设定"说明(AC-12/30、DESIGN §38) -assert.match(panel, /demoValue\(run\?\.data_domain/, "演示值必须按数据域判定后才显示"); +assert.match(panel, /const domainName = run\?\.data_domain/, "演示值必须按数据域判定后才显示"); +assert.match(panel, /demoValue\(domainName, simulation\?\.baseline_probability_view \|\| run\?\.probability_view\)/, + "基线演示值必须取自服务端基线视图,不能由前端合成"); +assert.match(panel, /if \(first && first\.data_domain === "demo"\) await applyScenario\(\[\], first\)/, + "首屏演示值只对演示域取值,production 域不得请求演示表"); assert.match(panel, /未完成真实历史校准/, "未校准时必须说明为何不显示概率"); assert.match(panel, /正式审批由人工决定/, "演示值旁必须有用途边界说明"); assert.match(lib, /domain !== "demo"/, "lib 必须在非演示域返回 null"); @@ -49,6 +53,12 @@ assert.match(lib, /EMPTY_DIMENSIONS = "当前方案尚未配置核查维度"/); assert.match(panel, /shown\.layout === "radar" && /, "空维度用空状态,不补六轴"); assert.match(panel, /文字列表与图等价/, "图必须有等价文字列表"); +assert.match(panel, /width=\{\d+\} height=\{\d+\} viewBox=/, "雷达必须给显式尺寸,否则会撑满容器(真渲染验证过的缺陷)"); +assert.match(panel, / item\.assumed\)/, + "没有勾选假设时不得画出实线情景轮廓"); +assert.match(panel, /阶段 \{stage \?\? "—"\} · \{stageName\(stage\)\}/, "维度必须同时给出阶段序号与名称"); // 6. 乱序与过期响应必须丢弃(AC-31) assert.match(panel, /ticket !== seq\.current/, "旧请求晚到必须丢弃"); diff --git a/src/components/xingbang/PrescreenPanel.tsx b/src/components/xingbang/PrescreenPanel.tsx index 9518e01..3a78b4b 100644 --- a/src/components/xingbang/PrescreenPanel.tsx +++ b/src/components/xingbang/PrescreenPanel.tsx @@ -50,6 +50,9 @@ export default function PrescreenPanel({project, request, busy, setBusy, setErro } else { setActions([]); } + // 演示域的基线演示值来自服务端演示表:首屏就要能看到"演示值 + 人工设定说明", + // 而不是等用户勾选后才出现数字(13 §7)。production 域不取,避免越域数值。 + if (first && first.data_domain === "demo") await applyScenario([], first); } catch (e: any) { setError(e.message); } finally { @@ -69,15 +72,16 @@ export default function PrescreenPanel({project, request, busy, setBusy, setErro .catch((e: any) => setError(e.message)); } - async function applyScenario(keys: string[]) { - if (!run) return; + async function applyScenario(keys: string[], target?: RunView | null) { + const current = target || run; + if (!current) return; const ticket = ++seq.current; setBusy(true); setError(""); setNotice(""); setScenarioState(keys.length ? "computing" : "baseline"); try { const result: Simulation = await request( - `${PRESCREEN}${projectPath}/runs/${encodeURIComponent(run.id)}/simulations`, - {assumptions: keys, expected_revision: run.revision}); + `${PRESCREEN}${projectPath}/runs/${encodeURIComponent(current.id)}/simulations`, + {assumptions: keys, expected_revision: current.revision}); if (ticket !== seq.current) return; // 旧请求晚到:丢弃,不覆盖新结果 const returned = (result.assumptions || []).map((item) => item.key).sort().join(","); if (returned !== [...keys].sort().join(",")) return; // 结果与当前选择不一致:丢弃 @@ -111,9 +115,10 @@ export default function PrescreenPanel({project, request, busy, setBusy, setErro opener.current?.focus(); } - const baseline = demoValue(run?.data_domain || "demo", run?.probability_view); - const scenario = simulation && simulation.status === "ready" - ? demoValue(run?.data_domain || "demo", simulation.probability_view) : null; + const domainName = run?.data_domain || "demo"; + const baseline = demoValue(domainName, simulation?.baseline_probability_view || run?.probability_view); + const scenario = simulation && simulation.status === "ready" && selected.length + ? demoValue(domainName, simulation.probability_view) : null; const dimensions = run?.dimension_results || []; // 刻度信息来自呈现层:运行视图只带阶段序数,因此默认同一刻度;方案带 scale_id 时按实际判断。 const shown = presentationFor(dimensions.map((item: any) => ({scale_id: item.scale_id || "stage"}))); @@ -170,7 +175,7 @@ export default function PrescreenPanel({project, request, busy, setBusy, setErro const overlay = scenarioStages.get(item.id); const stage = overlay ? overlay.scenario_stage : item.stage; return

- {item.id} · {stateLabel(item.state)} · 阶段 {stageName(stage)} + {item.id} · {stateLabel(item.state)} · 阶段 {stage ?? "—"} · {stageName(stage)} {overlay?.assumed ? "(本情景假设该维度交叉核验成立;原项目仍待核实)" : ""} {" "}