/* ============================================================================= * M01_MasterData_UI_LogicLab_Foot.ts * 화면(모달) 바닥에 붙는 비목 소계 줄(737-1 · PLAN 748-3) — 단가산출 상세(노무비 · 재료비 · 경비 · 계 네 칸) · * 텍스트 수식(노무비 · 재료비 · 경비 세 칸 · 계 칸 없음 — 중복 표기) 두 보기가 같이 씀. * 값 = 서버 셈 그대로(여기서 다시 셈 안 함) · 계산 전 「—」. * ========================================================================== */ import { createCalcFormulaRow } from "@ui/ui_template_calc_row"; import { el } from "@ui/ui_template_elements"; import { formatMoney } from "./M01_MasterData_UI_Logic_Money"; import { tl } from "./M01_MasterData_UI_LogicLab_Text"; export type FootKey = "labor" | "material" | "cost"; const LABEL: Record = { labor: "노무비", material: "재료비", cost: "경비" }; export const FOOT_KEYS = Object.keys(LABEL) as FootKey[]; /** 서버 비목 이름 → 칸 */ export const FOOT_OF: Record = { 노무비: "labor", 재료비: "material", 경비: "cost", }; /** 비목 소계 줄 — `total` 을 주면 맨 끝 「계」 칸까지 네 칸(주지 않으면 세 칸) */ export function buildFoot( sums: Record, calculated: boolean, total?: number, ): HTMLElement { const cells = FOOT_KEYS.map((k) => { const out = el("span", { className: "ui-calc-row__out is-key", text: calculated ? formatMoney(sums[k]) : "—", }); const row = createCalcFormulaRow(LABEL[k], null, out); row.dataset.group = k; row.dataset.subtotal = calculated ? String(sums[k]) : ""; return row; }); const foot = el("div", { className: "m01lab__foot", children: [ el("div", { className: "m01lab__sums", children: cells }), ...(total === undefined ? [] : [ el("p", { className: "m01lab__total", attrs: { "data-sum": calculated ? String(total) : "" }, children: [ el("span", { text: `${tl("Total")} ` }), el("span", { text: calculated ? formatMoney(total) : "—" }), ], }), ]), ], }); if (total === undefined) foot.dataset.cols = "3"; return foot; }