Files
Aislo/B08_Quantity/B08_Quantity_UI_Earthwork_Sheets.ts
T
eomsangdonandClaude Sonnet 5.5 88dd941d73 fix(B08·B09): 표 아래 안내 글 제작 · 셈 설명 지움 · 늘 한 줄 · 페이지 스크롤 0(236-1)
- B09 표 탭 안내 글 = 쓸모 있는 한 줄(lineHint) · 묶음 탭과 같은 줄임표
- B08 표 아래 안내 · 경고 줄 = footNote 한 줄 · 서버 알림은 한 줄로 이어 붙임
- 새 시험 test_236_1 · 창 높이별 창 끝까지 셈 헬퍼

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018jonfdxn1Xit9bdkNJpE4G
2026-10-10 19:09:56 +09:00

127 lines
4.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* =============================================================================
* B08_Quantity_UI_Earthwork_Sheets.ts
* 토공 보조 탭 셋(PLAN 69-2) — 토공집계표 · 평균운반거리 · 종방향 무대운반거리.
*
* 칸 · 식 = 거창 실무 워크북 같은 이름 시트 그대로 · 값은 서버가 셈(`…_Engine_Earthwork_Summary`).
* 운반 Q · L = 저장된 유토곡선 배분(B07 토적도와 같은 정본) — 없으면 그 사유만 보임.
* 표 = 공용 많은 자료 표(`ui_template_data_table`).
* ========================================================================== */
import { createDataTable, type DataColumn, type DataRow } from "@ui/ui_template_data_table";
import { note, tableCard, type EarthworkTable, type HaulList } from "./B08_Quantity_UI_Earthwork";
import { footNote } from "./B08_Quantity_UI_Foot";
const fmt = (value: number | null | undefined): string =>
value == null || !Number.isFinite(value)
? "-"
: value.toLocaleString("ko-KR", { maximumFractionDigits: 2 });
const SUMMARY_COLUMNS: DataColumn[] = [
{ key: "group", label: "구분", width: 120 },
{ key: "kind", label: "공종", width: 72 },
{ key: "spec", label: "규격", width: 128 },
{ key: "unit", label: "단위", width: 56 },
{ key: "value", label: "계", kind: "number", decimals: 2, width: 112 },
{ key: "note", label: "비고", width: 200 },
];
/** 토공집계표 — 구분 · 공종 · 규격 · 단위 · 계 · 비고 */
export function renderEarthworkSummary(host: HTMLElement, table: EarthworkTable): void {
const info = footNote(
"연암 · 경암은 좌측 패널 비율대로 나눈 암 · 「비율 미정」은 비율 확인 뒤 채움",
);
const grid = createDataTable({
columns: SUMMARY_COLUMNS,
// 칸이 없는 글(공종 · 규격 · 비고)은 빈칸 — 공용 표는 "" 를 「-」(값 없음)로 그림
rows: table.summary.map((row) => ({
...row,
kind: row.kind || " ",
spec: row.spec || " ",
note: row.note || " ",
})),
frozen: 1,
mergeSame: ["group", "spec"], // 201-1 같은 구분 · 규격 이어지면 세로 병합(빈칸은 안 합침)
caption: "토공집계표",
fillViewport: true,
});
host.replaceChildren(tableCard([info], grid.root));
}
function haulNote(table: EarthworkTable): HTMLElement[] {
return table.haul_saved
? []
: [footNote("유토곡선 배분이 저장되지 않았습니다 — 횡단 설계 [확정] 뒤에 채워집니다.")];
}
/** 운반 시트 한 장 — 묶음마다 토량(Q) · 거리(L) · Q×L · 맨 아래 합계 · 아래 평균운반거리 줄 */
function haulSheet(
host: HTMLElement,
table: EarthworkTable,
groups: Array<[string, HaulList]>,
caption: string,
): void {
const columns: DataColumn[] = [
{ key: "no", label: "번호", width: 56 },
...groups.flatMap(([label], g) =>
[
["q", "토량(Q)"],
["l", "거리(L)"],
["ql", "Q×L"],
].map(([key, text]) => ({
key: `${key}${g}`,
label: text,
group: [label],
kind: "number" as const,
decimals: 2,
width: 104,
})),
),
];
const count = Math.max(0, ...groups.map(([, list]) => list.rows.length));
const rows: DataRow[] = Array.from({ length: count }, (_, i) => {
const out: DataRow = { no: String(i + 1) };
groups.forEach(([, list], g) => {
const item = list.rows[i];
if (item) Object.assign(out, { [`q${g}`]: item.q, [`l${g}`]: item.l, [`ql${g}`]: item.ql });
});
return out;
});
const total: DataRow = { no: "합계" };
groups.forEach(([, list], g) => Object.assign(total, { [`q${g}`]: list.q, [`ql${g}`]: list.ql }));
const averages = groups.map(([label, list], i) =>
note(
`${i + 1}) ${label} 평균운반거리: ${fmt(list.ql)} ÷ ${fmt(list.q)} = ${fmt(list.average_m)} M`,
),
);
const grid = createDataTable({
columns,
rows,
frozen: 1,
total,
caption,
fillViewport: true,
});
host.replaceChildren(tableCard(haulNote(table), grid.root, averages));
}
export function renderHaulDistance(host: HTMLElement, table: EarthworkTable): void {
haulSheet(
host,
table,
[
["덤프트럭", table.haul.dump_truck],
["불도우저", table.haul.dozer],
],
"덤프트럭 · 불도우저 평균운반거리 — 단위 ㎥ · m",
);
}
export function renderFreeHaul(host: HTMLElement, table: EarthworkTable): void {
haulSheet(
host,
table,
[["종방향무대", table.haul.free_haul]],
"종방향 무대운반거리 — 단위 ㎥ · m",
);
}