From 1c75337388574d8bbf19c134dbd03acf73311aa0 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Thu, 1 Oct 2026 10:38:28 +0900 Subject: [PATCH] =?UTF-8?q?feat(m01-easycalc):=20=EC=B9=B4=EB=93=9C?= =?UTF-8?q?=EB=A1=9C=20=EC=83=88=EB=A1=9C=20=EC=83=9D=EA=B8=B4=20=EC=84=A4?= =?UTF-8?q?=EA=B3=84=20=EA=B0=92=20=EC=8B=9C=ED=97=98=EA=B0=92=EC=9D=84=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=EA=B0=92=20=EA=B7=9C=EC=B9=99=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B0=94=EB=A1=9C=20=EC=B1=84=EC=9B=80(=EA=B8=88?= =?UTF-8?q?=EC=95=A1=20=EA=B3=A7=EC=9E=A5=20=EB=B3=B4=EC=9E=84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016PSXsvyDxjNmufteN5bqmt --- M01_MasterData/EasyCalc/M01_EasyCalc_Entry.ts | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/M01_MasterData/EasyCalc/M01_EasyCalc_Entry.ts b/M01_MasterData/EasyCalc/M01_EasyCalc_Entry.ts index 757f42998..79366262c 100644 --- a/M01_MasterData/EasyCalc/M01_EasyCalc_Entry.ts +++ b/M01_MasterData/EasyCalc/M01_EasyCalc_Entry.ts @@ -18,7 +18,7 @@ import { showToast, } from "@ui/ui_template_elements"; import { openModal } from "@ui/ui_template_modal"; -import type { CalcAnswer } from "../M01_MasterData_UI_Logic_Api"; +import type { CalcAnswer, LogicInput } from "../M01_MasterData_UI_Logic_Api"; import { formatMoney } from "../M01_MasterData_UI_Logic_Money"; import { calcLater, @@ -124,6 +124,23 @@ const blocksSave = (c: EasyCard): boolean => !c.name.trim() || (c.qtyFormula === null && !(c.qty !== null && Number.isFinite(c.qty) && c.qty > 0)); +/** 카드를 넣어 새로 생긴 설계 값의 시험값 — 서버 자동값(`master_auto.values`)과 같은 규칙: + * 고르기 = 첫째 · 범위 = 낮은 끝 · 그 밖 숫자 0 · 값이 「원」 인 가격 값은 비워 둠(0 원처럼 안 보이게) */ +function fillNew( + inputs: LogicInput[], + trial: Record, + known: Set, +): Record { + const out = { ...trial }; + for (const spec of inputs) { + if (known.has(spec.이름)) continue; + known.add(spec.이름); + if (out[spec.이름] !== undefined || String(spec.단위 ?? "").includes("원")) continue; + out[spec.이름] = spec.고르기?.length ? spec.고르기[0] : (spec.범위?.[0] ?? 0); + } + return out; +} + /** 「추가」 옆에 놓는 단추 — 누르면 큰 창 */ export function createEasyCalcButton(): HTMLButtonElement { return createButton({ label: te("Open"), variant: "filled", onClick: openEasyCalc }); @@ -293,6 +310,8 @@ function openEasyCalc(): void { const cardsHost = el("div", { className: "m01-easycalc__cards" }); const sheetHost = el("div"); let trialShape = ""; + /** 연 때 있던 설계 값 — 서버 자동값을 그대로 둠 · 이 밖에 새로 생긴 값만 채움 */ + const known = new Set(doc.inputs.map((i) => i.이름)); const name = createInputField({ label: te("Name"), @@ -360,6 +379,7 @@ function openEasyCalc(): void { const shape = JSON.stringify(doc.inputs); if (shape !== trialShape) { trialShape = shape; + trial = fillNew(doc.inputs, trial, known); renderTrialStrip(trialHost, doc.inputs, trial, (next) => { trial = next; calc();