fix(M02): 일위대가 목록 합계 · 단위 · 새 항목 두 단추 — 수량 없으면 기준 합(작은 글 「기준」) · 담은 로직 0 「—」 · 단위 = 일위대가 문서 단위 · 누른 단추가 진하게
39-8 B2 · B3 · B4 — 서버 목록 칸 labor 에 기준 · 단위 · laborSum · Col note · buildTwoWay choose. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016PSXsvyDxjNmufteN5bqmt
This commit is contained in:
@@ -22,12 +22,21 @@ export interface ItemRow extends TreeItem {
|
||||
도번?: string | null;
|
||||
면적번?: string | null;
|
||||
수정일?: Partial<Record<"structure" | "area" | "labor", string>>;
|
||||
labor?: { 번호: string | null; 로직수: number; 합계: number | null } | null;
|
||||
labor?: {
|
||||
번호: string | null;
|
||||
로직수: number;
|
||||
/** 수량 반영 합 · 기준(단가) 합 · 일위대가 문서 단위 */
|
||||
합계: number | null;
|
||||
기준?: number | null;
|
||||
단위?: string | null;
|
||||
} | null;
|
||||
}
|
||||
|
||||
export interface Col<R> {
|
||||
head: string;
|
||||
get: (row: R) => string;
|
||||
/** 값 뒤 작은 글(예 「기준」) — 없으면 없음 */
|
||||
note?: (row: R) => string;
|
||||
}
|
||||
|
||||
const TEXT = {
|
||||
@@ -51,6 +60,17 @@ const latest = (row: ItemRow): string =>
|
||||
.pop(),
|
||||
);
|
||||
|
||||
/** 일위대가 합계(39-8 B2) — 수량 반영 합이 있으면 그것 · 없으면 기준(단가) 합 + 작은 글 「기준」 ·
|
||||
* 담은 로직 0 · 계산값 없음 = 「—」 */
|
||||
export function laborSum(row: ItemRow): { text: string; note: string } {
|
||||
const l = row.labor;
|
||||
if (!l?.로직수) return { text: DASH, note: "" };
|
||||
if (l.합계) return { text: money(l.합계), note: "" };
|
||||
return typeof l.기준 === "number"
|
||||
? { text: money(l.기준), note: "기준" }
|
||||
: { text: DASH, note: "" };
|
||||
}
|
||||
|
||||
const NAME: Col<ItemRow> = { head: "이름", get: (r) => leafName(r) };
|
||||
const FOLDER: Col<ItemRow> = { head: "폴더", get: (r) => folderOf(r).join(" / ") };
|
||||
const UNIT: Col<ItemRow> = { head: "단위", get: (r) => r.단위 ?? "" };
|
||||
@@ -73,9 +93,9 @@ export const ITEM_COLS: Record<ListKind, Col<ItemRow>[]> = {
|
||||
{ head: "일위대가번", get: (r) => r.labor?.번호 || DASH },
|
||||
NAME,
|
||||
FOLDER,
|
||||
UNIT,
|
||||
{ head: "단위", get: (r) => r.labor?.단위 ?? "" }, // 일위대가 문서 단위(39-8 B3)
|
||||
{ head: "담은 로직 수", get: (r) => (r.labor ? String(r.labor.로직수) : DASH) },
|
||||
{ head: "합계", get: (r) => money(r.labor?.합계) },
|
||||
{ head: "합계", get: (r) => laborSum(r).text, note: (r) => laborSum(r).note },
|
||||
changed("labor"),
|
||||
],
|
||||
item: [
|
||||
@@ -184,7 +204,14 @@ export function buildItemList(): ItemListHandle {
|
||||
className: "m01-master__table-row",
|
||||
children: cols.map((c) => {
|
||||
const text = c.get(row);
|
||||
return el("td", { text, attrs: { title: text } });
|
||||
const note = c.note?.(row) ?? "";
|
||||
return el("td", {
|
||||
text,
|
||||
attrs: { title: note ? `${text} ${note}` : text },
|
||||
children: note
|
||||
? [el("small", { className: "m01-master__muted", text: ` ${note}` })]
|
||||
: [],
|
||||
});
|
||||
}),
|
||||
});
|
||||
// 고를 수 없는 줄 — 흐리게 · 누르면 까닭 한 줄(고르기 안 함)
|
||||
|
||||
@@ -185,10 +185,21 @@ export function buildTwoWay(opt: TwoWayOptions): HTMLElement {
|
||||
const copy = createButton({ label: TEXT.makeCopy, variant: "ghost" });
|
||||
const below = el("div", { className: "m02-itempick__below" });
|
||||
let busy = false;
|
||||
fresh.addEventListener("click", opt.onNew);
|
||||
/** 누른 단추 = 지금 화면 — 진한 단추가 고른 쪽 · 복사 생성 목록은 그쪽일 때만 보임 */
|
||||
const choose = (which: HTMLElement): void => {
|
||||
for (const b of [fresh, copy]) {
|
||||
b.classList.toggle("ui-btn--filled", b === which);
|
||||
b.classList.toggle("ui-btn--ghost", b !== which);
|
||||
}
|
||||
below.hidden = which !== copy;
|
||||
};
|
||||
fresh.addEventListener("click", () => {
|
||||
choose(fresh);
|
||||
opt.onNew();
|
||||
});
|
||||
copy.addEventListener("click", () => {
|
||||
choose(copy);
|
||||
if (below.firstChild) return;
|
||||
copy.classList.add("is-active");
|
||||
const picker = buildPicker({
|
||||
...opt.picker,
|
||||
onPick: (picked) =>
|
||||
|
||||
@@ -86,9 +86,19 @@ def items(folder: Path) -> list[dict[str, Any]]:
|
||||
return out
|
||||
|
||||
|
||||
def _number(sums: Any) -> float | None:
|
||||
"""`계산값` 합 칸의 `계` — 수 아닌 값(옛 꼴) · 없음 = null(「—」)."""
|
||||
total = sums.get("계") if isinstance(sums, dict) else None
|
||||
try:
|
||||
return None if total is None or isinstance(total, bool) else float(total)
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
def _list_extras(folder: Path, col: str) -> dict[str, Any]:
|
||||
"""목록 칸(39-5) — `수정일` = 도면 · 면적산출 · 일위대가 파일 시각 · `labor` = 일위대가 문서의
|
||||
번호 · 담은 로직 수 · 합계(`계산값.반영합.계` · 없으면 null) — 파일이 없으면 칸 없음."""
|
||||
번호 · 담은 로직 수 · 합계(`계산값.반영합.계`) · 기준(`계산값.기준합.계`) · 단위 —
|
||||
파일이 없으면 칸 없음."""
|
||||
stamps: dict[str, str] = {}
|
||||
for kind in ("structure", "area", "labor"):
|
||||
path = folder / kind / f"{col}.json"
|
||||
@@ -103,15 +113,13 @@ def _list_extras(folder: Path, col: str) -> dict[str, Any]:
|
||||
doc = json.loads(path.read_bytes())
|
||||
except ValueError:
|
||||
doc = {}
|
||||
total = ((doc.get("계산값") or {}).get("반영합") or {}).get("계")
|
||||
try:
|
||||
total = None if total is None or isinstance(total, bool) else float(total)
|
||||
except (TypeError, ValueError):
|
||||
total = None # 수 아닌 값(옛 꼴)은 「—」
|
||||
calc = doc.get("계산값") or {}
|
||||
labor = {
|
||||
"번호": doc.get("일위대가번"),
|
||||
"로직수": len(doc.get("담은로직") or []),
|
||||
"합계": total,
|
||||
"합계": _number(calc.get("반영합")),
|
||||
"기준": _number(calc.get("기준합")), # 수량 없는 일위대가 = 단가 합(39-8 B2)
|
||||
"단위": doc.get("단위"), # 일위대가 문서 단위(구조물 열 단위 아님 · B3)
|
||||
}
|
||||
return {"수정일": stamps, "labor": labor}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user