修改告警导出异常
This commit is contained in:
@@ -612,13 +612,16 @@ function fnShowSet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// key替换中文title
|
// key替换中文title
|
||||||
function mapKeysWithReduce(data: any, titleMapping: any) {
|
function mapKeysWithReduce(data: any[], titleMapping: Record<string, string>) {
|
||||||
return data.map((item:any) => {
|
return data.map((item: any) => {
|
||||||
return Object.keys(item).reduce((newItem:any, key: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;
|
const title = titleMapping[key] || key;
|
||||||
newItem[title] = item[key];
|
newItem[title] = item[key];
|
||||||
return newItem;
|
return newItem;
|
||||||
});
|
}, {}); // 确保初始值是一个空对象
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,6 +676,7 @@ function fnExportAll() {
|
|||||||
|
|
||||||
return filteredObj;
|
return filteredObj;
|
||||||
});
|
});
|
||||||
|
console.log(mappArr);
|
||||||
|
|
||||||
res.data = mapKeysWithReduce(res.data, mappArr);
|
res.data = mapKeysWithReduce(res.data, mappArr);
|
||||||
writeSheet(res.data, 'alarm', sortData).then(fileBlob => {
|
writeSheet(res.data, 'alarm', sortData).then(fileBlob => {
|
||||||
|
|||||||
@@ -427,13 +427,16 @@ function fnCancelConfirm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// key替换中文title
|
// key替换中文title
|
||||||
function mapKeysWithReduce(data: any, titleMapping: any) {
|
function mapKeysWithReduce(data: any[], titleMapping: Record<string, string>) {
|
||||||
return data.map((item:any) => {
|
return data.map((item: any) => {
|
||||||
return Object.keys(item).reduce((newItem:any, key: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;
|
const title = titleMapping[key] || key;
|
||||||
newItem[title] = item[key];
|
newItem[title] = item[key];
|
||||||
return newItem;
|
return newItem;
|
||||||
});
|
}, {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -838,7 +838,6 @@ function fnRecordExport(type: string = 'txt') {
|
|||||||
let content = '';
|
let content = '';
|
||||||
if (type == 'txt') {
|
if (type == 'txt') {
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
debugger;
|
|
||||||
const epsDat = [
|
const epsDat = [
|
||||||
row.epsFlag,
|
row.epsFlag,
|
||||||
row.epsOdb,
|
row.epsOdb,
|
||||||
|
|||||||
Reference in New Issue
Block a user