const EstForms = (() => { const common = ["Code", "Name", "Size", "Unite"]; function data(id, project) { if (id === 109) return { columns: ["Code", "Name", "start", "end", "weight", "progress"], rows: EstSchedule.calculate(project).rows, }; const table = { 1: "EstMainDat", 117: "EstMainDat", 2: "HeadMainDat", 115: "HeadMainDat", 3: "CostMainDat", 4: "MachMainDat", 119: "MachGijunDat", 101: "EstiMateDat", 21: "SilJukDat", 5: "StuffcDat", 6: "LaborcDat", 7: "Wonga", 22: "Wonga", }[id]; if (table) { const columns = table === "Wonga" ? ["Gubun", "Name", "Youl", "VSusic", "Cost"] : table === "CostMainDat" ? ["Code", "LineData"] : table === "HeadMainDat" ? [...common, "GN", "NU", "GU", "JU", "SU", "TC"] : [...common, "GN", "TU", "TC", "NC", "GC", "JC", "SC"]; return { table, columns, rows: project.tables[table] || [] }; } const totals = { 106: "EstMainDat", 118: "EstMainDat", 103: "HeadMainDat", 116: "HeadMainDat", 104: "CostMainDat", 105: "MachMainDat", }[id]; if (totals) { const rows = totals === "EstMainDat" ? (project.tables[totals] || []).filter((r) => Number(r.Level) > 0) : [...EstNative.groups(project.tables[totals] || []).values()].map((group) => { const row = { ...group.rows[0] }; const titleTable = { HeadMainDat: "HeadTitleDat", CostMainDat: "CostTitleDat", MachMainDat: "MachTitleDat", }[totals]; const title = project.tables[titleTable]?.find((item) => item.Code === row.Code); if (title) return { ...row, ...title }; for (const key of [...EstMath.components, "TC"]) row[key] = group.rows .slice(1) .filter((r) => Number(r.CalcIndex || 0) < 2) .reduce((n, r) => n + EstMath.num(r[key]), 0); return row; }); return { table: totals, columns: [...common, "NC", "GC", "JC", "SC", "TC"], rows }; } if ([107, 108].includes(id)) return { columns: ["Code", "Name", "originalGN", "GN", "originalTC", "TC", "difference", "status"], rows: EstBusiness.changes(project), }; const kinds = { 13: 6, 110: 5, 111: 105, 161: 21, 162: 101, 112: 6, 113: 5, 114: 105, 163: 21, 164: 101, }; if (kinds[id]) { const output = EstResources.calculate(project, [112, 113, 114, 163, 164].includes(id)); return { columns: [ ...([112, 113, 114, 163, 164].includes(id) ? ["WorkCode", "WorkName"] : []), "Code", "Name", "Size", "Unite", "quantity", "amount", ], errors: output.errors, rows: output.rows.filter((r) => r.kind === kinds[id]), }; } if (id === 14) return { columns: ["Code", "Name", "formula", "GN", "TargetCode"], rows: (project.quantitySheets || []).flatMap((sheet) => EstQuantity.calculate(sheet).items.map((item) => ({ ...item, Code: sheet.Code, Name: item.Name || sheet.Name, })), ), }; return null; } const labels = { originalGN: "당초 수량", originalTC: "당초 금액", difference: "증감", status: "상태", quantity: "소요량/시간", amount: "금액", start: "시작일", end: "종료일", weight: "가중치", progress: "진도(%)", WorkCode: "공종 코드", WorkName: "공종명", formula: "산식", TargetCode: "연결 내역", TU: "단가", TC: "금액", NC: "노무비", GC: "재료비", JC: "경비", SC: "산출경비", }; function grid(output) { const { esc } = EstApp, number = (v) => new Intl.NumberFormat("ko-KR", { maximumFractionDigits: 12 }).format(v); return `
| ${esc(labels[key] || EstModel.labels[key] || key)} | `).join("")}
|---|
| ${esc(typeof row[key] === "number" ? number(row[key]) : key === "LineData" ? EstText.clean(row[key] || "") : (row[key] ?? ""))} | `).join("")}