diff --git a/M02_MasterTemplete/DataFlow/M02_DF_InputPanel.ts b/M02_MasterTemplete/DataFlow/M02_DF_InputPanel.ts index 3fb3a69c5..a6a67a002 100644 --- a/M02_MasterTemplete/DataFlow/M02_DF_InputPanel.ts +++ b/M02_MasterTemplete/DataFlow/M02_DF_InputPanel.ts @@ -21,12 +21,10 @@ import { type SubInfo, } from "../../M01_MasterData/M01_MasterData_Api_Fetch"; import { cfPlain, cfUserElementAdd, cfUserElements, cfValues } from "./M02_DF_Api"; -import type { CfBox, CfElementRef, CfGroup, CfLogic } from "./M02_DF_Model"; +import type { CfBox, CfGroup, CfLogic } from "./M02_DF_Model"; import { GROUPS, M01_OF, - MACHINE_SEP, - USER_PREFIX, addElement, elementOf, machineFields, @@ -243,39 +241,10 @@ function drawChosen( if (node && a.ok && a.value !== null && a.value !== undefined) node.textContent = typeof a.value === "number" ? fmt(a.value) : String(a.value); }), - // Api 가 아직 값을 못 주면 M01 줄에서 바로 읽어 보임(값 칸만 — 요소는 그대로) - () => - els.forEach( - (e) => - void m01Value(group, e).then((v) => { - const node = values.get(e.ref); - if (node && v !== null) node.textContent = fmt(v); - }), - ), + () => undefined, // 값을 못 받아도 요소는 넣을 수 있음 — 값 칸만 「—」 ); } -/** 요소 한 개의 값을 M01 줄에서 읽음 — 이름으로 찾아 키가 같은 줄 · 못 찾으면 null */ -async function m01Value(group: CfGroup, e: CfElementRef): Promise { - if (e.ref.startsWith(USER_PREFIX)) return null; - try { - const [key, field] = e.ref.split(MACHINE_SEP); - const page = await fetchRows( - await fileOf(group), - 1, - 30, - e.name.split(" · ")[0].split(" ")[0], - false, - "", - "", - ); - const row = (page.rows as M01Row[]).find((r) => r["키"] === key); - return row ? valueOf(group, row, field || "가격") : null; - } catch { - return null; - } -} - /** M01 줄 찾기 — 구분 · 상세구분 · 이름 · 내가 만든 것도 함께 */ async function drawFind( host: HTMLElement, @@ -406,7 +375,6 @@ async function drawFind( list, ); void load(); - void USER_PREFIX; } /** 새 요소 — M01 표 「추가」 화면 꼴(이름 · 규격 · 단위 · 값) · 마스터에 안 쓰고 사용자 요소로 */ diff --git a/M02_MasterTemplete/DataFlow/M02_DF_InputPanel_Material.ts b/M02_MasterTemplete/DataFlow/M02_DF_InputPanel_Material.ts index 0d2e45136..80a288717 100644 --- a/M02_MasterTemplete/DataFlow/M02_DF_InputPanel_Material.ts +++ b/M02_MasterTemplete/DataFlow/M02_DF_InputPanel_Material.ts @@ -1,11 +1,10 @@ /* ============================================================================= * M02_DF_InputPanel_Material.ts * 입력 판 — 재료 요소 방식 셋(고정 · 선택 자리 · 조건 찾기) · 자재 찾기(띄어쓰기 AND · 규격까지 · 쪽 넘기기 · 전체 수) - * 서버 `/api/m02/df/materials` 를 먼저 부르고 아직 없으면 M01 `/pick?kind=price` 로 같은 모양을 만듦 + * 서버 `/api/m02/df/materials`(cfMaterials) * 글 [한, 영] 짝은 아래 TEXT · 단추는 공용 작은 크기 * ========================================================================== */ -import { API_BASE_URL } from "@config/config_frontend"; import { currentLanguageIndex } from "@ui/ui_template_locale"; import { createButton, @@ -15,7 +14,7 @@ import { showToast, } from "@ui/ui_template_elements"; import { fetchFiles, fetchSubs, type SubInfo } from "../../M01_MasterData/M01_MasterData_Api_Fetch"; -import { cfValues } from "./M02_DF_Api"; +import { cfMaterials, cfValues } from "./M02_DF_Api"; import type { CfElementRef, CfLogic, CfMaterialMode, CfMaterialRule } from "./M02_DF_Model"; import { catchNote, @@ -101,48 +100,9 @@ export interface MatPage { items: MatItem[]; } -async function getJson(path: string): Promise { - const res = await fetch(`${API_BASE_URL}${path}`, { credentials: "include" }); - if (!res.ok) throw new Error(String(res.status)); - return (await res.json()) as T; -} - -/** 서버가 없으면 M01 값 줄에서 같은 모양으로 — 띄어쓰기 AND(이름 + 규격) · 쪽은 앞에서 잘라 줌 */ -async function fallback(q: MatQuery): Promise { - const r = await getJson<{ items: Record[] }>( - `/m01/pick?${new URLSearchParams({ kind: "price", q: q.q, limit: "200" })}`, - ); - const rows = r.items.filter((i) => !q.sub || i["구분"] === q.sub); - const items = rows.map((i): MatItem => ({ - ref: String(i["ref"]), - name: String(i["이름"] ?? ""), - spec: String(i["규격"] ?? ""), - unit: String(i["단위"] ?? ""), - price: typeof i["값"] === "number" ? i["값"] : null, - 구분: String(i["구분"] ?? ""), - })); - const from = (q.page - 1) * q.size; - return { - total: items.length, - page: q.page, - size: q.size, - items: items.slice(from, from + q.size), - }; -} - +/** 서버 자재 찾기 — 띄어쓰기로 나눈 말을 모두 포함 · 쪽 넘기기 · 전체 수 */ export async function searchMaterials(q: MatQuery): Promise { - const params = new URLSearchParams({ - q: q.q, - page: String(q.page), - size: String(q.size), - sub: q.sub ?? "", - detail: q.detail ?? "", - }); - try { - return await getJson(`/m02/df/materials?${params}`); - } catch { - return fallback(q); - } + return cfMaterials({ q: q.q, sub: q.sub, detail: q.detail, page: q.page, size: q.size }); } let subsCache: SubInfo[] | null = null;