- 704-2 Labor_Sheet 줄 · 소계 · 계 = calcSheetRows(표본 셋 DOM 전후 같음) - 새 M01_MasterData_UI_LogicLab_Est.ts — /text 묶음 그대로 · 묶음이 쓰는 시험 입력(714-3 usedInputs) = 머리 변수 칸 · 「준비 중」 자리 걷음 - 낡은 시험 test_704_logic_standard 고침 — 계산서가 계산 줄 부품을 공용 계산서 안에서 씀(import 자리만 바뀜) - 새 지킴 시험 test_714_2_calc_sheet Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
1.9 KiB
TypeScript
50 lines
1.9 KiB
TypeScript
/* =============================================================================
|
|
* M01_MasterData_UI_LogicLab_Est.ts
|
|
* 「인력·재료·경비」 보기(PLAN 714-2) — 공용 단가산출 계산서(`A00_Common/calc_sheet.ts`)에 시험 계산 읽는 식(`/text`)을 그대로.
|
|
* 묶음 머리 변수 칸 = 그 묶음 줄들이 쓰는 시험 입력(714-3 `usedInputs`) · 바꾸면 시험 계산 입력 고침 + 다시 셈(정본 안 바뀜)
|
|
* ========================================================================== */
|
|
|
|
import { el } from "@ui/ui_template_elements";
|
|
import { createText } from "@ui/ui_template_text";
|
|
import { calcSheetRows } from "../A00_Common/calc_sheet";
|
|
import type { LogicInput } from "./M01_MasterData_UI_Logic_Api";
|
|
import { safeReason } from "./M01_MasterData_UI_Logic_Text";
|
|
import { usedInputs, type PreviewTextAnswer } from "./M01_MasterData_UI_LogicLab_Formula";
|
|
import { tl } from "./M01_MasterData_UI_LogicLab_Text";
|
|
|
|
export interface EstContext {
|
|
text: PreviewTextAnswer | null;
|
|
unit: string;
|
|
inputs: LogicInput[];
|
|
values: Record<string, string>;
|
|
onInput?: (name: string, value: string) => void;
|
|
}
|
|
|
|
export function buildEst(ctx: EstContext): HTMLElement {
|
|
const host = el("div", { className: "m01lab-est", attrs: { "data-est": "" } });
|
|
const text = ctx.text;
|
|
if (!text || (text.ok && text.계산됨 === false)) {
|
|
host.append(createText(tl("Formula_Slot"), "muted"));
|
|
return host;
|
|
}
|
|
if (!text.ok) {
|
|
host.append(createText(safeReason(text.reason), "error"));
|
|
return host;
|
|
}
|
|
const names = ctx.inputs.map((x) => x.이름);
|
|
host.append(
|
|
...calcSheetRows({
|
|
묶음: text.groups,
|
|
계: text.계,
|
|
sumLabel: `${tl("Total")} (${ctx.unit || "원"})`,
|
|
inputs: ctx.inputs,
|
|
values: ctx.values,
|
|
onInput: ctx.onInput,
|
|
uses: (_, gi) => [
|
|
...new Set(text.groups[gi].줄.flatMap((line) => usedInputs(line, names).map(([n]) => n))),
|
|
],
|
|
}),
|
|
);
|
|
return host;
|
|
}
|