diff --git a/src/views/faultManage/active-alarm/index.vue b/src/views/faultManage/active-alarm/index.vue index 910713d4..375ab56a 100644 --- a/src/views/faultManage/active-alarm/index.vue +++ b/src/views/faultManage/active-alarm/index.vue @@ -612,13 +612,16 @@ function fnShowSet() { } // key替换中文title -function mapKeysWithReduce(data: any, titleMapping: any) { - return data.map((item:any) => { - return Object.keys(item).reduce((newItem:any, key:any) => { +function mapKeysWithReduce(data: any[], titleMapping: Record) { + return data.map((item: any) => { + if (typeof item !== 'object' || item === null) { + return item; // 如果不是对象,直接返回原值 + } + return Object.keys(item).reduce((newItem: Record, key: string) => { const title = titleMapping[key] || key; newItem[title] = item[key]; return newItem; - }); + }, {}); // 确保初始值是一个空对象 }); } @@ -673,6 +676,7 @@ function fnExportAll() { return filteredObj; }); + console.log(mappArr); res.data = mapKeysWithReduce(res.data, mappArr); writeSheet(res.data, 'alarm', sortData).then(fileBlob => { diff --git a/src/views/faultManage/history-alarm/index.vue b/src/views/faultManage/history-alarm/index.vue index d4c58eec..434a18ee 100644 --- a/src/views/faultManage/history-alarm/index.vue +++ b/src/views/faultManage/history-alarm/index.vue @@ -427,13 +427,16 @@ function fnCancelConfirm() { } // key替换中文title -function mapKeysWithReduce(data: any, titleMapping: any) { - return data.map((item:any) => { - return Object.keys(item).reduce((newItem:any, key:any) => { +function mapKeysWithReduce(data: any[], titleMapping: Record) { + return data.map((item: any) => { + if (typeof item !== 'object' || item === null) { + return item; + } + return Object.keys(item).reduce((newItem: Record, key: string) => { const title = titleMapping[key] || key; newItem[title] = item[key]; return newItem; - }); + }, {}); }); } diff --git a/src/views/neUser/sub/index.vue b/src/views/neUser/sub/index.vue index f42ef2ae..0702ca5a 100644 --- a/src/views/neUser/sub/index.vue +++ b/src/views/neUser/sub/index.vue @@ -838,7 +838,6 @@ function fnRecordExport(type: string = 'txt') { let content = ''; if (type == 'txt') { for (const row of rows) { - debugger; const epsDat = [ row.epsFlag, row.epsOdb,