Files
Aislo/M02_MasterTemplete/M02_MasterTemplete_Labor_LogicMats.ts
T
eomsangdonandClaude Opus 5.5 482ef981c0 refactor(856-3): 일위대가 단가산출 줄 누름 = 줄 쌓기 한 길 — 프로젝트 사본은 굳힌 SK 문서 보기만 · M01 로직 줄 창 걷음
- 프로젝트 사본(구조물 고르기 카드 · B08 카드) 단가산출 줄 누름 = 사본 참조사본의 굳힌 SK 문서째 줄 쌓기 보기만(memory · 고침 칸 잠김 · 저장 없음 · 층 파일 읽기 0) · 사본에 없으면 알림
- 셈 주입 원본 층 카드 = 그 층 SK 줄 쌓기 읽기만(옛 「프로젝트 사본 줄」 안내 대신)
- M01 로직을 바로 담은 줄(저장본 0) = 창 없이 안내 한 줄 · 프로젝트 · 셈 주입 표(늘 보기만)의 [로직 추가] M01 바로 담기 갈래 지움(서버 from-logic 은 project 층 안 받음 · 서버 고침 0)
- Labor_RowModal = 자재 모달만 · Labor_LogicMats 고침 손잡이 · setLogicMark · 안 쓰는 글 키 지움
- 시험: 856-0 가짜 DOM 에 사본 보기 · 원본 층 읽기만 · 로직 줄 안내 덧 · 소스 글자 시험(175 · 222-1 · 742-1 · 806-1 둘 · logic_mats) 지움 · 811-1 · mat_marks 는 글자 줄만 지우고 700 줄 · 날 단추 · 서버 ↔ 화면 허용 값 짝 남김

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 05:32:35 +09:00

90 lines
3.9 KiB
TypeScript

/* =============================================================================
* M02_MasterTemplete_Labor_LogicMats.ts
* 자재목록 표의 로직 자재 줄(103-1) — 담은 로직 맨 위 층 재료 줄(서버 calc `줄[].재료`) · 사용자 자재 줄과 같은 칸
* (코드 · 이름 · 규격 · 수량 · 단위 · 가격 다섯 · 단가 / 금액) · 사용자 자재 앞.
* · 보기만(856-3 — 로직 줄 창 · [바꾸기] · [기본] · 세 칸 고침 걷음 · 일위대가 면적 보기 `Labor_View` 가 씀)
* · 금액은 로직 단가 안이라 합에 다시 안 더함 · 수량은 로직 것 · 하위 로직 안 재료는 안 보임(엔진이 맨 위 층만 고름)
* ========================================================================== */
import { el } from "@ui/ui_template_elements";
import { formatMoney } from "../common_util/common_util_money";
import type { LaborCalc, LaborRow } from "./M02_MasterTemplete_Labor_Api";
import { lineId } from "./M02_MasterTemplete_Labor_Calc";
import { markCells } from "./M02_MasterTemplete_Labor_MatMarks";
import { moneyCell, PRICE_SLOTS } from "./M02_MasterTemplete_Labor_Rows";
import { tc } from "./M02_MasterTemplete_Labor_Text";
import type { LogicMat } from "./M02_Labor_LogicMats_Model";
const num = (v: number | null): string =>
v === null
? "—"
: Number(v.toPrecision(12)).toLocaleString("ko-KR", { maximumFractionDigits: 6 });
/** 담은 로직 차례대로 그 줄 로직 자재 — calc 답이 없으면 빈 것(답이 오면 다시 그림) */
export function logicMatRows(
rows: LaborRow[],
calc: LaborCalc | null,
wait: boolean,
): HTMLElement[] {
return rows.flatMap((row) => {
const line = row.참조 ? undefined : calc?.줄.find((l) => lineId(l) === lineId(row));
return (line?.재료 ?? []).map((mat) => matRow(row, mat, wait));
});
}
function matRow(row: LaborRow, mat: LogicMat, wait: boolean): HTMLElement {
const item = mat.품목;
const name = item?.이름 ?? mat.이름;
const owner = `${row.별칭 ?? row.로직} · ${mat.이름}`;
const priceCell = (slot: (typeof PRICE_SLOTS)[number]): HTMLElement => {
const base = !!item?.값칸 && item.값칸 === slot;
const v = mat.가격?.[slot];
return el("td", {
className: `m02-labrow__num m02-labrow__price${base ? " is-base-price" : ""}`,
text: wait ? "…" : v === null || v === undefined ? "—" : formatMoney(v),
attrs: { "data-label": slot, "data-price-slot": slot },
});
};
const money = moneyCell(mat.단가, mat.금액, wait, tc("Labor_AppliedSum"));
money.title = tc("LogicMat_Inside");
return el("tr", {
className: `m02-labrow__row m02-labrow__logic-mat${mat.고름 ? " is-picked-mat" : ""}`,
attrs: { "data-labor-logic-mat": `${row.로직}|${mat.차례}` },
children: [
el("td", { className: "m02-labrow__code", text: item?.키 ?? "—" }),
el("td", {
className: "m02-labrow__name",
children: [
el("strong", { text: name, attrs: { title: name } }),
el("small", {
className: "m02-labrow__key",
text: mat.고름 ? `${owner} · ${tc("LogicMat_Picked")}` : owner,
attrs: { title: owner },
}),
...(mat.까닭
? [el("small", { className: "ui-text ui-text--error", text: mat.까닭 })]
: []),
],
}),
el("td", {
className: "m02-labrow__spec",
text: item?.규격 ?? "",
attrs: { title: item?.규격 ?? "" },
}),
el("td", {
className: "m02-labrow__qty",
text: wait ? "…" : num(mat.수량),
attrs: { "data-label": tc("Labor_QtyCol") },
}),
el("td", {
className: "m02-labrow__unit",
text: mat.단위,
attrs: { "data-label": tc("Labor_Unit") },
}),
...markCells(row.자재표시?.[String(mat.차례)] ?? {}),
...PRICE_SLOTS.map(priceCell),
money,
],
});
}