const EstStandard = (() => { let page = 0; function usage(project) { const sources = new Map(); for (const row of project.tables.SilJukDat || []) { if (!row.Code) continue; const rows = sources.get(row.Code) || []; rows.push(row); sources.set(row.Code, rows); } return (project.tables.EstMainDat || []).flatMap((row, index) => { if (Number(row.Level) > 0 || Number(row.LinkIndex) !== 21) return []; const matches = sources.get(row.Code) || []; const source = matches.length === 1 ? EstNative.price(structuredClone(matches[0]), 21) : null; const appliedPrice = row.TU == null ? EstMath.units.reduce((sum, field) => sum + EstMath.num(row[field]), 0) : EstMath.num(row.TU); const sourcePrice = source ? EstMath.num(source.TC) : null; return [ { index, Code: row.Code || "", Name: row.Name || "", Size: row.Size || "", Unite: row.Unite || "", GN: EstMath.num(row.GN), appliedPrice, sourcePrice, difference: source ? appliedPrice - sourcePrice : null, TC: EstMath.num(row.TC), status: !matches.length ? "연결 없음" : matches.length > 1 ? "코드 중복" : "연결됨", }, ]; }); } function changes(project) { const labels = { new: "신규", deleted: "삭제", changed: "변경", unchanged: "동일" }; return EstBusiness.changes(project) .filter((row) => Number(row.LinkIndex) === 21 || Number(row.originalLinkIndex) === 21) .map((row) => ({ ...row, status: labels[row.status] || row.status })); } function render() { const { state, esc, number, byId } = EstApp, isChange = state.view === "standard-change", rows = isChange ? changes(state.project) : usage(state.project); page = Math.max(0, Math.min(page, Math.ceil(rows.length / 100) - 1)); const visible = rows.slice(page * 100, page * 100 + 100), value = (v) => (v == null ? "" : number(v)); if (isChange) { byId("work-content").innerHTML = `
| 구분 | 코드 | 품명 | 당초 수량 | 변경 수량 | 당초 금액 | 변경 금액 | 증감 | 작업 |
|---|---|---|---|---|---|---|---|---|
| ${esc(row.status)} | ${esc(row.Code)} | ${esc(row.Name)} | ${value(row.originalGN)} | ${value(row.GN)} | ${value(row.originalTC)} | ${value(row.TC)} | ${value(row.difference)} | ${row.index == null ? "" : ``} |
내역에 적용된 단가와 현재 표준시장단가 자료를 비교합니다.
| 코드 | 품명 | 규격 | 단위 | 수량 | 내역 단가 | 기초 단가 | 차이 | 금액 | 연결 | 작업 |
|---|---|---|---|---|---|---|---|---|---|---|
| ${esc(row.Code)} | ${esc(row.Name)} | ${esc(row.Size)} | ${esc(row.Unite)} | ${value(row.GN)} | ${value(row.appliedPrice)} | ${value(row.sourcePrice)} | ${value(row.difference)} | ${value(row.TC)} | ${esc(row.status)} |