fix(est): avoid reused quantity references
This commit is contained in:
@@ -151,6 +151,14 @@ const EstQuantity = (() => {
|
||||
for (const row of project.tables.EstMainDat)
|
||||
if (quantities.has(row.Code) && !Number(row.Level)) row.GN = quantities.get(row.Code);
|
||||
}
|
||||
function newCode(items) {
|
||||
const codes = new Set(items.map((row) => row.Code));
|
||||
for (const row of items)
|
||||
for (const match of String(row.formula || "").matchAll(/\[([^\]]+)\]/g)) codes.add(match[1]);
|
||||
let index = 1;
|
||||
while (codes.has(`Q${index}`)) index++;
|
||||
return `Q${index}`;
|
||||
}
|
||||
function selector(state) {
|
||||
const { esc } = EstApp;
|
||||
return `<div class="business-tools"><label>수량산출서 <select id="quantity-sheet-choice"><option value="manual">수식표 직접 작성</option>${(state.project.quantitySheets || []).map((sheet) => `<option value="${esc(sheet.Code)}" ${state.quantitySheet === sheet.Code ? "selected" : ""}>${esc(sheet.Name || sheet.Code)}</option>`).join("")}</select></label><button data-quantity-new>새 산출서</button></div>`;
|
||||
@@ -270,6 +278,6 @@ const EstQuantity = (() => {
|
||||
}
|
||||
});
|
||||
}
|
||||
return { entities, fromWpt, calculate, totals, applyTotals, selector, render, install };
|
||||
return { entities, fromWpt, calculate, totals, applyTotals, newCode, selector, render, install };
|
||||
})();
|
||||
if (typeof module !== "undefined" && module.exports) module.exports = EstQuantity;
|
||||
|
||||
Reference in New Issue
Block a user