diff --git a/M01_MasterData/M01_MasterData_UI_LogicLab_Modal.ts b/M01_MasterData/M01_MasterData_UI_LogicLab_Modal.ts index 2eba698a..f392be09 100644 --- a/M01_MasterData/M01_MasterData_UI_LogicLab_Modal.ts +++ b/M01_MasterData/M01_MasterData_UI_LogicLab_Modal.ts @@ -57,21 +57,35 @@ export interface ModalTarget { export interface TableTarget { title: string; table: string; - /** 찾은 줄 — 줄의 키·원문번호 글, 또는 줄 차례(0부터) */ - row?: string | number | null; + /** 찾은 줄 — 찾기 조건(예 {구분: 합판}) · 줄의 키·원문번호 글 · 줄 차례(0부터) */ + row?: Record | string | number | null; /** 찾은 값 칸 이름 */ col?: string | null; } +const sameCond = (have: unknown, want: unknown, range: boolean): boolean => { + if (range && Array.isArray(have)) { + const n = Number(want); + const [low, high] = have as (number | null)[]; + return (low == null || n >= low) && (high == null || n <= high); + } + return String(have) === String(want); +}; + function tableView(table: TableRow, target: TableTarget): HTMLElement { const lines = table.줄 ?? []; const at = target.row; + const kinds = table.조건 ?? {}; const hit = at === undefined || at === null ? null : typeof at === "number" ? (lines[at] ?? null) - : (lines.find((line) => line["키"] === at || line["원문번호"] === at) ?? null); + : typeof at === "string" + ? (lines.find((line) => line["키"] === at || line["원문번호"] === at) ?? null) + : (lines.find((line) => + Object.entries(at).every(([c, want]) => sameCond(line[c], want, kinds[c] === "범위")), + ) ?? null); const cols = [...Object.keys(table.조건 ?? {}), ...Object.keys(table.값칸 ?? {})]; const rows = lines.map((line) => el("tr", { diff --git a/M01_MasterData/M01_MasterData_UI_Logic_Api.ts b/M01_MasterData/M01_MasterData_UI_Logic_Api.ts index 5d478add..1626f95d 100644 --- a/M01_MasterData/M01_MasterData_UI_Logic_Api.ts +++ b/M01_MasterData/M01_MasterData_UI_Logic_Api.ts @@ -210,8 +210,8 @@ export const fetchMaterials = (cond: { /** 자동값 길(`GET /logic/auto`) — 입력 이름 → 견본값 · 서버에 아직 없거나 값이 없으면 빈 채로(화면은 그냥 안 채움) */ export const fetchAuto = (key: string): Promise> => - request<{ 입력?: Record }>(`/logic/auto?${query({ key })}`) - .then((d) => d.입력 ?? {}) + request<{ 값?: Record }>(`/logic/auto?${query({ key })}`) + .then((d) => d.값 ?? {}) .catch(() => ({})); export const runCalc = (body: {