diff --git a/M01_MasterData/EasyCalc/M01_EasyCalc_Pick.ts b/M01_MasterData/EasyCalc/M01_EasyCalc_Pick.ts index a7b9bc8cb..570e67dda 100644 --- a/M01_MasterData/EasyCalc/M01_EasyCalc_Pick.ts +++ b/M01_MasterData/EasyCalc/M01_EasyCalc_Pick.ts @@ -16,7 +16,7 @@ import { import { openModal } from "@ui/ui_template_modal"; import { fetchPick, fetchSubs, type SubInfo } from "../M01_MasterData_Api_Fetch"; import { fetchMaterials } from "../M01_MasterData_UI_Logic_Api"; -import { listEasy, listMachines, machineElement } from "./M01_EasyCalc_Api"; +import { listEasy, listMachines, machineElement, plainError } from "./M01_EasyCalc_Api"; import type { PickResult } from "./M01_EasyCalc_Model"; import "./M01_EasyCalc_Pick.css"; @@ -64,6 +64,8 @@ const te = (key: keyof typeof TEXT, vars: Record = {}): ); const won = (n: number): string => Math.round(n).toLocaleString("ko-KR"); +/** 목록에 그릴 줄 수 — 더 찾으려면 이름을 쳐서 좁힘 */ +const SHOW = 100; const MAT_FILE = "재료_자재품목.json"; /** 목록 한 줄 — 고르면 PickResult(수량 빼고) 를 만들어 줌 */ @@ -294,16 +296,17 @@ export function openEasyPick(kind?: Kind): Promise { return void list.replaceChildren( el("p", { className: "m01-easypick__muted", text: te("Hint") }), ); - count.textContent = te("Count", { n: found.total, m: found.items.length }); + const shown = found.items.slice(0, SHOW); + count.textContent = te("Count", { n: found.total, m: shown.length }); list.replaceChildren( - ...(found.items.length - ? found.items.map((c) => + ...(shown.length + ? shown.map((c) => rowOf(c, () => stepQty(k, c, back ? () => stepList(k, canBack) : null)), ) : [el("p", { className: "m01-easypick__muted", text: te("None") })]), ); - } catch { - if (mine === seq) showToast(te("Failed"), "error"); + } catch (e) { + if (mine === seq) showToast(plainError(e), "error"); } }; if (src.grouped) bar.unshift(...subFilters(filter, load)); @@ -348,7 +351,11 @@ export function openEasyPick(kind?: Kind): Promise { const submit = async (): Promise => { const n = parse(); if (n === null) return qty.setError(te("QtyBad")); - done({ ...(await c.make()), qty: n }); + try { + done({ ...(await c.make()), qty: n }); + } catch (e) { + qty.setError(plainError(e)); + } }; qty.input.addEventListener("input", refresh); qty.input.addEventListener("keydown", (ev) => ev.key === "Enter" && void submit());