// 원본 연차(다차수) 「내역서데이타 불러오기」·「상단데이타 불러오기」·「하단데이타 불러오기」(TFRMESTMULTIEDIT popLoadEst 0xedb784 → // 0xf11a60 — spec_part §7): 고른 .estx 의 내역서 줄을 차수 열에 짝지어 옮기고(행 수는 현재 내역 그대로), 차수 수식칸에 파일 이름을 적는다. // 상단·하단은 설계변경 내역만 받으며 상단 = 당초값(「_」 짝 칸)·하단 = 변경값(원본 옵션 +0x37 = 0 기준). 금액은 파일 값 그대로(다시 셈 없음). const EstAnnualLoad = (() => { const num = (v) => Number(v) || 0; const ORIGINAL = [ "Name", "Size", "Unite", "GN", "TU", "TC", "NU", "NC", "GU", "GC", "JU", "JC", "SU", "SC", "Bigo", ]; // 차수 계산에서 불러온 줄을 쓰면 true function row(year, index, target) { const loaded = year.rows?.[index]; if (!loaded) return false; Object.assign(target, structuredClone(loaded)); target.CalcIndex = num(loaded.CalcIndex) >= 2 ? 3 : 1; return true; } function rows(source, tag) { const list = structuredClone(source.tables?.EstMainDat || []); if (!list.length) throw Error("내역서 데이타를 찾을수 없습니다."); if (tag) { const changed = list.some((r) => Object.entries(r).some(([k, v]) => k.endsWith("_") && v != null && v !== ""), ); if (!changed) throw Error("설계변경을 한 내역서가 아닙니다."); if (tag === 1) for (const r of list) for (const k of ORIGINAL) if (`${k}_` in r) r[k] = r[`${k}_`]; } return list; } async function load(state, index, tag) { const file = await new Promise((resolve) => { const picker = document.createElement("input"); picker.type = "file"; picker.accept = ".estx"; picker.addEventListener("change", () => resolve(picker.files[0])); picker.click(); }); if (!file) return; const source = await EstApp.api(`/api/import?name=${encodeURIComponent(file.name)}`, { method: "POST", body: await file.arrayBuffer(), }); const list = rows(source, tag); EstApp.change((project) => { const year = project.annual[index]; year.rows = list.slice(0, project.tables.EstMainDat.length); year.formula = file.name.replace(/\.estx$/i, ""); }, false); state.notice = `「${file.name}」 내역서 ${list.length}줄을 차수에 불러왔습니다.`; } function handle(name, state, node) { if (name !== "annual-load") return false; load(state, Number(node.dataset.row), Number(node.dataset.tag)).catch((error) => { state.notice = error.message; EstApp.render(); }); return true; } return { row, rows, handle }; })();