diff --git a/M01_MasterData/LogicBuilder/M01_LB_Steps.ts b/M01_MasterData/LogicBuilder/M01_LB_Steps.ts index 9e92ed7e1..0dca8c47b 100644 --- a/M01_MasterData/LogicBuilder/M01_LB_Steps.ts +++ b/M01_MasterData/LogicBuilder/M01_LB_Steps.ts @@ -6,7 +6,12 @@ * ========================================================================== */ import { createButton, el, showToast } from "@ui/ui_template_elements"; -import type { CalcAnswer, CalcLine, LogicInput } from "../M01_MasterData_UI_Logic_Api"; +import { + fetchLogics, + type CalcAnswer, + type CalcLine, + type LogicInput, +} from "../M01_MasterData_UI_Logic_Api"; import { formatMoney } from "../M01_MasterData_UI_Logic_Money"; import { addCard, @@ -23,6 +28,7 @@ import { setCond, type LbLogic, type LbLookup, type LbRef } from "./M01_LB_Block import { calcBody, calcView } from "./M01_LB_Steps_Calc"; import { chip, + logicNames, lookupValue, note, numBox, @@ -42,6 +48,7 @@ import "./M01_LB_Steps.css"; type Kind = "person" | "material" | "machine" | "logic" | "percent" | "locked"; let picking = false; +let namesLoading = false; /* ------------------------------ ① 입력값 ------------------------------ */ @@ -367,4 +374,19 @@ export function renderSteps( ), section(tx("S5"), [el("li", { className: "m01-lbsteps-row", children: [resultView(ctx)] })]), ); + // 다른 일위대가 이름 — 목록을 한 번 받은 뒤 다시 그림 + if ( + !logicNames.size && + !namesLoading && + JSON.stringify([lb.calcs, lb.lookups]).includes('"k":"logic"') + ) { + namesLoading = true; + fetchLogics() + .then((all) => { + for (const l of all) logicNames.set(l.키, l.이름); + renderSteps(host, lb, ans, on); + }) + .catch(() => undefined) + .finally(() => (namesLoading = false)); + } } diff --git a/M01_MasterData/LogicBuilder/M01_LB_Steps_Cell.ts b/M01_MasterData/LogicBuilder/M01_LB_Steps_Cell.ts index e3b1ae55d..35a73f203 100644 --- a/M01_MasterData/LogicBuilder/M01_LB_Steps_Cell.ts +++ b/M01_MasterData/LogicBuilder/M01_LB_Steps_Cell.ts @@ -33,7 +33,7 @@ export const TEXT = { SrcCalc: ["계산 · ", "calc · "], SrcFixed: ["고정값", "fixed value"], SrcAny: ["무관(조건에서 뺌)", "any (remove condition)"], - Other: ["다른 일위대가 결과", "Other unit price result"], + Other: ["다른 일위대가", "Other unit price"], Hard: ["이 화면에서 못 고치는 값", "Value not editable here"], Mul: ["×", "×"], Div: ["÷", "÷"], @@ -197,6 +197,9 @@ export const isRef = (r: Ref, k: "lookup", id: string): boolean => r.k === k && export const lookupNo = (ctx: Ctx, id: string): number => ctx.lb.lookups.findIndex((l) => l.id === id) + 1; +/** 로직 이름 — 목록을 한 번 받아 채움(키 → 이름) · 못 받으면 「다른 일위대가」 */ +export const logicNames = new Map(); + export function refText(ctx: Ctx, r: Ref): string { switch (r.k) { case "input": @@ -210,7 +213,7 @@ export function refText(ctx: Ctx, r: Ref): string { return `${tx("LkNum")}${lookupNo(ctx, r.id)}${lk ? ` · ${lk.col}` : ""}`; } case "logic": - return `${tx("Other")} ${r.key}${r.field ? ` · ${r.field}` : ""}`; + return `${logicNames.get(r.key) ?? tx("Other")}${r.field ? ` · ${r.field}` : ""}`; case "cost": return tx(`Base_${r.name}`); default: