feat(est-test): 수량산출서 복사와 순서 이동

- 현재 산출서 아래에 복사본 추가, 내역 연결은 비워 이중 반영 방지
- 산출서 위로·아래로, 순서 변경 ESTX 저장은 명확한 문구로 거부
- 단추 지킴 시험이 cjs 화면 파일도 검사

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 15:04:11 +09:00
co-authored by Claude Opus 5.5
parent fc3bab4ea7
commit e7e59fc513
10 changed files with 142 additions and 4 deletions
+52
View File
@@ -0,0 +1,52 @@
// 원본 수량산출(TFRMMULLANG) 공종 단위 조작 — 공종복사하기·붙여넣기(mnuCopy·mnuPaste)와 순서 이동.
// 복사본은 현재 산출서 바로 아래에 넣고, 내역 이중 반영을 막기 위해 내역 연결을 비운다.
const EstQuantitySheets = (() => {
function copy(project, code, uid) {
const sheets = project.quantitySheets || [],
index = sheets.findIndex((sheet) => sheet.Code === code);
if (index < 0) throw Error("복사할 수량산출서를 고르세요.");
const used = new Set(sheets.map((sheet) => sheet.Code));
let next = `Q${uid}`;
for (let n = 2; used.has(next); n++) next = `Q${uid}_${n}`;
const sheet = structuredClone(sheets[index]);
sheet.Code = next;
sheet.Name = `${sheets[index].Name || sheets[index].Code} 복사본`;
for (const item of sheet.items || []) {
item.TargetCode = "";
item.TargetKey = "";
delete item.LinkCode;
delete item.LinkIndex;
}
sheets.splice(index + 1, 0, sheet);
return next;
}
function move(project, code, step) {
const sheets = project.quantitySheets || [],
index = sheets.findIndex((sheet) => sheet.Code === code),
next = index + step;
if (index < 0 || next < 0 || next >= sheets.length) return false;
[sheets[index], sheets[next]] = [sheets[next], sheets[index]];
return true;
}
function handle(name, state) {
const code = state.quantitySheet;
if (name === "quantity-sheet-copy") {
EstApp.change((project) => {
state.quantitySheet = copy(project, code, EstApp.uid());
}, false);
state.notice = "산출서를 복사했습니다. 복사본의 내역 연결은 비워 두었습니다.";
} else if (name === "quantity-sheet-up" || name === "quantity-sheet-down") {
const step = name === "quantity-sheet-up" ? -1 : 1,
sheets = state.project.quantitySheets || [],
index = sheets.findIndex((sheet) => sheet.Code === code);
if (index < 0 || index + step < 0 || index + step >= sheets.length)
throw Error("더 옮길 수 없습니다.");
EstApp.change((project) => move(project, code, step), false);
} else return false;
return true;
}
return { copy, move, handle };
})();