// 원본 공내역 파일로저장(TfrmEstMain.mnuFileNullSaveClick 0x10cdc44 → 0x113cf38). // 내역·일위대가 제목·일위대가 상세의 금액(TC·NC·GC·JC·SC)을 비우고, 공람 방법(PrintGongMethod)에 따라 // 0 = 단가(TU·NU·GU·JU·SU)도 비움(수량만 남김) · 1 = 수량(GN)을 비움(단가만 남김) · 2 = 금액만 비움. const EstBlank = (() => { const tables = ["EstMainDat", "HeadTitleDat", "HeadMainDat"]; const amounts = ["TC", "NC", "GC", "JC", "SC"]; const units = ["TU", "NU", "GU", "JU", "SU"]; const methods = [ [0, "수량만 남김(단가·금액 비움)"], [1, "단가만 남김(수량·금액 비움)"], [2, "수량·단가 남김(금액만 비움)"], ]; function make(project, method) { if (![0, 1, 2].includes(method)) throw Error("공내역 방법을 고르세요."); const blank = structuredClone(project); const clear = method === 0 ? [...amounts, ...units] : method === 1 ? [...amounts, "GN"] : amounts; for (const table of tables) for (const row of blank.tables[table] || []) for (const key of clear) if (row[key] != null) row[key] = 0; // 금액을 비운 원가계산서가 옛 합계를 보이지 않도록 원가 금액도 비운다(원본 WongaDat 처리 확인 전 웹 보조). for (const row of blank.tables.Wonga || []) if (row.Cost != null) row.Cost = 0; delete blank.id; blank.name = `${project.name || "내역서"} (공내역)`; blank.options = { ...blank.options, AutoCalc: false, SourceRefresh: false }; blank.calculation = { errors: [], warnings: [], direct: {}, total: 0 }; blank.blankMethod = method; return blank; } function open(state) { const project = state.project; EstActions.form( "공내역 파일로 저장", [ { name: "method", label: "남길 값", value: Number(project.printSettings?.PrintGongMethod ?? 0), choices: methods, }, { name: "format", label: "파일 형식", value: project.originalArchive ? "estx" : "json", choices: project.originalArchive ? [ ["estx", "원본 구조 ESTX"], ["json", "웹 작업 JSON"], ] : [["json", "웹 작업 JSON"]], }, ], async ({ method, format }) => { const blank = make(project, Number(method)); if (format === "estx") { const response = await fetch("/api/export-estx", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(blank), }); if (!response.ok) throw Error((await response.json()).error); EstApp.download(`${blank.name}.estx`, await response.blob(), "application/octet-stream"); } else EstApp.download(`${blank.name}.estweb.json`, JSON.stringify(blank, null, 2)); state.notice = "공내역 파일을 내려받았습니다. 현재 작업은 바뀌지 않았습니다."; EstApp.render(); }, ); } function handle(name, state) { if (name !== "blank-save") return false; open(state); return true; } return { methods, make, handle }; })();