告警根据中英文导出
This commit is contained in:
@@ -4,8 +4,6 @@ import { parseObjLineToHump } from '@/utils/parse-utils';
|
|||||||
import { parseDateToStr } from '@/utils/date-utils';
|
import { parseDateToStr } from '@/utils/date-utils';
|
||||||
import useUserStore from '@/store/modules/user';
|
import useUserStore from '@/store/modules/user';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询列表
|
* 查询列表
|
||||||
* @param query 查询参数
|
* @param query 查询参数
|
||||||
@@ -28,8 +26,6 @@ export async function listAct(query: Record<string, any>) {
|
|||||||
querySQL += ` and pv_flag = '${query.pvFlag}' `;
|
querySQL += ` and pv_flag = '${query.pvFlag}' `;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (query.neId) {
|
if (query.neId) {
|
||||||
querySQL += ` and ne_id like '%${query.neId}%' `;
|
querySQL += ` and ne_id like '%${query.neId}%' `;
|
||||||
}
|
}
|
||||||
@@ -69,7 +65,6 @@ export async function listAct(query: Record<string, any>) {
|
|||||||
msg: result.msg,
|
msg: result.msg,
|
||||||
};
|
};
|
||||||
result.data.data.forEach((item: any) => {
|
result.data.data.forEach((item: any) => {
|
||||||
console.log(item)
|
|
||||||
const itemData = item['alarm_event'];
|
const itemData = item['alarm_event'];
|
||||||
if (Array.isArray(itemData)) {
|
if (Array.isArray(itemData)) {
|
||||||
if (itemData.length === 1 && itemData[0]['total'] >= 0) {
|
if (itemData.length === 1 && itemData[0]['total'] >= 0) {
|
||||||
@@ -84,12 +79,6 @@ export async function listAct(query: Record<string, any>) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 事件告警导出
|
* 事件告警导出
|
||||||
* @param query 查询参数
|
* @param query 查询参数
|
||||||
@@ -133,7 +122,3 @@ export async function exportAll(query: Record<string, any>) {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -611,6 +611,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) => {
|
||||||
|
const title = titleMapping[key] || key;
|
||||||
|
newItem[title] = item[key];
|
||||||
|
return newItem;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出全部
|
* 导出全部
|
||||||
*/
|
*/
|
||||||
@@ -622,39 +633,56 @@ function fnExportAll() {
|
|||||||
const key = 'exportAlarm';
|
const key = 'exportAlarm';
|
||||||
message.loading({ content: t('common.loading'), key });
|
message.loading({ content: t('common.loading'), key });
|
||||||
let sortArr: any = [];
|
let sortArr: any = [];
|
||||||
|
let writeSheetOpt: any = [];
|
||||||
|
let mappArr: any = {};
|
||||||
tableColumnsDnd.value.forEach((item: 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;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
//提供给writeSheet排序参数
|
||||||
// 排序字段
|
|
||||||
const sortData = {
|
const sortData = {
|
||||||
header: sortArr,
|
header: writeSheetOpt,
|
||||||
};
|
};
|
||||||
|
|
||||||
exportAll(queryParams).then(res => {
|
exportAll(queryParams).then(res => {
|
||||||
if (res.code === RESULT_CODE_SUCCESS) {
|
if (res.code === RESULT_CODE_SUCCESS) {
|
||||||
res.data = res.data.map((objA: any) => {
|
res.data = res.data.map((objA: any) => {
|
||||||
let filteredObj: any = {};
|
let filteredObj: any = {};
|
||||||
|
//sort Data
|
||||||
sortArr.forEach((key: any) => {
|
sortArr.forEach((key: any) => {
|
||||||
if (objA.hasOwnProperty(key)) {
|
if (objA.hasOwnProperty(key)) {
|
||||||
filteredObj[key] = objA[key];
|
filteredObj[key] = objA[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dict.activeAckState.map((item: any) => {
|
const mapProps = (dict: any, key: string) => {
|
||||||
if (item.value === `${filteredObj.ackState}`)
|
const item = dict.find(
|
||||||
filteredObj.ackState = item.label;
|
(item: any) => item.value === `${filteredObj[key]}`
|
||||||
});
|
);
|
||||||
|
if (item) {
|
||||||
|
filteredObj[key] = item.label;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mapProps(dict.activeAckState, 'ackState');
|
||||||
|
mapProps(dict.activeClearType, 'clearType');
|
||||||
|
mapProps(dict.activeAlarmSeverity, 'origSeverity');
|
||||||
|
mapProps(dict.activeAlarmType, 'alarmType');
|
||||||
|
|
||||||
return filteredObj;
|
return filteredObj;
|
||||||
});
|
});
|
||||||
message.success({
|
|
||||||
content: t('common.msgSuccess', { msg: t('common.export') }),
|
res.data = mapKeysWithReduce(res.data, mappArr);
|
||||||
key,
|
writeSheet(res.data, 'alarm', sortData).then(fileBlob => {
|
||||||
duration: 3,
|
saveAs(fileBlob, `alarm_${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, `alarm_${Date.now()}.xlsx`)
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
message.error({
|
message.error({
|
||||||
content: `${res.msg}`,
|
content: `${res.msg}`,
|
||||||
|
|||||||
@@ -308,6 +308,17 @@ const onSelectChange = (
|
|||||||
state.selectedRow = record;
|
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';
|
const key = 'exportAlarm';
|
||||||
message.loading({ content: t('common.loading'), key });
|
message.loading({ content: t('common.loading'), key });
|
||||||
let sortArr: any = [];
|
let sortArr: any = [];
|
||||||
|
let writeSheetOpt: any = [];
|
||||||
|
let mappArr: any = {};
|
||||||
tableColumnsDnd.value.forEach((item: 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 = {
|
const sortData = {
|
||||||
header: sortArr,
|
header: writeSheetOpt,
|
||||||
};
|
};
|
||||||
|
|
||||||
exportAll(queryParams).then(res => {
|
exportAll(queryParams).then(res => {
|
||||||
@@ -337,21 +353,20 @@ function fnExportAll() {
|
|||||||
filteredObj[key] = objA[key];
|
filteredObj[key] = objA[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dict.activeAckState.map((item: any) => {
|
|
||||||
if (item.value === `${filteredObj.ackState}`)
|
|
||||||
filteredObj.ackState = item.label;
|
|
||||||
});
|
|
||||||
|
|
||||||
return filteredObj;
|
return filteredObj;
|
||||||
});
|
});
|
||||||
message.success({
|
res.data = mapKeysWithReduce(res.data, mappArr);
|
||||||
content: t('common.msgSuccess', { msg: t('common.export') }),
|
|
||||||
key,
|
writeSheet(res.data, 'alarm', sortData).then(fileBlob => {
|
||||||
duration: 3,
|
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 {
|
} else {
|
||||||
message.error({
|
message.error({
|
||||||
content: `${res.msg}`,
|
content: `${res.msg}`,
|
||||||
@@ -625,11 +640,6 @@ onMounted(() => {
|
|||||||
:loading="tableState.loading"
|
:loading="tableState.loading"
|
||||||
:data-source="tableState.data"
|
:data-source="tableState.data"
|
||||||
:size="tableState.size"
|
:size="tableState.size"
|
||||||
:row-selection="{
|
|
||||||
columnWidth: 2,
|
|
||||||
selectedRowKeys: state.selectedRowKeys,
|
|
||||||
onChange: onSelectChange,
|
|
||||||
}"
|
|
||||||
:pagination="tablePagination"
|
:pagination="tablePagination"
|
||||||
:scroll="{ x: 2500, y: 400 }"
|
:scroll="{ x: 2500, y: 400 }"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -426,6 +426,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) => {
|
||||||
|
const title = titleMapping[key] || key;
|
||||||
|
newItem[title] = item[key];
|
||||||
|
return newItem;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出全部
|
* 导出全部
|
||||||
*/
|
*/
|
||||||
@@ -437,12 +448,18 @@ function fnExportAll() {
|
|||||||
const key = 'exportAlarmHis';
|
const key = 'exportAlarmHis';
|
||||||
message.loading({ content: t('common.loading'), key });
|
message.loading({ content: t('common.loading'), key });
|
||||||
let sortArr: any = [];
|
let sortArr: any = [];
|
||||||
|
let writeSheetOpt: any = [];
|
||||||
|
let mappArr: any = {};
|
||||||
tableColumnsDnd.value.forEach((item: 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;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// 排序字段
|
//提供给writeSheet排序参数
|
||||||
const sortData = {
|
const sortData = {
|
||||||
header: sortArr,
|
header: writeSheetOpt,
|
||||||
};
|
};
|
||||||
exportAll(queryParams).then(res => {
|
exportAll(queryParams).then(res => {
|
||||||
if (res.code === RESULT_CODE_SUCCESS) {
|
if (res.code === RESULT_CODE_SUCCESS) {
|
||||||
@@ -470,14 +487,17 @@ function fnExportAll() {
|
|||||||
|
|
||||||
return filteredObj;
|
return filteredObj;
|
||||||
});
|
});
|
||||||
message.success({
|
|
||||||
content: t('common.msgSuccess', { msg: t('common.export') }),
|
res.data = mapKeysWithReduce(res.data, mappArr);
|
||||||
key,
|
|
||||||
duration: 3,
|
writeSheet(res.data, 'alarm', sortData).then(fileBlob => {
|
||||||
|
saveAs(fileBlob, `history-alarm_${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, `history-alarm_${Date.now()}.xlsx`)
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
message.error({
|
message.error({
|
||||||
content: `${res.msg}`,
|
content: `${res.msg}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user