feat(m01-easycalc): 카드로 새로 생긴 설계 값 시험값을 자동값 규칙으로 바로 채움(금액 곧장 보임)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016PSXsvyDxjNmufteN5bqmt
This commit is contained in:
@@ -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<string, unknown>,
|
||||
known: Set<string>,
|
||||
): Record<string, unknown> {
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user