feat(M01): 입력 없는 로직 열 때 한 번 계산 · 비목 몫으로 갈린 줄에 몫 표시 (PLAN 4장)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WRFJmmhPi4exAzHgPZHMT
This commit is contained in:
2026-09-24 10:07:23 +09:00
co-authored by Claude Sonnet 5
parent bb4500b4c3
commit f94bdcfc8a
3 changed files with 18 additions and 2 deletions
@@ -87,6 +87,8 @@ interface Entry {
qty: string;
qtyTag: string;
qtyFrag: Fragment[];
/** 한 줄이 비목 몫으로 갈렸을 때 이 묶음의 몫 이름(예 「노무비」) */
share?: string;
price: string;
amount: number | null;
/** 덧줄이면 true */
@@ -188,7 +190,12 @@ function infoBox(ctx: DetailContext): HTMLElement {
const spread = (e: Entry, line?: CalcLine): Entry[] => {
const parts = Object.entries(line?.비목 ?? {}).filter(([, v]) => v !== 0);
if (!parts.length) return [e];
return parts.map(([k, v]) => ({ ...e, group: OF_COST[k] ?? "other", amount: v }));
return parts.map(([k, v]) => ({
...e,
group: OF_COST[k] ?? "other",
amount: v,
...(parts.length > 1 ? { share: k } : {}),
}));
};
function entries(ctx: DetailContext): Entry[] {
@@ -275,6 +282,9 @@ function lineRow(e: Entry): HTMLElement {
el("td", {
children: [
el("div", { text: e.name }),
...(e.share
? [el("div", { className: "m01-logic__tag", text: `${e.share} ${tl("Share")}` })]
: []),
...(e.spec ? [el("div", { className: "m01-logic__muted", text: e.spec })] : []),
],
}),
@@ -30,6 +30,7 @@ const TEXT = {
G_other: ["그 밖 (인력·자재·경비 어디에도 안 맞는 줄)", "Other (fits none of the three)"],
Tag_Table: ["표", "Table"],
Subtotal: ["소계", "Subtotal"],
Share: ["몫", "Share"],
Total: ["계", "Total"],
Extra: ["덧줄", "Extra"],
Col_Name: ["이름", "Name"],
@@ -139,7 +139,12 @@ export function buildCalc(host: HTMLElement, ctx: CalcContext): void {
ctx.onText?.(answer);
});
}
if (ctx.savedKey !== null && !autoAsked.has(ctx.values)) {
if (!fields.length && !autoAsked.has(ctx.values)) {
autoAsked.add(ctx.values); // 입력이 없으면 채울 것이 없음 — 열 때 한 번 바로 계산
queueMicrotask(() => {
if (previewSeq === mySeqAtOpen) host.querySelector("button")?.click();
});
} else if (ctx.savedKey !== null && !autoAsked.has(ctx.values)) {
autoAsked.add(ctx.values);
void fetchAuto(ctx.savedKey).then((auto) => {
const names = (ctx.row.입력 ?? [])