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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user