diff --git a/src/views/modules/eam/eam_device_list.vue b/src/views/modules/eam/eam_device_list.vue index 7b87cf5..c268d93 100644 --- a/src/views/modules/eam/eam_device_list.vue +++ b/src/views/modules/eam/eam_device_list.vue @@ -1127,6 +1127,7 @@ searchData: { site: this.$store.state.user.site, userName: this.$store.state.user.name, + buDesc: '', objectID: '', objectDesc: '', locationID: '', @@ -4112,7 +4113,7 @@ this.searchData.page = 1 excel.exportTable({ url: "/pms/eamObject/getEamObjectList", - columnMapping: this.columnList,//可以直接用table,不需要的列就剔除 + columnMapping: this.getExportColumnMapping(),//可以直接用table,不需要的列就剔除 mergeSetting: [],//需要合并的列 params: this.searchData, fileName: this.exportName+".xlsx", @@ -4122,6 +4123,59 @@ }); }, + // 导出时判断是否是RFID BU(仅RFID追加扩展字段列) + isRfidBuForExport () { + const normalizeBu = (value) => value == null ? '' : String(value).toUpperCase() + const currentBuDesc = normalizeBu(this.searchData.buDesc) + if (currentBuDesc !== '') { + return currentBuDesc.indexOf('RFID') !== -1 + } + if (Array.isArray(this.userBuList) && this.userBuList.length === 1) { + const buItem = this.userBuList[0] || {} + const buDesc = normalizeBu(buItem.buDesc) + const buNo = normalizeBu(buItem.buNo) + return buDesc.indexOf('RFID') !== -1 || buNo.indexOf('RFID') !== -1 + } + return false + }, + + // 设备导出列:RFID在基础列后追加扩展列,其他BU保持不变 + getExportColumnMapping () { + const exportColumnList = Array.isArray(this.columnList) ? [...this.columnList] : [] + if (!this.isRfidBuForExport()) { + return exportColumnList + } + const rfidExtraColumnList = [ + { columnProp: 'workshop', columnLabel: '车间' }, + { columnProp: 'warrantyStartDate', columnLabel: '保修开始时间' }, + { columnProp: 'warrantyEndDate', columnLabel: '保修结束时间' }, + { columnProp: 'warrantyExpiredFlag', columnLabel: '是否已过保' }, + { columnProp: 'voltage', columnLabel: '电压' }, + { columnProp: 'currentA', columnLabel: '电流A' }, + { columnProp: 'powerKw', columnLabel: '功率KW' }, + { columnProp: 'totalSize', columnLabel: '设备总尺寸:长*宽*高(m)' }, + { columnProp: 'splitSize', columnLabel: '设备分体尺寸:长*宽*高(m)' }, + { columnProp: 'totalWeight', columnLabel: '设备总重量' }, + { columnProp: 'splitModuleWeight', columnLabel: '设备分体模块重量' }, + ] + const existColumnMap = exportColumnList.reduce((map, item) => { + if (!item) { + return map + } + const propKey = item.columnProp || item.property + if (propKey) { + map[propKey] = true + } + return map + }, {}) + rfidExtraColumnList.forEach((column) => { + if (!existColumnMap[column.columnProp]) { + exportColumnList.push(column) + } + }) + return exportColumnList + }, + // 导出excel // async createExportData () { // this.searchData.limit = -1