From 879cf783b6e2f4df8a5540123fce43077b556c2c Mon Sep 17 00:00:00 2001 From: lai <371757574@qq.com> Date: Wed, 16 Oct 2024 20:30:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=AF=BC=E5=87=BA=E5=BC=82?= =?UTF-8?q?=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 | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/views/faultManage/active-alarm/index.vue b/src/views/faultManage/active-alarm/index.vue index 910713d4..7c23e444 100644 --- a/src/views/faultManage/active-alarm/index.vue +++ b/src/views/faultManage/active-alarm/index.vue @@ -612,13 +612,17 @@ function fnShowSet() { } // key替换中文title -function mapKeysWithReduce(data: any, titleMapping: any) { - return data.map((item:any) => { - return Object.keys(item).reduce((newItem:any, key:any) => { +// key替换中文title +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/faultManage/history-alarm/index.vue b/src/views/faultManage/history-alarm/index.vue index d4c58eec..ec745df8 100644 --- a/src/views/faultManage/history-alarm/index.vue +++ b/src/views/faultManage/history-alarm/index.vue @@ -427,13 +427,17 @@ function fnCancelConfirm() { } // key替换中文title -function mapKeysWithReduce(data: any, titleMapping: any) { - return data.map((item:any) => { - return Object.keys(item).reduce((newItem:any, key:any) => { +// key替换中文title +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; - }); + }, {}); }); }