告警根据中英文导出
This commit is contained in:
@@ -308,6 +308,17 @@ const onSelectChange = (
|
||||
state.selectedRow = record;
|
||||
};
|
||||
|
||||
// key替换中文title
|
||||
function mapKeysWithReduce(data: any, titleMapping: any) {
|
||||
return data.map((item:any) => {
|
||||
return Object.keys(item).reduce((newItem:any, key:any) => {
|
||||
const title = titleMapping[key] || key;
|
||||
newItem[title] = item[key];
|
||||
return newItem;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出全部
|
||||
*/
|
||||
@@ -319,13 +330,18 @@ function fnExportAll() {
|
||||
const key = 'exportAlarm';
|
||||
message.loading({ content: t('common.loading'), key });
|
||||
let sortArr: any = [];
|
||||
let writeSheetOpt: any = [];
|
||||
let mappArr: any = {};
|
||||
tableColumnsDnd.value.forEach((item: any) => {
|
||||
if (item.dataIndex) sortArr.push(item.dataIndex);
|
||||
if (item.dataIndex) {
|
||||
sortArr.push(item.dataIndex);
|
||||
writeSheetOpt.push(item.title);
|
||||
mappArr[item.dataIndex] = item.title;
|
||||
}
|
||||
});
|
||||
|
||||
// 排序字段
|
||||
const sortData = {
|
||||
header: sortArr,
|
||||
header: writeSheetOpt,
|
||||
};
|
||||
|
||||
exportAll(queryParams).then(res => {
|
||||
@@ -337,21 +353,20 @@ function fnExportAll() {
|
||||
filteredObj[key] = objA[key];
|
||||
}
|
||||
});
|
||||
dict.activeAckState.map((item: any) => {
|
||||
if (item.value === `${filteredObj.ackState}`)
|
||||
filteredObj.ackState = item.label;
|
||||
});
|
||||
|
||||
return filteredObj;
|
||||
});
|
||||
message.success({
|
||||
content: t('common.msgSuccess', { msg: t('common.export') }),
|
||||
key,
|
||||
duration: 3,
|
||||
res.data = mapKeysWithReduce(res.data, mappArr);
|
||||
|
||||
writeSheet(res.data, 'alarm', sortData).then(fileBlob => {
|
||||
saveAs(fileBlob, `evnet_${Date.now()}.xlsx`);
|
||||
|
||||
message.success({
|
||||
content: t('common.msgSuccess', { msg: t('common.export') }),
|
||||
key,
|
||||
duration: 3,
|
||||
});
|
||||
});
|
||||
writeSheet(res.data, 'alarm', sortData).then(fileBlob =>
|
||||
saveAs(fileBlob, `evnet_${Date.now()}.xlsx`)
|
||||
);
|
||||
} else {
|
||||
message.error({
|
||||
content: `${res.msg}`,
|
||||
@@ -625,11 +640,6 @@ onMounted(() => {
|
||||
:loading="tableState.loading"
|
||||
:data-source="tableState.data"
|
||||
:size="tableState.size"
|
||||
:row-selection="{
|
||||
columnWidth: 2,
|
||||
selectedRowKeys: state.selectedRowKeys,
|
||||
onChange: onSelectChange,
|
||||
}"
|
||||
:pagination="tablePagination"
|
||||
:scroll="{ x: 2500, y: 400 }"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user