|
|
|
@@ -23,6 +23,13 @@ const EstReport = (() => {
|
|
|
|
|
marginRight: settings.marginRight ?? settings.margin ?? 12,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// 원본 공정표 용지(mnuA0·A1·A3·A4·B4) — CSS 낱말이 없는 A0·A1 은 mm 로
|
|
|
|
|
function pageSize(paper, orientation) {
|
|
|
|
|
const mm = { A0: [841, 1189], A1: [594, 841] }[paper];
|
|
|
|
|
if (!mm) return `${paper} ${orientation}`;
|
|
|
|
|
const [w, h] = orientation === "landscape" ? [mm[1], mm[0]] : mm;
|
|
|
|
|
return `${w}mm ${h}mm`;
|
|
|
|
|
}
|
|
|
|
|
function preview(all = false) {
|
|
|
|
|
const { state, esc } = EstApp;
|
|
|
|
|
const settings = setting(),
|
|
|
|
@@ -106,7 +113,7 @@ const EstReport = (() => {
|
|
|
|
|
: state.project.calculation;
|
|
|
|
|
const errors = [...(totals?.errors || []), ...(output?.errors || [])];
|
|
|
|
|
const source = `<!doctype html><html lang="ko"><head><meta charset="UTF-8"><title>${esc(state.project.name)} · ${esc(title)}</title>
|
|
|
|
|
<style>@page{size:${settings.paper} ${settings.orientation};margin:${settings.marginTop}mm ${settings.marginRight}mm ${settings.marginBottom}mm ${settings.marginLeft}mm}*{box-sizing:border-box}body{font:${settings.font}pt "Malgun Gothic",sans-serif;color:#111;margin:0}
|
|
|
|
|
<style>@page{size:${pageSize(settings.paper, settings.orientation)};margin:${settings.marginTop}mm ${settings.marginRight}mm ${settings.marginBottom}mm ${settings.marginLeft}mm}*{box-sizing:border-box}body{font:${settings.font}pt "Malgun Gothic",sans-serif;color:#111;margin:0}
|
|
|
|
|
h1{font-size:17pt;margin:0 0 4mm}h2{font-size:12pt;margin:0 0 3mm}.summary{margin:2mm 0 4mm}
|
|
|
|
|
table{width:100%;border-collapse:collapse;font-size:inherit}thead{display:table-header-group}tr{break-inside:avoid}
|
|
|
|
|
th,td{border:1px solid #777;padding:1.5mm;vertical-align:top;overflow-wrap:anywhere}th{background:#eee}
|
|
|
|
@@ -179,7 +186,7 @@ const EstReport = (() => {
|
|
|
|
|
`<option value="${row.Index}" ${String(row.Index) === s.form ? "selected" : ""}>${esc(row.Name)}</option>`,
|
|
|
|
|
)
|
|
|
|
|
.join("")}</select></label>
|
|
|
|
|
<label>용지 <select id="print-paper">${["A4", "A3"].map((v) => `<option ${v === s.paper ? "selected" : ""}>${v}</option>`).join("")}</select></label>
|
|
|
|
|
<label>용지 <select id="print-paper">${["A4", "A3", "B4", "A1", "A0"].map((v) => `<option ${v === s.paper ? "selected" : ""}>${v}</option>`).join("")}</select></label>
|
|
|
|
|
<label>방향 <select id="print-orientation"><option value="landscape" ${s.orientation === "landscape" ? "selected" : ""}>가로</option><option value="portrait" ${s.orientation === "portrait" ? "selected" : ""}>세로</option></select></label>
|
|
|
|
|
${[
|
|
|
|
|
["marginTop", "위 여백(mm)", 0, 50],
|
|
|
|
@@ -198,7 +205,7 @@ const EstReport = (() => {
|
|
|
|
|
<label id="print-gong-wrap" ${["115", "116", "117", "118"].includes(String(s.form)) ? "" : "hidden"}>공람용 방법 <select id="print-gong"><option value="0" ${Number(s.PrintGongMethod) === 0 ? "selected" : ""}>수량만</option><option value="1" ${Number(s.PrintGongMethod) === 1 ? "selected" : ""}>단가만</option><option value="2" ${Number(s.PrintGongMethod) === 2 ? "selected" : ""}>수량·단가</option></select></label>
|
|
|
|
|
<label>업체명<input data-print="company" value="${esc(s.company)}"></label>
|
|
|
|
|
${table ? '<label>출력 범위 <select id="print-scope"><option value="current">현재 호표·검색 결과 전체 행</option><option value="all">현재 자료의 모든 호표·행</option></select></label>' : ""}
|
|
|
|
|
<button data-action="print-document">인쇄 / PDF 저장</button><button data-action="export-report-xlsx">서식 Excel 저장</button><span id="print-error" role="status"></span></div>
|
|
|
|
|
<button data-action="print-document">인쇄 / PDF 저장</button><button data-action="export-report-xlsx">서식 Excel 저장</button><button data-action="print-default-save">기본양식저장</button><button data-action="print-default-open">기본양식열기</button><span id="print-error" role="status"></span></div>
|
|
|
|
|
<label>문서 본문(표지·갑지·설명서·시방서·심사·공정 문서)<textarea data-print="notes" rows="3" style="width:100%">${esc(s.notes)}</textarea></label>
|
|
|
|
|
<iframe id="print-frame" title="인쇄할 문서" style="width:100%;height:65vh;border:1px solid #aaa"></iframe>`,
|
|
|
|
|
);
|
|
|
|
@@ -353,5 +360,28 @@ const EstReport = (() => {
|
|
|
|
|
EstApp.byId("print-error").textContent = error.message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return { open, preview, print, exportExcel };
|
|
|
|
|
// 원본 미리보기 기본양식저장·기본양식열기(TFRMESTPREVIEW2 mnuFormatSave·mnuFromatOpen) — 서식 고르기·본문 글은 빼고 용지·여백·글자·줄 수 등
|
|
|
|
|
const POST = (body) => ({
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: { "Content-Type": "application/json" },
|
|
|
|
|
body: JSON.stringify(body),
|
|
|
|
|
});
|
|
|
|
|
async function saveDefault() {
|
|
|
|
|
const { form, notes, ...data } = setting();
|
|
|
|
|
await EstApp.api("/api/forms", POST({ kind: "print", name: "기본양식", data }));
|
|
|
|
|
EstApp.byId("print-error").textContent = "인쇄 기본양식을 저장했습니다.";
|
|
|
|
|
}
|
|
|
|
|
async function openDefault() {
|
|
|
|
|
const found = (await EstApp.api("/api/forms")).find(
|
|
|
|
|
(f) => f.kind === "print" && f.name === "기본양식",
|
|
|
|
|
);
|
|
|
|
|
if (!found) throw Error("저장한 인쇄 기본양식이 없습니다.");
|
|
|
|
|
const { form, notes, ...data } = found.data;
|
|
|
|
|
EstApp.change((project) => {
|
|
|
|
|
project.printSettings = { ...(project.printSettings || {}), ...data };
|
|
|
|
|
}, false);
|
|
|
|
|
await open();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { open, preview, print, exportExcel, saveDefault, openDefault, pageSize };
|
|
|
|
|
})();
|
|
|
|
|