/** * STMATE 내역 행 끼워 넣기 (app_modals.js) — api = window.STMATE_APP * 내역 도구(wITNum · wBoqRate · wM_Rate · wExpnd)는 scr_ui_boq_dlg.js · 가격지 비교(wM_Boxa)·기준단가 수정(wM_Edt_Hal)은 scr_ui_dan.js */ (function (global) { "use strict"; /** * 내역 행 끼워 넣기 — 선택 행 앞(선택 없으면 끝) · 저장 원천(boq_rows)·계산 원천(boqItems) 함께 * 코드가 단가목록에 있으면 명칭·규격·단위를 단가목록 값으로 */ function insertBoqRow(api, code, name, spec, unit, qty) { const { ctx, renderWorkspace } = api; const B = global.STMATE_UI_BOQ; if (!ctx.dbfData || !ctx.dbfData.boq_rows) return alert("열린 내역서 없음"); ctx.dbfData.boq_deleted = ctx.dbfData.boq_deleted || []; const model = { rows: ctx.dbfData.boq_rows, items: ctx.state.boqItems, deleted: ctx.dbfData.boq_deleted, }; const c = String(code || "").trim(); const cr = (ctx.dbfData.costn_rows || []).find((r) => String(r.CODE || "").trim() === c); const row = B.makeRow(model, { BDCODE1: c, NAME1: cr ? cr.NAME || "" : name || "", SIZE1: cr ? cr.SIZE || "" : spec || "", UNIT1: cr ? cr.UNIT || "" : unit || "", QTY1: String(Number(qty) || 0), }); const ix = B.indexesOf(model.rows, ctx.uiState.boqSel || []); const res = B.insertRows(model, ix.length ? ix[0] : model.rows.length, [row]); if (!res.ok) alert(res.error); ctx.uiState.boqSel = [row._recno]; renderWorkspace(); return row; } global.STMATE_APP_MODALS = { insertBoqRow }; })(window);