Browse Source

fix:能源告警配置

temp
zhaohy 4 months ago
parent
commit
042fc8f16f
  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>
</div> </div>
<div style="flex: 4; width: 100%">2</div> <div style="flex: 4; width: 100%; display: flex; gap: 5px">
<div style="flex: 4; width: 100%">3</div> <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> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, onMounted } from 'vue'; // Vue refonMounted watchEffect import { ref, onMounted } from 'vue'; // Vue refonMounted watchEffect
import * as echarts from 'echarts';
defineOptions({ defineOptions({
name: 'alarmOverview', // name name: 'alarmOverview', // name
}); });
const info = ref({}); 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> </script>
<style lang="less" scoped> <style lang="less" scoped>
.box { .box {

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

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

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

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

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

@ -26,14 +26,11 @@
import { ref } from 'vue'; import { ref } from 'vue';
import { NsMessage } from '/nerv-lib/component'; import { NsMessage } from '/nerv-lib/component';
import { http } from '/nerv-lib/util'; import { http } from '/nerv-lib/util';
// import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms'; import { energyAlarms } from '/@/api/alarmSettings/energyAlarm';
import { dict } from '/@/api';
const visible = ref(false); const visible = ref(false);
// //
const infoObject = ref({ const infoObject = ref({
id: null,
accountNo: null,
enableRules: 0, enableRules: 0,
}); });
const formRef = ref(); const formRef = ref();
@ -44,8 +41,6 @@
infoObject.value = value; infoObject.value = value;
} else { } else {
infoObject.value = { infoObject.value = {
id: null,
accountNo: null,
enableRules: 0, enableRules: 0,
}; };
} }
@ -145,9 +140,9 @@
}, },
}, },
{ {
field: 'priority', field: 'monitorFrequency',
label: '监测频率', label: '监测频率',
component: 'nsSelectApi', component: 'NsSelect',
rules: [ rules: [
{ {
required: true, required: true,
@ -156,14 +151,30 @@
}, },
], ],
componentProps: { componentProps: {
api: () => dict({ params: { dicKey: 'ENERGY_TYPE' } }), allowClear: true,
// params: { dicKey: 'ENERGY_TYPE' }, placeholder: '请选择优先级',
immediate: true, options: [
// resultField: 'data.ENERGY_TYPE', {
labelField: 'cnValue', label: '小时',
valueField: 'cnValue', value: 1,
placeholder: '请选择能耗种类', },
autoSelectFirst: true, {
label: '每日',
value: 2,
},
{
label: '每周',
value: 3,
},
{
label: '月度',
value: 4,
},
{
label: '年度',
value: 5,
},
],
}, },
}, },
], ],
@ -185,24 +196,21 @@
// //
formRef.value.triggerSubmit().then(() => { formRef.value.triggerSubmit().then(() => {
// //
// http.post(deviceAlarms.addOrUpNewData, infoObject.value).then(() => { http.post(energyAlarms.addOrUpNewData, infoObject.value).then(() => {
// NsMessage.success(''); emit('editObject', null);
// visible.value = false; if (infoObject.value.id) {
// emit('editObject', null); NsMessage.success('告警编辑成功');
// }); } else {
// if (infoObject.value.id) { NsMessage.success('告警创建成功');
// NsMessage.success(''); }
// } else { handleClose();
// NsMessage.success(''); });
// }
}); });
}; };
const handleClose = () => { const handleClose = () => {
// //
formRef.value.formElRef.clearValidate(); formRef.value.formElRef.clearValidate();
infoObject.value = { infoObject.value = {
id: null,
accountNo: null,
enableRules: 0, enableRules: 0,
}; };
visible.value = false; 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 })" /> @click="clickSwitch({ enableRules: record.enableRules, record: record })" />
</template> </template>
<!-- <template v-if="column.dataIndex === 'equipmentInfo'">
{{ record.site + '>' + record.deviceType + '>' + record.deviceName }}
</template> -->
</template> </template>
</ns-view-list-table> </ns-view-list-table>
<!-- 新增or编辑界面 --> <!-- 新增or编辑界面 -->
@ -46,7 +43,7 @@
NsModal.confirm({ NsModal.confirm({
title: '启用状态', title: '启用状态',
icon: createVNode(ExclamationCircleOutlined), icon: createVNode(ExclamationCircleOutlined),
content: '确定' + (data.record.enableRules === 1 ? '关闭' : '启用') + '吗?', content: '确定' + (data.record.enableRules === 1 ? '关闭' : '启用') + '规则吗?',
onOk: () => { onOk: () => {
http http
.post(deviceAlarms.configAddOrUpNewData, { .post(deviceAlarms.configAddOrUpNewData, {
@ -54,7 +51,7 @@
enableRules: data.record.enableRules === 1 ? 0 : 1, enableRules: data.record.enableRules === 1 ? 0 : 1,
}) })
.then(() => { .then(() => {
NsMessage.success('操作成功'); NsMessage.success(data.record.enableRules === 1 ? '规则已关闭' : '规则已启用');
mainRef.value?.nsTableRef.reload(); mainRef.value?.nsTableRef.reload();
}); });
}, },
@ -193,7 +190,7 @@
confirm: true, confirm: true,
handle: () => { handle: () => {
http.post(deviceAlarms.configDel, { ids: data.id }).then(() => { http.post(deviceAlarms.configDel, { ids: data.id }).then(() => {
NsMessage.success('操作成功'); NsMessage.success('规则删除成功');
mainRef.value?.nsTableRef.reload(); mainRef.value?.nsTableRef.reload();
}); });
}, },

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

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

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

@ -74,7 +74,7 @@
'grey-background': record.enableRules === 1 ? false : true, 'grey-background': record.enableRules === 1 ? false : true,
}" }"
@click=" @click="
clickSwitch({ type: 2, enableRules: record.enableRules, record: record }) clickSwitch({ type: 3, enableRules: record.enableRules, record: record })
" /> " />
</template> </template>
</template> </template>
@ -107,6 +107,7 @@
import configureEnergyAlarms from './energyAlarm/configureEnergyAlarms.vue'; import configureEnergyAlarms from './energyAlarm/configureEnergyAlarms.vue';
import configureDeviceAlarms from './equipmentAlarm/configureDeviceAlarms.vue'; import configureDeviceAlarms from './equipmentAlarm/configureDeviceAlarms.vue';
import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms'; import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms';
import { energyAlarms } from '/@/api/alarmSettings/energyAlarm';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'; import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
export default { export default {
@ -133,7 +134,7 @@
// //
const energyAlarmConfig = energyAlarmConfigs( const energyAlarmConfig = energyAlarmConfigs(
editeEnergyAlarm, editeEnergyAlarm,
mainRefEquipmentAlarm, mainEnergyAlarmConfig,
energyAlarm, energyAlarm,
configureEnergyAlarms, configureEnergyAlarms,
); );
@ -157,7 +158,11 @@
NsModal.confirm({ NsModal.confirm({
title: '启用状态', title: '启用状态',
icon: createVNode(ExclamationCircleOutlined), icon: createVNode(ExclamationCircleOutlined),
content: '确定' + (data.record.enableRules === 1 ? '关闭' : '启用') + '吗?', content:
'确定' +
(data.record.enableRules === 1 ? '关闭' : '启用') +
(data.type === 1 ? '通知' : '告警') +
'吗?',
onOk: () => { onOk: () => {
if (data.type === 1) { if (data.type === 1) {
// //
@ -167,7 +172,7 @@
enableRules: data.record.enableRules === 1 ? 0 : 1, enableRules: data.record.enableRules === 1 ? 0 : 1,
}) })
.then(() => { .then(() => {
NsMessage.success('操作成功'); NsMessage.success(data.record.enableRules === 1 ? '通知已关闭' : '通知已启用');
mainRef.value?.nsTableRef.reload(); mainRef.value?.nsTableRef.reload();
}); });
} }
@ -179,19 +184,19 @@
enableRules: data.record.enableRules === 1 ? 0 : 1, enableRules: data.record.enableRules === 1 ? 0 : 1,
}) })
.then(() => { .then(() => {
NsMessage.success('操作成功'); NsMessage.success(data.record.enableRules === 1 ? '告警已关闭' : '告警已启用');
mainRefEquipmentAlarm.value?.nsTableRef.reload(); mainRefEquipmentAlarm.value?.nsTableRef.reload();
}); });
} }
// //
if (data.type === 3) { if (data.type === 3) {
http http
.post(deviceAlarms.addOrUpNewData, { .post(energyAlarms.addOrUpNewData, {
id: data.record.id, id: data.record.id,
enableRules: data.record.enableRules === 1 ? 0 : 1, enableRules: data.record.enableRules === 1 ? 0 : 1,
}) })
.then(() => { .then(() => {
NsMessage.success('操作成功'); NsMessage.success(data.record.enableRules === 1 ? '告警已关闭' : '告警已启用');
mainEnergyAlarmConfig.value?.nsTableRef.reload(); 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 { http } from '/nerv-lib/util';
import { NsMessage } from '/nerv-lib/component'; import { NsMessage } from '/nerv-lib/component';
import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms'; import { energyAlarms } from '/@/api/alarmSettings/energyAlarm';
import { ref } from 'vue';
const tableKeyMap = [ const tableKeyMap = [
{ {
title: '序号', title: '序号',
@ -31,14 +29,13 @@ const tableKeyMap = [
}, },
{ {
title: '监测时长', title: '监测时长',
dataIndex: 'monitor', dataIndex: 'monitorFrequency',
}, },
{ {
title: '是否启用', title: '是否启用',
dataIndex: 'enableRules', dataIndex: 'enableRules',
}, },
]; ];
const mockData = ref(data.listData);
const doWnload = (url: any) => { const doWnload = (url: any) => {
const a = document.createElement('a'); const a = document.createElement('a');
document.body.appendChild(a); document.body.appendChild(a);
@ -51,14 +48,13 @@ const doWnload = (url: any) => {
export const energyAlarmConfigs = ( export const energyAlarmConfigs = (
editeEnergyAlarm: any, editeEnergyAlarm: any,
mainRefEquipmentAlarm: any, mainEnergyAlarmConfig: any,
energyAlarm: any, energyAlarm: any,
configureDeviceAlarms: any, configureDeviceAlarms: any,
) => { ) => {
return { return {
title: '告警规则', title: '告警规则',
api: deviceAlarms.getTableList, api: energyAlarms.getTableList,
value: mockData.value,
headerActions: [ headerActions: [
{ {
label: '新增', label: '新增',
@ -73,7 +69,6 @@ export const energyAlarmConfigs = (
name: 'groupImport', name: 'groupImport',
type: 'primary', type: 'primary',
extra: { extra: {
// api: props.postImportApi, // 导入接口名
title: '设备信息', // 弹窗title title: '设备信息', // 弹窗title
templateName: 'whiteListUser', // 所使用的文件名称 templateName: 'whiteListUser', // 所使用的文件名称
indexName: '设备id', // 匹配类型字段 indexName: '设备id', // 匹配类型字段
@ -122,9 +117,9 @@ export const energyAlarmConfigs = (
dynamicParams: ['uuid', 'appealType'], dynamicParams: ['uuid', 'appealType'],
confirm: true, confirm: true,
handle: (data: any) => { handle: (data: any) => {
http.post(deviceAlarms.del, { id: data.id }).then(() => { http.post(energyAlarms.del, { id: data.id }).then(() => {
NsMessage.success('操作成功'); NsMessage.success('操作成功');
mainRefEquipmentAlarm.value?.nsTableRef.reload(); mainEnergyAlarmConfig.value?.nsTableRef.reload();
}); });
}, },
}, },
@ -139,6 +134,7 @@ export const energyAlarmConfigs = (
component: 'NsSelect', component: 'NsSelect',
componentProps: { componentProps: {
placeholder: '请选择告警优先级', placeholder: '请选择告警优先级',
allowClear: true,
options: [ options: [
{ {
label: '紧急', label: '紧急',
@ -160,6 +156,7 @@ export const energyAlarmConfigs = (
label: '告警标题', label: '告警标题',
component: 'NsInput', component: 'NsInput',
componentProps: { componentProps: {
allowClear: true,
placeholder: '请输入告警标题关键字', placeholder: '请输入告警标题关键字',
}, },
}, },
@ -168,6 +165,7 @@ export const energyAlarmConfigs = (
label: '错误码', label: '错误码',
component: 'NsInput', component: 'NsInput',
componentProps: { componentProps: {
allowClear: true,
placeholder: '请输入告警错误码', placeholder: '请输入告警错误码',
}, },
}, },
@ -176,6 +174,7 @@ export const energyAlarmConfigs = (
label: '启用状态', label: '启用状态',
component: 'NsSelect', component: 'NsSelect',
componentProps: { componentProps: {
allowClear: true,
placeholder: '请选择启用状态', placeholder: '请选择启用状态',
options: [ options: [
{ {

Loading…
Cancel
Save