fix(M01): 잡힌 품목 이름 · 모달 검색 칸 괄호 앞 낱말 · 상세 재료 줄 모달 서버 품목 · 단위경고 딱지 상세 줄에도 (PLAN 8-5)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WRFJmmhPi4exAzHgPZHMT
This commit is contained in:
@@ -6,10 +6,10 @@
|
||||
|
||||
import { createButton, el } from "@ui/ui_template_elements";
|
||||
import { fetchRows, type Row } from "./M01_MasterData_Api_Fetch";
|
||||
import type { ElementBrief, LogicInput, LogicRow } from "./M01_MasterData_UI_Logic_Api";
|
||||
import type { CalcLine, ElementBrief, LogicInput, LogicRow } from "./M01_MasterData_UI_Logic_Api";
|
||||
import { openPickTable } from "./M01_MasterData_UI_Logic_PickTable";
|
||||
import { tx } from "./M01_MasterData_UI_Logic_Text";
|
||||
import { condText, type PickCond } from "./M01_MasterData_UI_LogicLab_Modal";
|
||||
import { condText, headWord, type PickCond } from "./M01_MasterData_UI_LogicLab_Modal";
|
||||
|
||||
interface Chosen {
|
||||
ref: string;
|
||||
@@ -33,7 +33,6 @@ export function pickBody(values: Record<string, string>): { 고름?: Record<stri
|
||||
}
|
||||
|
||||
const nameOf = (row: Row): string => `${row["이름"] ?? ""} ${row["규격"] ?? ""}`.trim();
|
||||
const firstWord = (text: string): string => text.trim().split(/\s+/)[0] ?? "";
|
||||
|
||||
const MATERIAL_KEYS = /^MT\d{6}$/;
|
||||
const MACHINE_CODE = /^\d{4}-\d{4}$/;
|
||||
@@ -73,17 +72,18 @@ export function materialRows(
|
||||
? (item.요소 as unknown as PickCond)
|
||||
: null;
|
||||
const brief = (cond ? prices[condText(cond)] : prices[item.요소]) ?? null;
|
||||
const label = item.이름 ?? (brief?.이름 as string | undefined) ?? "";
|
||||
const named = item.이름 && !/^[A-Z]{2}\d{6}/.test(item.이름) ? item.이름 : "";
|
||||
const label = named || (brief?.이름 as string | undefined) || "";
|
||||
const held = mine.get(i);
|
||||
const nowRef = held?.ref ?? brief?.ref;
|
||||
const nowName =
|
||||
held?.label ?? (brief ? `${brief.이름 ?? ""} ${brief.규격 ?? ""}`.trim() : "") ?? "";
|
||||
const seeds = [cond?.["검색어"], cond?.이름, cond?.상세구분, cond?.구분, label]
|
||||
.map((w) => firstWord(String(w ?? "")))
|
||||
.map(headWord)
|
||||
.filter((w, k, all) => w && all.indexOf(w) === k);
|
||||
const current = el("span", {
|
||||
className: "m01-logic__muted",
|
||||
text: `${nowName || tx("Mat_NoPrice")} `,
|
||||
attrs: { "data-mat-idx": String(i), "data-ref": brief?.ref ?? "" },
|
||||
});
|
||||
const button = pickButton(tx("Pick_Item"), () =>
|
||||
openPickTable({
|
||||
@@ -91,7 +91,7 @@ export function materialRows(
|
||||
title: `${tx("Pick_MatTitle")} · ${label}`,
|
||||
seed: seeds[0] ?? "",
|
||||
alt: seeds.slice(1),
|
||||
isCurrent: (r) => String(r["키"]) === nowRef,
|
||||
isCurrent: (r) => String(r["키"]) === (mine.get(i)?.ref ?? current.dataset.ref),
|
||||
onPick: (r) => {
|
||||
mine.set(i, { ref: String(r["키"]), label: nameOf(r) });
|
||||
current.textContent = `${nameOf(r)} `;
|
||||
@@ -103,6 +103,22 @@ export function materialRows(
|
||||
});
|
||||
}
|
||||
|
||||
/** 계산 답의 `품목` 을 잡힌 품목 글로 — 고른 재료가 있는 줄은 그대로 */
|
||||
export function showItems(
|
||||
host: HTMLElement,
|
||||
values: Record<string, string>,
|
||||
lines: CalcLine[],
|
||||
): void {
|
||||
const mine = picksOf(values);
|
||||
host.querySelectorAll<HTMLElement>("[data-mat-idx]").forEach((span) => {
|
||||
const i = Number(span.dataset.matIdx);
|
||||
const item = lines[i]?.품목;
|
||||
if (!item || mine.has(i)) return;
|
||||
span.dataset.ref = item.키;
|
||||
span.textContent = `${`${item.이름 ?? ""} ${item.규격 ?? ""}`.trim() || item.키} `;
|
||||
});
|
||||
}
|
||||
|
||||
/** 기계 입력 칸 — 표 모달로 고르면 입력값(원문 분류번호 · 키 목록이면 키) */
|
||||
const machines = new Map<string, Row | null>();
|
||||
async function machineRow(code: string): Promise<Row | null> {
|
||||
|
||||
Reference in New Issue
Block a user