feat(est-test): 묶음 인쇄 간지 일괄적용·기본양식 저장·전체선택/해제
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,7 @@ const EstPrintBatch = (() => {
|
||||
Name: row.Name2 || row.Name || String(row.Index),
|
||||
checked: saved ? saved.includes(row.Index) : Number(row.Checked) === 1,
|
||||
gangi: project.printBatch?.gangi ?? Number(row.PrintGangiShow) === 1,
|
||||
outline: Number(row.PrintGangiOutLineShow ?? 1) === 1,
|
||||
outline: project.printBatch?.outline ?? Number(row.PrintGangiOutLineShow ?? 1) === 1,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -54,7 +54,21 @@ const EstPrintBatch = (() => {
|
||||
}
|
||||
|
||||
let catalog = [];
|
||||
// 간지 설정값 일괄적용(btnGangiAllSet): 간지 인쇄·겹테두리를 모든 서식에 같게. 기본양식에저장(btnSaveToMain):
|
||||
// 고른 서식·간지 설정을 서버 양식 보관함(종류 print, 이름 「묶음기본양식」)에 — 묶음 설정이 없는 공사에서 열 때 씀.
|
||||
const DEFAULT = "묶음기본양식";
|
||||
const post = (body) => ({
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
async function open(state) {
|
||||
if (!state.project.printBatch) {
|
||||
const saved = (await EstApp.api("/api/forms")).find(
|
||||
(f) => f.kind === "print" && f.name === DEFAULT,
|
||||
);
|
||||
if (saved) EstApp.change((project) => (project.printBatch = saved.data), false);
|
||||
}
|
||||
const defaults = await EstApp.api("/api/print-catalog");
|
||||
const original = new Map((state.project.printCatalog || []).map((row) => [row.Index, row]));
|
||||
catalog = defaults.map((row) => ({ ...row, ...original.get(row.Index) }));
|
||||
@@ -64,16 +78,17 @@ const EstPrintBatch = (() => {
|
||||
const list = forms(catalog, state.project);
|
||||
EstApp.showDialog(
|
||||
"묶음 인쇄(설계서 일체)",
|
||||
`<p>인쇄할 서식을 고르세요. 인쇄표 차례대로 이어 인쇄합니다.</p><label><input type="checkbox" name="pb-gangi" ${list[0]?.gangi ? "checked" : ""}>간지 인쇄</label><div style="max-height:260px;overflow:auto;columns:2">${list.map((f) => `<label style="display:block"><input type="checkbox" name="pb-form" value="${esc(f.Index)}" ${f.checked ? "checked" : ""}>${esc(f.Name)}</label>`).join("")}</div><button data-action="print-batch-preview">미리보기</button> <button data-action="print-batch-print">인쇄</button><p id="print-batch-note"></p><iframe id="print-batch-frame" style="width:100%;height:360px;border:1px solid #ccc"></iframe>`,
|
||||
`<p>인쇄할 서식을 고르세요. 인쇄표 차례대로 이어 인쇄합니다.</p><label><input type="checkbox" name="pb-gangi" ${list[0]?.gangi ? "checked" : ""}>간지 인쇄</label> <label><input type="checkbox" name="pb-outline" ${list[0]?.outline !== false ? "checked" : ""}>간지 겹테두리</label> (모든 서식에 일괄적용) <button data-action="print-batch-all">전체선택</button><button data-action="print-batch-none">선택해제</button><button data-action="print-batch-default">기본양식에저장</button><div style="max-height:260px;overflow:auto;columns:2">${list.map((f) => `<label style="display:block"><input type="checkbox" name="pb-form" value="${esc(f.Index)}" ${f.checked ? "checked" : ""}>${esc(f.Name)}</label>`).join("")}</div><button data-action="print-batch-preview">미리보기</button> <button data-action="print-batch-print">인쇄</button><p id="print-batch-note"></p><iframe id="print-batch-frame" style="width:100%;height:360px;border:1px solid #ccc"></iframe>`,
|
||||
);
|
||||
}
|
||||
function read(state) {
|
||||
const checked = [...document.querySelectorAll('#dialog-content [name="pb-form"]:checked')].map(
|
||||
(n) => (/^\d+$/.test(n.value) ? Number(n.value) : n.value),
|
||||
);
|
||||
const gangi = document.querySelector('#dialog-content [name="pb-gangi"]').checked;
|
||||
const gangi = document.querySelector('#dialog-content [name="pb-gangi"]').checked,
|
||||
outline = document.querySelector('#dialog-content [name="pb-outline"]').checked;
|
||||
if (!checked.length) throw Error("인쇄할 서식을 하나 이상 고르세요.");
|
||||
const next = { checked, gangi };
|
||||
const next = { checked, gangi, outline };
|
||||
if (JSON.stringify(next) !== JSON.stringify(state.project.printBatch))
|
||||
EstApp.change((project) => (project.printBatch = next), false);
|
||||
return next;
|
||||
@@ -96,7 +111,18 @@ const EstPrintBatch = (() => {
|
||||
EstApp.render();
|
||||
});
|
||||
else if (name === "print-batch-preview") build(state);
|
||||
else if (name === "print-batch-print") {
|
||||
else if (name === "print-batch-all" || name === "print-batch-none")
|
||||
for (const n of document.querySelectorAll('#dialog-content [name="pb-form"]'))
|
||||
n.checked = name === "print-batch-all";
|
||||
else if (name === "print-batch-default") {
|
||||
const data = read(state);
|
||||
EstApp.api("/api/forms", post({ kind: "print", name: DEFAULT, data }))
|
||||
.then(
|
||||
() =>
|
||||
(EstApp.byId("print-batch-note").textContent = "묶음 인쇄 기본양식을 저장했습니다."),
|
||||
)
|
||||
.catch((error) => (EstApp.byId("print-batch-note").textContent = error.message));
|
||||
} else if (name === "print-batch-print") {
|
||||
const frame = build(state);
|
||||
frame.onload = () => frame.contentWindow.print();
|
||||
} else return false;
|
||||
|
||||
Reference in New Issue
Block a user