feat(est-test): 수량산출서 검색과 전체보기
- 원본처럼 이름·항목 명칭·규격에서 빈칸·|·괄호를 빼고 찾아 목록을 좁힘 - 고르기 줄을 산출서 모듈로 옮겨 700줄 제한 유지 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -106,8 +106,53 @@ const EstQuantitySheets = (() => {
|
||||
return editor;
|
||||
}
|
||||
|
||||
// 원본 수량산출 검색(TFRMMULLANG btnSerch·btnAllDisplay): 명칭·규격에서 빈칸·|·괄호를 빼고 포함 검색.
|
||||
const loose = (text) =>
|
||||
String(text ?? "")
|
||||
.replace(/[\s|()[\]{}]/g, "")
|
||||
.toLowerCase();
|
||||
function matches(sheet, query) {
|
||||
const q = loose(query);
|
||||
if (!q) return true;
|
||||
return [sheet.Name, sheet.Code, ...(sheet.items || []).flatMap((i) => [i.Name, i.Size])].some(
|
||||
(t) => loose(t).includes(q),
|
||||
);
|
||||
}
|
||||
|
||||
// 수량산출서 고르기 줄(원본 공종 목록 + 검색·전체보기).
|
||||
function selector(state) {
|
||||
const { esc } = EstApp;
|
||||
const options = (state.project.quantitySheets || [])
|
||||
.filter((sheet) => matches(sheet, state.quantityQuery) || sheet.Code === state.quantitySheet)
|
||||
.map(
|
||||
(sheet) =>
|
||||
`<option value="${esc(sheet.Code)}" ${state.quantitySheet === sheet.Code ? "selected" : ""}>${esc(sheet.Name || sheet.Code)}</option>`,
|
||||
)
|
||||
.join("");
|
||||
return `<div class="business-tools"><label>수량산출서 <select id="quantity-sheet-choice"><option value="manual">수식표 직접 작성</option>${options}</select></label><input data-quantity-query value="${esc(state.quantityQuery || "")}" placeholder="명칭·규격" aria-label="산출서 검색"><button data-action="quantity-sheet-search">검색</button><button data-action="quantity-sheet-all">전체보기</button><button data-quantity-new>새 산출서</button><button data-quantity-excel>Excel 셀 수량 연결</button><button data-quantity-excel-links>Excel 연결 관리</button></div>`;
|
||||
}
|
||||
|
||||
function handle(name, state, node) {
|
||||
const code = state.quantitySheet;
|
||||
if (name === "quantity-sheet-search" || name === "quantity-sheet-all") {
|
||||
state.quantityQuery =
|
||||
name === "quantity-sheet-all"
|
||||
? ""
|
||||
: (document.querySelector("[data-quantity-query]")?.value ?? "");
|
||||
const first = (state.project.quantitySheets || []).find((s) =>
|
||||
matches(s, state.quantityQuery),
|
||||
);
|
||||
if (state.quantityQuery && !first) throw Error("찾는 수량산출서가 없습니다.");
|
||||
if (
|
||||
first &&
|
||||
!matches(
|
||||
state.project.quantitySheets.find((s) => s.Code === code) || {},
|
||||
state.quantityQuery,
|
||||
)
|
||||
)
|
||||
state.quantitySheet = first.Code;
|
||||
return true;
|
||||
}
|
||||
if (name === "quantity-sheet-copy") {
|
||||
EstApp.change((project) => {
|
||||
state.quantitySheet = copy(project, code, EstApp.uid());
|
||||
@@ -176,5 +221,5 @@ const EstQuantitySheets = (() => {
|
||||
.join("");
|
||||
}
|
||||
|
||||
return { copy, move, mark, free, excelView, handle };
|
||||
return { copy, move, mark, free, excelView, matches, selector, handle };
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user