feat(M01): 로직 개선 시험 「텍스트 수식」 컨테이너 — 서버 /text 가 준 줄(비목 묶음 · 소계 · 끝수 · 까닭 옅게)을 그대로 찍음

- `runText` API + 시험 계산 때 `/calc` 와 같은 몸으로 같이 부름 · 화면은 다시 계산하지 않음
- 멈추면 서버 까닭 한 줄
- ORCA 13-4-1 · 12-4 · 12-17-1 소계 합이 호표 계와 같음 · 모달 표 뜸

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WRFJmmhPi4exAzHgPZHMT
This commit is contained in:
2026-09-21 19:46:56 +09:00
co-authored by Claude Sonnet 5
parent b99585da59
commit 448ef6080f
7 changed files with 118 additions and 13 deletions
@@ -1,19 +1,60 @@
/* =============================================================================
* M01_MasterData_UI_LogicLab_Formula.ts
* 「텍스트 수식」 컨테이너 자리 — 비목 묶음별 `이름 : 단가 * 수량식 = 금액` 줄은 여기서 채움(PLAN 3-2)
* 「텍스트 수식」 컨테이너 — 서버(`POST /text`)가 준 줄을 그대로 찍음(화면에서 다시 계산하지 않음)
* 비목 묶음 제목 · 줄(`이름 : 글`) · 소계 · 끝수 한 마디 · 까닭 있는 줄은 옅게
* ========================================================================== */
import { el } from "@ui/ui_template_elements";
import type { CalcLine, LogicRow } from "./M01_MasterData_UI_Logic_Api";
import type { TextAnswer } from "./M01_MasterData_UI_Logic_Api";
import { formatNumber } from "./M01_MasterData_UI_Logic_Edit";
import { tx } from "./M01_MasterData_UI_Logic_Text";
import { tl } from "./M01_MasterData_UI_LogicLab_Text";
export interface FormulaContext {
row: LogicRow;
/** 마지막 시험 계산의 줄 — 호표 차례 뒤에 덧줄 */
lines: CalcLine[] | null;
text: TextAnswer | null;
}
/** 자리만 — 줄을 채우는 일감이 `host` 안에 그림 */
export function buildFormula(host: HTMLElement, _ctx: FormulaContext): void {
host.replaceChildren(el("p", { className: "m01-logic__muted", text: tl("Formula_Slot") }));
const muted = (text: string): HTMLElement => el("p", { className: "m01-logic__muted", text });
export function buildFormula(host: HTMLElement, ctx: FormulaContext): void {
const text = ctx.text;
if (!text) {
host.replaceChildren(muted(tl("Formula_Slot")));
return;
}
if (!text.ok) {
host.replaceChildren(
el("div", {
className: "m01-logic__reasons",
children: [el("strong", { text: tx("Calc_Stopped") }), el("div", { text: text.reason })],
}),
);
return;
}
const blocks = text.groups.flatMap((g) => [
el("h4", { className: "m01lab__group", text: g.비목 }),
...g..map((line) =>
el("div", {
className: `m01lab__text${line. ? " m01lab__text--off" : ""}`,
attrs: { "data-text-line": line. },
children: [
el("div", { text: `${line.} : ${line.}` }),
...(line. ? [el("div", { className: "m01-logic__muted", text: line.까닭 })] : []),
],
}),
),
el("p", {
className: "m01lab__subtotal-text",
attrs: { "data-text-sub": String(g.) },
text: `${g.} ${tl("Subtotal")} ${formatNumber(g.)}${g. ? ` (${g.})` : ""}`,
}),
]);
blocks.push(
el("p", {
className: "m01lab__total",
attrs: { "data-text-sum": String(text.) },
text: `${tl("Total")} ${formatNumber(text.)}`,
}),
);
host.replaceChildren(...blocks);
}