- 화면: 「내역 점검」 카드 [단가 갱신] 단추 · 점 배지 · 호버 · 미리 보기 창([재생성] · [적용]) 걷음 · 연결 점검 목록 그대로 - 서버: POST …/estimation/prices · …/prices/preview 걷음(openapi 469 → 467) · GET 답 `book` · `stale` 칸(매 GET 단가 책 견줌) 걷음 - B09_Estimation_Refresh · B09_Estimation_Copy_Prices 지움(사본 단가 읽기 = 단가.json 바로) · Bill_Library 서고 다시 굳힘(changed · refresh_copy) 걷음 - 단가 책: 첫 굳힘 `make_book`(옛 refresh_book 의 단가 갱신 몫 · book_stale · book_diff · labor_editions 걷음) - 시험: 죽은 길만 보던 test_296 · test_703_3 지움 · 203_1 배지 · 795_4 ⑤ ⑥ · 719_2 서고 업데이트 지움 · 144 길 = 없음 확인 - test_253_3: B9-4 화면 꼴 뒤 낡은 단언(엑셀 꼴 식 글)을 작업량 값 줄로 고침 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
111 lines
4.4 KiB
TypeScript
111 lines
4.4 KiB
TypeScript
/* =============================================================================
|
|
* B09_Estimation_UI_Check.ts
|
|
* B09 좌측 「내역 점검」 묶음(PLAN 203-1) — 연결 점검(옛 「연결 점검」 탭 내용 · 859-2 [단가 갱신] 걷음).
|
|
*
|
|
* 연결 점검 = 「빈 줄 n」(설계내역서 금액 모르는 줄 · 안내 · 집계표와 같은 수 · 701-2) 목록 +
|
|
* 그 밖 확인 목록(일위대가 · 단가산출 · 재료 등 · 탭 · 키마다 하나)(누르면 그 탭 그 줄로 · 까닭 = 공용 호버) + 서버 알림 · M01 에 없는 키
|
|
* ========================================================================== */
|
|
|
|
import { attachHoverInfo } from "@ui/ui_template_hover_info";
|
|
import { createBadge } from "@ui/ui_template_badge";
|
|
import { createText } from "@ui/ui_template_text";
|
|
import type { Row } from "./B09_Estimation_Calc_Base";
|
|
import { blankRows, tabName, type Link, type TabId } from "./B09_Estimation_UI_Tabs";
|
|
|
|
export interface CheckItem {
|
|
link: Link;
|
|
tab: string;
|
|
name: string;
|
|
why: string;
|
|
}
|
|
|
|
const BLANK_WHY = "금액 모름 — 단가연결 칸 ● · 이은 호표의 빈 줄을 확인";
|
|
|
|
/** 빈 줄(설계내역서 줄마다 하나 · 까닭 모음) · 그 밖 확인 줄(탭 · 키마다 하나) · 알림 글 */
|
|
export function checkItems(
|
|
sheets: Row,
|
|
payload: Row,
|
|
): { items: CheckItem[]; others: CheckItem[]; notes: string[] } {
|
|
const why = new Map<string, string[]>();
|
|
const order: string[] = [];
|
|
const named = new Map<string, Row>();
|
|
for (const g of (sheets.gaps || []) as Row[]) {
|
|
const id = `${g.tab}|${g.key}`;
|
|
if (!why.has(id)) (why.set(id, []), order.push(id), named.set(id, g));
|
|
const list = why.get(id)!;
|
|
if (g.why && !list.includes(String(g.why))) list.push(String(g.why));
|
|
}
|
|
const item = (tab: string, key: string, name: unknown, reasons?: string[]): CheckItem => ({
|
|
link: { tab: tab as TabId, key },
|
|
tab: tabName(tab),
|
|
name: String(name ?? ""),
|
|
why: reasons?.length ? reasons.join(" · ") : BLANK_WHY,
|
|
});
|
|
const items = blankRows(sheets).map((r) => item("bill", r.key, r.name, why.get(`bill|${r.key}`)));
|
|
const others = order
|
|
.filter((id) => !id.startsWith("bill|"))
|
|
.map((id) => item(named.get(id)!.tab, named.get(id)!.key, named.get(id)!.name, why.get(id)));
|
|
const notes: string[] = [...(payload.notes || [])];
|
|
const missing: string[] = payload.inputs?.missing || [];
|
|
if (missing.length) notes.push(`M01 에 없는 키 ${missing.length} — ${missing.join(" · ")}`);
|
|
return { items, others, notes };
|
|
}
|
|
|
|
export interface CheckPanel {
|
|
/** 묶음 안 연결 점검 자리 */
|
|
list: HTMLElement;
|
|
draw: (payload: Row, sheets: Row) => void;
|
|
}
|
|
|
|
export function createCheckPanel(goto: (link: Link) => void): CheckPanel {
|
|
let items: CheckItem[] = [];
|
|
const box = document.createElement("div");
|
|
box.className = "b09-check";
|
|
attachHoverInfo(box, (row) => items[Number(row.dataset.i)]?.why, "[data-i]");
|
|
|
|
const head = (text: string): HTMLElement => {
|
|
const p = createText(text, "muted");
|
|
p.classList.add("b09-check__head");
|
|
return p;
|
|
};
|
|
const list = (group: CheckItem[], offset: number): HTMLElement => {
|
|
const rows = document.createElement("div");
|
|
rows.className = "ui-sidebar-list";
|
|
rows.append(
|
|
...group.map((item, n) => {
|
|
const row = document.createElement("button");
|
|
row.type = "button";
|
|
row.className = "ui-sidebar-row";
|
|
row.dataset.i = String(offset + n);
|
|
const name = document.createElement("span");
|
|
name.textContent = item.name;
|
|
const tab = createBadge(item.tab, "neutral", { size: 18 });
|
|
tab.classList.add("b09-check__tab");
|
|
row.append(name, tab);
|
|
row.addEventListener("click", () => goto(item.link));
|
|
return row;
|
|
}),
|
|
);
|
|
return rows;
|
|
};
|
|
|
|
const draw = (next: Row, sheets: Row): void => {
|
|
const made = checkItems(sheets, next);
|
|
items = [...made.items, ...made.others];
|
|
const blank = [
|
|
head(`금액 빈 줄 ${made.items.length}`),
|
|
...(made.items.length ? [list(made.items, 0)] : []),
|
|
];
|
|
const others = made.others.length
|
|
? [head(`그 밖 확인 ${made.others.length}곳`), list(made.others, made.items.length)]
|
|
: [];
|
|
const notes = made.notes.map((text) => {
|
|
const p = createText(text, "muted");
|
|
p.classList.add("b09-check__note");
|
|
return p;
|
|
});
|
|
box.replaceChildren(...blank, ...others, ...notes);
|
|
};
|
|
return { list: box, draw };
|
|
}
|