fix:能源告警配置
This commit is contained in:
9
hx-ai-intelligent/src/api/alarmSettings/energyAlarm.ts
Normal file
9
hx-ai-intelligent/src/api/alarmSettings/energyAlarm.ts
Normal file
@@ -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', //配置设备告警删除
|
||||
}
|
@@ -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 中导入 ref、onMounted 和 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 {
|
||||
|
@@ -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: '告警点位',
|
||||
|
@@ -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(energyAlarms.configAddOrUpNewData, data)
|
||||
// .then((res) => {
|
||||
// if (res.msg === 'success') {
|
||||
// // 操作成功时的处理
|
||||
// if (data.id) {
|
||||
// NsMessage.success('告警规则编辑成功');
|
||||
// } else {
|
||||
// NsMessage.success('告警规则新增成功');
|
||||
// }
|
||||
// emit('editObject', null);
|
||||
// handleClose();
|
||||
// }
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// // 错误处理
|
||||
// console.error('请求失败:', error);
|
||||
// });
|
||||
});
|
||||
//调用接口
|
||||
// http
|
||||
// .post(props.api, data)
|
||||
// .then(() => {
|
||||
// isLoading.value = false;
|
||||
// NsMessage.success('操作成功', 1, () => {
|
||||
// navigateBack();
|
||||
// });
|
||||
// })
|
||||
// .catch(() => {
|
||||
// isLoading.value = false;
|
||||
// });
|
||||
};
|
||||
//取消按钮
|
||||
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>
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
});
|
||||
},
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
});
|
||||
}
|
||||
|
@@ -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: [
|
||||
{
|
||||
|
Reference in New Issue
Block a user