// 원본 「새내역서 파일로저장」(mnuSaveNewEst 0x113384c) — 현재 문서는 그대로 두고 설계변경 흔적을 지운 새 작업을 따로 저장. // 표 12개(노임·자재·견적·표준·기계기준·기계 본문/호표·단산 본문/호표·일위 본문/호표·내역서)의 「_」로 끝나는 칸(당초값)을 비우고 // 신규 표시(NewItem)를 끄며, 원가 안전관리비 특례 줄(CalcIndex 4)은 1 로, 당초 사본(baseline)은 뺀다. 재계산 없음. const EstNewEstimate = (() => { const TABLES = [ "LaborcDat", "StuffcDat", "EstiMateDat", "SilJukDat", "MachGijunDat", "MachMainDat", "MachTitleDat", "CostMainDat", "CostTitleDat", "HeadMainDat", "HeadTitleDat", "EstMainDat", ]; function build(project, name) { const next = structuredClone(project); delete next.id; delete next.baseline; next.name = name; for (const table of TABLES) for (const row of next.tables[table] || []) { for (const key of Object.keys(row)) if (key.endsWith("_")) row[key] = null; if ("NewItem" in row) row.NewItem = false; } for (const row of next.tables.Wonga || []) if ((Number(row.CalcIndex) & 0xff) === 4) row.CalcIndex = 1; return next; } async function run(state) { const name = prompt("새 내역서 이름", `${state.project.name || "내역서"} (새 내역서)`)?.trim(); if (!name) return; const result = await EstApp.api("/api/save", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(build(state.project, name)), }); EstApp.download(`${result.name}.estweb.json`, JSON.stringify(result, null, 2)); state.notice = `새 내역서 「${result.name}」를 따로 저장했습니다. 지금 화면은 그대로입니다.`; EstApp.render(); } function handle(name, state) { if (name !== "save-new-estimate") return false; run(state).catch((error) => { state.notice = error.message; EstApp.render(); }); return true; } return { build, handle }; })();