修改告警导出异常

This commit is contained in:
lai
2024-10-17 10:29:22 +08:00
parent 55456f9220
commit c5c2926d99
3 changed files with 15 additions and 9 deletions

View File

@@ -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<string, string>) {
return data.map((item: any) => {
if (typeof item !== 'object' || item === null) {
return item; // 如果不是对象,直接返回原值
}
return Object.keys(item).reduce((newItem: Record<string, any>, 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 => {

View File

@@ -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<string, string>) {
return data.map((item: any) => {
if (typeof item !== 'object' || item === null) {
return item;
}
return Object.keys(item).reduce((newItem: Record<string, any>, key: string) => {
const title = titleMapping[key] || key;
newItem[title] = item[key];
return newItem;
});
}, {});
});
}

View File

@@ -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,