var OpenAlone = sessionStorage.getItem("OpenAlone") || ""; let topDocument; if(OpenAlone === 'Y') { try { topDocument = parent.document; } catch (e) { topDocument = document; } } else { try { topDocument = top.document; } catch (e) { topDocument = document; } } const queryParams = getQueryParams(); let sBJDID = queryParams['BJDID'] || ''; let sSource = queryParams['FROMPARENTDIV'] || ''; // 获取 BJFLID 和 BJDYZ function getBJFLIDAndBJDYZ() { let bjflid = getQueryParams()['BJFLID'] || ''; let bjdyz = getQueryParams()['BJDYZ'] || ''; if (!bjflid) { const txtBJFLIDElem = document.getElementById('txtBJFLID'); if (txtBJFLIDElem) { bjflid = txtBJFLIDElem.value || ''; } } if (!bjdyz) { const txtBJDYZElem = document.getElementById('txtBJDYZ'); if (txtBJDYZElem) { bjdyz = txtBJDYZElem.value || ''; } } if ((!bjflid || !bjdyz) && topDocument) { try { if (!bjflid) { const parentBJFLIDElem = topDocument.getElementById('txtBJFLID') || topDocument.getElementById('ctl00_CphForm_txtBJFLID') || topDocument.querySelector('[id*="txtBJFLID"]'); if (parentBJFLIDElem) { bjflid = parentBJFLIDElem.value || ''; } if (!bjflid) { const parentCbxBJFLIDElem = topDocument.getElementById('cbxBJFLID') || topDocument.getElementById('ctl00_CphForm_cbxBJFLID') || topDocument.querySelector('[id*="cbxBJFLID"]'); if (parentCbxBJFLIDElem) { bjflid = parentCbxBJFLIDElem.value || ''; } } } if (!bjdyz) { const parentBJDYZElem = topDocument.getElementById('txtBJDYZ') || topDocument.getElementById('ctl00_CphForm_txtBJDYZ') || topDocument.querySelector('[id*="txtBJDYZ"]'); if (parentBJDYZElem) { bjdyz = parentBJDYZElem.value || ''; } } } catch (e) { console.warn('从父页面获取BJFLID/BJDYZ失败:', e); } } return { bjflid, bjdyz }; } // 初始获取 let { bjflid: sBJFLID, bjdyz: sBJDYZ } = getBJFLIDAndBJDYZ(); console.log('sBJDID:', sBJDID); console.log('FROMPARENTDIV:', sSource); console.log('sBJFLID:', sBJFLID); console.log('sBJDYZ:', sBJDYZ); const FILTERABLE_COLUMNS = [ 'XLXHID', // 型号 'XLGGID', // 规格 'XLBZID', // 标准 'DYDJID', // 电压等级 'JLDW', // 计量单位 'CPYT' // 产品用途 ]; const { createApp, h } = Vue; const { ElTableV2, ElButton, ElSelect, ElSelectV2, ElOption, ElInput, ElCheckbox, ElDialog, ElPopover, ElScrollbar, ElIcon, ElCheckboxGroup, ElTag, ElMessage, ElMessageBox, ElDropdown, ElDropdownMenu, ElDropdownItem, ElDrawer, ElForm, ElFormItem, ElInputNumber, ElRow, ElCol, ElProgress } = ElementPlus; const { Filter, Operation, Edit } = ElementPlusIconsVue; const app = createApp({ components: { ElTableV2, ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem, ElDrawer, ElForm, ElFormItem, ElInputNumber, ElRow, ElCol, ElProgress }, data: function () { return { tableWidth: 1600, tableHeight: 800, importing: false, showLoading: false, loadingProgress: 0, loadingTimer: null, // 列最小宽度映射表 COLUMN_MIN_WIDTH_MAP: { XLXHID: 120, XLGGID: 120, XLBZID: 100, DYDJID: 100, JLDW: 100, CPYT: 240, BJCP: 250, BJSL: 100, BJDHQCLCB: 130, CLCB: 130, JGBJJ: 120, JGBBJ: 120, TZQCPBJ: 100, TZCPBJ: 100, CPBJ: 100, TZQBJJE: 100, TZBJJE: 100, BJJE: 120, BZ: 200, BJSDBZ: 100 }, dynamicWidths: {}, resizingKey: '', startX: 0, startWidth: 0, isResizing: false, sJGEJGB: '', bjcphgColumnName: '材料清单未生成', title: '批量调价', filteredItems: [], items: [], priceUpDialogVisible: false, priceDownDialogVisible: false, batchPriceDialogVisible: false, materialPriceDialogVisible: false, priceUpForm: { range: 'C', value: 0, rangeOptions: ['N', 'Y', 'C'], formulaLabel: '新报价=原报价/(1-' }, priceDownForm: { range: 'C', value: 0, rangeOptions: ['N', 'Y', 'C'], formulaLabel: '新报价=原报价*(1-' }, materialPriceForm: { range: 'C', rangeOptions: ['Y', 'C'], referenceColumn: 'LJ', // 固定为料价价差率 adjustRatio: '', materialType: 'XDZ', hasNoTablePrice: false, isNonPurchased: false, canEditNonPurchased: true }, batchPriceForm: { adjustType: 'up', range: 'C', value: 0, materialType: 'relative', materialValue: 0, rangeOptions: ['N', 'Y', 'C'] }, tempColumnFilters: {}, columnFilters: {}, columnUniqueValues: {}, filterPopoverVisible: {}, filterSearch: {}, tableVersion: 0, columnVisibility: { BJDHQCLCB: false, CLCB: false, JGBJJ: false, TZQCPBJ: false, TZCPBJ: false, CPBJ: true, TZQBJJE: false, TZBJJE: false, BJJE: true, CLZL: false, CLCBJCL: false, JGBBJJCL: false, JGBBJJCE: false, FBH: false, CPBJXJ: false, BJXJKD: false, BJXJJJ: false, XJBJCE: false, BZ: false, BJSDBZ: false, XLXSBJDMX_WHRID: false, XLXSBJDMX_WHR: false, XLXSBJDMX_WHSJ: false, XLXSBJDMX_XH: false, PX0: false }, decimalPlaces: {}, // 动态列 dynamicColumns: [], buttonVisibility: { BJSD: true, BJSF: true, BJXF: true, JMBGS: false, LJJCLLX: false, BJXJ: false, CLYLBL: false }, queryDrawerVisible: false, queryConditions: { XLJGID: '', XLGGID: '', JMBGS: '', ZJMS: '', ZJMZ: '', BJSLS: '', BJSLZ: '', BJJES: '', BJJEZ: '', DJS: '', DJZ: '', BH: [], CPYT: [], XJBJCEWF: false }, showJMBGS: false, showLSBJ: false, showBH: false, showXJBJ: false, bhOptions: [], bjslUnit: 'M', xlggOptions: [], xlbzOptions: [], xlbzAllOptions: [], dydjOptions: [], xlysOptions: [], cpytOptions: [], JGBBJBMValue: '', BJDHQLJBMValue: '', iXSWS: 5, showXJBJ: false, jmbgsButtonText: '基价表格式', dynamicYZButtons: [], selectedRows: [], selectedRowMap: {}, // 以XH为键的已选记录映射,用于O(1)查找,避免大数据量全选卡死 useCPML: false, // 是否使用产品目录(true=产品目录,false=产品用途) bjdyz: '', // BJDYZ 参数,用于生成列标题 sortField: '', sortOrder: '', dynamicWidths: {}, resizingKey: '', startX: 0, startWidth: 0, isResizing: false, bjxjDialogVisible: false, bjxjForm: { range: 'C', rangeOptions: ['Y', 'C'], kdValue: '', jjValue: '', onlyNegative: false }, // 因子对话框 yzDialogVisible: false, yzForm: { dialogTitle: '因子调价', range: 'C', rangeOptions: ['Y', 'C'], showReferenceColumn: false, referenceColumn: '', referenceColumnOptions: [], factorLabel: '因子值:', factorValue: '', factorUnit: '', showOnlyNegative: false, onlyNegative: false, showHasTablePrice: false, hasTablePrice: false, showPurchased: false, isPurchased: false, isNonPurchased: false, YZID: '', YZType: '' } }; }, async created() { try { // 确保loadingProgress已初始化(但不设置 showLoading,由 loadData 控制) if (this.loadingProgress === undefined) { this.loadingProgress = 0; } // 延迟重新获取 BJFLID 和 BJDYZ setTimeout(() => { const { bjflid, bjdyz } = getBJFLIDAndBJDYZ(); if (bjflid) { sBJFLID = bjflid; console.log('延迟获取到 sBJFLID:', sBJFLID); } if (bjdyz) { sBJDYZ = bjdyz; console.log('延迟获取到 sBJDYZ:', sBJDYZ); } if (bjflid || bjdyz) { this.loadColumnVisibility(); } }, 500); GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373006.ashx'; await Promise.all([ GThinking.Web.AjaxServiceProxy.invoke('IsJGEJGB', false, { 'sBJDID': sBJDID }, result => { console.log("IsJGEJGB_CallBack"); console.log(result); this.sJGEJGB = result; if (this.sJGEJGB === "Y") { this.bjcphgColumnName = '材料清单未生成'; } else { this.bjcphgColumnName = '无表价'; } this.COLUMN_MIN_WIDTH_MAP['BJCPBHG'] = this.bjcphgColumnName.length >= 6 ? 150 : 100; this.calcTableSize(); }, CallBackNULLJSON, "IsJGEJGB_CallBack"), GThinking.Web.AjaxServiceProxy.invoke('GetXLYSList', false, {}, CallBackFun, CallBackNULLJSON, "GetXLYSList_CallBack"), GThinking.Web.AjaxServiceProxy.invoke('GetXLBZList', false, { 'sBJDID': sBJDID, 'sXLXHID': '', 'sXLGGID': '' }, result => { this.xlbzAllOptions = result; }, CallBackNULLJSON, "GetXLBZList_CallBack") ]); GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; this.loadColumnVisibility(); this.loadButtonConfig(); this.loadQueryOptions(); this.loadDecimalPlaces(); this.loadDynamicColumns(); // 会在列可见性配置加载完成后再次调用 this.loadUseCPML(); this.loadData(); } catch (error) { console.error("数据加载失败:", error); } finally { // this.$nextTick(() => { // this.$refs.table?.forceUpdate(); // }); } }, computed: { columns() { return this.generateColumns(); }, safeLoadingProgress() { // 确保 loadingProgress 始终有值,避免 Vue 3 警告 try { const progress = this.loadingProgress; if (typeof progress === 'number' && !isNaN(progress)) { return Math.max(0, Math.min(100, progress)); } return 0; } catch (e) { return 0; } } }, watch: { showLoading(newVal, oldVal) { if (newVal) { // 开始加载时启动进度条 this.loadingProgress = 0; // 使用 nextTick 确保 DOM 更新后再启动进度条 this.$nextTick(() => { this.startLoadingProgress(); }); } else { // 加载完成时清除定时器并重置进度 if (this.loadingTimer) { clearInterval(this.loadingTimer); this.loadingTimer = null; } // 快速完成到100%然后重置 this.loadingProgress = 100; setTimeout(() => { this.loadingProgress = 0; }, 300); } } }, beforeMount() { // 在挂载前确保属性存在,避免 Vue 3 警告 if (this.loadingProgress === undefined) { this.loadingProgress = 0; } if (this.loadingTimer === undefined) { this.loadingTimer = null; } }, mounted() { // 确保 loadingProgress 在实例上存在(Vue 3 响应式初始化) this.loadingProgress = this.loadingProgress ?? 0; this.loadingTimer = this.loadingTimer ?? null; this.calcTableSize(); this.calculateColumnWidths(); window.addEventListener('resize', this._onResize = this.resizeColumns.bind(this)); this.$nextTick(() => { const appElement = document.getElementById('app'); if (appElement) { appElement.style.opacity = '1'; appElement.style.pointerEvents = 'auto'; } }); }, beforeUnmount() { window.removeEventListener('resize', this._onResize); // 清理进度条定时器 if (this.loadingTimer) { clearInterval(this.loadingTimer); this.loadingTimer = null; } }, methods: { startLoadingProgress() { // 清除之前的定时器 if (this.loadingTimer) { clearInterval(this.loadingTimer); this.loadingTimer = null; } // 如果loading已经结束,不再启动进度条 if (!this.showLoading) { return; } // 立即设置初始值 this.loadingProgress = 0; // 根据数据量估算加载时间 // 如果有历史数据,根据数据量估算;否则使用默认值 let estimatedDuration = 3000; // 默认3秒 if (this.items && this.items.length > 0) { // 根据已有数据量估算:每1000条数据约需1秒,最少2秒,最多8秒 const dataCount = this.items.length; estimatedDuration = Math.max(2000, Math.min(8000, Math.ceil(dataCount / 1000) * 1000)); } else { // 如果没有历史数据,根据筛选条件估算 // 如果有筛选条件,可能数据量较大,使用较长的时间 const hasFilters = Object.keys(this.columnFilters || {}).some(key => this.columnFilters[key] && this.columnFilters[key].length > 0 ); if (hasFilters) { estimatedDuration = 4000; // 有筛选条件,估算4秒 } else { estimatedDuration = 3000; // 无筛选条件,估算3秒 } } const targetProgress = 96; // 最终进度96% const updateInterval = 50; // 每50ms更新一次 const startTime = Date.now(); // 使用自定义分段函数实现前面非常快、后面非常慢的效果 // 前30%时间快速达到85%,后70%时间缓慢达到96% const customEasing = (t) => { if (t <= 0.3) { // 前30%时间:快速从0到85% return (t / 0.3) * 0.85; } else { // 后70%时间:缓慢从85%到96% const remainingProgress = 0.96 - 0.85; // 11% const remainingTime = (t - 0.3) / 0.7; // 0到1 // 使用指数函数让后面非常慢 const slowProgress = 1 - Math.pow(1 - remainingTime, 3); return 0.85 + slowProgress * remainingProgress; } }; // 使用箭头函数保持 this 上下文 const interval = setInterval(() => { // 如果loading已经结束,清除定时器 if (!this.showLoading) { clearInterval(interval); this.loadingTimer = null; return; } // 计算已过时间 const elapsed = Date.now() - startTime; const progress = Math.min(elapsed / estimatedDuration, 1); // 0 到 1 // 应用自定义缓动函数,使前面非常快、后面非常慢 const easedProgress = customEasing(progress); // 计算当前进度(0 到 96) const currentProgress = Math.min(Math.round(easedProgress * 100), targetProgress); // 更新进度值 - Vue 3 会自动检测响应式变化 this.loadingProgress = currentProgress; // 如果达到96%,停止动画,等待实际完成 if (currentProgress >= targetProgress) { clearInterval(interval); this.loadingTimer = null; } }, updateInterval); this.loadingTimer = interval; }, // 获取当前筛选结果的明细ID(逗号分隔),用于“所查记录”范围 getFilteredIds() { if (!this.filteredItems || this.filteredItems.length === 0) return ''; return this.filteredItems .map(row => row.XLXSBJDMX_XH || row.XH) .filter(Boolean) .join(','); }, applyFilter() { if (!this.items || !Array.isArray(this.items)) { this.filteredItems = []; return; } // 如果数据量较大,显示loading并使用异步处理 const dataCount = this.items.length; const shouldShowLoading = dataCount > 1000; if (shouldShowLoading) { this.showLoading = true; } // 使用异步处理大数据量筛选,避免阻塞UI const filterData = () => { let filteredData = this.items.filter(row => { return Object.keys(this.columnFilters).every(key => { const filters = this.columnFilters[key]; if (!filters || filters.length === 0) return true; const value = (row[key] ?? '').toString().trim(); return filters.some(f => (f ?? '').toString().trim() === value); }); }); filteredData = filteredData.sort((a, b) => { const aXSSX = a.XLXSBJDMX_XSSX || a.XSSX || a.XH || 0; const bXSSX = b.XLXSBJDMX_XSSX || b.XSSX || b.XH || 0; return aXSSX - bXSSX; }); this.filteredItems = filteredData; this.tableVersion += 1; // 强制刷新表格渲染 if (shouldShowLoading) { this.showLoading = false; } }; if (shouldShowLoading) { // 使用setTimeout让UI有机会渲染loading状态 setTimeout(() => { filterData(); }, 10); } else { filterData(); } }, handleHeaderClick(column) { if (this.isResizing) return; }, updateColumnValues(key) { if (!this.items || !Array.isArray(this.items) || this.items.length === 0) return; // 按其他已选筛选条件先过滤,做到二级联动 const sourceData = (this.items || []).filter(row => { return Object.keys(this.columnFilters || {}).every(fk => { if (fk === key) return true; // 当前列不参与过滤 const filters = this.columnFilters[fk]; if (!filters || filters.length === 0) return true; const value = (row[fk] ?? '').toString().trim(); return filters.some(f => (f ?? '').toString().trim() === value); }); }); const allValues = sourceData.map(row => { const value = (row[key] ?? '').toString().trim(); return { label: value || '空', value }; }); const uniqueValues = Array.from(new Map( allValues.map(item => [item.value, item]) ).values()).sort((a, b) => { if (a.value === '') return -1; if (b.value === '') return 1; return a.value.localeCompare(b.value, undefined, { numeric: true, sensitivity: 'base', caseFirst: 'false' }); }); this.columnUniqueValues[key] = uniqueValues; }, resizeColumns() { const container = this.$refs.tableContainer; if (container) { const scrollbarWidth = container.offsetWidth - container.clientWidth; this.tableWidth = container.getBoundingClientRect().width - scrollbarWidth - 1; this.tableHeight = container.clientHeight; console.log('自适应表宽高:', this.tableWidth, this.tableHeight); } }, calcTableSize() { const container = this.$refs.tableContainer; if (!container) return; const scrollbarWidth = container.offsetWidth - container.clientWidth; this.tableWidth = container.getBoundingClientRect().width - scrollbarWidth - 1; this.tableHeight = container.clientHeight; console.log(' calcTableSize ', this.tableWidth, this.tableHeight); }, calculateColumnWidths() { console.log('批量调价使用固定列宽'); }, generateColumns() { const getWidth = (key, defaultWidth) => this.dynamicWidths[key] || defaultWidth; const columns = [ // 选择列 { key: 'selection', title: '', width: 55, minWidth: 55, fixed: 'left', headerCellRenderer: () => { const selectedXHSet = new Set(this.selectedRows.map(sel => sel.XH)); const allSelected = this.filteredItems.length > 0 && this.filteredItems.every(row => selectedXHSet.has(row.XH)); const someSelected = this.filteredItems.some(row => selectedXHSet.has(row.XH)); return h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'center', height: '100%', width: '100%' } }, [ h(ElCheckbox, { modelValue: allSelected, indeterminate: someSelected && !allSelected, onChange: (checked) => { if (checked) { // 全选:使用批量方式,避免大数据量下 O(n²) 卡死 const existingXHs = new Set(this.selectedRows.map(sel => sel.XH)); const newRows = []; this.filteredItems.forEach(row => { if (!existingXHs.has(row.XH)) { existingXHs.add(row.XH); newRows.push(row); this.selectedRowMap[row.XH] = row; } }); if (newRows.length > 0) { this.selectedRows = this.selectedRows.concat(newRows); } } else { // 取消全选:使用 Set 批量过滤 const filteredXHs = new Set(this.filteredItems.map(row => row.XH)); this.selectedRows = this.selectedRows.filter(sel => { const keep = !filteredXHs.has(sel.XH); if (!keep) { delete this.selectedRowMap[sel.XH]; } return keep; }); } } }) ]); }, cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); const isSelected = !!this.selectedRowMap[rowData.XH]; return h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'center', height: '100%', width: '100%' } }, [ h(ElCheckbox, { modelValue: isSelected, onChange: (checked) => { if (checked) { if (!this.selectedRowMap[rowData.XH]) { this.selectedRowMap[rowData.XH] = rowData; this.selectedRows = this.selectedRows.concat([rowData]); } } else { if (this.selectedRowMap[rowData.XH]) { delete this.selectedRowMap[rowData.XH]; this.selectedRows = this.selectedRows.filter(sel => sel.XH !== rowData.XH); } } } }) ]); } }, // 隐藏的序号列(用于判断是哪列) { key: 'XH', title: '', width: 0, minWidth: 0, cellRenderer: () => h('div', { style: { display: 'none' } }) }, // 显示序号列(使用后台序号) { key: 'XSSX', title: '显示序号', width: getWidth('XSSX', 80), minWidth: 80, align: 'center', headerCellRenderer: () => { const self = this; return h('div', { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', width: '100%', height: '100%', textAlign: 'center', position: 'relative' } }, [ h('span', '显示序号'), h('div', { class: 'resizer', onMousedown: (e) => { e.stopPropagation(); self.startResizing('XSSX', e); } }) ]); }, cellRenderer: ({ rowData, rowIndex }) => { const displayIndex = rowData?.XLXSBJDMX_XSSX || rowData?.XSSX || (rowIndex + 1); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' } }, displayIndex); } }, // 型号列 this.buildFilterableColumn({ key: 'XLXHID', title: '型号', width: 120, minWidth: 120, align: 'center', cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' } }, rowData.XLXHID || ''); } }), // 规格列 this.buildFilterableColumn({ key: 'XLGGID', title: '规格', width: 120, minWidth: 120, align: 'center', cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' } }, rowData.XLGGID || ''); } }), // 标准列 this.buildFilterableColumn({ key: 'XLBZID', title: '标准', width: 100, minWidth: 100, align: 'center', cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' } }, rowData.XLBZID || ''); } }), // 电压等级列 this.buildFilterableColumn({ key: 'DYDJID', title: '电压等级', width: 100, minWidth: 100, align: 'center', cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' } }, rowData.DYDJID || ''); } }), // 计量单位列 this.buildFilterableColumn({ key: 'JLDW', title: '计量单位', width: 100, minWidth: 100, align: 'center', cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' } }, rowData.JLDW || ''); } }), // 产品用途/产品目录列 this.buildFilterableColumn({ key: 'CPYT', title: this.useCPML ? '产品目录' : '产品用途', width: 240, minWidth: 240, align: 'center', cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' } }, rowData.CPYT || ''); } }), // 报价产品列 this.buildFilterableColumn({ key: 'BJCP', title: '报价产品', width: 250, minWidth: 250, cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center' } }, rowData.BJCP || ''); } }), // 报价数量列 { key: 'BJSL', title: '报价数量', width: getWidth('BJSL', 100), minWidth: 100, align: 'right', headerCellRenderer: () => { const self = this; return h('div', { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', width: '100%', height: '100%', textAlign: 'center', position: 'relative' } }, [ h('span', '报价数量'), h('div', { class: 'resizer', onMousedown: (e) => { e.stopPropagation(); self.startResizing('BJSL', e); } }) ]); }, cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.BJSL, this.getDecimalPlace('BJSL'))); } }, // 报价单行情料价列 ...(this.columnVisibility.BJDHQCLCB ? [{ key: 'BJDHQCLCB', title: this.BJDHQLJBMValue || '报价单行情料价', width: getWidth('BJDHQCLCB', 130), minWidth: 130, align: 'right', headerCellRenderer: this.createCenteredHeader(this.BJDHQLJBMValue || '报价单行情料价', 'BJDHQCLCB'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.BJDHQCLCB, this.getDecimalPlace('BJDHQCLCB'))); } }] : []), // 价格表行情料价列 ...(this.columnVisibility.CLCB ? [{ key: 'CLCB', title: '价格表行情料价', width: getWidth('CLCB', 130), minWidth: 130, align: 'right', headerCellRenderer: this.createCenteredHeader('价格表行情料价', 'CLCB'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.CLCB, this.getDecimalPlace('CLCB'))); } }] : []), // 基价列 ...(this.columnVisibility.JGBJJ ? [{ key: 'JGBJJ', title: '基价', width: getWidth('JGBJJ', 120), minWidth: 120, align: 'right', headerCellRenderer: this.createCenteredHeader('基价', 'JGBJJ'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.JGBJJ, this.getDecimalPlace('JGBJJ'))); } }] : []), // 表价列 { key: 'JGBBJ', title: this.JGBBJBMValue || '表价', width: getWidth('JGBBJ', 120), minWidth: 120, align: 'right', headerCellRenderer: this.createCenteredHeader(this.JGBBJBMValue || '表价', 'JGBBJ'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.JGBBJ, this.getDecimalPlace('JGBBJ'))); } }, // 动态因子列(放在表价列之后) ...this.dynamicColumns.map(col => ({ key: col.prop, title: col.label, width: getWidth(col.prop, col.width || 100), minWidth: col.width || 100, align: col.align || 'right', headerCellRenderer: this.createCenteredHeader(col.label, col.prop), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: col.align === 'right' ? 'flex-end' : 'center' } }, this.formatNumber(rowData[col.prop], col.decimalPlace || this.iXSWS)); } })), // 调整前报价列 ...(this.columnVisibility.TZQCPBJ ? [{ key: 'TZQCPBJ', title: '调整前报价', width: getWidth('TZQCPBJ', 100), minWidth: 100, align: 'right', headerCellRenderer: this.createCenteredHeader('调整前报价', 'TZQCPBJ'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.TZQCPBJ, this.getDecimalPlace('TZQCPBJ'))); } }] : []), // 调整报价列 ...(this.columnVisibility.TZCPBJ ? [{ key: 'TZCPBJ', title: '调整报价(%)', width: getWidth('TZCPBJ', 150), minWidth: 150, align: 'right', headerCellRenderer: this.createCenteredHeader('调整报价(%)', 'TZCPBJ'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.TZCPBJ, this.getDecimalPlace('TZCPBJ'))); } }] : []), // 报价列 ...(this.columnVisibility.CPBJ ? [{ key: 'CPBJ', title: '报价', width: getWidth('CPBJ', 100), minWidth: 100, align: 'right', headerCellRenderer: this.createCenteredHeader('报价', 'CPBJ'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.CPBJ, this.getDecimalPlace('CPBJ'))); } }] : []), // 报价金额列 ...(this.columnVisibility.TZQBJJE ? [{ key: 'TZQBJJE', title: '报价金额', width: getWidth('TZQBJJE', 100), minWidth: 100, align: 'right', headerCellRenderer: this.createCenteredHeader('报价金额', 'TZQBJJE'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.TZQBJJE, this.getDecimalPlace('TZQBJJE'))); } }] : []), // 调整金额列 ...(this.columnVisibility.TZBJJE ? [{ key: 'TZBJJE', title: '调整金额(元)', width: getWidth('TZBJJE', 100), minWidth: 100, align: 'right', headerCellRenderer: this.createCenteredHeader('调整金额(元)', 'TZBJJE'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.TZBJJE, this.getDecimalPlace('TZBJJE'))); } }] : []), // 报价金额列 ...(this.columnVisibility.BJJE ? [{ key: 'BJJE', title: this.columnVisibility.TZQBJJE ? '调整后报价金额' : '报价金额', width: getWidth('BJJE', 120), minWidth: 120, align: 'right', headerCellRenderer: this.createCenteredHeader(this.columnVisibility.TZQBJJE ? '调整后报价金额' : '报价金额', 'BJJE'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.BJJE, this.getDecimalPlace('BJJE'))); } }] : []), // 材料重量列 ...(this.columnVisibility.CLZL ? [{ key: 'CLZL', title: '材料重量', width: getWidth('CLZL', 100), minWidth: 100, align: 'right', headerCellRenderer: this.createCenteredHeader('材料重量', 'CLZL'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.CLZL, this.getDecimalPlace('CLZL'))); } }] : []), // 料价价差率列 ...(this.columnVisibility.CLCBJCL ? [{ key: 'CLCBJCL', title: '料价价差率(%)', width: getWidth('CLCBJCL', 120), minWidth: 120, align: 'right', headerCellRenderer: this.createCenteredHeader('料价价差率(%)', 'CLCBJCL'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.CLCBJCL, this.getDecimalPlace('CLCBJCL'))); } }] : []), // 表价价差率列 ...(this.columnVisibility.JGBBJJCL ? [{ key: 'JGBBJJCL', title: '表价价差率(%)', width: getWidth('JGBBJJCL', 120), minWidth: 120, align: 'right', headerCellRenderer: this.createCenteredHeader('表价价差率(%)', 'JGBBJJCL'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.JGBBJJCL, this.getDecimalPlace('JGBBJJCL'))); } }] : []), // 产品报价限价列 ...(this.columnVisibility.CPBJXJ ? [{ key: 'CPBJXJ', title: '产品报价限价', width: getWidth('CPBJXJ', 120), minWidth: 120, align: 'right', headerCellRenderer: this.createCenteredHeader('产品报价限价', 'CPBJXJ'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.CPBJXJ, this.getDecimalPlace('CPBJXJ'))); } }] : []), // 报价限价扣点列 ...(this.columnVisibility.BJXJKD ? [{ key: 'BJXJKD', title: '报价限价扣点', width: getWidth('BJXJKD', 120), minWidth: 120, align: 'right', headerCellRenderer: this.createCenteredHeader('报价限价扣点', 'BJXJKD'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.BJXJKD, this.getDecimalPlace('BJXJKD'))); } }] : []), // 报价限价加价列 ...(this.columnVisibility.BJXJJJ ? [{ key: 'BJXJJJ', title: '报价限价加价', width: getWidth('BJXJJJ', 120), minWidth: 120, align: 'right', headerCellRenderer: this.createCenteredHeader('报价限价加价', 'BJXJJJ'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.BJXJJJ, this.getDecimalPlace('BJXJJJ'))); } }] : []), // 限价报价差额列 ...(this.columnVisibility.XJBJCE ? [{ key: 'XJBJCE', title: '限价报价差额', width: getWidth('XJBJCE', 120), minWidth: 120, align: 'right', headerCellRenderer: this.createCenteredHeader('限价报价差额', 'XJBJCE'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'flex-end' } }, this.formatNumber(rowData.XJBJCE, this.getDecimalPlace('XJBJCE'))); } }] : []), // 备注列 ...(this.columnVisibility.BZ ? [{ key: 'BZ', title: '备注', width: getWidth('BZ', 200), minWidth: 200, headerCellRenderer: this.createCenteredHeader('备注', 'BZ'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h('div', { style: { paddingLeft: '8px', paddingRight: '8px', height: '100%', display: 'flex', alignItems: 'center' } }, rowData.BZ || ''); } }] : []), // 报价锁定列 ...(this.columnVisibility.BJSDBZ ? [{ key: 'BJSDBZ', title: '报价锁定', width: getWidth('BJSDBZ', 100), minWidth: 100, align: 'center', headerCellRenderer: this.createCenteredHeader('报价锁定', 'BJSDBZ'), cellRenderer: ({ rowData }) => { if (!rowData) return h('div', ''); return h(ElTag, { type: rowData.BJSDBZ === 'Y' ? 'success' : 'info', size: 'small' }, () => rowData.BJSDBZ === 'Y' ? '锁定' : '未锁定'); } }] : []) ]; // 过滤掉不可见的列 const filteredColumns = columns.filter(col => { // 隐藏的序号列始终隐藏 if (col.key === 'XH') { return false; } if (col.key && this.columnVisibility.hasOwnProperty(col.key)) { // 只有当值为 true 时才显示 const isVisible = this.columnVisibility[col.key] === true; if (!isVisible && col.key.startsWith('TZYZ_')) { console.log('generateColumns: 过滤掉不可见的动态列:', col.key, '可见性:', this.columnVisibility[col.key]); } return isVisible; } // 如果列可见性配置中不存在该列,默认显示(兼容性处理) return true; }); // 调试日志:统计动态列 const dynamicCols = filteredColumns.filter(col => col.key && col.key.startsWith('TZYZ_')); if (dynamicCols.length > 0) { console.log('generateColumns: 动态列过滤结果 - 数量:', dynamicCols.length, ', 列名:', dynamicCols.map(col => col.key)); } else { console.log('generateColumns: 警告 - 没有动态列被显示!'); console.log('generateColumns: dynamicColumns 数组:', this.dynamicColumns); console.log('generateColumns: columnVisibility 中 TZYZ_ 相关的配置:', Object.keys(this.columnVisibility).filter(key => key.startsWith('TZYZ_')).map(key => `${key}: ${this.columnVisibility[key]}`)); } return filteredColumns; }, createHeaderWithResizer() { return ({ column }) => { return h('div', { // 拖动条样式 style: { display: 'flex', justifyContent: 'center', alignItems: 'center', position: 'relative', width: '100%', height: '100%', textAlign: 'center', }, onMousedown: (e) => { e.stopPropagation(); } }, [ column.title, h('div', { class: 'resizer', // style: { // position: 'absolute', // right: '-6px', // top: 0, // bottom: 0, // width: '3px', // background: '#ddd', // cursor: 'col-resize', // zIndex: 10, // transform: 'translateX(100%)' // }, onMousedown: (e) => { e.stopPropagation(); this.startResizing(column.key, e); } }) ]); }; }, buildFilterableColumn(columnConfig) { const self = this; const columnKey = columnConfig.key; const getWidth = (key, defaultWidth) => self.dynamicWidths[key] || defaultWidth; return { ...columnConfig, width: getWidth(columnKey, columnConfig.width || columnConfig.minWidth || 100), headerCellRenderer: () => { return h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'center', width: '100%', height: '100%', textAlign: 'center', position: 'relative' }, onMousedown: (e) => { e.stopPropagation(); } }, [ h('span', columnConfig.title), h('div', { class: 'resizer', onMousedown: (e) => { e.stopPropagation(); self.startResizing(columnKey, e); } }), h(ElPopover, { trigger: 'click', visible: self.filterPopoverVisible[columnKey], 'onUpdate:visible': (val) => { self.filterPopoverVisible[columnKey] = val; if (val) { self.tempColumnFilters[columnKey] = [...(self.columnFilters[columnKey] || [])]; self.updateColumnValues(columnKey); } }, placement: 'bottom', width: 220, popperClass: 'filter-popover' }, { default: () => [ h('div', { class: 'filter-content' }, [ h('div', { style: { padding: '0 12px 8px', flexShrink: 0 } }, [ h(ElInput, { modelValue: self.filterSearch[columnKey] || '', size: 'small', clearable: true, placeholder: '输入关键字定位', onInput: (val) => { self.filterSearch[columnKey] = val || ''; } }) ]), h(ElScrollbar, { class: 'filter-scroll' }, { default: () => { const keyword = (self.filterSearch[columnKey] || '').toString().trim().toLowerCase(); const options = (self.columnUniqueValues[columnKey] || []).filter(opt => { if (!keyword) return true; const label = (opt.label || '').toString().trim().toLowerCase(); const value = (opt.value || '').toString().trim().toLowerCase(); return label.includes(keyword) || value.includes(keyword); }); return [ h(ElCheckboxGroup, { modelValue: self.tempColumnFilters[columnKey] || [], onChange: (val) => { self.tempColumnFilters[columnKey] = val; } }, { default: () => options.map(opt => h(ElCheckbox, { label: opt.label, value: opt.value, style: { display: 'block', margin: '4px 0', width: '100%' } }, () => opt.label === '' ? '空' : opt.label) ) }) ]; } }), h('div', { class: 'filter-footer', style: { display: 'flex', gap: '8px', justifyContent: 'flex-end', padding: '8px', background: '#fff', borderTop: '1px solid #ebeef5' } }, [ h(ElButton, { size: 'small', onClick: () => { self.tempColumnFilters[columnKey] = []; self.columnFilters[columnKey] = []; self.applyFilter(); } }, () => '重置'), h(ElButton, { type: 'primary', size: 'small', onClick: () => { self.columnFilters[columnKey] = [...self.tempColumnFilters[columnKey]]; self.filterPopoverVisible[columnKey] = false; self.applyFilter(); } }, () => '筛选') ]) ]) ], reference: () => h(ElIcon, { class: 'filter-trigger', style: { position: 'absolute', right: 0, top: '50%', transform: 'translateY(-50%)', cursor: 'pointer', color: self.columnFilters[columnKey]?.length ? '#409EFF' : '#909399', fontSize: '14px' }, onClick: (e) => e.stopPropagation() }, () => h(Filter)) }) ]); } }; }, // 创建居中的标题渲染器(支持列宽调整) createCenteredHeader(title, columnKey) { const self = this; return (props) => { const column = props.column; const key = columnKey || column.key; return h('div', { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', width: '100%', height: '100%', textAlign: 'center', position: 'relative' } }, [ h('span', title), h('div', { class: 'resizer', onMousedown: (e) => { e.stopPropagation(); self.startResizing(key, e); } }) ]); }; }, // 获取列宽(优先使用自定义宽度) getColumnWidth(columnKey, defaultWidth) { return this.dynamicWidths[columnKey] || defaultWidth; }, resetFilters() { this.applyFilter(); }, updateItemFields(item, resultItem) { item.BHGXX = []; if (resultItem.XLXHHG !== undefined && resultItem.XLXHHG !== null) { item.XLXHHG = resultItem.XLXHHG; if (item.XLXHHG === 'N') { item.BHGXX.push({ type: 'warning', label: '型号' }); } } if (resultItem.XLGGHG !== undefined && resultItem.XLGGHG !== null) { item.XLGGHG = resultItem.XLGGHG; if (item.XLGGHG === 'N') { item.BHGXX.push({ type: 'warning', label: '规格' }); } } if (resultItem.DYDJHG !== undefined && resultItem.DYDJHG !== null) { item.DYDJHG = resultItem.DYDJHG; if (item.DYDJHG === 'N') { item.BHGXX.push({ type: 'warning', label: '电压等级' }); } } if (resultItem.BJCPBHG !== undefined && resultItem.BJCPBHG !== null) { item.BJCPBHG = resultItem.BJCPBHG; } if (resultItem.XLWBBJDMX_XLBZID && !item.XLWBBJDMX_XLBZID) { item.XLWBBJDMX_XLBZID = resultItem.XLWBBJDMX_XLBZID; if (resultItem.XLBZ_XLBZLXMC) { item.XLBZ_XLBZLXMC = resultItem.XLBZ_XLBZLXMC; } } if (resultItem.XLWBBJDMX_DYDJID && !item.XLWBBJDMX_DYDJID) { item.XLWBBJDMX_DYDJID = resultItem.XLWBBJDMX_DYDJID; } }, startResizing(key, event) { this.isResizing = true; this.resizingKey = key; this.startX = event.clientX; this.startWidth = this.dynamicWidths[key] || 100; document.addEventListener('mousemove', this.handleColumnResizeMove); document.addEventListener('mouseup', this.stopResizing); }, handleColumnResizeMove(event) { if (!this.resizingKey) return; const delta = event.clientX - this.startX; const minWidth = this.COLUMN_MIN_WIDTH_MAP[this.resizingKey] || 50; const newWidth = Math.max( this.startWidth + delta, minWidth ); this.dynamicWidths[this.resizingKey] = newWidth; this.$forceUpdate(); }, stopResizing() { setTimeout(() => { this.isResizing = false; }, 100); this.resizingKey = ''; document.removeEventListener('mousemove', this.handleColumnResizeMove); document.removeEventListener('mouseup', this.stopResizing); }, loadXLGGList(index, value) { const { XLWBBJDMX_XLXHID, XLWBBJDMX_XLGGID, XLWBBJDMX_XLBZID, XLWBBJDMX_DYDJID } = this.filteredItems[index]; const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373006.ashx'; GThinking.Web.AjaxServiceProxy.invoke('GetXLGGList', false, { 'sBJDID': currentBJDID, 'sXLXHID': XLWBBJDMX_XLXHID || '' }, result => { console.log('loadXLGGList:', result); const exists = result.some(item => item.CodeID === value); if (value && !exists) { result.push({ CodeID: value, CodeMC: value }); } this.xlggOptions = result; }, CallBackNULLJSON, "GetXLGGList_CallBack"); }, loadXLBZList(index) { const { XLWBBJDMX_XLXHID, XLWBBJDMX_XLGGID, XLWBBJDMX_XLBZID, XLWBBJDMX_DYDJID } = this.filteredItems[index]; const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373006.ashx'; GThinking.Web.AjaxServiceProxy.invoke('GetXLBZList', false, { 'sBJDID': currentBJDID, 'sXLXHID': XLWBBJDMX_XLXHID || '', 'sXLGGID': XLWBBJDMX_XLGGID || '' }, result => { console.log('loadXLBZList:', result); this.xlbzOptions = result; }, CallBackNULLJSON, "GetXLBZList_CallBack"); }, loadDYDJList(index, value) { const { XLWBBJDMX_XLXHID, XLWBBJDMX_XLGGID, XLWBBJDMX_XLBZID, XLWBBJDMX_DYDJID } = this.filteredItems[index]; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke('GetDYDJList', false, { 'sBJDID': sBJDID, 'sXLXHID': XLWBBJDMX_XLXHID || '', 'sXLGGID': XLWBBJDMX_XLGGID || '', 'sXLBZID': XLWBBJDMX_XLBZID || '' }, result => { console.log('loadDYDJList:', result); const exists = result.some(item => item.CodeID === value); if (value && !exists) { result.push({ CodeID: value, CodeMC: value }); } this.dydjOptions = result; }, CallBackNULLJSON, "GetDYDJList_CallBack"); }, handleChange(index, fieldName) { let editedItem = this.filteredItems[index]; const sXLXHID = editedItem.XLWBBJDMX_XLXHID || ' '; const sXLGGID = editedItem.XLWBBJDMX_XLGGID || ' '; const sXLBZID = editedItem.XLWBBJDMX_XLBZID || ' '; const sDYDJID = editedItem.XLWBBJDMX_DYDJID || ' '; const sXLYSID = editedItem.XLWBBJDMX_XLYSID || ' '; let sBGLM = ''; if (fieldName === 'XLWBBJDMX_XLXHID') { sBGLM = 'XLXHID'; } else if (fieldName === 'XLWBBJDMX_XLGGID') { sBGLM = 'XLGGID'; } else if (fieldName === 'XLWBBJDMX_DYDJID') { sBGLM = 'DYDJID'; } if (fieldName === 'XLWBBJDMX_XLBZID') { if (sXLBZID && sXLBZID.trim() !== '' && this.xlbzAllOptions && this.xlbzAllOptions.length > 0) { const xlbzAllOption = this.xlbzAllOptions.find(opt => opt.CodeID === sXLBZID ); editedItem.XLBZ_XLBZLXMC = xlbzAllOption?.CodeMC || ' '; } else { editedItem.XLBZ_XLBZLXMC = ' '; } sBGLM = 'XLBZID'; console.log('XLBZLXMC:', editedItem.XLBZ_XLBZLXMC); } if (fieldName === 'XLWBBJDMX_XLYSID') { const colorName = this.xlysOptions.find( opt => opt.CodeID === sXLYSID )?.CodeMC || ''; editedItem.XLYSB_XLYSMC = colorName; } const originalIndex = this.items.findIndex( item => item.XLWBBJDMX_DRHH === editedItem.XLWBBJDMX_DRHH ); if (originalIndex !== -1) { this.items[originalIndex] = { ...editedItem }; } console.log('handleChange:', index); console.log('Parameters:', editedItem); console.log('BGLM:', sBGLM); GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke('AfterBgBJCP', false, { 'sBJDID': sBJDID, 'CPXX': editedItem, 'sBGLM': sBGLM }, result => { console.log('AfterBgBJCP:', result); editedItem.BHGXX = []; if (result.XLXHHG !== undefined && result.XLXHHG !== null) { editedItem.XLXHHG = result.XLXHHG; if (editedItem.XLXHHG === 'N') { editedItem.BHGXX.push({ type: 'warning', label: '型号' }); } } if (result.XLGGHG !== undefined && result.XLGGHG !== null) { editedItem.XLGGHG = result.XLGGHG; if (editedItem.XLGGHG === 'N') { editedItem.BHGXX.push({ type: 'warning', label: '规格' }); } } if (result.DYDJHG !== undefined && result.DYDJHG !== null) { editedItem.DYDJHG = result.DYDJHG; if (editedItem.DYDJHG === 'N') { editedItem.BHGXX.push({ type: 'warning', label: '电压等级' }); } } if (result.BJCPBHG !== undefined && result.BJCPBHG !== null) { editedItem.BJCPBHG = result.BJCPBHG; } if (result.XLWBBJDMX_XLBZID && !editedItem.XLWBBJDMX_XLBZID) { editedItem.XLWBBJDMX_XLBZID = result.XLWBBJDMX_XLBZID; if (result.XLBZ_XLBZLXMC) editedItem.XLBZ_XLBZLXMC = result.XLBZ_XLBZLXMC; } if (result.XLWBBJDMX_DYDJID && !editedItem.XLWBBJDMX_DYDJID) { editedItem.XLWBBJDMX_DYDJID = result.XLWBBJDMX_DYDJID; } console.log('editedItem:', editedItem); if (originalIndex !== -1) { this.items[originalIndex] = { ...editedItem }; } // 强制更新视图 //this.$forceUpdate(); }, CallBackNULLJSON, "AfterBgBJCP_CallBack"); }, handleFieldChange(rowIndex, fieldName, newValue) { const editedItem = this.filteredItems[rowIndex]; const originalIndex = this.items.findIndex( item => item.XLWBBJDMX_DRHH === editedItem.XLWBBJDMX_DRHH ); if (originalIndex !== -1) { this.items[originalIndex][fieldName] = newValue; } if (fieldName === 'XLWBBJDMX_XLYSID') { const colorName = this.xlysOptions.find( opt => opt.CodeID === newValue )?.CodeMC || ''; editedItem.XLYSB_XLYSMC = colorName; this.items[originalIndex].XLYSB_XLYSMC = colorName; } }, getUniqueFilters(prop) { const uniqueValues = new Set(this.items.map(item => item[prop])); const sortedUniqueValues = Array.from(uniqueValues).sort((a, b) => a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base', caseFirst: 'false' }) ); return Array.from(sortedUniqueValues).map(value => ({ text: value, value })); }, importQuoteDetails() { if (this.importing) return; this.importing = true; this.showLoading = true; const nonCompliantItems = this.filteredItems.filter(item => item.BJCPBHG === 'Y'); this.InsertBJDMX(this.items); // if (nonCompliantItems.length > 0) { // this.nonCompliantItems = nonCompliantItems; // this.dialogVisible = true; // } else { // this.InsertBJDMX(this.items); // } }, handleClose(done) { this.dialogVisible = false; done(); }, continueImport() { this.dialogVisible = false; this.InsertBJDMX(this.items); }, InsertBJDMX(items) { // 调用服务端红本验证方法 console.log('Checking redbook coverage...'); GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke('IFFGQCP', false, { 'sBJDID': sBJDID }, result => { console.log('IFFGQCP response:', result); // 3. 处理验证结果(result直接是字符串) if (result === 'N') { // 验证未通过时显示确认提示 this.showLoading = false; this.$confirm('当前导入明细产品未完全覆盖红本,是否继续?', '操作确认', { confirmButtonText: '继续导入', cancelButtonText: '取消', type: 'warning' }).then(() => { // 用户确认后执行插入操作 this.showLoading = true; this.executeInsert(items); }).catch(() => { // 用户取消操作 this.showLoading = false; this.importing = false; this.$message({ type: 'info', message: '操作已取消', duration: 2000 }); }); } else { // 4. 验证通过(返回不是'N')时直接执行插入 console.log('红本验证通过:', result); this.executeInsert(items); } }, (error) => { this.showLoading = false; this.importing = false; ElMessage.error({ message: '网络异常或服务错误', duration: 2000, showClose: false }); }, "IFFGQCP_CallBack"); }, // 提取的插入执行方法(保持不变) executeInsert(items) { console.log('Inserting details:', items); this.SFDR = false; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke('InsertBJDMX', false, { 'InfoList': items }, result => { console.log('InsertBJDMX response:', result); if (result?.Success) { this.showLoading = false; const successMsg = result.Message || '导入成功!'; ElMessage.success({ message: successMsg, duration: 3000, showClose: false }); // 3秒后关闭界面 setTimeout(() => { this.SFDR = true; this.closePanel(); this.importing = false; }, 3000); } else { this.showLoading = false; this.importing = false; const errorMsg = result?.ErrorMessage || '未知错误'; ElMessage.error({ message: errorMsg, duration: 3000, showClose: false }); } }, (error) => { this.showLoading = false; this.importing = false; ElMessage.error({ message: '网络异常或服务错误', duration: 2000, showClose: false }); }, "InsertBJDMX_CallBack"); }, handleEditClick(index) { if (this.currentEditIndex === index) { this.currentEditIndex = -1 } else { const prev = this.currentEditIndex; this.currentEditIndex = index; this.$nextTick(() => { if (prev > -1) { this.filteredItems[prev] = { ...this.filteredItems[prev] }; } }); } }, handlePreview() { GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; //获取预览文件信息 GThinking.Web.AjaxServiceProxy.invoke('GetYLXX', false, { 'sBJDID': sBJDID }, result => { console.log('GetYLXX:', result); this.WJLX = result.WJLX; this.DOCGRPID = result.DOCGRPID; this.RWJXJG = result.RWJXJG; this.XZJG = result.XZJG; this.RWWCSJ = result.RWWCSJ; sessionStorage.setItem('quoteData', result.RWJXJG); sessionStorage.setItem('XZJGData', result.XZJG); sessionStorage.setItem("quoteBJDID", sBJDID); sessionStorage.setItem('RWWCSJ', this.RWWCSJ); const sourceElement = topDocument.getElementById('divBYZDY_102373016'); if (sourceElement) { sessionStorage.setItem('OpenMoudle', '102373016'); } else { sessionStorage.setItem('OpenMoudle', '102849002'); } if (this.WJLX && (this.WJLX.toUpperCase() === 'XLS' || this.WJLX.toUpperCase() === 'XLSX')) { GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'GetFileUrlJDLJ', false, { DOCGRPID: this.DOCGRPID }, (result) => this.handleFileUrlJDLJCallback(result), (error) => ElMessage.error(`获取文件失败: ${error}`), "GetFileUrl_CallBack", 40000 ); } else { GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'GetFileUrl', false, { DOCGRPID: this.DOCGRPID }, (result) => this.handleFileUrlCallback(result), (error) => ElMessage.error(`获取文件失败: ${error}`), "GetFileUrl_CallBack", 40000 ); } }, CallBackNULLJSON, "GetYLXX_CallBack") }, handleFileUrlCallback(result) { console.log("GetFileUrlJDLJ 返回结果:", result); if (!result || result === '') { ElMessage.error('文件路径不存在'); return; } const basePath = '../../work/temp/S_XLXSBJ/'; const fullUrl = basePath + result; this.openPreview(fullUrl); }, handleFileUrlJDLJCallback(result) { console.log("GetFileUrlJDLJ 返回结果:", result); if (!result || result === '') { ElMessage.error('文件路径不存在'); return; } const basePath = '../../work/temp/S_XLXSBJ/'; const fullUrl = basePath + result; this.openPreview(result); }, openPreview(fileUrl) { this.previewUrl = fileUrl; const ext = fileUrl.split('.').pop().toLowerCase(); this.fileExtension = ext; const imageTypes = ['png', 'jpg', 'jpeg', 'gif']; const officeTypes = ['xls', 'xlsx']; // 获取当前页面的协议、域名和端口 // 拼接动态地址 const basePath = '../Components/N_XLBJAIZL/'; if (imageTypes.includes(ext)) { this.previewType = 'image'; sessionStorage.setItem('imageFilePath', fileUrl); const pageName = 'ImageCompare.html'; const sUrl = basePath + pageName; this.showZDYDIVWJYL(sUrl); } else if (ext === 'pdf') { this.previewType = 'pdf'; sessionStorage.setItem('pdfFilePath', fileUrl); const pageName = 'PDFCompare.html'; const sUrl = basePath + pageName; this.showZDYDIVWJYL(sUrl); //this.$message.error('PDF暂不支持预览!'); // this.previewType = 'pdf'; // this.currentPdfPage = 1; // this.pdfSource = fileUrl; // console.log("fileUrl 返回结果:", fileUrl); } else if (officeTypes.includes(ext)) { this.previewType = 'office'; sessionStorage.setItem('excelFilePath', fileUrl); const pageName = 'ExcelCompare.html'; const sUrl = basePath + pageName; this.showZDYDIVWJYL(sUrl); //this.officePreviewUrl = `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(fileUrl)}`; } else { sessionStorage.setItem("wordFilePath", fileUrl); const pageName = "WordCompare.html"; const sUrl = basePath + pageName; this.showZDYDIVWJYL(sUrl); } //console.log("officePreviewUrl 返回结果:", this.officePreviewUrl); }, showZDYDIVWJYL(url) { console.log('开始加载iframe,URL:', url); // 创建内部容器div_ZDY2 const innerContainer = document.createElement('div'); innerContainer.id = 'divZDY_102849002_WJYL'; innerContainer.style.width = '100%'; innerContainer.style.height = '100%'; // 创建iframe元素 const iframe = document.createElement('iframe'); iframe.id = 'iframeZDY_102849002_WJYL'; iframe.style.width = '100%'; iframe.style.height = '100%'; iframe.style.marginLeft = 'auto'; iframe.style.backgroundColor = '#ffffff'; iframe.src = url; iframe.scrolling = 'no'; iframe.frameBorder = '0'; // 添加iframe加载完成事件监听 iframe.onload = function() { console.log('iframe加载完成'); try { // 尝试访问iframe内部的文档 const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; console.log('iframe文档状态:', iframeDoc.readyState); // 检查iframe中的脚本是否有错误 if (iframe.contentWindow.console) { console.log('iframe控制台可用'); } // 发送消息到iframe setTimeout(() => { console.log('向iframe发送消息...'); iframe.contentWindow.postMessage({ type: 'INIT', quoteData: sessionStorage.getItem('quoteData'), filePath: sessionStorage.getItem('excelFilePath') }, '*'); }, 1000); } catch (error) { console.error('访问iframe内容时出错:', error); alert('加载iframe内容失败: ' + error.message); } }; // 添加iframe加载错误事件监听 iframe.onerror = function() { console.error('iframe加载错误'); alert('iframe加载失败,请检查URL是否正确'); }; // 确保父容器存在 var parentDiv = topDocument.getElementById('div_BYZDY'); var OpenAlone = sessionStorage.getItem("OpenAlone") || ''; if (OpenAlone === "Y") { url = url.replace("../Components/N_XLBJAIZL/",""); } iframe.src = url; if (parentDiv) { //parentDiv.innerHTML = ''; parentDiv.appendChild(iframe); parentDiv.style.display = "block"; console.log('iframe已添加到父容器'); var divBYZDY_102373016 = topDocument.getElementById('divBYZDY_102373016'); if (divBYZDY_102373016) { divBYZDY_102373016.style.display='none'; } } else { console.error('找不到父容器div_BYZDY'); alert('找不到容器元素,请检查页面结构'); return; } innerContainer.style.display = 'flex'; // 创建一个包含 @keyframes 规则的样式标签 const style = topDocument.createElement('style'); style.innerHTML = "@keyframes slideInFromRight {0% {transform: translateX(100%);opacity: 0;}100% {transform: translateX(0);opacity: 1;}}"; topDocument.head.appendChild(style); // 设置内联动画样式 innerContainer.style.animation = 'slideInFromRight 0.5s ease-out forwards'; console.log('iframe加载流程已完成,等待加载事件...'); }, showDXTH() { this.showReplaceButton = false; ElMessageBox.confirm( '确认后将清空型号、规格、标准、电压等级,重新解析替换,是否继续?', '操作确认', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' } ).then(() => { this.handleDXTH(); }).catch(() => { // 用户点击“取消” }); }, handleDXTH() { GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke('CXDXTH', false, { 'sBJDID': sBJDID }, result => { if (result && result.Success === true) { GThinking.Web.AjaxServiceProxy.invoke('GetXLCPList', false, { 'sBJDID': sBJDID }, result => { console.log("GetXLCPList_CallBack"); console.log(result); const processedData = result.map(item => { const bhgxx = []; if (item.XLXHHG === 'N') { bhgxx.push({ type: 'warning', label: '型号' }); } if (item.XLGGHG === 'N') { bhgxx.push({ type: 'warning', label: '规格' }); } if (item.DYDJHG === 'N') { bhgxx.push({ type: 'warning', label: '电压等级' }); } return { ...item, BHGXX: bhgxx }; }); this.items = processedData; this.resetFilters(); ElMessage.success({ message: '等效替换成功!', duration: 3000, type: 'success', showClose: false }); }, CallBackNULLJSON, "GetXLCPList_CallBack"); } else { const errorMessage = result.ErrorMessage || '未知错误'; ElMessage.error({ message: errorMessage, duration: 3000, type: 'error', showClose: false }); } }, CallBackNULLJSON, "DXTH_CallBack"); }, showPP() { this.showReplaceButton = false; ElMessageBox.confirm( '是否匹配标准和电压等级?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' } ).then(() => { this.handlePP(); }).catch(() => { // 用户点击“取消” }); }, handlePP() { GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke('PPBZDYDJ', false, { 'sBJDID': sBJDID }, result => { if (result && result.Success === true) { GThinking.Web.AjaxServiceProxy.invoke('GetXLCPList', false, { 'sBJDID': sBJDID }, result => { console.log("GetXLCPList_CallBack"); console.log(result); const processedData = result.map(item => { const bhgxx = []; if (item.XLXHHG === 'N') { bhgxx.push({ type: 'warning', label: '型号' }); } if (item.XLGGHG === 'N') { bhgxx.push({ type: 'warning', label: '规格' }); } if (item.DYDJHG === 'N') { bhgxx.push({ type: 'warning', label: '电压等级' }); } return { ...item, BHGXX: bhgxx }; }); this.items = processedData; this.resetFilters(); ElMessage.success({ message: '匹配成功!', duration: 3000, type: 'success', showClose: false }); }, CallBackNULLJSON, "GetXLCPList_CallBack"); } else { const errorMessage = result.ErrorMessage || '未知错误'; ElMessage.error({ message: errorMessage, duration: 3000, type: 'error', showClose: false }); } }, CallBackNULLJSON, "PP_CallBack"); }, showQK() { this.showReplaceButton = false; ElMessageBox.confirm( '是否清空筛选记录的标准和电压等级后重新匹配?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' } ).then(() => { this.handleQK(); }).catch(() => { // 用户点击“取消” }); }, handleQK() { const sXHList = this.filteredItems.map(item => item.XLWBBJDMX_DRHH).join(','); GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke('QKHPPBZDYDJ', false, { 'sBJDID': sBJDID, 'sXHList': sXHList }, result => { if (result && result.Success === true) { GThinking.Web.AjaxServiceProxy.invoke('GetXLCPList', false, { 'sBJDID': sBJDID }, result => { console.log("GetXLCPList_CallBack"); console.log(result); const processedData = result.map(item => { const bhgxx = []; if (item.XLXHHG === 'N') { bhgxx.push({ type: 'warning', label: '型号' }); } if (item.XLGGHG === 'N') { bhgxx.push({ type: 'warning', label: '规格' }); } if (item.DYDJHG === 'N') { bhgxx.push({ type: 'warning', label: '电压等级' }); } return { ...item, BHGXX: bhgxx }; }); this.items = processedData; this.resetFilters(); ElMessage.success({ message: '匹配成功!', duration: 3000, type: 'success', showClose: false }); }, CallBackNULLJSON, "GetXLCPList_CallBack"); } else { const errorMessage = result.ErrorMessage || '未知错误'; ElMessage.error({ message: errorMessage, duration: 3000, type: 'error', showClose: false }); } }, CallBackNULLJSON, "QK_CallBack"); }, // 加载数据 loadData() { this.showLoading = true; this.loadingProgress = 0; // 立即重置进度 // 重新加载数据时清空已选记录,避免旧数据残留导致状态不一致 this.selectedRows = []; this.selectedRowMap = {}; // 直接启动进度条,不依赖监听器 this.$nextTick(() => { this.startLoadingProgress(); }); const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; const currentBJFLID = getQueryParams()['BJFLID'] || (document.getElementById('txtBJFLID') ? document.getElementById('txtBJFLID').value : '') || ''; const currentBJDYZ = getQueryParams()['BJDYZ'] || (document.getElementById('txtBJDYZ') ? document.getElementById('txtBJDYZ').value : '') || ''; console.log('loadData - BJDID:', currentBJDID); if (!currentBJDID) { ElMessage.warning('报价单ID不能为空'); this.items = []; this.showLoading = false; return; } GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'GetPLTJData', false, { BJDID: currentBJDID, BJDYZ: currentBJDYZ || '', sortField: this.sortField || '', sortOrder: this.sortOrder || '', CPYT: this.queryConditions.CPYT && this.queryConditions.CPYT.length > 0 ? this.queryConditions.CPYT.join(',') : '', XLJGID: this.queryConditions.XLJGID || '', XLGGID: this.queryConditions.XLGGID || '', ZJMS: this.queryConditions.ZJMS || '', ZJMZ: this.queryConditions.ZJMZ || '', BJSLS: this.queryConditions.BJSLS || '', BJSLZ: this.queryConditions.BJSLZ || '', BJJES: this.queryConditions.BJJES || '', BJJEZ: this.queryConditions.BJJEZ || '', DJS: this.queryConditions.DJS || '', DJZ: this.queryConditions.DJZ || '', JMBGS: this.queryConditions.JMBGS || '', BH: this.queryConditions.BH && this.queryConditions.BH.length > 0 ? this.queryConditions.BH.join(',') : '', XJBJCEWF: this.queryConditions.XJBJCEWF ? 'Y' : '' }, result => { console.log('GetPLTJData result:', result); // 延迟5秒用于测试进度条效果 setTimeout(() => { if (result && Array.isArray(result)) { this.items = result; this.applyFilter(); if (result.length === 0) { ElMessage.info('没有查询到数据'); } } else if (result && result.d && Array.isArray(result.d)) { this.items = result.d; this.applyFilter(); } else { console.log('数据格式异常,result:', result); ElMessage.warning('数据格式异常: ' + (typeof result === 'object' ? JSON.stringify(result) : result)); this.items = []; } this.showLoading = false; // 确保显示 this.$nextTick(() => { const appElement = document.getElementById('app'); if (appElement) { appElement.style.opacity = '1'; appElement.style.pointerEvents = 'auto'; } }); }, 100); // 延迟0.1秒 }, error => { console.error('加载数据失败:', error); // 延迟5秒用于测试进度条效果 setTimeout(() => { ElMessage.error('加载数据失败: ' + (error || '未知错误')); this.items = []; this.showLoading = false; // 确保显示(即使加载失败) this.$nextTick(() => { const appElement = document.getElementById('app'); if (appElement) { appElement.style.opacity = '1'; appElement.style.pointerEvents = 'auto'; } }); }, 100); // 延迟0.1秒 }, 'GetPLTJData_CallBack', 40000 ); }, // 加载列显示配置 loadColumnVisibility() { // 获取 BJDID const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || sBJDID || ''; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'GetColumnVisibility', false, { BJDID: currentBJDID || '' }, result => { console.log('列显示配置:', result); if (result && typeof result === 'object') { // 合并列可见性配置,确保布尔值正确传递 Object.keys(result).forEach(key => { this.columnVisibility[key] = result[key] === true; }); // 注意:showLSBJ 现在由 loadQueryOptions 从后端返回的 QueryVisibility 中获取 // 列可见性配置加载完成后,重新加载动态列配置(根据可见性过滤) this.loadDynamicColumns(); // 强制重新生成列(触发响应式更新) this.$forceUpdate(); } }, error => { console.error('加载列显示配置失败:', error); }, 'GetColumnVisibility_CallBack', 40000 ); }, // 加载按钮配置 loadButtonConfig() { const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || sBJDID || ''; console.log('loadButtonConfig: 开始加载按钮配置,BJDID=', currentBJDID); GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'GetButtonConfig', false, { BJDID: currentBJDID || '' }, result => { console.log('按钮配置:', result); if (result && typeof result === 'object') { // 服务端返回格式:{ ButtonVisibility: {...}, DynamicYZButtons: [...], JMBGSButtonText: "..." } if (result.ButtonVisibility) { this.buttonVisibility = { ...this.buttonVisibility, ...result.ButtonVisibility }; // 注意:showJMBGS 和 showXJBJ 现在由 loadQueryOptions 从后端返回的 QueryVisibility 中获取 } if (result.DynamicYZButtons) { this.dynamicYZButtons = result.DynamicYZButtons; } if (result.BJDYZ) { this.bjdyz = result.BJDYZ; } if (result.JMBGSButtonText) { this.jmbgsButtonText = result.JMBGSButtonText; } // 按钮配置加载完成后,重新加载动态列配置(以获取因子标签和 BJDYZ) this.loadDynamicColumns(); } }, error => { console.error('loadButtonConfig: 加载按钮配置失败', error); }, 'GetButtonConfig_CallBack', 40000 ); }, // 加载是否使用产品目录 loadUseCPML() { GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'GetUseCPML', false, {}, result => { console.log('是否使用产品目录:', result); this.useCPML = result === true; // 强制更新列标题 this.$nextTick(() => { this.$forceUpdate(); }); }, error => { console.error('loadUseCPML: 加载失败', error); this.useCPML = false; // 默认使用产品用途 }, 'GetUseCPML_CallBack', 40000 ); }, // 加载查询选项 loadQueryOptions() { const currentBJDID = getQueryParams()['BJDID'] || ''; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'GetQueryOptions', false, { BJDID: currentBJDID }, result => { console.log('查询选项:', result); if (result && typeof result === 'object') { // 映射后端返回的选项(如果存在) if (result.CPYTOptions) { this.cpytOptions = result.CPYTOptions.map(item => ({ value: item.value || item.CPYT, label: item.label || item.CPYTMC || item.text || item.value, CPYT: item.value || item.CPYT, CPYTMC: item.label || item.CPYTMC || item.text })); } if (result.BHOptions) { this.bhOptions = result.BHOptions.map(item => ({ value: item.value || item.BH, label: item.label || item.text || item.value })); } // 从后端返回的 QueryVisibility 中获取查询项可见性配置 if (result.QueryVisibility) { if (typeof result.QueryVisibility.showJMBGS === 'boolean') { this.showJMBGS = result.QueryVisibility.showJMBGS; } if (typeof result.QueryVisibility.showLSBJ === 'boolean') { this.showLSBJ = result.QueryVisibility.showLSBJ; } if (typeof result.QueryVisibility.showBH === 'boolean') { this.showBH = result.QueryVisibility.showBH; } if (typeof result.QueryVisibility.showXJBJ === 'boolean') { this.showXJBJ = result.QueryVisibility.showXJBJ; } } } }, error => { console.error('加载查询选项失败:', error); }, 'GetQueryOptions_CallBack', 40000 ); }, // 加载小数位数配置 loadDecimalPlaces() { const CPBJMRXSWS = getQueryParams()['CPBJMRXSWS'] || (document.getElementById('txtCPBJMRXSWS') ? document.getElementById('txtCPBJMRXSWS').value : '') || ''; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'GetDecimalPlaces', false, { CPBJMRXSWS: CPBJMRXSWS }, result => { console.log('小数位数配置:', result); if (result && typeof result === 'object') { this.decimalPlaces = { ...this.decimalPlaces, ...result }; } }, error => { console.error('加载小数位数配置失败:', error); }, 'GetDecimalPlaces_CallBack', 40000 ); }, // 加载动态列配置(完全根据服务端的列可见性配置生成) // 服务端返回的列可见性配置中,TZYZ_BJ01, TZYZ_BJ02 等字段名是基于索引位置的 // 对于可见的列(visible = true),生成对应的动态列 loadDynamicColumns() { this.dynamicColumns = []; // 如果没有列可见性配置,无法生成动态列 if (!this.columnVisibility || Object.keys(this.columnVisibility).length === 0) { console.log('loadDynamicColumns: 列可见性配置为空,等待配置加载'); return; } // 获取 BJDYZ(优先从服务端返回,其次从参数或页面元素) const currentBJDYZ = this.bjdyz || getQueryParams()['BJDYZ'] || (document.getElementById('txtBJDYZ') ? document.getElementById('txtBJDYZ').value : '') || ''; // 构建因子ID到原始标签的映射(从 BJDYZ 解析) const yzIdToRawLabelMap = {}; const yzIdToTJLXMap = {}; // 因子ID到TJLX的映射 if (currentBJDYZ) { const sBJDYZ = currentBJDYZ.split(','); for (let i = 0; i < sBJDYZ.length && i < 20; i++) { const sYZItem = sBJDYZ[i].trim(); if (!sYZItem) continue; const parts = sYZItem.split('|'); if (parts.length >= 2) { const yzId = parts[0].trim(); const rawLabel = parts[1].trim(); // 原始标签,包含后缀如 (JD), (JJ) 等 yzIdToRawLabelMap[yzId] = rawLabel; // 从 dynamicYZButtons 中获取 TJLX if (this.dynamicYZButtons && Array.isArray(this.dynamicYZButtons)) { const btn = this.dynamicYZButtons.find(b => b.YZID === yzId); if (btn && btn.TJLX) { yzIdToTJLXMap[yzId] = btn.TJLX; } } } } } console.log('loadDynamicColumns: 列可见性配置:', this.columnVisibility); console.log('loadDynamicColumns: 因子原始标签映射:', yzIdToRawLabelMap); console.log('loadDynamicColumns: 因子TJLX映射:', yzIdToTJLXMap); // 遍历所有可能的因子列位置(TZYZ_BJ01 到 TZYZ_BJ20) for (let i = 1; i <= 20; i++) { const dataFieldName = 'TZYZ_BJ' + i.toString().padStart(2, '0'); // TZYZ_BJ01, TZYZ_BJ02 等 // 检查列可见性配置 if (this.columnVisibility.hasOwnProperty(dataFieldName)) { const isVisible = this.columnVisibility[dataFieldName] === true; if (!isVisible) { console.log(`跳过不可见列 [${i}]: ${dataFieldName}`); continue; } // 获取因子标签(参考 XLBJD_PLTJList 的逻辑) const yzId = 'BJ' + i.toString().padStart(2, '0'); let yzLabel = ''; // 从 BJDYZ 中获取原始标签 const rawLabel = yzIdToRawLabelMap[yzId]; if (rawLabel) { // 根据 TJLX 处理标签(参考 XLBJD_PLTJList 的逻辑) const tjlx = yzIdToTJLXMap[yzId] || ''; if (tjlx === '1') { // 调价格:TJLX == "1" yzLabel = rawLabel .replace(/\(\)/g, '') .replace(/\(JD\)/g, '(%)') .replace(/\(JJ\)/g, '(元)') .replace(/\(KD\)/g, '(%)') .replace(/\(MD\)/g, '(%)') .replace(/\(DD\)/g, '(%)') .replace(/\(XX\)/g, '(不参与调价)') .replace(/\(MX\)/g, '') .replace(/\(DX\)/g, '') .replace(/\(SX\)/g, '(%)') .replace(/\(MP\)/g, '(%)'); } else { // 调因子值:TJLX != "1" yzLabel = rawLabel .replace(/\(\)/g, '') .replace(/\(JD\)/g, '(%)') .replace(/\(JJ\)/g, '') .replace(/\(KD\)/g, '(%)') .replace(/\(MP\)/g, '(%)'); } } else { // 如果 BJDYZ 中没有,尝试从 dynamicYZButtons 中获取(作为后备) if (this.dynamicYZButtons && Array.isArray(this.dynamicYZButtons)) { const btn = this.dynamicYZButtons.find(b => b.YZID === yzId); if (btn && btn.Text) { yzLabel = btn.Text; } } // 如果还是没有,使用默认标签 if (!yzLabel) { yzLabel = `因子${i}`; } } // 根据后缀确定小数位数 let decimalPlace = this.iXSWS || 5; if (rawLabel && (rawLabel.endsWith('(MX)') || rawLabel.endsWith('(DX)'))) { decimalPlace = 4; } else { decimalPlace = 2; } console.log(`添加动态列 [${i}]: ${dataFieldName} (${yzLabel}), 可见: ${isVisible}, 小数位: ${decimalPlace}`); this.dynamicColumns.push({ prop: dataFieldName, // 使用数据字段名(TZYZ_BJ01, TZYZ_BJ02 等)来读取服务端数据 label: yzLabel, width: 100, align: 'right', visible: true, decimalPlace: decimalPlace }); } } console.log('动态列配置最终结果:', this.dynamicColumns); console.log('动态列数量:', this.dynamicColumns.length); }, // 获取小数位数 getDecimalPlace(fieldName) { return this.decimalPlaces[fieldName] || this.iXSWS || 5; }, // 格式化数字 formatNumber(value, decimals = 2) { if (value === null || value === undefined || value === '') return '0'; const num = parseFloat(value); if (isNaN(num)) return '0'; return num.toFixed(decimals); }, // 报价锁定下拉菜单 handleLockCommand(command) { const isLock = command === 'BJSD-SD'; // 确定锁定范围 - 只对勾选的记录进行操作 if (this.selectedRows.length === 0) { ElMessage.warning('请先选择要操作的记录'); return; } const sBJDXHList = this.selectedRows.map(row => row.XH || row.XLXSBJDMX_XH).join(','); const sPLSZAll = 'N'; // N=勾选记录 this.showLoading = true; const currentBJDID = getQueryParams()['BJDID'] || ''; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'BatchLock', false, { BJDID: currentBJDID, lockType: isLock ? 'Y' : 'N', PLSZAll: sPLSZAll, selectedIds: sBJDXHList }, result => { if (result && result.success !== false) { ElMessage.success(isLock ? '锁定成功' : '解锁成功'); this.loadData(); } else { ElMessage.error(result?.msg || (isLock ? '锁定失败' : '解锁失败')); } this.showLoading = false; }, error => { ElMessage.error((isLock ? '锁定失败' : '解锁失败') + ': ' + (error || '未知错误')); this.showLoading = false; }, 'BatchLock_CallBack', 40000 ); }, // 报价上浮 handlePriceUp() { this.priceUpForm = { range: this.selectedRows.length > 0 ? 'N' : 'C', value: 0, rangeOptions: this.selectedRows.length > 0 ? ['N', 'Y', 'C'] : ['Y', 'C'], formulaLabel: '新报价=原报价/(1-' }; this.priceUpDialogVisible = true; }, // 确认报价上浮 confirmPriceUp() { if (!this.priceUpForm.value) { ElMessage.warning('请输入上浮值'); return; } const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; const currentBJFLID = getQueryParams()['BJFLID'] || (document.getElementById('txtBJFLID') ? document.getElementById('txtBJFLID').value : '') || ''; const JCLLX = getQueryParams()['JCLLX'] || (document.getElementById('txtJCLLX') ? document.getElementById('txtJCLLX').value : '') || ''; const LJJCLLX = getQueryParams()['LJJCLLX'] || (document.getElementById('txtLJJCLLX') ? document.getElementById('txtLJJCLLX').value : '') || ''; const CPBJMRXSWS = getQueryParams()['CPBJMRXSWS'] || (document.getElementById('txtCPBJMRXSWS') ? document.getElementById('txtCPBJMRXSWS').value : '') || ''; let sBJDXHList = ''; let sPLSZAll = 'C'; if (this.priceUpForm.range === 'N') { if (this.selectedRows.length === 0) { ElMessage.warning('请先选择要调价的记录'); return; } sPLSZAll = 'N'; sBJDXHList = this.selectedRows.map(row => row.XH || row.XLXSBJDMX_XH).join(','); } else if (this.priceUpForm.range === 'Y') { sPLSZAll = 'Y'; } else { // 所查记录:只传当前筛选集合,且改用 PLSZAll='N' 限制更新范围 sPLSZAll = 'N'; sBJDXHList = this.getFilteredIds(); if (!sBJDXHList) { ElMessage.warning('当前无可调价的所查记录'); this.showLoading = false; return; } } this.showLoading = true; console.log('调用 BatchPriceAdjust (报价上浮):', { BJDID: currentBJDID, adjustType: 'up', range: this.priceUpForm.range, value: this.priceUpForm.value }); GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'BatchPriceAdjust', false, { BJDID: currentBJDID || '', adjustType: 'up', range: this.priceUpForm.range || '', value: String(this.priceUpForm.value || 0), materialType: '', materialValue: '0', selectedIds: sBJDXHList || '', PLSZAll: sPLSZAll || '', JCLLX: JCLLX || '', LJJCLLX: LJJCLLX || '', CPBJMRXSWS: CPBJMRXSWS || '' }, result => { console.log('BatchPriceAdjust (报价上浮) 返回结果:', result); this.showLoading = false; if (result && result.success !== false) { ElMessage.success('报价上浮成功'); this.priceUpDialogVisible = false; this.loadData(); } else { ElMessage.error(result?.msg || '报价上浮失败'); } }, error => { console.error('BatchPriceAdjust (报价上浮) 错误:', error); this.showLoading = false; ElMessage.error('报价上浮失败: ' + (error || '未知错误')); }, 'BatchPriceUp_CallBack', 40000 ); }, // 报价下浮 handlePriceDown() { this.priceDownForm = { range: this.selectedRows.length > 0 ? 'N' : 'C', value: 0, rangeOptions: this.selectedRows.length > 0 ? ['N', 'Y', 'C'] : ['Y', 'C'], formulaLabel: '新报价=原报价*(1-' }; this.priceDownDialogVisible = true; }, // 确认报价下浮 confirmPriceDown() { if (!this.priceDownForm.value) { ElMessage.warning('请输入下浮值'); return; } const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; const JCLLX = getQueryParams()['JCLLX'] || (document.getElementById('txtJCLLX') ? document.getElementById('txtJCLLX').value : '') || ''; const LJJCLLX = getQueryParams()['LJJCLLX'] || (document.getElementById('txtLJJCLLX') ? document.getElementById('txtLJJCLLX').value : '') || ''; const CPBJMRXSWS = getQueryParams()['CPBJMRXSWS'] || (document.getElementById('txtCPBJMRXSWS') ? document.getElementById('txtCPBJMRXSWS').value : '') || ''; let sBJDXHList = ''; let sPLSZAll = 'C'; if (this.priceDownForm.range === 'N') { if (this.selectedRows.length === 0) { ElMessage.warning('请先选择要调价的记录'); return; } sPLSZAll = 'N'; sBJDXHList = this.selectedRows.map(row => row.XH || row.XLXSBJDMX_XH).join(','); } else if (this.priceDownForm.range === 'Y') { sPLSZAll = 'Y'; } else { sPLSZAll = 'N'; sBJDXHList = this.getFilteredIds(); if (!sBJDXHList) { ElMessage.warning('当前无可调价的所查记录'); this.showLoading = false; return; } } this.showLoading = true; console.log('调用 BatchPriceAdjust (报价下浮):', { BJDID: currentBJDID, adjustType: 'down', range: this.priceDownForm.range, value: this.priceDownForm.value }); GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'BatchPriceAdjust', false, { BJDID: currentBJDID || '', adjustType: 'down', range: this.priceDownForm.range || '', value: String(this.priceDownForm.value || 0), materialType: '', materialValue: '0', selectedIds: sBJDXHList || '', PLSZAll: sPLSZAll || '', JCLLX: JCLLX || '', LJJCLLX: LJJCLLX || '', CPBJMRXSWS: CPBJMRXSWS || '' }, result => { console.log('BatchPriceAdjust (报价下浮) 返回结果:', result); this.showLoading = false; if (result && result.success !== false) { ElMessage.success('报价下浮成功'); this.priceDownDialogVisible = false; this.loadData(); } else { ElMessage.error(result?.msg || '报价下浮失败'); } }, error => { console.error('BatchPriceAdjust (报价下浮) 错误:', error); this.showLoading = false; ElMessage.error('报价下浮失败: ' + (error || '未知错误')); }, 'BatchPriceDown_CallBack', 40000 ); }, // 批量调价 handleBatchPriceAdjust() { this.batchPriceForm = { adjustType: 'up', range: this.selectedRows.length > 0 ? 'N' : 'C', value: 0, materialType: 'relative', materialValue: 0 }; this.batchPriceDialogVisible = true; }, // 确认批量调价 confirmBatchPriceAdjust() { if (this.batchPriceForm.adjustType !== 'material' && !this.batchPriceForm.value) { ElMessage.warning('请输入调价值'); return; } if (this.batchPriceForm.adjustType === 'material' && !this.batchPriceForm.materialValue) { ElMessage.warning('请输入材料成本值'); return; } const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; const JCLLX = getQueryParams()['JCLLX'] || (document.getElementById('txtJCLLX') ? document.getElementById('txtJCLLX').value : '') || ''; const LJJCLLX = getQueryParams()['LJJCLLX'] || (document.getElementById('txtLJJCLLX') ? document.getElementById('txtLJJCLLX').value : '') || ''; const CPBJMRXSWS = getQueryParams()['CPBJMRXSWS'] || (document.getElementById('txtCPBJMRXSWS') ? document.getElementById('txtCPBJMRXSWS').value : '') || ''; let sBJDXHList = ''; let sPLSZAll = 'C'; if (this.batchPriceForm.range === 'N') { if (this.selectedRows.length === 0) { ElMessage.warning('请先选择要调价的记录'); return; } sPLSZAll = 'N'; sBJDXHList = this.selectedRows.map(row => row.XH || row.XLXSBJDMX_XH).join(','); } else if (this.batchPriceForm.range === 'Y') { sPLSZAll = 'Y'; } else { sPLSZAll = 'N'; sBJDXHList = this.getFilteredIds(); if (!sBJDXHList) { ElMessage.warning('当前无可调价的所查记录'); this.showLoading = false; return; } } this.showLoading = true; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'BatchPriceAdjust', false, { BJDID: currentBJDID || '', adjustType: this.batchPriceForm.adjustType || '', range: this.batchPriceForm.range || '', value: String(this.batchPriceForm.value || 0), materialType: this.batchPriceForm.materialType || '', materialValue: String(this.batchPriceForm.materialValue || 0), selectedIds: sBJDXHList || '', PLSZAll: sPLSZAll || '', JCLLX: JCLLX || '', LJJCLLX: LJJCLLX || '', CPBJMRXSWS: CPBJMRXSWS || '' }, result => { console.log('BatchPriceAdjust 返回结果:', result); this.showLoading = false; if (result && result.success !== false) { ElMessage.success('批量调价成功'); this.batchPriceDialogVisible = false; this.loadData(); } else { ElMessage.error(result?.msg || '批量调价失败'); } }, error => { console.error('BatchPriceAdjust 错误:', error); this.showLoading = false; ElMessage.error('批量调价失败: ' + (error || '未知错误')); }, 'BatchPriceAdjust_CallBack', 40000 ); }, // 关闭对话框方法 closePriceUpDialog() { this.priceUpDialogVisible = false; }, closePriceDownDialog() { this.priceDownDialogVisible = false; }, closeBatchPriceDialog() { this.batchPriceDialogVisible = false; }, // 打开查询条件抽屉 openQueryDrawer() { this.queryDrawerVisible = true; }, // 确认查询 confirmQueryDrawer() { this.queryDrawerVisible = false; this.loadData(); }, // 重置筛选 handleResetFilter() { this.sortField = ''; this.sortOrder = ''; this.queryConditions = { XLJGID: '', XLGGID: '', JMBGS: '', ZJMS: '', ZJMZ: '', BJSLS: '', BJSLZ: '', BJJES: '', BJJEZ: '', DJS: '', DJZ: '', BH: [], CPYT: [], XJBJCEWF: false }; this.applyFilter(); this.loadData(); }, // 基价表格式 handleJMBGS() { ElMessage.info('基价表格式功能待实现'); }, // 料价价差率 handleMaterialPrice() { const self = this; // 获取 BJFLID,优先从 URL 参数或页面元素获取,如果为空则通过 BJDID 从后端获取 const { bjflid } = getBJFLIDAndBJDYZ(); const currentBJFLID = bjflid || getQueryParams()['BJFLID'] || (document.getElementById('txtBJFLID') ? document.getElementById('txtBJFLID').value : '') || ''; // 初始化表单 this.materialPriceForm = { range: this.selectedRows.length > 0 ? 'N' : 'C', rangeOptions: this.selectedRows.length > 0 ? ['N', 'Y', 'C'] : ['Y', 'C'], referenceColumn: 'LJ', // 固定为料价价差率 adjustRatio: '', materialType: 'XDZ', hasNoTablePrice: false, isNonPurchased: false, canEditNonPurchased: true }; this.materialPriceDialogVisible = true; }, // 确认料价价差率 confirmMaterialPrice() { if (!this.materialPriceForm.adjustRatio) { ElMessage.warning('请输入调整比率'); return; } const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; const JCLLX = getQueryParams()['JCLLX'] || (document.getElementById('txtJCLLX') ? document.getElementById('txtJCLLX').value : '') || ''; const LJJCLLX = getQueryParams()['LJJCLLX'] || (document.getElementById('txtLJJCLLX') ? document.getElementById('txtLJJCLLX').value : '') || ''; const CPBJMRXSWS = getQueryParams()['CPBJMRXSWS'] || (document.getElementById('txtCPBJMRXSWS') ? document.getElementById('txtCPBJMRXSWS').value : '') || ''; let sBJDXHList = ''; let sPLSZAll = 'C'; if (this.materialPriceForm.range === 'N') { if (this.selectedRows.length === 0) { ElMessage.warning('请先选择要调价的记录'); return; } sPLSZAll = 'N'; sBJDXHList = this.selectedRows.map(row => row.XH || row.XLXSBJDMX_XH).join(','); } else if (this.materialPriceForm.range === 'Y') { sPLSZAll = 'Y'; } else { sPLSZAll = 'C'; } if (sPLSZAll === 'C') { // 所查 -> 仅当前筛选,改为 N + 列表限制 sPLSZAll = 'N'; sBJDXHList = this.getFilteredIds(); if (!sBJDXHList) { ElMessage.warning('当前无可调价的所查记录'); this.showLoading = false; return; } } // 构建参数字符串:调价范围|参照栏目|调整比率|材料成本类型|无表价,非外购 const paramStr = [ this.materialPriceForm.range || 'C', this.materialPriceForm.referenceColumn || '', this.materialPriceForm.adjustRatio || '0', this.materialPriceForm.materialType || 'XDZ', (this.materialPriceForm.hasNoTablePrice ? 'Y' : 'N') + ',' + (this.materialPriceForm.isNonPurchased ? 'Y' : 'N') ].join('|'); this.showLoading = true; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'BatchMaterialPriceAdjust', false, { BJDID: currentBJDID, paramStr: paramStr, selectedIds: sBJDXHList, PLSZAll: sPLSZAll, JCLLX: JCLLX, LJJCLLX: LJJCLLX, CPBJMRXSWS: CPBJMRXSWS }, result => { if (result && result.success !== false) { ElMessage.success('料价价差率调价成功'); this.materialPriceDialogVisible = false; this.loadData(); } else { ElMessage.error(result?.msg || '料价价差率调价失败'); } this.showLoading = false; }, error => { ElMessage.error('料价价差率调价失败: ' + (error || '未知错误')); this.showLoading = false; }, 'BatchMaterialPriceAdjust_CallBack', 40000 ); }, // 产品报价限价 handleBJXJ() { this.bjxjForm = { range: this.selectedRows.length > 0 ? 'N' : 'C', rangeOptions: this.selectedRows.length > 0 ? ['N', 'Y', 'C'] : ['Y', 'C'], kdValue: '', jjValue: '', onlyNegative: false }; this.bjxjDialogVisible = true; }, // 关闭产品报价限价对话框 closeBJXJDialog() { this.bjxjDialogVisible = false; }, // 确认产品报价限价 confirmBJXJ() { if (!this.bjxjForm.kdValue && !this.bjxjForm.jjValue) { ElMessage.warning('请输入报价限价扣点或报价限价加价'); return; } const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; const JCLLX = getQueryParams()['JCLLX'] || (document.getElementById('txtJCLLX') ? document.getElementById('txtJCLLX').value : '') || ''; const LJJCLLX = getQueryParams()['LJJCLLX'] || (document.getElementById('txtLJJCLLX') ? document.getElementById('txtLJJCLLX').value : '') || ''; const CPBJMRXSWS = getQueryParams()['CPBJMRXSWS'] || (document.getElementById('txtCPBJMRXSWS') ? document.getElementById('txtCPBJMRXSWS').value : '') || ''; let sBJDXHList = ''; let sPLSZAll = 'C'; if (this.bjxjForm.range === 'N') { if (this.selectedRows.length === 0) { ElMessage.warning('请先选择要调价的记录'); return; } sPLSZAll = 'N'; sBJDXHList = this.selectedRows.map(row => row.XH || row.XLXSBJDMX_XH).join(','); } else if (this.bjxjForm.range === 'Y') { sPLSZAll = 'Y'; } else { sPLSZAll = 'C'; } this.showLoading = true; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'BatchPriceLimit', false, { BJDID: currentBJDID, kdValue: this.bjxjForm.kdValue || '', jjValue: this.bjxjForm.jjValue || '', onlyNegative: this.bjxjForm.onlyNegative ? 'true' : 'false', selectedIds: sBJDXHList, PLSZAll: sPLSZAll, JCLLX: JCLLX, LJJCLLX: LJJCLLX, CPBJMRXSWS: CPBJMRXSWS }, result => { if (result && result.success !== false) { ElMessage.success('产品报价限价调价成功'); this.bjxjDialogVisible = false; this.loadData(); } else { ElMessage.error(result?.msg || '产品报价限价调价失败'); } this.showLoading = false; }, error => { ElMessage.error('产品报价限价调价失败: ' + (error || '未知错误')); this.showLoading = false; }, 'BatchPriceLimit_CallBack', 40000 ); }, // 材料用量比例 handleCLYLBL() { const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; if (!currentBJDID) { ElMessage.error('无法获取报价单ID'); return; } // 打开材料用量比例页面 const url = '../N_XLXSBJ/XLBJD_CLYLBLInfo.aspx?BJDID=' + encodeURIComponent(currentBJDID); window.open(url, '_blank', 'width=1200,height=800,scrollbars=yes,resizable=yes'); }, // 截面比公式 handleJMBGS() { // 从后端获取截面比公式的配置信息 const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; if (!currentBJDID) { ElMessage.error('无法获取报价单ID'); return; } this.showLoading = true; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'GetJMBGSYZID', false, { BJDID: currentBJDID }, result => { this.showLoading = false; if (result && result.Success !== false && result.YZID) { // 获取因子详细信息 GThinking.Web.AjaxServiceProxy.invoke( 'GetYZInfo', false, { YZID: result.YZID, BJDID: currentBJDID }, yzResult => { this.showLoading = false; if (yzResult && yzResult.Success !== false) { // 使用因子对话框 this.yzForm = { dialogTitle: result.JMBGSButtonText || '截面比公式', range: this.selectedRows.length > 0 ? 'N' : 'C', rangeOptions: this.selectedRows.length > 0 ? ['N', 'Y', 'C'] : ['Y', 'C'], showReferenceColumn: yzResult.ShowReferenceColumn || false, referenceColumn: '', referenceColumnOptions: yzResult.ReferenceColumnOptions || [], factorLabel: yzResult.FactorLabel || '因子值:', factorValue: '', factorUnit: yzResult.FactorUnit || '', showOnlyNegative: yzResult.ShowOnlyNegative || false, onlyNegative: false, showHasTablePrice: yzResult.ShowHasTablePrice || false, hasTablePrice: false, showPurchased: yzResult.ShowPurchased || false, isPurchased: false, isNonPurchased: false, YZID: result.YZID, YZType: 'JMBGS', JJFS: yzResult.JJFS || '' }; this.yzDialogVisible = true; } else { ElMessage.error(yzResult?.Message || '获取因子信息失败'); } }, error => { this.showLoading = false; ElMessage.error('获取因子信息失败: ' + (error || '未知错误')); }, 'GetYZInfo_CallBack', 40000 ); } else { ElMessage.error(result?.Message || '获取截面比公式配置失败'); } }, error => { this.showLoading = false; ElMessage.error('获取截面比公式配置失败: ' + (error || '未知错误')); }, 'GetJMBGSYZID_CallBack', 40000 ); }, // 处理因子按钮下拉命令 handleYZCommand(command, yzItem) { if (!command || !yzItem) { return; } // 解析命令 if (command.startsWith('CZ|')) { // 重置操作:CZ|YZID|Text|TJYS const parts = command.split('|'); if (parts.length >= 4) { const yzid = parts[1]; const text = parts[2]; const tjys = parts[3]; this.handleYZReset(yzid, text, tjys); } } else if (command.startsWith('CL')) { // 清空操作:CLBJ01 const yzidChild = command.substring(2); this.handleYZClear(yzidChild, yzItem); } }, // 因子重置操作 handleYZReset(yzid, text, tjys) { const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; if (!currentBJDID || !yzid) { ElMessage.error('无法获取报价单ID或因子ID'); return; } // 显示确认提示 ElMessageBox.confirm( `即将重置当前记录所有明细的【${text}】,是否继续?`, '操作确认', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' } ).then(() => { this.showLoading = true; // 调用重置服务 GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'ResetFactor', false, { BJDID: currentBJDID, YZID: yzid, TJYS: tjys || '' }, result => { this.showLoading = false; if (result && result.success) { ElMessage.success(result.msg || '重置成功'); this.loadData(); } else { ElMessage.error(result?.msg || '重置失败'); } }, error => { this.showLoading = false; ElMessage.error('重置失败: ' + (error || '未知错误')); }, 'ResetFactor_CallBack', 40000 ); }).catch(() => { // 用户取消操作 }); }, // 因子清空操作 handleYZClear(yzidChild, yzItem) { const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; if (!currentBJDID || !yzItem || !yzItem.YZID) { ElMessage.error('无法获取报价单ID或因子ID'); return; } // 从 yzidChild 中提取实际的因子ID(去掉 CL 前缀,然后转换为 YZID) // yzidChild 格式为 "CLBJ01",需要转换为对应的 YZID // 这里需要根据 yzItem 来获取因子信息 const yzText = yzItem.Text || ''; // 显示确认提示 ElMessageBox.confirm( `即将清空当前记录所有明细的【${yzText}】是否继续?`, '操作确认', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' } ).then(() => { this.showLoading = true; // 调用清空服务(将因子值设为0) GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'ClearFactor', false, { BJDID: currentBJDID, YZID: yzItem.YZID }, result => { this.showLoading = false; if (result && result.success) { ElMessage.success(result.msg || '清空成功'); this.loadData(); } else { ElMessage.error(result?.msg || '清空失败'); } }, error => { this.showLoading = false; ElMessage.error('清空失败: ' + (error || '未知错误')); }, 'ClearFactor_CallBack', 40000 ); }).catch(() => { // 用户取消操作 }); }, // 动态因子按钮 handleYZButton(yzItem) { const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; if (!currentBJDID || !yzItem.YZID) { ElMessage.error('无法获取报价单ID或因子ID'); return; } this.showLoading = true; // 从后端获取因子详细信息 GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'GetYZInfo', false, { YZID: yzItem.YZID, BJDID: currentBJDID }, result => { this.showLoading = false; if (result && result.Success !== false) { const bcytj = result.BCYTJ || 'N'; // 如果 BCYTJ === 'Y',不打开对话框,直接更新因子值 if (bcytj === 'Y') { ElMessageBox.confirm( '即将更新选中记录的因子值,是否继续?', '操作确认', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' } ).then(() => { this.updateFactorValueDirectly(yzItem, result); }).catch(() => { // 用户取消操作 }); return; } // BCYTJ === 'N' 时,打开对话框 // 根据原实现构建因子对话框数据 const jjfs = result.JJFS || yzItem.JJFS || ''; const yzmc = result.YZMC || yzItem.Text || '因子调价'; let factorLabel = yzmc + ':'; let factorUnit = ''; // 根据计算方式设置单位 if (jjfs === 'JD' || jjfs === 'KD' || jjfs === 'SX' || jjfs === 'DD' || jjfs === 'MD' || jjfs === 'MP') { factorUnit = '%'; } else if (jjfs === 'JJ') { // 需要检查 TJLX,这里先默认使用元 factorUnit = '元'; } else if (jjfs === 'MX' || jjfs === 'DX') { factorUnit = ''; } // 解析默认调价范围 const mrtjfw = result.MRTJFW || ''; let hasTablePrice = false; let isPurchased = false; let isNonPurchased = false; if (mrtjfw.indexOf('1') >= 0) { hasTablePrice = true; } if (mrtjfw.indexOf('2') >= 0) { isPurchased = true; } if (mrtjfw.indexOf('3') >= 0) { isNonPurchased = true; } // 构建对话框表单 const defYZZ = result.DefYZZ ? parseFloat(result.DefYZZ) : 0; this.yzForm = { dialogTitle: yzmc, range: this.selectedRows.length > 0 ? 'N' : 'C', rangeOptions: this.selectedRows.length > 0 ? ['N', 'Y', 'C'] : ['Y', 'C'], factorLabel: factorLabel, factorValue: defYZZ, factorUnit: factorUnit, showOnlyNegative: bcytj === 'Y', onlyNegative: false, showHasTablePrice: true, hasTablePrice: hasTablePrice, showPurchased: true, isPurchased: isPurchased, isNonPurchased: isNonPurchased, YZID: yzItem.YZID, YZType: 'YZ', JJFS: jjfs, DefYZZ: result.DefYZZ || '', MinYZZ: result.MinYZZ || '', MaxYZZ: result.MaxYZZ || '', BCYTJ: bcytj, JGBBJBM: result.JGBBJBM || '表价', TJYS: result.TJYS || '' }; this.yzDialogVisible = true; } else { ElMessage.error(result?.Message || '获取因子信息失败'); } }, error => { this.showLoading = false; ElMessage.error('获取因子信息失败: ' + (error || '未知错误')); }, 'GetYZInfo_CallBack', 40000 ); }, // 直接更新因子值(BCYTJ === 'Y' 时使用) updateFactorValueDirectly(yzItem, yzInfo) { const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; if (!currentBJDID || !yzItem.YZID) { ElMessage.error('无法获取报价单ID或因子ID'); return; } let sBJDXHList = ''; let sPLSZAll = this.selectedRows.length > 0 ? 'N' : 'C'; if (sPLSZAll === 'N') { if (this.selectedRows.length === 0) { ElMessage.warning('请先选择要调价的记录'); return; } sBJDXHList = this.selectedRows.map(row => row.XH || row.XLXSBJDMX_XH).join(','); } else { // 所查记录 -> 仅当前筛选,改为 N + 过滤列表 sPLSZAll = 'N'; sBJDXHList = this.getFilteredIds(); if (!sBJDXHList) { ElMessage.warning('当前无可调价的所查记录'); return; } } this.showLoading = true; // 调用更新因子值服务 GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'UpdateFactorValue', false, { BJDID: currentBJDID, YZID: yzItem.YZID, TJYS: yzInfo.TJYS || '', selectedIds: sBJDXHList, PLSZAll: sPLSZAll }, result => { this.showLoading = false; if (result && result.success !== false) { const msg = sBJDXHList ? '所选明细更新完成!' : '所查明细更新完成!'; ElMessage.success(result.msg || msg); this.loadData(); } else { ElMessage.error(result?.msg || '更新因子值失败'); } }, error => { this.showLoading = false; ElMessage.error('更新因子值失败: ' + (error || '未知错误')); }, 'UpdateFactorValue_CallBack', 40000 ); }, // 关闭因子对话框 closeYZDialog() { this.yzDialogVisible = false; }, // 确认因子调价 confirmYZ() { if (!this.yzForm.range) { ElMessage.warning('调价范围不允许为空!'); return; } const factorValue = this.yzForm.factorValue; if (factorValue === null || factorValue === undefined || factorValue === '') { ElMessage.warning('请输入因子值'); return; } const numFactorValue = parseFloat(factorValue); if (isNaN(numFactorValue)) { ElMessage.warning('因子值必须是数字'); return; } // 验证最小值 if (this.yzForm.MinYZZ && this.yzForm.MinYZZ !== '') { const minValue = parseFloat(this.yzForm.MinYZZ); if (!isNaN(minValue) && numFactorValue < minValue) { ElMessage.warning(`不允许低于设置的调价最小值${this.yzForm.MinYZZ}!`); return; } } // 验证最大值 if (this.yzForm.MaxYZZ && this.yzForm.MaxYZZ !== '') { const maxValue = parseFloat(this.yzForm.MaxYZZ); if (!isNaN(maxValue) && numFactorValue > maxValue) { ElMessage.warning(`不允许高于设置的调价最大值${this.yzForm.MaxYZZ}!`); return; } } const currentBJDID = getQueryParams()['BJDID'] || (document.getElementById('txtBJDID') ? document.getElementById('txtBJDID').value : '') || ''; const JCLLX = getQueryParams()['JCLLX'] || (document.getElementById('txtJCLLX') ? document.getElementById('txtJCLLX').value : '') || ''; const LJJCLLX = getQueryParams()['LJJCLLX'] || (document.getElementById('txtLJJCLLX') ? document.getElementById('txtLJJCLLX').value : '') || ''; const CPBJMRXSWS = getQueryParams()['CPBJMRXSWS'] || (document.getElementById('txtCPBJMRXSWS') ? document.getElementById('txtCPBJMRXSWS').value : '') || ''; let sBJDXHList = ''; let sPLSZAll = this.yzForm.range || 'C'; if (sPLSZAll === 'N') { if (this.selectedRows.length === 0) { ElMessage.warning('请先选择要调价的记录'); return; } sBJDXHList = this.selectedRows.map(row => row.XH || row.XLXSBJDMX_XH).join(','); } if (sPLSZAll === 'C') { // 所查记录 -> 仅当前筛选,改为 N + 过滤列表 sPLSZAll = 'N'; sBJDXHList = this.getFilteredIds(); if (!sBJDXHList) { ElMessage.warning('当前无可调价的所查记录'); this.showLoading = false; return; } } this.showLoading = true; GThinking.Web.AjaxServiceProxy.servicePath = 'S_XLXSBJ/102373016.ashx'; GThinking.Web.AjaxServiceProxy.invoke( 'BatchFactorAdjust', false, { BJDID: currentBJDID, YZID: this.yzForm.YZID, isJMBGS: this.yzForm.YZType === 'JMBGS' ? 'true' : 'false', factorValue: String(this.yzForm.factorValue || '0'), JJFS: this.yzForm.JJFS || '', onlyNegative: this.yzForm.onlyNegative ? 'true' : 'false', hasTablePrice: this.yzForm.hasTablePrice ? 'true' : 'false', isPurchased: this.yzForm.isPurchased ? 'true' : 'false', isNonPurchased: this.yzForm.isNonPurchased ? 'true' : 'false', selectedIds: sBJDXHList, PLSZAll: sPLSZAll, JCLLX: JCLLX, LJJCLLX: LJJCLLX, CPBJMRXSWS: CPBJMRXSWS }, result => { this.showLoading = false; if (result && result.success !== false) { ElMessage.success('因子调价成功'); this.yzDialogVisible = false; this.loadData(); } else { ElMessage.error(result?.msg || '因子调价失败'); } }, error => { this.showLoading = false; ElMessage.error('因子调价失败: ' + (error || '未知错误')); }, 'BatchFactorAdjust_CallBack', 40000 ); }, // 处理数字输入(用于限制输入格式) handlePriceInput(formName, event, fieldName) { const value = event.target ? event.target.value : event; // 只允许数字和小数点 const cleaned = value.replace(/[^\d.]/g, ''); // 确保只有一个小数点 const parts = cleaned.split('.'); if (parts.length > 2) { const finalValue = parts[0] + '.' + parts.slice(1).join(''); if (fieldName) { this[formName][fieldName] = finalValue; } else { this[formName].value = finalValue; } } else { if (fieldName) { this[formName][fieldName] = cleaned; } else { this[formName].value = cleaned; } } }, closeMaterialPriceDialog() { this.materialPriceDialogVisible = false; }, closePanel() { const parentDoc = topDocument || document; const docs = [parentDoc, document]; const overlayIds = [ 'divZDY_102373016', 'divZDY_102849002', 'divZDY_102849001', 'divZDY_102849000', 'divBYZDY_102373016', 'divBYZDY_102849001', 'divBYZDY_102849000' ]; // 强制清理遮罩/容器并隐藏 div_ZDY/div_BYZDY docs.forEach(doc => { overlayIds.forEach(id => { const el = doc.getElementById(id); if (el && el.parentNode) { el.parentNode.removeChild(el); } }); const zdy = doc.getElementById('div_ZDY'); if (zdy) { zdy.innerHTML = ''; zdy.style.display = 'none'; } const byzdy = doc.getElementById('div_BYZDY'); if (byzdy) { byzdy.innerHTML = ''; byzdy.style.display = 'none'; } }); // 移除自身 iframe(如果存在) const frameEl = window.frameElement; if (frameEl && frameEl.parentNode) { try { frameEl.parentNode.removeChild(frameEl); } catch (e) { console.warn(e); } } // 尝试刷新父页面报价单(若存在) try { const frameElement = parentDoc.getElementById('XLBJDInfo_frame'); if (frameElement && frameElement.contentWindow && frameElement.contentWindow.location) { frameElement.contentWindow.location.reload(); } } catch (e) { console.warn('刷新父页报价单失败', e); } // 刷新报价单 const frameElement = parentDoc.getElementById('XLBJDInfo_frame'); if (!frameElement) { console.log('未找到 XLBJDInfo_frame'); } else { const iframeDoc = frameElement.contentWindow.document; if (!iframeDoc) { console.log('跨域访问被阻止'); } else { const reloadButton = iframeDoc.getElementById('ctl00_CPHButton_btnReLoad'); if (reloadButton) { reloadButton.click(); } else { console.log('未找到 btnReLoad 控件'); } } } } } }); function CallBackNULLJSON(result, userContext, methodName) { } function CallBackFun(result, userContext, methodName) { console.log("CallBackFun"); const app = window.app; if (userContext == "GetXLCPList_CallBack") { } if (userContext == "IsJGEJGB_CallBack") { } if (userContext == "GetXLYSList_CallBack") { console.log("GetXLYSList_CallBack"); console.log(result); // 查看 result 的结构 app.xlysOptions = result; } } function getQueryParams() { const params = {}; window.location.search.substring(1).split('&').forEach(param => { const [key, value] = param.split('='); params[key] = decodeURIComponent(value || ''); }); return params; } app.use(ElementPlus); app.component('Filter', Filter); app.component('Operation',ElementPlusIconsVue.Operation); window.app = app.mount('#app');