修改告警导出异常
This commit is contained in:
@@ -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 => {
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}, {});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user