refactor(856-1): 단가산출 상세 몸 걷기 — 줄 쌓기 한 벌 · 열 때 서버 셈 한 번

- 지움: M01 LogicLab_Ho · LogicLab_Cover · M02 Sangeun_Cover_Model · Sangeun_Undo · Sangeun_BaseHead · Labor_RowSk
- Sangeun_Detail: 숨긴 몸 · 바탕 원값(bare) 셈 · 덮개 고침 · 재료 고름 · 키 글자 약속(SK-000000) 걷음 → 모드 옵션(page · ref · memory)
- Sangeun_Tabs: 몸 그릇 · 숨김 걷음 · Sangeun_Cover: 뺀 줄 띠 걷음 · 셈 보기 덧칸 끔(머리 띠는 안 씀) · 머리 띠 타입만 둠(856-2 에서 파일째)
- 일위대가 줄 모달: 로직 줄 · 셈 주입 줄 = 안내 한 줄(856-3 까지) · 상세 · [적용] 걷음 · 줄 패치 칸 · 타입 걷음(저장본 0)
- M01 LogicLab_Detail: M02 몸 칸 걷음(M01 보기 그대로) · 지운 파일만 쓰던 글 키 16 · CSS 규칙 걷음
- 시험: 지운 몸만 붙든 시험 지움(717_3 · 722 · 748_0 · helper 728_2 · 748_0) · 섞인 파일은 몸 꼴 · 글 대조 함수 · 줄만 지움(서버 셈 시험 남김) · 856-0 단언 뒤집음
- 수치: 열 때 /sangeun/calc 2 → 1 · 숨은 몸 DOM 2 → 0 · 화면 파일 줄 −1.9 천 안팎

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 19:36:59 +09:00
co-authored by Claude Opus 5.5
parent 13c1bd961a
commit d6715dcec5
44 changed files with 129 additions and 3279 deletions
@@ -1,31 +1,24 @@
/* =============================================================================
* M02_MasterTemplete_Labor_RowModal.ts
* 일위대가표 줄 누름 모달(PLAN 723-2 · 723-3 · 요구서_내역16 2장 4 · 5) — 일위대가표에서 빠진 줄 동작을 모달 안으로.
* · 로직 줄(단가산출 문서 없음) · 셈 주입 SK 줄 = 머리(이름 · 「1 ㎡ 당」) ·
* 단가산출 상세 줄 모드(717-2b · `Labor_RowSk` · 수식 보기 하나(836-3) · 옛 [항목 추가] · [율 줄 추가] 없음) ·
* 일위대가표 줄 누름 모달(PLAN 723-2 · 요구서_내역16 2장 4 · 5 · 856-1) — 일위대가표에서 빠진 줄 동작을 모달 안으로.
* · 로직 줄(단가산출 문서 없음) · 셈 주입 줄(프로젝트 사본) = 머리(이름 · 「1 ㎡ 당」 · 옵션 값 · 메모) + 안내 한 줄
* (856-1 — 옛 단가산출 상세 몸 · [적용] 걷음 · 고침 = 단가산출 줄 쌓기 · 856-3 에서 줄 쌓기 보기로) ·
* 로직 자재(바꾸기 · 기본 · 세 칸 · `Labor_LogicMats`)
* · [적용] = 그 줄 덮개(M02 변경 항목) + 옵션(상세 옵션 칸 → 그 줄 입력값)
* · 808-1(요구 701-4 · 5) — 옛 [옵션] · [단가산출로도 저장] · [항목 추가] · [율 줄 추가] 걷음 · 일위대가 줄 = 저장 때
* M01 로직 줄 + 고침으로 펼쳐 담김(740-1 · `본뜬` = 온 단가산출) → 수식 문서 없음 = 수식 보기 없이 단가산출 상세 몸만 +
* 안내(온 단가산출 이름 · 수식은 그 단가산출에서 고쳐 다시 담음)
* · 사용자 자재 줄 = 자재 모달(세 칸 · `Labor_MatTable` 한 줄)
* · 고침 = 그 줄 화면 캐시(저장은 [저장]) · 금액은 표가 다시 셈 → `watch` 로 받아 다시 그림
* ========================================================================== */
import { createBanner } from "@ui/ui_template_banner";
import { createButton, el, showToast } from "@ui/ui_template_elements";
import { askConfirm, openModal } from "@ui/ui_template_modal";
import { el, showToast } from "@ui/ui_template_elements";
import { openModal } from "@ui/ui_template_modal";
import { createText } from "@ui/ui_template_text";
import type { ItemLogic } from "./M02_MasterTemplete_Api_Fetch";
import type { LaborCalc, LaborMat, LaborRow, MatMarkKey } from "./M02_MasterTemplete_Labor_Api";
import { logicMatRows } from "./M02_MasterTemplete_Labor_LogicMats";
import { setLogicMark, setMark } from "./M02_MasterTemplete_Labor_MatMarks";
import { matTable } from "./M02_MasterTemplete_Labor_MatTable";
import { mountRowSk, type RowSkHandle } from "./M02_MasterTemplete_Labor_RowSk";
import { tc } from "./M02_MasterTemplete_Labor_Text";
import type { SkScope } from "./M02_MasterTemplete_Sangeun_Cover";
import { releaseTied } from "./M02_Labor_LogicMats_Model";
import { keepKnown, valueLine } from "./M02_Labor_Values_Model";
import { valueLine } from "./M02_Labor_Values_Model";
/** 표가 다시 센 답을 받음 — 돌려준 함수 = 그만 받음 */
export type CalcWatch = (fn: (calc: LaborCalc | null) => void) => () => void;
@@ -36,11 +29,8 @@ export interface RowModalOptions {
title: string;
/** 일위대가 머리(이름 · 「1 ㎡ 당」) */
head: string;
/** 줄 분모(SK 단위 기본) */
unit: string;
scope: SkScope;
readOnly: boolean;
/** 셈 주입(프로젝트 복사본) — 단가산출 상세 없음 */
/** 셈 주입(프로젝트 복사본) — 안내 글이 다름 */
inject: boolean;
/** 사용자 자재 코드 — 로직 자재 [바꾸기]로 같은 품목 막음 */
userMats: string[];
@@ -50,16 +40,18 @@ export interface RowModalOptions {
}
const TEXT = {
Apply: ["적용", "Apply"],
NoDoc: [
"M01 로직을 바로 쓴 줄 — 수식 탭은 단가산출 문서가 있어야 열림(단가산출을 만들어 담음) · 여기서는 단가산출 상세만",
"Uses the M01 logic directly — the equation tab needs a build-up document",
"M01 로직을 바로 담은 줄 — 단가산출 화면 없음 · 고침은 단가산출로 담아(일위대가 [로직 추가]) 그 줄에서",
"Uses the M01 logic directly — add it as a build-up to edit",
],
FromSk: [
"단가산출 「{k}」 에서 담아 온 줄(담을 때 펼침) — 수식은 그 단가산출에서 고쳐 다시 담음 · 여기서는 단가산출 상세만",
"Copied from build-up 「{k}」 — edit its equation there and re-add",
"단가산출 「{k}」 에서 담아 온 줄 — 고침은 그 단가산출에서 고쳐 다시 담음",
"Copied from build-up 「{k}」 — edit it there and re-add",
],
Inject: [
"프로젝트 사본 줄 — 단가산출 화면 없음 · 수식 고침은 M02 단가산출에서 고쳐 [재생성]",
"Project copy line — edit the build-up in M02 and regenerate",
],
Discard: ["적용 안 한 고침이 있음 — 버리고 닫을까?", "Discard unapplied edits?"],
} as const;
const t = (k: keyof typeof TEXT): string => TEXT[k][0];
@@ -69,7 +61,6 @@ export function openRowModal(o: RowModalOptions): void {
const info = el("div", { attrs: { "data-row-head": "" } });
const mats = el("div", { attrs: { "data-row-mats": "" } });
let calc: LaborCalc | null = null;
const line = () => calc?.줄.find((l) => !row.참조 && l.로직 === row.로직);
const draw = (): void => {
const values = valueLine(o.logic?.입력 ?? [], row.입력값);
@@ -117,84 +108,25 @@ export function openRowModal(o: RowModalOptions): void {
);
};
/** 옵션 → 그 줄 입력값(로직 줄만 · 아는 입력만) · 같으면 참 */
function setValues(next: Record<string, string | number>): boolean {
if (row.참조) return true;
const values = o.logic ? keepKnown(o.logic.입력, next).kept : next;
if (JSON.stringify(values) === JSON.stringify(row.입력값)) return true;
const before = row.입력값;
row.입력값 = values;
releaseTied(row, before, line()?.재료 ?? []); // 바뀐 입력에 걸린 고름 = 기본(103-1)
return false;
}
// 단가산출 상세 줄 모드(723-3) — 셈 주입(프로젝트 복사본)엔 없음 · 수식 단추 = 모달 머리(808-1)
const slot = el("span", { className: "m02-main__tools" });
const skHost = el("div", { attrs: { "data-row-sk-host": "" } });
let sk: RowSkHandle | null = null;
const skMount = (): void => {
if (o.inject) return;
sk?.destroy();
sk = mountRowSk(skHost, {
row,
scope: o.scope,
title: o.title,
unit: o.unit,
readOnly: !edit,
slot,
});
};
let close = (): void => {};
const finish = (): void => {
stop();
sk?.destroy();
};
const apply = createButton({
label: t("Apply"),
variant: "filled",
onClick: () => {
const got = sk?.take() ?? null;
if (got) {
if (got.patch) row.패치 = got.patch;
else delete row.패치;
setValues(got.values);
o.done(true);
draw();
}
finish(); // [적용] = 그 줄에 남기고 닫음(저장은 페이지 [저장]) · 코드 닫기는 beforeClose 안 거침
close();
},
});
// 수식 문서 없는 줄(808-1) — 안내 한 줄(온 단가산출 = `본뜬`)
// 안내 한 줄(856-1) — 로직 줄 = 온 단가산출(`본뜬`) · 셈 주입 = 프로젝트 사본
const from = row.본뜬 && typeof row.본뜬.이름 === "string" ? row.본뜬.이름 : "";
const noDoc =
!row.참조 && !o.inject
? createBanner({
tone: "info",
text: from ? t("FromSk").replace("{k}", from) : t("NoDoc"),
})
: null;
apply.dataset.rowApply = "";
const note = createBanner({
tone: "info",
text: o.inject ? t("Inject") : from ? t("FromSk").replace("{k}", from) : t("NoDoc"),
});
const stop = o.watch((c) => {
calc = c;
draw();
});
const tools = edit && !o.inject ? [apply] : [];
({ close } = openModal({
openModal({
title: o.title,
closeLabel: tc("In_Close"),
width: "1100px",
wide: true,
actions: row.참조 ? [slot, ...tools] : tools, // 로직 줄 = 머리 단추 없음(상세만)
beforeClose: async () => {
if (sk?.take() && !(await askConfirm({ message: t("Discard"), danger: true }))) return false;
finish();
return true;
},
mount: (body) => body.append(info, ...(noDoc ? [noDoc] : []), skHost, mats),
}));
beforeClose: () => (stop(), true),
mount: (body) => body.append(info, note, mats),
});
draw();
skMount();
}
export interface MatModalOptions {