- 바꿈: 고르기 → 선택 · 다시 고르기 · 다시 고름 → 재선택 · 고름 풀기 → 선택 해제 · 고른 → 선택한 · 고를 → 선택할 · 고르세요 → 선택하세요 · 골라 → 선택해 · 안 고르면 → 선택하지 않으면 등(TS 280 · Python 43 · CAD 앱 글 포함) - 남김: 「면고르기 · 노면고르기및다짐」 = 공종 이름(사용자 확정) · 수식 문서 칸 · 파일 · 판정 · 상태 값을 겸하는 글(「고름」 · 「고르기」 · 「고른자재」 · 「고른」 · 「고를 것」 · 「규격 없음 — 고르기」 · 「단위 다름 — 고르기」 · 그 칸 이름을 가리키는 검사 글) · 「고르게」(가지런 뜻) · 주석 · 이름 · 자료 파일 - 파이썬 짝: `master_unit_swap.ts` ↔ `resources/master_data/scripts/master_unit.py` 같은 글(「선택해야 셈」) — 자료 값 아님 - 시험: 바뀐 글을 기대하던 15 개를 새 글로(소스 글 대조 포함) - 목록 · 남긴 자리 = sub1 tmp/s894/표_용어_선택.md · typecheck 0 · CAD 앱 다시 지음 · 관련 + 관문 3,250 중 바뀐 글 시험 고친 뒤 통과(남은 1 = test_442_2 · 다른 창 860-6 의 station_display 자리 · 이번 일 무관) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
246 lines
11 KiB
TypeScript
246 lines
11 KiB
TypeScript
/* =============================================================================
|
|
* M02_MasterTemplete_Hopyo_View.ts
|
|
* 엑셀 불러오기 [수정] 모달(PLAN 809-1 · 요구 702 · 703) — 엑셀 보기 오른쪽 호표 목록 [수정](`Hopyo_Sheet`)이 엶.
|
|
* 경쟁사 로직 인정 · 요소만 연결 — 몸 = 일위대가 컨테이너 부품(`Labor_Table` · 806-1 조합과 한 벌 · 읽기만) + 덧칸 둘:
|
|
* · 표지 = 로직 줄 「단가산출 N」 · 「일위대가 N」 칩 / 요소 줄 「✓ 연결됨」 · 「후보 n」 · 「못 이음」(엑셀 값 그대로)
|
|
* · 엑셀 금액 = 그 줄 엑셀 금액 계
|
|
* 줄 = 서버 `GET …/hopyo-view/{키}/{번}`(`M02_Hopyo_View` · 엑셀 숫자 그대로 고정 줄 · 저장 없음 · 금액 = 엑셀 판 ·
|
|
* 일위대가표 머리 판 고르기(859-4 `Labor_Basis`) = [우리 단가로] 미리 셈 · 후보 창 머리 = 자재 판정).
|
|
* · 단가산출 줄 누름 = 그 블록 가져온 식 모달(`Hopyo_Imported` · 미리 보기 · 층에 안 씀 · 저장 = 모달 [저장] ·
|
|
* 835-1 — 옛 「누르면 SK 만듦」 걷음 · [엑셀 단가 그대로 | 우리 단가로])
|
|
* · 일위대가 줄 누름 = 그 하위 호표 [수정] 모달 · 후보 줄 누름 = 후보 목록(고르기 = [내 일위대가로] 뒤 일위대가 [연결])
|
|
* · 머리 = 표지 수 · 고른 판 단가(860-3 · 셈 답 = 표 합계 · 다른 판 금액 작게) · [내 일위대가로](807-1 `Hopyo_Mine`) · [구조물 조합으로](만든 SC 있을 때 · `Hopyo_ToItem`) · [엑셀 보기]
|
|
* 기초 판정 · 「우리 기초로 바꾸기」 없음(요구 703).
|
|
* ========================================================================== */
|
|
|
|
import { createBadge } from "@ui/ui_template_badge";
|
|
import { createButton, el } from "@ui/ui_template_elements";
|
|
import { loadingError, showLoading } from "@ui/ui_template_loading";
|
|
import { t as L } from "@ui/ui_template_locale";
|
|
import { openModal } from "@ui/ui_template_modal";
|
|
import { createTable } from "@ui/ui_template_table";
|
|
import { createText } from "@ui/ui_template_text";
|
|
import { createToolbar } from "@ui/ui_template_toolbar";
|
|
import { formatPrice } from "../common_util/common_util_money";
|
|
import { call } from "./M02_MasterTemplete_Api_Fetch";
|
|
import { at, type HopyoBrief, type HopyoScope } from "./M02_MasterTemplete_Hopyo_Api";
|
|
import { mineButton } from "./M02_MasterTemplete_Hopyo_Mine";
|
|
import { toItem } from "./M02_MasterTemplete_Hopyo_ToItem";
|
|
import { openImported } from "./M02_MasterTemplete_Hopyo_Imported";
|
|
import type { LaborDetailHandle } from "./M02_MasterTemplete_Labor_Detail";
|
|
import { mountLaborTable } from "./M02_MasterTemplete_Labor_Table";
|
|
|
|
const TEXT = {
|
|
Title: "제{n}호표 — 엑셀 불러오기",
|
|
Mark: "표지",
|
|
Excel: "엑셀 금액",
|
|
Linked: "✓ 연결됨",
|
|
Near: "후보 {n}",
|
|
None: "못 이음",
|
|
Logic: "로직 {n}",
|
|
ExcelPrice: "엑셀 단가",
|
|
OurPrice: "우리 단가",
|
|
ExcelShort: "엑셀",
|
|
OurShort: "우리",
|
|
Hint: "경쟁사 로직 그대로 · 요소만 연결 — 단가산출 줄을 누르면 수식 탭 · 금액 = 엑셀",
|
|
Sheet: "엑셀 보기",
|
|
NearTitle: "이음 후보 — {name}",
|
|
NearHint: "선택 = [내 일위대가로] 뒤 내 일위대가의 [연결]",
|
|
Key: "키",
|
|
Name: "이름",
|
|
Close: "닫기",
|
|
} as const satisfies Record<string, string>;
|
|
const t = (k: keyof typeof TEXT): string => TEXT[k];
|
|
const why = (e: unknown): string => (e instanceof Error ? e.message : String(e));
|
|
const enc = encodeURIComponent;
|
|
|
|
type Money = Record<"노무비" | "재료비" | "경비" | "계", number | null>;
|
|
/** 줄 표지(서버 `M02_Hopyo_View.mark`) */
|
|
export interface ViewMark {
|
|
차례: number;
|
|
갈래: "로직" | "요소";
|
|
표지: "단가산출" | "일위대가" | "연결됨" | "후보" | "못 이음";
|
|
번?: number | null;
|
|
이음?: Record<string, string>;
|
|
후보?: { 키: string; 이름: string }[];
|
|
/** 자재 줄 판정(단가산출 불러오기와 같은 말 · 859-4) */
|
|
판정?: string;
|
|
엑셀: Money;
|
|
}
|
|
export interface ViewReply {
|
|
번: number;
|
|
이름: string;
|
|
규격: string | null;
|
|
단위: string | null;
|
|
금액: Money | null;
|
|
문서: unknown;
|
|
줄: ViewMark[];
|
|
}
|
|
|
|
export const readHopyoView = (file: HopyoScope, key: string, no: number): Promise<ViewReply> =>
|
|
call(at(file, `/hopyo-view/${enc(key)}/${no}`));
|
|
|
|
/** 표지 칸 글 */
|
|
export function markText(m: ViewMark): string {
|
|
if (m.갈래 === "로직") return `${m.표지}${m.번 ? ` ${m.번}` : ""}`;
|
|
if (m.표지 === "연결됨") return t("Linked");
|
|
if (m.표지 === "후보") return t("Near").replace("{n}", String(m.후보?.length ?? 0));
|
|
return t("None");
|
|
}
|
|
|
|
/** 표지 칸 꼴 — 로직 = 칩 · 연결됨 초록 · 후보 주황 · 못 이음 빨강 */
|
|
const markTone = (m: ViewMark): string =>
|
|
m.갈래 === "로직"
|
|
? "ui-hopyo-grid__tag is-pum"
|
|
: m.표지 === "연결됨"
|
|
? "ui-text--success"
|
|
: m.표지 === "후보"
|
|
? "ui-text--warning"
|
|
: "ui-text--error";
|
|
|
|
export interface ViewOptions {
|
|
/** 실무자료 파일 층 */
|
|
file: HopyoScope;
|
|
key: string;
|
|
/** 가져온 식 SK 를 만들 층 */
|
|
target: HopyoScope;
|
|
no: number;
|
|
/** 목록 한 줄([내 일위대가로] · 엑셀 단가) */
|
|
brief?: HopyoBrief;
|
|
canWrite: boolean;
|
|
/** 모달 닫고 엑셀 보기 그 호표 */
|
|
onSheet?: () => void;
|
|
}
|
|
|
|
/** 후보 줄 — 후보 목록 */
|
|
function showNear(name: string, m: ViewMark): void {
|
|
openModal({
|
|
title: t("NearTitle").replace("{name}", name),
|
|
closeLabel: t("Close"),
|
|
dialogClass: "m02-modal",
|
|
mount: (body) => {
|
|
const rows = (m.후보 ?? []).map((c) => [c.키, c.이름]);
|
|
if (m.판정) body.append(createText(m.판정, "muted")); // 859-4 단가산출 불러오기와 같은 판정 말
|
|
body.append(createTable([{ label: t("Key") }, { label: t("Name") }], rows, { density: "data" })); // prettier-ignore
|
|
body.append(createText(t("NearHint"), "hint"));
|
|
},
|
|
});
|
|
}
|
|
|
|
/** [구조물 조합으로] — 만든 SC(이 파일 층에서 옮긴 것)로 구조물 조합 만들기 */
|
|
const itemButton = (target: HopyoScope, sc: string, name: string, unit: string): HTMLElement =>
|
|
createButton({ label: L("M02_CheckToItem"), size: 28, variant: "ghost", onClick: () => toItem({ target, sc, name, unit }) }); // prettier-ignore
|
|
|
|
/** [수정] 모달 */
|
|
export function openHopyoView(o: ViewOptions): void {
|
|
const root = el("div", { className: "m02-hopyo", attrs: { "data-hopyo-view": `${o.key}|${o.no}` } }); // prettier-ignore
|
|
const host = el("div", { attrs: { "data-hopyo-view-body": "" } });
|
|
let table: LaborDetailHandle | null = null;
|
|
let close = (): void => {};
|
|
|
|
/** 단가산출 줄 — 가져온 식 모달(미리 보기 · 저장은 모달 [저장] · 835-1) */
|
|
const openSk = (m: ViewMark): void =>
|
|
openImported({ file: o.file, key: o.key, no: m.번!, target: o.target, canWrite: o.canWrite });
|
|
|
|
function draw(r: ViewReply): void {
|
|
const count = (k: ViewMark["표지"]): number => r.줄.filter((m) => m.표지 === k).length;
|
|
const logic = r.줄.filter((m) => m.갈래 === "로직").length;
|
|
const name = [r.이름, r.규격].filter(Boolean).join(" ");
|
|
const badges = [
|
|
createBadge(t("Logic").replace("{n}", String(logic)), "accent"),
|
|
createBadge(`${t("Linked")} ${count("연결됨")}`, "success"),
|
|
createBadge(t("Near").replace("{n}", String(count("후보"))), "warning"),
|
|
createBadge(`${t("None")} ${count("못 이음")}`, "danger"),
|
|
];
|
|
badges.forEach((b, i) => (b.dataset.viewCount = ["로직", "연결됨", "후보", "못 이음"][i]));
|
|
const sheet = createButton({ label: t("Sheet"), size: 28, variant: "ghost", onClick: () => { close(); o.onSheet?.(); } }); // prettier-ignore
|
|
// 860-3 머리 금액 = 고른 판 이름 · 금액(표 합계 = 셈 답) · 다른 판 금액은 곁에 작게(우리 = 한 번 셈한 뒤)
|
|
const excel = r.금액?.계 ?? null;
|
|
let ours: number | null = null;
|
|
let main = createText("", "muted", 14);
|
|
let other = createText("", "muted", 12);
|
|
const paintPrice = (basis: unknown, total: number | null): void => {
|
|
if (basis === "우리") ours = total;
|
|
const won = (v: number | null): string => (v == null ? "—" : formatPrice(v));
|
|
const head = `${t(basis === "우리" ? "OurPrice" : "ExcelPrice")} ${won(total)}`;
|
|
const side = basis === "우리" ? `${t("ExcelShort")} ${won(excel)}` : ours == null ? "" : `${t("OurShort")} ${won(ours)}`; // prettier-ignore
|
|
const [m, s] = [createText(head, "muted", 14), createText(side, "muted", 12)];
|
|
m.dataset.hopyoPrice = basis === "우리" ? "우리" : "엑셀";
|
|
s.hidden = !side;
|
|
main.replaceWith(m);
|
|
other.replaceWith(s);
|
|
[main, other] = [m, s];
|
|
};
|
|
paintPrice("엑셀", excel);
|
|
const items: (HTMLElement | "divider")[] = [
|
|
el("strong", { text: `제${r.번}호표 ${name}` }),
|
|
...badges,
|
|
"divider",
|
|
main,
|
|
other,
|
|
...(o.brief ? [mineButton(o.file, o.key, o.brief)] : []),
|
|
...(o.brief?.만든 && o.canWrite
|
|
? [itemButton(o.target, o.brief.만든, name, r.단위 ?? "")]
|
|
: []),
|
|
...(o.onSheet ? [sheet] : []),
|
|
];
|
|
root.replaceChildren(createToolbar({ items }), createText(t("Hint"), "hint"), host);
|
|
table?.destroy();
|
|
table = mountLaborTable(host, r.문서, {
|
|
layer: o.target.layer,
|
|
owner: o.target.owner,
|
|
column: `제${r.번}호표`,
|
|
mode: "precombo",
|
|
readOnly: true,
|
|
onChanged: () => {},
|
|
view: {
|
|
cols: [
|
|
{ key: "x_mark", label: t("Mark"), width: 96 },
|
|
{ key: "x_excel", label: t("Excel"), kind: "number", decimals: 1, trim: true, width: 96 },
|
|
],
|
|
cell: (n, key) => {
|
|
const m = r.줄[n];
|
|
if (!m) return null;
|
|
return key === "x_mark" ? markText(m) : m.엑셀.계;
|
|
},
|
|
tone: (n, key) => (key === "x_mark" && r.줄[n] ? markTone(r.줄[n]) : null),
|
|
onCalc: (got, doc) => paintPrice(doc.본뜬?.단가기준 ?? "엑셀", got.반영합?.계 ?? null),
|
|
onRow: (n) => {
|
|
const m = r.줄[n];
|
|
const line = (r.문서 as { 담은로직?: { 별칭?: string | null }[] }).담은로직?.[n];
|
|
const label = line?.별칭 ?? name;
|
|
if (m?.표지 === "단가산출" && m.번) return (openSk(m), true);
|
|
if (m?.표지 === "일위대가" && m.번) return void openHopyoView({ ...o, no: m.번, brief: undefined }), true; // prettier-ignore
|
|
if (m?.표지 === "후보") return (void showNear(label, m), true);
|
|
return true; // 요소 줄 = 엑셀 숫자 그대로(모달 없음)
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
async function load(): Promise<void> {
|
|
const stop = showLoading(root);
|
|
try {
|
|
draw(await readHopyoView(o.file, o.key, o.no));
|
|
} catch (e) {
|
|
root.replaceChildren(loadingError(why(e), () => void load()));
|
|
} finally {
|
|
stop();
|
|
}
|
|
}
|
|
|
|
({ close } = openModal({
|
|
title: t("Title").replace("{n}", String(o.no)),
|
|
closeLabel: t("Close"),
|
|
wide: true,
|
|
width: "1400px",
|
|
dialogClass: "m02-modal m02-hopyo__view-modal",
|
|
beforeClose: () => {
|
|
table?.destroy();
|
|
return true;
|
|
},
|
|
mount: (body) => body.append(root),
|
|
}));
|
|
void load();
|
|
}
|