From c5c2926d998dae2e1e0afd867139f5fbe8a8d2c8 Mon Sep 17 00:00:00 2001 From: lai <371757574@qq.com> Date: Thu, 17 Oct 2024 10:29:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=8A=E8=AD=A6=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/faultManage/active-alarm/index.vue | 12 ++++++++---- src/views/faultManage/history-alarm/index.vue | 11 +++++++---- src/views/neUser/sub/index.vue | 1 - 3 files changed, 15 insertions(+), 9 deletions(-) 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,