fks-yangshouda 5 months ago
parent
commit
141f2a3e6f
  1. 9
      hx-ai-intelligent/src/api/alarmSettings/energyAlarm.ts
  2. 326
      hx-ai-intelligent/src/view/alarmManagement/alarmOverview/index.vue
  3. 8
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/energyAlarm/configureEnergyAlarms.vue
  4. 170
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/energyAlarm/editConfigureEnergyAlarm.vue
  5. 64
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/energyAlarm/editeEnergyAlarm.vue
  6. 9
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/configureDeviceAlarms.vue
  7. 3
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/editConfigureDeviceAlarm.vue
  8. 19
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/index.vue
  9. 21
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/ts/energyAlarmConfig.ts

9
hx-ai-intelligent/src/api/alarmSettings/energyAlarm.ts

@ -0,0 +1,9 @@
export enum energyAlarms {
getTableList = '/carbon-smart/api/AlarmEnergyConsumption/selectAlarmEnergyConsumption', //能耗告警分页
addOrUpNewData = '/carbon-smart/api/AlarmEnergyConsumption/creatOrUpdate', //能耗告警添加 修改
del = '/carbon-smart/api/AlarmEnergyConsumption/delete', //能耗删除
configGetTableList = '/carbon-smart/api/AlarmEquipmentRule/selectAlarmEquipmentRule', //配置设备告警分页
configAddOrUpNewData = '/carbon-smart/api/AlarmEquipmentRule/creatOrUpdate', //配置设备告警添加 修改
configFindById = '/carbon-smart/api/AlarmEquipmentRule/findById', //配置设备告警 查询详情
configDel = '/carbon-smart/api/AlarmEquipmentRule/delete', //配置设备告警删除
}

326
hx-ai-intelligent/src/view/alarmManagement/alarmOverview/index.vue

@ -25,19 +25,339 @@
</div>
</div>
</div>
<div style="flex: 4; width: 100%">2</div>
<div style="flex: 4; width: 100%">3</div>
<div style="flex: 4; width: 100%; display: flex; gap: 5px">
<div
style="flex: 1; height: 100%; background-color: white; border-radius: 4px; padding: 12px">
<div ref="echartPieOne" style="width: 100%; height: 100%"></div>
</div>
<div style="flex: 1; height: 100%; background-color: white; border-radius: 4px"> xxxx </div>
</div>
<!-- 告警矩形 echarts -->
<div style="flex: 4; width: 100%; background-color: white; border-radius: 4px; padding: 12px">
<div ref="graphChart" style="width: 100%; height: 100%"></div>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted } from 'vue'; // Vue refonMounted watchEffect
import * as echarts from 'echarts';
defineOptions({
name: 'alarmOverview', // name
});
const info = ref({});
onMounted(() => {});
let chartInstance: echarts.ECharts | null = null;
let chartInstanceOne: echarts.ECharts | null = null;
const graphChart = ref(null);
const echartPieOne = ref(null);
const getGraphChart = () => {
let dayData = [];
let energyAlarm = [];
let wgAlarm = [];
let equipmentAlarm = [];
let total = [];
// Extend data for 30 days
for (let i = 1; i < 30; i++) {
dayData.push(`3/${i}`);
energyAlarm.push(Math.floor(Math.random() * 11)); // Assuming the same value for simplicity
wgAlarm.push(Math.floor(Math.random() * 11)); // Assuming the same value for simplicity
equipmentAlarm.push(Math.floor(Math.random() * 11)); // Assuming the same value for simplicity
total.push(0); // Assuming the same value for simplicity
}
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(graphChart.value);
const option = {
title: {
text: '告警趋势/ 近30天',
textStyle: {
fontSize: 16,
fontWeight: 'normal',
color: '#aaaaaa',
},
left: '1%',
top: '2%',
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
formatter: function (params) {
let res =
params[0].axisValue +
'<br/>' +
params[0].marker +
' ' +
params[0].seriesName +
' : ' +
params[0].data +
'<br/>' +
params[1].marker +
' ' +
params[1].seriesName +
' : ' +
params[1].data +
'<br/>' +
params[2].marker +
' ' +
params[2].seriesName +
' : ' +
params[2].data +
'<br/>';
return res;
},
},
grid: {
left: '2%', //
right: '2%', //
borderWidth: 0,
y2: 60, //
},
legend: [
{
top: 5,
left: 'center', //
textStyle: {
color: 'rgb(89, 89, 89)',
fontSize: '14',
fontWeight: 'normal',
}, //
data: ['设备告警', '网关告警', '能源告警'],
itemGap: 30, //
},
],
toolbox: {
show: true,
feature: {
restore: {},
saveAsImage: {},
},
},
calculable: true,
xAxis: [
{
type: 'category',
splitLine: {
show: false,
},
axisTick: {
show: false,
},
splitArea: {
show: false,
},
data: dayData,
},
],
yAxis: [
{
type: 'value',
shwo: false,
splitLine: {
show: true,
},
axisLine: {
show: false,
},
axisTick: {
show: false,
},
splitArea: {
show: false,
},
axisLabel: {
show: false, //
},
},
],
dataZoom: [
{
height: 12,
start: 0,
end: 100,
handleSize: '300%', //
bottom: 15,
},
],
series: [
{
name: '能源告警',
type: 'bar',
stack: '能源告警',
barMaxWidth: 40,
barGap: '10%',
itemStyle: {
normal: {
barBorderRadius: 0,
color: 'rgb(246, 189, 22)',
},
},
data: energyAlarm,
},
{
name: '网关告警',
type: 'bar',
stack: '能源告警',
barMaxWidth: 40,
barGap: '10%',
itemStyle: {
normal: {
barBorderRadius: 0,
color: 'rgb(91, 143, 249)',
},
},
data: wgAlarm,
},
{
name: '设备告警',
type: 'bar',
stack: '能源告警',
barMaxWidth: 40,
barGap: '10%',
itemStyle: {
normal: {
barBorderRadius: 0,
color: 'rgb(48, 191, 120)',
},
},
data: equipmentAlarm,
},
{
name: '总数',
type: 'bar',
stack: '能源告警',
barMaxWidth: 40,
barHight: 0,
itemStyle: {
normal: {
barBorderRadius: 0,
color: 'rgba(0,0,0,0)',
},
},
label: {
show: true,
color: '#000000',
position: 'top',
top: '10',
formatter: function (value) {
return (
Number(energyAlarm[value.dataIndex]) +
Number(wgAlarm[value.dataIndex]) +
Number(equipmentAlarm[value.dataIndex])
);
},
},
data: total,
},
],
};
chartInstance = echarts.init(graphChart.value);
chartInstance.setOption(option);
};
const getEchartPieOne = () => {
if (chartInstanceOne) {
chartInstanceOne.dispose();
}
chartInstanceOne = echarts.init(echartPieOne.value);
var m2R2Data = [
{ value: 335, name: '紧急', itemStyle: { color: '#F56E53' } },
{ value: 310, name: '重要', itemStyle: { color: '#F7C122' } },
{ value: 234, name: '一般', itemStyle: { color: '#3BC27F' } },
];
const option = {
title: [
{
text: '优先级 / 近30天',
textStyle: {
fontSize: 16,
fontWeight: 'normal',
color: '#aaaaaa',
},
left: '2%',
top: '2%',
},
{
text: '优先级',
subtext: 12312 + '个',
textStyle: {
fontSize: 24,
color: 'black',
},
subtextStyle: {
fontSize: 24,
fontWeight: '700',
color: 'black',
},
textAlign: 'center',
x: '44.3%',
y: '46%',
},
],
tooltip: {
trigger: 'item',
formatter: function (parms) {
var str = parms.marker + ' :' + parms.data.value;
return str;
},
},
legend: {
//
right: 50,
top: 'center',
orient: 'vertical',
//
icon: 'circle',
itemWidth: 12,
itemHeight: 12,
itemGap: 16,
textStyle: {
fontSize: 14,
},
},
series: [
{
name: '优先级',
type: 'pie',
center: ['45%', '50%'],
radius: ['50%', '70%'],
clockwise: false, //
avoidLabelOverlap: false,
label: {
normal: {
show: true,
position: 'outter',
textStyle: {
fontSize: 14,
fontWeight: 'bold',
},
formatter: function (parms) {
return '[ ' + parms.data.name + ' ] : ' + parms.data.value;
},
},
},
labelLine: {
show: true, // 线
length: 10, // 线
length2: 20, // 线
// lineStyle
},
data: m2R2Data,
},
],
};
chartInstanceOne = echarts.init(echartPieOne.value);
chartInstanceOne.setOption(option);
};
onMounted(() => {
//
getGraphChart();
//
getEchartPieOne();
});
</script>
<style lang="less" scoped>
.box {

8
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/energyAlarm/configureEnergyAlarms.vue

@ -52,7 +52,7 @@
NsModal.confirm({
title: '启用状态',
icon: createVNode(ExclamationCircleOutlined),
content: '确定' + (data.record.enableRules === 1 ? '关闭' : '启用') + '吗?',
content: '确定' + (data.record.enableRules === 1 ? '关闭' : '启用') + '规则吗?',
onOk: () => {
http
.post(deviceAlarms.addOrUpNewData, {
@ -60,7 +60,7 @@
enableRules: data.record.enableRules === 1 ? 0 : 1,
})
.then(() => {
NsMessage.success('操作成功');
NsMessage.success(data.record.enableRules === 1 ? '规则已关闭' : '规则已启用');
mainRef.value?.nsTableRef.reload();
});
},
@ -88,7 +88,7 @@
name: 'RoleTypeAdd',
type: 'primary',
handle: () => {
editConfigureEnergyAlarms.value.toggle(null, configureEnergyAlarmsData.value.va);
editConfigureEnergyAlarms.value.toggle(null, configureEnergyAlarmsData.value);
},
},
{
@ -148,7 +148,7 @@
},
{
title: '对比类型',
dataIndex: 'valueType',
dataIndex: 'comparisonType',
},
{
title: '告警点位',

170
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/energyAlarm/editConfigureEnergyAlarm.vue

@ -40,9 +40,9 @@
@change="selectDeviceType"
placeholder="请选择数据来源" />
</a-form-item>
<a-form-item label="设备/节点" name="jdDevice">
<a-form-item label="设备/节点" name="deviceNode">
<a-tree-select
v-model:value="infoObject.jdDevice"
v-model:value="infoObject.deviceNode"
style="width: 100%"
placeholder="请选择设备节点"
:disabled="!infoObject.sbtype"
@ -52,8 +52,7 @@
children: 'children',
label: infoObject.sbtype && infoObject.sbtype[1] === 1 ? 'deviceName' : 'pointName',
value: 'id',
}"
@select="selectJdDeviceChange" />
}" />
</a-form-item>
<a-form-item label="启用规则" name="enableRules">
<a-switch
@ -72,16 +71,16 @@
show-count
:maxlength="30" />
</a-form-item>
<a-form-item label="规则类型" name="resource">
<a-radio-group v-model:value="infoObject.resource">
<a-form-item label="规则类型" name="ruleType">
<a-radio-group v-model:value="infoObject.ruleType">
<a-radio value="1"> (and) </a-radio>
<a-radio value="2"> (or) </a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="对比类型" name="qzType">
<a-form-item label="对比类型" name="comparisonType">
<a-cascader
v-model:value="infoObject.sbtype"
:options="deviceTypeTreeData"
v-model:value="infoObject.comparisonType"
:options="comparisonTypeData"
:showSearch="false"
placeholder="请选择对比类型" />
</a-form-item>
@ -91,8 +90,7 @@
<a-select
v-model:value="infoObject.alarmList[index - 1].logic"
style="width: 70px; margin-left: 12px"
:options="ljOptions"
@change="handleQzChange" />
:options="ljOptions" />
<span style="line-height: 32px; margin-left: 32px">{{ `数值${index}:` }}</span>
<a-input
style="width: 65px; margin-left: 6px"
@ -133,6 +131,7 @@
import type { SelectProps } from 'ant-design-vue';
import type { ShowSearchType } from 'ant-design-vue/es/cascader';
import { device, group } from '/@/api/deviceManage';
import { energyAlarms } from '/@/api/alarmSettings/energyAlarm';
import { http } from '/nerv-lib/util';
import { dict } from '/@/api';
import { async } from '@antv/x6/lib/registry/marker/async';
@ -150,8 +149,8 @@
const infoObject = ref({
id: null,
site: null,
jdDevice: null,
resource: null,
deviceNode: null,
ruleType: null,
abnormalDescription: null,
sbtype: null,
enableRules: 0,
@ -159,6 +158,53 @@
});
//
const delAlarmList = ref([]);
//
const comparisonTypeData = ref([
{
value: '1',
label: '数值',
children: [
{
value: '1',
label: '输入数值',
},
{
value: '2',
label: '同比',
},
{
value: '3',
label: '环比',
},
{
value: '4',
label: '对比基准',
},
],
},
{
value: '2',
label: '比例',
children: [
{
value: '1',
label: '输入比例',
},
{
value: '2',
label: '同比',
},
{
value: '3',
label: '环比',
},
{
value: '4',
label: '对比基准',
},
],
},
]);
const formRef = ref();
//
const siteDataTree = ref([]);
@ -169,6 +215,9 @@
//
//
const selectDeviceType = async (value: any, selectedOptions: any) => {
if (!infoObject.value.id) {
infoObject.value.deviceNode = null;
}
if (value[value.length - 1] === 1) {
//
await http
@ -196,28 +245,12 @@
}
};
//
const selectJdDeviceChange = (value: any, node: any) => {
console.log(value, 'value');
console.log(node, 'node');
};
//
const dwOptions = ref<SelectProps['options']>([
{ value: '电压 (U)', label: '电压 (U)', code: '1' },
{ value: '电流 (I)', label: '电流 (I)', code: '2' },
{ value: '电流 (I)', label: 'a相电流 (Ia)', code: '3' },
]);
//
const filterDeviceType: ShowSearchType['filter'] = (inputValue: any, path: any) => {
return path.some(
(option: any) => option.cnValue.toLowerCase().indexOf(inputValue.toLowerCase()) > -1,
);
};
//
const qzOptions = ref<SelectProps['options']>([
{ value: '实时值', label: '实时值', code: '1' },
{ value: '平均值', label: '平均值', code: '2' },
]);
//
const ljOptions = ref<SelectProps['options']>([
{ value: 0, label: '≥' },
@ -226,19 +259,6 @@
{ value: 3, label: '<' },
{ value: 4, label: '=' },
]);
//
const filterOption = (input: string, option: any) => {
console.log('搜索', option.value);
return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0;
};
const handleQzChange = (value: string) => {
//code
qzOptions.value.forEach((item) => {
if (item.value === value) {
console.log('符合', item.code);
}
});
};
//
const clickSwitch = () => {
if (infoObject.value.enableRules === 1) {
@ -247,7 +267,6 @@
infoObject.value.enableRules = 1;
}
};
const emit = defineEmits(['editObject']);
//
const toggle = async (value: any, info: any) => {
//
@ -275,13 +294,24 @@
});
//
if (value) {
value.ruleType = value.ruleType + '';
value.comparisonType = value.comparisonType.split(',');
value.sbtype = [value.dataSourcesType, value.dataSourcesWay];
delete value.dataSourcesType;
delete value.dataSourcesWay;
infoObject.value = value;
///
deviceTypeTreeData.value.forEach((item: any) => {
if (item.id === infoObject.value.sbtype[0]) {
selectDeviceType(infoObject.value.sbtype, [{ ...item }]);
}
});
} else {
infoObject.value = {
id: null,
site: null,
jdDevice: null,
resource: null,
deviceNode: null,
ruleType: null,
abnormalDescription: null,
sbtype: null,
enableRules: 0,
@ -296,10 +326,10 @@
site: [{ required: true, message: '请选择站点', trigger: 'change' }],
sbtype: [{ required: true, message: '请选择设备类型', trigger: 'change' }],
enableRules: [{ required: true, message: '请选择启用规则', trigger: 'change' }],
jdDevice: [{ required: true, message: '请选择设备名称', trigger: 'change' }],
deviceNode: [{ required: true, message: '请选择设备名称', trigger: 'change' }],
sbAdress: [{ required: true, message: '请选择设备点位', trigger: 'change' }],
qzType: [{ required: true, message: '请选择取值类型', trigger: 'change' }],
resource: [{ required: true, message: '请选择规则类型', trigger: 'change' }],
comparisonType: [{ required: true, message: '请选择对比类型', trigger: 'change' }],
ruleType: [{ required: true, message: '请选择规则类型', trigger: 'change' }],
abnormalDescription: [
{
required: true,
@ -320,19 +350,28 @@
//
const btnClick = () => {
console.log(infoObject.value, '数据');
infoObject.value.alarmList.forEach((item) => {
if (item.logic === null || item.num === null) {
return;
}
});
if (infoObject.value.alarmList.length < 2) {
NsMessage.error('请选择逻辑和数值');
return;
}
//
formRef.value.validate().then(() => {
console.log(energyAlarm.value, '数据');
//
let data = { ...infoObject.value };
//id
data.equipmentAlarmId = energyAlarm.value.id;
data.errorCode = energyAlarm.value.errorCode;
data.dataSourcesType = data.sbtype[0];
data.dataSourcesWay = data.sbtype[1];
data.hxAlarmRuleLogicList = [...infoObject.value.alarmList, ...delAlarmList.value];
data.comparisonType = data.comparisonType.toString;
data.hxAlarmRuleLogicList.forEach((item) => {
const num = Number(item.num);
if (!isNaN(num)) {
@ -343,19 +382,25 @@
});
data.ruleType = Number(data.ruleType);
delete data.alarmList;
});
//
// http
// .post(props.api, data)
// .then(() => {
// isLoading.value = false;
// NsMessage.success('', 1, () => {
// navigateBack();
// });
// .post(energyAlarms.configAddOrUpNewData, data)
// .then((res) => {
// if (res.msg === 'success') {
// //
// if (data.id) {
// NsMessage.success('');
// } else {
// NsMessage.success('');
// }
// emit('editObject', null);
// handleClose();
// }
// })
// .catch(() => {
// isLoading.value = false;
// .catch((error) => {
// //
// console.error('', error);
// });
});
};
//
const handleClose = () => {
@ -365,8 +410,8 @@
infoObject.value = {
id: null,
site: null,
resource: null,
jdDevice: null,
ruleType: null,
deviceNode: null,
abnormalDescription: null,
sbtype: null,
enableRules: 0,
@ -384,7 +429,7 @@
}
};
//
const deleteAlarmList = (index: num) => {
const deleteAlarmList = (index: number) => {
if (index < infoObject.value.alarmList.length && index >= 0) {
const alarmItemToDelete = infoObject.value.alarmList[index];
if (alarmItemToDelete?.id) {
@ -398,7 +443,6 @@
defineExpose({
toggle,
handleClose,
dwOptions,
formRef,
});
</script>

64
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/energyAlarm/editeEnergyAlarm.vue

@ -26,14 +26,11 @@
import { ref } from 'vue';
import { NsMessage } from '/nerv-lib/component';
import { http } from '/nerv-lib/util';
// import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms';
import { dict } from '/@/api';
import { energyAlarms } from '/@/api/alarmSettings/energyAlarm';
const visible = ref(false);
//
const infoObject = ref({
id: null,
accountNo: null,
enableRules: 0,
});
const formRef = ref();
@ -44,8 +41,6 @@
infoObject.value = value;
} else {
infoObject.value = {
id: null,
accountNo: null,
enableRules: 0,
};
}
@ -145,9 +140,9 @@
},
},
{
field: 'priority',
field: 'monitorFrequency',
label: '监测频率',
component: 'nsSelectApi',
component: 'NsSelect',
rules: [
{
required: true,
@ -156,14 +151,30 @@
},
],
componentProps: {
api: () => dict({ params: { dicKey: 'ENERGY_TYPE' } }),
// params: { dicKey: 'ENERGY_TYPE' },
immediate: true,
// resultField: 'data.ENERGY_TYPE',
labelField: 'cnValue',
valueField: 'cnValue',
placeholder: '请选择能耗种类',
autoSelectFirst: true,
allowClear: true,
placeholder: '请选择优先级',
options: [
{
label: '小时',
value: 1,
},
{
label: '每日',
value: 2,
},
{
label: '每周',
value: 3,
},
{
label: '月度',
value: 4,
},
{
label: '年度',
value: 5,
},
],
},
},
],
@ -185,24 +196,21 @@
//
formRef.value.triggerSubmit().then(() => {
//
// http.post(deviceAlarms.addOrUpNewData, infoObject.value).then(() => {
// NsMessage.success('');
// visible.value = false;
// emit('editObject', null);
// });
// if (infoObject.value.id) {
// NsMessage.success('');
// } else {
// NsMessage.success('');
// }
http.post(energyAlarms.addOrUpNewData, infoObject.value).then(() => {
emit('editObject', null);
if (infoObject.value.id) {
NsMessage.success('告警编辑成功');
} else {
NsMessage.success('告警创建成功');
}
handleClose();
});
});
};
const handleClose = () => {
//
formRef.value.formElRef.clearValidate();
infoObject.value = {
id: null,
accountNo: null,
enableRules: 0,
};
visible.value = false;

9
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/configureDeviceAlarms.vue

@ -11,9 +11,6 @@
}"
@click="clickSwitch({ enableRules: record.enableRules, record: record })" />
</template>
<!-- <template v-if="column.dataIndex === 'equipmentInfo'">
{{ record.site + '>' + record.deviceType + '>' + record.deviceName }}
</template> -->
</template>
</ns-view-list-table>
<!-- 新增or编辑界面 -->
@ -46,7 +43,7 @@
NsModal.confirm({
title: '启用状态',
icon: createVNode(ExclamationCircleOutlined),
content: '确定' + (data.record.enableRules === 1 ? '关闭' : '启用') + '吗?',
content: '确定' + (data.record.enableRules === 1 ? '关闭' : '启用') + '规则吗?',
onOk: () => {
http
.post(deviceAlarms.configAddOrUpNewData, {
@ -54,7 +51,7 @@
enableRules: data.record.enableRules === 1 ? 0 : 1,
})
.then(() => {
NsMessage.success('操作成功');
NsMessage.success(data.record.enableRules === 1 ? '规则已关闭' : '规则已启用');
mainRef.value?.nsTableRef.reload();
});
},
@ -193,7 +190,7 @@
confirm: true,
handle: () => {
http.post(deviceAlarms.configDel, { ids: data.id }).then(() => {
NsMessage.success('操作成功');
NsMessage.success('规则删除成功');
mainRef.value?.nsTableRef.reload();
});
},

3
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/editConfigureDeviceAlarm.vue

@ -79,8 +79,7 @@
v-model:value="infoObject.valueType"
placeholder="请选择取值类型"
style="width: 100%"
:options="qzOptions"
@change="handleQzChange" />
:options="qzOptions" />
</a-form-item>
<a-form-item label="异常描述" name="abnormalDescription">
<a-textarea

19
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/index.vue

@ -74,7 +74,7 @@
'grey-background': record.enableRules === 1 ? false : true,
}"
@click="
clickSwitch({ type: 2, enableRules: record.enableRules, record: record })
clickSwitch({ type: 3, enableRules: record.enableRules, record: record })
" />
</template>
</template>
@ -107,6 +107,7 @@
import configureEnergyAlarms from './energyAlarm/configureEnergyAlarms.vue';
import configureDeviceAlarms from './equipmentAlarm/configureDeviceAlarms.vue';
import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms';
import { energyAlarms } from '/@/api/alarmSettings/energyAlarm';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
export default {
@ -133,7 +134,7 @@
//
const energyAlarmConfig = energyAlarmConfigs(
editeEnergyAlarm,
mainRefEquipmentAlarm,
mainEnergyAlarmConfig,
energyAlarm,
configureEnergyAlarms,
);
@ -157,7 +158,11 @@
NsModal.confirm({
title: '启用状态',
icon: createVNode(ExclamationCircleOutlined),
content: '确定' + (data.record.enableRules === 1 ? '关闭' : '启用') + '吗?',
content:
'确定' +
(data.record.enableRules === 1 ? '关闭' : '启用') +
(data.type === 1 ? '通知' : '告警') +
'吗?',
onOk: () => {
if (data.type === 1) {
//
@ -167,7 +172,7 @@
enableRules: data.record.enableRules === 1 ? 0 : 1,
})
.then(() => {
NsMessage.success('操作成功');
NsMessage.success(data.record.enableRules === 1 ? '通知已关闭' : '通知已启用');
mainRef.value?.nsTableRef.reload();
});
}
@ -179,19 +184,19 @@
enableRules: data.record.enableRules === 1 ? 0 : 1,
})
.then(() => {
NsMessage.success('操作成功');
NsMessage.success(data.record.enableRules === 1 ? '告警已关闭' : '告警已启用');
mainRefEquipmentAlarm.value?.nsTableRef.reload();
});
}
//
if (data.type === 3) {
http
.post(deviceAlarms.addOrUpNewData, {
.post(energyAlarms.addOrUpNewData, {
id: data.record.id,
enableRules: data.record.enableRules === 1 ? 0 : 1,
})
.then(() => {
NsMessage.success('操作成功');
NsMessage.success(data.record.enableRules === 1 ? '告警已关闭' : '告警已启用');
mainEnergyAlarmConfig.value?.nsTableRef.reload();
});
}

21
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/ts/energyAlarmConfig.ts

@ -1,9 +1,7 @@
import data from '../notificationManagementMock.json';
import { http } from '/nerv-lib/util';
import { NsMessage } from '/nerv-lib/component';
import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms';
import { energyAlarms } from '/@/api/alarmSettings/energyAlarm';
import { ref } from 'vue';
const tableKeyMap = [
{
title: '序号',
@ -31,14 +29,13 @@ const tableKeyMap = [
},
{
title: '监测时长',
dataIndex: 'monitor',
dataIndex: 'monitorFrequency',
},
{
title: '是否启用',
dataIndex: 'enableRules',
},
];
const mockData = ref(data.listData);
const doWnload = (url: any) => {
const a = document.createElement('a');
document.body.appendChild(a);
@ -51,14 +48,13 @@ const doWnload = (url: any) => {
export const energyAlarmConfigs = (
editeEnergyAlarm: any,
mainRefEquipmentAlarm: any,
mainEnergyAlarmConfig: any,
energyAlarm: any,
configureDeviceAlarms: any,
) => {
return {
title: '告警规则',
api: deviceAlarms.getTableList,
value: mockData.value,
api: energyAlarms.getTableList,
headerActions: [
{
label: '新增',
@ -73,7 +69,6 @@ export const energyAlarmConfigs = (
name: 'groupImport',
type: 'primary',
extra: {
// api: props.postImportApi, // 导入接口名
title: '设备信息', // 弹窗title
templateName: 'whiteListUser', // 所使用的文件名称
indexName: '设备id', // 匹配类型字段
@ -122,9 +117,9 @@ export const energyAlarmConfigs = (
dynamicParams: ['uuid', 'appealType'],
confirm: true,
handle: (data: any) => {
http.post(deviceAlarms.del, { id: data.id }).then(() => {
http.post(energyAlarms.del, { id: data.id }).then(() => {
NsMessage.success('操作成功');
mainRefEquipmentAlarm.value?.nsTableRef.reload();
mainEnergyAlarmConfig.value?.nsTableRef.reload();
});
},
},
@ -139,6 +134,7 @@ export const energyAlarmConfigs = (
component: 'NsSelect',
componentProps: {
placeholder: '请选择告警优先级',
allowClear: true,
options: [
{
label: '紧急',
@ -160,6 +156,7 @@ export const energyAlarmConfigs = (
label: '告警标题',
component: 'NsInput',
componentProps: {
allowClear: true,
placeholder: '请输入告警标题关键字',
},
},
@ -168,6 +165,7 @@ export const energyAlarmConfigs = (
label: '错误码',
component: 'NsInput',
componentProps: {
allowClear: true,
placeholder: '请输入告警错误码',
},
},
@ -176,6 +174,7 @@ export const energyAlarmConfigs = (
label: '启用状态',
component: 'NsSelect',
componentProps: {
allowClear: true,
placeholder: '请选择启用状态',
options: [
{

Loading…
Cancel
Save