Merge remote-tracking branch 'origin/main_laptop_1' into sub_laptop_3

This commit is contained in:
2026-10-01 11:42:12 +09:00
+21 -1
View File
@@ -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();