// 원본 작업모드 바꾸기(0x10cb8b4 — spec_pc §4): 내역서 1 · 설계변경 2 · 표준내역서 3(mnuProgramSEst) · 표준설계변경 4(mnuProgramSCEst). // 일반(1·2) ↔ 표준(3·4) 묶음이 바뀌면 지금 원가계산서를 옛 묶음 칸에 두고 새 묶음 원가계산서를 꺼낸다(0x113c80c) — 그 묶음에 // 둔 것이 없으면 설치 원가계산서 양식목록(일반 WongaFileList · 표준 SWongaFileList)에서 고른다. 모드 값은 TCommonOption.CurrentWorkMode. // 원본은 모드를 바꿀 때 지금 문서를 닫고 최근 작업 목록을 띄우지만, 웹은 지금 작업을 그대로 두고 화면만 옮긴다. // 그리고 「최근 계약심사목록」(mnuInvestWorkFileList 0x10d0c88): 저장한 작업 중 계약심사 작업만. const EstWorkMode = (() => { const NAMES = { 1: "내역서", 2: "설계변경", 3: "표준내역서", 4: "표준설계변경" }; const standard = (mode) => [3, 4, 12].includes(Number(mode)); const groupOf = (mode) => (standard(mode) ? "standard" : "general"); const mode = (project) => Number(project.options.WorkMode) || 1; // 묶음 바꾸기: 옛 원가계산서를 보관하고 새 묶음 것을 돌려줌(없으면 null) function swap(project, next) { const from = groupOf(mode(project)), to = groupOf(next); project.options.WorkMode = next; if (from === to) return { changed: false }; project.wongaByGroup ||= {}; project.wongaByGroup[from] = structuredClone(project.tables.Wonga || []); const kept = project.wongaByGroup[to]; if (kept) { project.tables.Wonga = structuredClone(kept); delete project.wongaByGroup[to]; } return { changed: true, found: Boolean(kept) }; } async function picker(state, std, after = "") { const { esc } = EstApp, list = await EstApp.api(`/api/wonga-formats?std=${std ? 1 : 0}`); EstApp.showDialog( `${std ? "표준" : "일반"} 원가계산서 양식목록`, `

${esc(after)}

${list .map( (f) => ``, ) .join("")}
No양식 이름
${f.index}${esc(f.name)}
`, ); } async function openForm(state, std, index) { const form = await EstApp.api(`/api/wonga-formats?std=${std}&index=${index}`); // 설치 양식은 번호(NumStr)로 서로 가리키는 꼴 — 번호 기준 계산(VerFormat 끔) EstApp.change((project) => { project.options.TotalFix = false; project.options.VerFormat = false; project.tables.Wonga = structuredClone(form.rows); }); EstApp.byId("dialog").close(); state.notice = `원가계산서를 「${form.name}」 양식으로 바꿨습니다.`; EstApp.render(); } async function switchTo(state, next) { const project = state.project; if (mode(project) === next) { state.view = next === 2 || next === 4 ? "change" : "EstMainDat"; return EstApp.render(); } let result; EstApp.change((p) => (result = swap(p, next))); state.view = next === 2 || next === 4 ? "change" : "EstMainDat"; state.notice = `작업모드: ${NAMES[next]}`; EstApp.render(); if (result.changed && !result.found) await picker( state, standard(next), `${NAMES[next]} 모드의 원가계산서 양식을 고르세요. (지금 원가계산서는 ${standard(next) ? "일반" : "표준"} 쪽에 보관)`, ); } async function investList(state) { const { esc } = EstApp, list = (await EstApp.api("/api/projects")).filter((p) => p.invest); EstApp.showDialog( "최근 계약심사목록", ` ${ list .map( (p) => ``, ) .join("") || '' }
구 분공 사 명최종작업일
계약심사${esc(p.name)}${esc(String(p.modified).slice(0, 10))}
계약심사 작업이 없습니다.
`, ); } function handle(name, state, node) { const fail = (error) => { state.notice = error.message; EstApp.render(); }; if (name === "work-mode") switchTo(state, Number(node.dataset.mode)).catch(fail); else if (name === "wonga-install-list") picker(state, standard(mode(state.project))).catch(fail); else if (name === "wonga-install-open") openForm(state, node.dataset.std, node.dataset.index).catch(fail); else if (name === "invest-work-list") investList(state).catch(fail); else return false; return true; } return { swap, groupOf, NAMES, handle }; })();