223 lines
5.7 KiB
TypeScript
223 lines
5.7 KiB
TypeScript
import { http } from '/nerv-lib/util';
|
||
import { NsMessage } from '/nerv-lib/component';
|
||
import { energyAlarms } from '/@/api/alarmManagement/alarmSettings/energyAlarm';
|
||
|
||
const tableKeyMap = [
|
||
{
|
||
title: '序号',
|
||
dataIndex: 'address',
|
||
customRender: (text: any) => {
|
||
return text.index + 1;
|
||
},
|
||
},
|
||
{
|
||
title: '优先级',
|
||
dataIndex: 'priority',
|
||
},
|
||
{
|
||
title: '告警标题',
|
||
dataIndex: 'alarmTitle',
|
||
},
|
||
{
|
||
title: '错误码',
|
||
dataIndex: 'errorCode',
|
||
},
|
||
{
|
||
title: '告警频率',
|
||
dataIndex: 'alarmFrequency',
|
||
},
|
||
{
|
||
title: '重复次数',
|
||
dataIndex: 'repetitions',
|
||
},
|
||
{
|
||
title: '频率间隔',
|
||
dataIndex: 'interval',
|
||
},
|
||
{
|
||
title: '监测时长',
|
||
dataIndex: 'monitorFrequency',
|
||
},
|
||
{
|
||
title: '是否启用',
|
||
dataIndex: 'enableRules',
|
||
},
|
||
];
|
||
const doWnload = (url: any) => {
|
||
const a = document.createElement('a');
|
||
document.body.appendChild(a);
|
||
a.href = encodeURI(url);
|
||
//设置下载的文件名
|
||
// a.download = fileName.value;
|
||
//触发a标签的点击事件,进行下载
|
||
a.click();
|
||
};
|
||
|
||
export const energyAlarmConfigs = (
|
||
editeEnergyAlarm: any,
|
||
mainEnergyAlarmConfig: any,
|
||
energyAlarm: any,
|
||
configureDeviceAlarms: any,
|
||
) => {
|
||
return {
|
||
title: '告警规则',
|
||
api: energyAlarms.getTableList,
|
||
headerActions: [
|
||
{
|
||
label: '新增',
|
||
name: 'energyAlarmAdd',
|
||
type: 'primary',
|
||
handle: () => {
|
||
editeEnergyAlarm.value.toggle();
|
||
},
|
||
},
|
||
{
|
||
label: '导入',
|
||
name: 'energyAlarmImport',
|
||
type: 'primary',
|
||
extra: {
|
||
title: '设备信息', // 弹窗title
|
||
templateName: 'whiteListUser', // 所使用的文件名称
|
||
indexName: '设备id', // 匹配类型字段
|
||
message: [
|
||
{ label: '1、若必填项未填写,则不能进行导入操作' },
|
||
{ label: `2、当重复时,则更新数据。` },
|
||
{ label: '3、数据将从模版的第五行进行导入。' },
|
||
{ label: '4、文件导入勿超过5MB。' },
|
||
],
|
||
},
|
||
},
|
||
{
|
||
label: '导出',
|
||
name: 'energyAlarmExports',
|
||
type: 'primary',
|
||
handle: () => {
|
||
doWnload('/hx-ai-intelligent/asset/file/whiteListUser.xlsx');
|
||
},
|
||
},
|
||
],
|
||
columns: tableKeyMap,
|
||
// rowSelection: null, 选择按钮
|
||
columnActions: {
|
||
title: '操作',
|
||
actions: [
|
||
{
|
||
label: '编辑',
|
||
name: 'energyAlarmEdit',
|
||
dynamicParams: ['uuid', 'appealType'],
|
||
handle: (data: any) => {
|
||
const obj = { ...data };
|
||
obj.priority = data.priority.value;
|
||
if (obj.alarmFrequency) {
|
||
obj.alarmFrequency = data.alarmFrequency.value;
|
||
}
|
||
if (obj.intervalDurationUnit) {
|
||
obj.intervalDurationUnit = data.intervalDurationUnit.value;
|
||
}
|
||
if (obj.monitorFrequency) {
|
||
obj.monitorFrequency = data.monitorFrequency.value;
|
||
}
|
||
if (obj.createWorkOrder) {
|
||
obj.createWorkOrder = data.createWorkOrder + '';
|
||
}
|
||
if (obj.alarmFrequency !== 2) {
|
||
obj.repetitions = null;
|
||
obj.intervalDuration = null;
|
||
obj.intervalDurationUnit = null;
|
||
}
|
||
editeEnergyAlarm.value.toggle(obj);
|
||
},
|
||
},
|
||
{
|
||
label: '配置',
|
||
name: 'alarmSettingsIndex',
|
||
dynamicParams: ['uuid', 'appealType'],
|
||
handle: (data: any) => {
|
||
energyAlarm.value = !energyAlarm.value;
|
||
configureDeviceAlarms.value.setconfigureDeviceAlarmsData(data);
|
||
},
|
||
},
|
||
{
|
||
label: '删除',
|
||
name: 'energyAlarmDel',
|
||
dynamicParams: ['uuid', 'appealType'],
|
||
confirm: true,
|
||
handle: (data: any) => {
|
||
http.post(energyAlarms.del, { id: data.id }).then(() => {
|
||
NsMessage.success('操作成功');
|
||
mainEnergyAlarmConfig.value?.nsTableRef.reload();
|
||
});
|
||
},
|
||
},
|
||
],
|
||
},
|
||
|
||
formConfig: {
|
||
schemas: [
|
||
{
|
||
field: 'priority',
|
||
label: '告警优先级',
|
||
component: 'NsSelect',
|
||
componentProps: {
|
||
placeholder: '请选择告警优先级',
|
||
allowClear: true,
|
||
options: [
|
||
{
|
||
label: '紧急',
|
||
value: 1,
|
||
},
|
||
{
|
||
label: '重要',
|
||
value: 2,
|
||
},
|
||
{
|
||
label: '一般',
|
||
value: 3,
|
||
},
|
||
],
|
||
},
|
||
},
|
||
{
|
||
field: 'alarmTitle',
|
||
label: '告警标题',
|
||
component: 'NsInput',
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '请输入告警标题关键字',
|
||
},
|
||
},
|
||
{
|
||
field: 'errorCode',
|
||
label: '错误码',
|
||
component: 'NsInput',
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '请输入告警错误码',
|
||
},
|
||
},
|
||
{
|
||
field: 'enableRules',
|
||
label: '启用状态',
|
||
component: 'NsSelect',
|
||
componentProps: {
|
||
allowClear: true,
|
||
placeholder: '请选择启用状态',
|
||
options: [
|
||
{
|
||
label: '启用',
|
||
value: 1,
|
||
},
|
||
{
|
||
label: '关闭',
|
||
value: 0,
|
||
},
|
||
],
|
||
},
|
||
},
|
||
],
|
||
},
|
||
// pagination: { pageSizeOptions: false },
|
||
rowKey: 'id',
|
||
};
|
||
};
|