Browse Source

add:配置设备告警对接接口 对接告警配置 里面的数据来源 设备节点

temp
zhaohy 5 months ago
parent
commit
de7a0ab88a
  1. 6
      hx-ai-intelligent/src/api/alarmSettings/deviceAlarms.ts
  2. 54
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/energyAlarm/configureEnergyAlarms.vue
  3. 342
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/energyAlarm/editConfigureEnergyAlarm.vue
  4. 50
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/energyAlarm/editeEnergyAlarm.vue
  5. 121
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/configureDeviceAlarms.vue
  6. 254
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/editConfigureDeviceAlarm.vue
  7. 20
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/editeEquipmentAlarm.vue
  8. 89
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/index.vue
  9. 246
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/notificationManagement/index.vue
  10. 6
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/ts/equipmentAlarmConfig.ts
  11. 4
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/ts/notificationManagementConfig.ts

6
hx-ai-intelligent/src/api/alarmSettings/deviceAlarms.ts

@ -1,5 +1,9 @@
export enum deviceAlarms {
getTableList = '/carbon-smart/api/AlarmEquipment/selectAlarmEquipment', //设备告警分页
addOrUpNewData = '/carbon-smart/api/AlarmEquipment/creatOrUpdate', //设备告警添加 修
addOrUpNewData = '/carbon-smart/api/AlarmEquipment/creatOrUpdate', //设备告警添加 修
del = '/carbon-smart/api/AlarmEquipment/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', //配置设备告警删除
}

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

@ -31,18 +31,23 @@
import editConfigureEnergyAlarm from './editConfigureEnergyAlarm.vue';
import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { device } from '/@/api/deviceManage';
export default {
components: { editConfigureEnergyAlarm },
setup() {
//
const configureDeviceAlarmsData = ref({});
//
const configureEnergyAlarmsData = ref({});
const show = ref(false);
const tableConfig = ref({});
const mainRef = ref({});
const editConfigureEnergyAlarms = ref({});
const mockData = ref(data.listData);
//
const orgId = ref('');
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result;
const clickSwitch = (data: any) => {
NsModal.confirm({
title: '启用状态',
@ -71,7 +76,7 @@
a.click();
};
const setconfigureDeviceAlarmsData = (value: any) => {
configureDeviceAlarmsData.value = value;
configureEnergyAlarmsData.value = value;
show.value = true;
tableConfig.value = {
title: '告警规则',
@ -83,7 +88,7 @@
name: 'RoleTypeAdd',
type: 'primary',
handle: () => {
editConfigureEnergyAlarms.value.toggle();
editConfigureEnergyAlarms.value.toggle(null, configureEnergyAlarmsData.value.va);
},
},
{
@ -172,7 +177,7 @@
name: 'FeedBackDetail',
dynamicParams: ['uuid', 'appealType'],
handle: (data: any) => {
editConfigureEnergyAlarms.value.toggle(data);
editConfigureEnergyAlarms.value.toggle(data, configureEnergyAlarmsData.value);
},
},
{
@ -190,29 +195,37 @@
title: value.errorCode,
schemas: [
{
field: 'provider',
field: 'deviceName',
label: '设备名称',
component: 'NsInput',
component: 'nsSelectApi',
componentProps: {
placeholder: '请输入设备名称',
api: device.queryDevicePage,
params: {
orgId: orgId.value,
pageNum: 1,
pageSize: 99,
},
placeholder: '请选择设备名称',
resultField: 'data.records',
labelField: 'deviceName',
valueField: 'id',
autoAddLink: true, //
},
},
{
field: 'provider',
field: 'devicePoint',
label: '设备点位',
component: 'nsSelectApi',
dynamicParams: {
id: 'deviceName', //
},
componentProps: {
api: '/api/community/objs/DictItem',
params: {
pageSize: 100,
code: 'MZ',
},
placeholder: '请选择设备点位',
api: device.queryDevicePoint,
resultField: 'data',
labelField: 'dictName',
valueField: 'dictValue',
immediate: true,
autoSelectFirst: false,
placeholder: '请选择设备点位',
labelField: 'code',
valueField: 'id',
dependency: 'deviceName',
},
},
{
@ -249,10 +262,11 @@
};
};
return {
configureDeviceAlarmsData,
configureEnergyAlarmsData,
show,
clickSwitch,
doWnload,
orgId,
tableConfig,
editConfigureEnergyAlarms,
setconfigureDeviceAlarmsData,

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

@ -6,6 +6,7 @@
:footer-style="{ textAlign: 'right' }"
:ok="btnClick"
:cancel="handleClose"
@close="handleClose"
placement="right">
<div style="padding: 18px; width: 100%; overflow: hidden">
<a-form ref="formRef" :model="infoObject" :rules="rules">
@ -18,41 +19,54 @@
placeholder="请选择站点"
allow-clear
tree-default-expand-all
:tree-data="zdTreeData"
tree-node-filter-prop="label">
<!-- 特殊处理情况 -->
<!-- <template #title="{ value: val, label }">
<b v-if="val === 'parent 1-1'" style="color: #08c">sss</b>
<template v-else>{{ label }}</template>
</template> -->
</a-tree-select>
:tree-data="siteDataTree"
:field-names="{
children: 'linkList',
label: 'orgName',
value: 'orgId',
}"
tree-node-filter-prop="orgName" />
</a-form-item>
<a-form-item label="数据来源" name="sbtype">
<a-cascader
v-model:value="infoObject.sbtype"
:options="sbOptions"
:show-search="{ filter }"
:options="deviceTypeTreeData"
:field-names="{
children: 'children',
label: 'cnValue',
value: 'id',
}"
:show-search="{ filterDeviceType }"
@change="selectDeviceType"
placeholder="请选择数据来源" />
</a-form-item>
<a-form-item label="设备节点" name="jdDevice">
<a-form-item label="设备/节点" name="jdDevice">
<a-tree-select
v-model:value="infoObject.jdDevice"
style="width: 100%"
placeholder="请选择设备节点"
:disabled="!infoObject.sbtype"
:tree-line="true && { showLeafIcon: false }"
:tree-data="jdTreeData" />
:tree-data="jdTreeData"
:field-names="{
children: 'children',
label: infoObject.sbtype && infoObject.sbtype[1] === 1 ? 'deviceName' : 'pointName',
value: 'id',
}"
@select="selectJdDeviceChange" />
</a-form-item>
<a-form-item label="启用规则" name="delivery">
<a-form-item label="启用规则" name="enableRules">
<a-switch
v-model:checked="infoObject.delivery"
:checked="infoObject.enableRules === 1 ? true : false"
:class="{
'blue-background': infoObject.delivery,
'grey-background': !infoObject.delivery,
}" />
'blue-background': infoObject.enableRules === 1 ? true : false,
'grey-background': infoObject.enableRules === 1 ? false : true,
}"
@click="clickSwitch" />
</a-form-item>
<a-form-item label="异常描述" name="desc">
<a-form-item label="异常描述" name="abnormalDescription">
<a-textarea
v-model:value="infoObject.desc"
v-model:value="infoObject.abnormalDescription"
style="height: 32px"
:autoSize="{ minRows: 1, maxRows: 1 }"
show-count
@ -64,11 +78,12 @@
<a-radio value="2"> (or) </a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="对比类型1" name="qzType">
<a-form-item label="对比类型" name="qzType">
<a-cascader
v-model:value="infoObject.sbtype"
:options="sbOptions"
placeholder="请选择数据来源" />
:options="deviceTypeTreeData"
:showSearch="false"
placeholder="请选择对比类型" />
</a-form-item>
<template v-for="index in infoObject.alarmList?.length" :key="index">
<div style="width: 100%; display: flex; margin-left: 42px; padding: 12px">
@ -93,8 +108,8 @@
</div>
<div
v-if="
infoObject.alarmList[index - 1].num === null ||
infoObject.alarmList[index - 1].logic === null
infoObject.alarmList[index - 1]?.num === null ||
infoObject.alarmList[index - 1]?.logic === null
"
style="width: 100%; color: #ff4d4f; text-align: center; margin-bottom: 5px">
请选择正确的逻辑{{ index }} 输入正确的数值{{ index }}
@ -114,121 +129,88 @@
</template>
<script lang="ts" setup>
import { NsMessage } from '/nerv-lib/component';
import { ref, toRaw } from 'vue';
import type { CascaderProps, TreeSelectProps, SelectProps } from 'ant-design-vue';
import { ref } from 'vue';
import type { SelectProps } from 'ant-design-vue';
import type { ShowSearchType } from 'ant-design-vue/es/cascader';
import { device } from '/@/api/deviceManage';
import { device, group } from '/@/api/deviceManage';
import { http } from '/nerv-lib/util';
import { dict } from '/@/api';
import { async } from '@antv/x6/lib/registry/marker/async';
import type { Rule } from 'ant-design-vue/es/form';
// import type { Rule } from 'ant-design-vue/es/form';
const visible = ref(false);
//
const energyAlarm = ref({});
//
const orgId = ref('');
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result;
//
const infoObject = ref({
id: null,
site: null,
jdDevice: null,
resource: null,
desc: null,
abnormalDescription: null,
sbtype: null,
delivery: null,
alarmList: [{ logic: null, num: null }],
enableRules: 0,
alarmList: [{ id: null, logic: null, num: null, isDelete: 0 }],
});
//
const delAlarmList = ref([]);
const formRef = ref();
//
const zdTreeData = ref<TreeSelectProps['treeData']>([
{
label: '铁路总局(T01)',
value: 'T01',
children: [
{
label: '济阳站(T0101)',
value: 'T0101',
},
],
},
]);
//
const sbOptions: CascaderProps['options'] = [
{
value: '3',
label: '3.电梯',
children: [
{
value: '301',
label: '301.扶梯',
},
{
value: '302',
label: '301.直梯',
},
],
},
{
value: '4',
label: '4.冷热源',
children: [
{
value: '401',
label: '402.冷水机组',
},
{
value: '402',
label: '403.热泵机组',
},
{
value: '403',
label: '403.锅炉',
},
{
value: '404',
label: '404.水处理机组',
},
{
value: '405',
label: '405.板式热交换机组',
},
],
},
];
const siteDataTree = ref([]);
//
let deviceTypeTreeData = ref([]);
//
const jdTreeData = ref([
{
title: 'parent 1',
value: 'parent 1',
children: [
{
title: 'parent 1-0',
value: 'parent 1-0',
children: [
{
title: 'my leaf',
value: 'leaf1',
},
{
title: 'your leaf',
value: 'leaf2',
},
],
},
{
title: 'parent 1-1',
value: 'parent 1-1',
},
],
},
]);
const jdTreeData = ref([]);
//
//
const selectDeviceType = async (value: any, selectedOptions: any) => {
if (value[value.length - 1] === 1) {
//
await http
.post(device.queryDevicePage, {
pageNum: 1,
pageSize: 999,
energyType: selectedOptions[0].cnValue,
orgId: orgId.value,
})
.then((res) => {
jdTreeData.value = res.data.records;
});
} else {
//
await http
.post(group.queryDeviceGroupTree, {
pageNum: 1,
pageSize: 999,
energyType: selectedOptions[0].cnValue,
orgId: orgId.value,
})
.then((res) => {
jdTreeData.value = res.data;
});
}
};
//
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 filter: ShowSearchType['filter'] = (inputValue: any, path: any) => {
//
const filterDeviceType: ShowSearchType['filter'] = (inputValue: any, path: any) => {
return path.some(
(option: any) => option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1,
(option: any) => option.cnValue.toLowerCase().indexOf(inputValue.toLowerCase()) > -1,
);
};
//
@ -238,30 +220,17 @@
]);
//
const ljOptions = ref<SelectProps['options']>([
{ value: '1', label: '≥' },
{ value: '2', label: '>' },
{ value: '3', label: '≤' },
{ value: '4', label: '<' },
{ value: '5', label: '=' },
{ value: 0, label: '≥' },
{ value: 1, label: '>' },
{ value: 2, label: '≤' },
{ 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 handleFocus = () => {
console.log('点击');
};
const handleChange = (value: string) => {
console.log(`selected ${value}`);
console.log('选择', infoObject.value.sbAdress);
//code
dwOptions.value.forEach((item) => {
if (item.value === value) {
console.log('符合', item.code);
}
});
};
const handleQzChange = (value: string) => {
//code
qzOptions.value.forEach((item) => {
@ -270,13 +239,39 @@
}
});
};
//
const clickSwitch = () => {
if (infoObject.value.enableRules === 1) {
infoObject.value.enableRules = 0;
} else {
infoObject.value.enableRules = 1;
}
};
const emit = defineEmits(['editObject']);
//
const toggle = (value: any) => {
//
http.post(device.queryDeviceTree, null).then((res) => {
console.log(res, '请求出来的数据');
NsMessage.success('操作成功');
const toggle = async (value: any, info: any) => {
//
let energyType = await dict({ params: { dicKey: 'ENERGY_TYPE' } });
energyType.data.data.forEach((item: any) => {
item.children = [
{
id: 1,
cnValue: '设备',
},
{
id: 2,
cnValue: '节点',
},
];
});
deviceTypeTreeData.value = energyType.data.data;
//
energyAlarm.value = info;
//
http.post('/carbon-smart/user/login/logInInfo', {}).then((res) => {
if (res.msg === 'success') {
siteDataTree.value = res.data.linkList;
}
});
//
if (value) {
@ -287,31 +282,40 @@
site: null,
jdDevice: null,
resource: null,
desc: null,
abnormalDescription: null,
sbtype: null,
delivery: null,
alarmList: [{ logic: null, num: null }],
enableRules: 0,
alarmList: [{ id: null, logic: null, num: null, isDelete: 0 }],
};
}
visible.value = !visible.value;
};
//
const rules: Record<string, Rule[]> = {
const rules = {
site: [{ required: true, message: '请选择站点', trigger: 'change' }],
sbtype: [{ required: true, message: '请选择设备类型', trigger: 'change' }],
delivery: [{ required: true, message: '请选择启用规则', trigger: 'change' }],
enableRules: [{ required: true, message: '请选择启用规则', trigger: 'change' }],
jdDevice: [{ required: true, message: '请选择设备名称', trigger: 'change' }],
sbAdress: [{ required: true, message: '请选择设备点位', trigger: 'change' }],
qzType: [{ required: true, message: '请选择取值类型', trigger: 'change' }],
resource: [{ required: true, message: '请选择规则类型', trigger: 'change' }],
desc: [{ required: true, message: '请输入异常描述', trigger: 'blur' }],
alarm: [{ required: true, message: '请选择逻辑', trigger: 'blur' }],
number: [{ required: true, message: '请输入数值', trigger: 'blur' }],
};
//
const changeSwitch = () => {
console.log(infoObject.value.selectSwitch, '开关');
abnormalDescription: [
{
required: true,
message: '请输入异常描述',
trigger: 'blur',
validator: (rules: any, abnormalDescription: any, cbfn: any) => {
if (abnormalDescription.trim() !== '') {
cbfn();
} else {
cbfn('告警标题不能为空');
}
},
},
],
logic: [{ required: true, message: '请选择逻辑', trigger: 'blur' }],
num: [{ required: true, message: '请输入数值', trigger: 'blur' }],
};
//
const btnClick = () => {
@ -319,18 +323,26 @@
infoObject.value.alarmList.forEach((item) => {
if (item.logic === null || item.num === null) {
// NsMessage.error('');
return;
}
});
if (infoObject.value.alarmList.length < 2) {
NsMessage.error('请选择逻辑和数值');
return;
}
//
formRef.value.validate().then(() => {
console.log('values', infoObject, toRaw(infoObject));
delAlarmList.value = [];
let data = { ...infoObject.value };
data.hxAlarmRuleLogicList = [...infoObject.value.alarmList, ...delAlarmList.value];
data.hxAlarmRuleLogicList.forEach((item) => {
const num = Number(item.num);
if (!isNaN(num)) {
item.num = Number(num.toFixed(2));
} else {
item.num = 0; // 0
}
});
data.ruleType = Number(data.ruleType);
delete data.alarmList;
});
//
// http
@ -354,10 +366,11 @@
id: null,
site: null,
resource: null,
desc: null,
jdDevice: null,
abnormalDescription: null,
sbtype: null,
delivery: null,
alarmList: [{ alarm: null, number: null }],
enableRules: 0,
alarmList: [{ id: null, logic: null, num: null, isDelete: 0 }],
};
visible.value = false;
delAlarmList.value = [];
@ -365,17 +378,22 @@
//
const addAlarmList = () => {
if (infoObject.value.alarmList) {
infoObject.value.alarmList.push({ logic: null, num: null });
infoObject.value.alarmList.push({ id: null, logic: null, num: null, isDelete: 0 });
} else {
infoObject.value.alarmList = [{ logic: null, num: null }];
infoObject.value.alarmList = [{ id: null, logic: null, num: null, isDelete: 0 }];
}
};
//
const deleteAlarmList = (index: number) => {
if (infoObject.value.alarmList[index]?.id) {
delAlarmList.value.push(infoObject.value.alarmList[index]);
const deleteAlarmList = (index: num) => {
if (index < infoObject.value.alarmList.length && index >= 0) {
const alarmItemToDelete = infoObject.value.alarmList[index];
if (alarmItemToDelete?.id) {
// delAlarmList
delAlarmList.value.push({ ...alarmItemToDelete, isDelete: 1 });
}
// infoObject
infoObject.value.alarmList.splice(index, 1);
}
infoObject.value.alarmList.splice(index, 1);
};
defineExpose({
toggle,

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

@ -2,11 +2,12 @@
<ns-drawer
v-model:visible="visible"
width="520"
:title="infoObject?.id ? '修改能源告警' : '新增能源告警'"
:title="' '"
:footer-style="{ textAlign: 'right' }"
:ok="btnClick"
:cancel="handleClose"
placement="right">
placement="right"
@close="handleClose">
<ns-form ref="formRef" :schemas="schemas" :model="infoObject" formLayout="vertical" />
<div style="margin-left: 52px">
应用规则:
@ -26,6 +27,7 @@
import { NsMessage } from '/nerv-lib/component';
import { http } from '/nerv-lib/util';
// import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms';
import { dict } from '/@/api';
const visible = ref(false);
//
@ -67,6 +69,13 @@
required: true,
message: '告警标题不能为空',
trigger: 'change',
validator: (rules: any, alarmTitle: any, cbfn: any) => {
if (alarmTitle && alarmTitle.trim() !== '') {
cbfn();
} else {
cbfn('告警标题不能为空');
}
},
},
],
componentProps: {
@ -138,7 +147,7 @@
{
field: 'priority',
label: '监测频率',
component: 'NsSelect',
component: 'nsSelectApi',
rules: [
{
required: true,
@ -147,21 +156,14 @@
},
],
componentProps: {
allowClear: true,
placeholder: '请选择监测频率',
componentProps: {
api: '/api/community/objs/DictItem',
params: {
pageSize: 100,
code: 'MZ',
},
placeholder: '请选择设备点位',
resultField: 'data',
labelField: 'dictName',
valueField: 'dictValue',
immediate: true,
autoSelectFirst: false,
},
api: () => dict({ params: { dicKey: 'ENERGY_TYPE' } }),
// params: { dicKey: 'ENERGY_TYPE' },
immediate: true,
// resultField: 'data.ENERGY_TYPE',
labelField: 'cnValue',
valueField: 'cnValue',
placeholder: '请选择能耗种类',
autoSelectFirst: true,
},
},
],
@ -188,14 +190,22 @@
// visible.value = false;
// emit('editObject', null);
// });
// if (infoObject.value.id) {
// NsMessage.success('');
// } else {
// NsMessage.success('');
// }
});
};
const handleClose = () => {
//
formRef.value.formElRef.clearValidate();
console.log(infoObject.value);
infoObject.value = {
id: null,
accountNo: null,
enableRules: 0,
};
visible.value = false;
NsMessage.success('操作成功');
};
defineExpose({
toggle,

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

@ -11,26 +11,22 @@
}"
@click="clickSwitch({ enableRules: record.enableRules, record: record })" />
</template>
<template v-if="column.dataIndex === 'equipmentInfo'">
{{
record?.enableRules
? record.enableRules + '>' + record.deviceType + '>' + record.deviceName
: '-'
}}
</template>
<!-- <template v-if="column.dataIndex === 'equipmentInfo'">
{{ record.site + '>' + record.deviceType + '>' + record.deviceName }}
</template> -->
</template>
</ns-view-list-table>
<!-- 新增or编辑界面 -->
<editConfigureDeviceAlarm ref="editConfigureDeviceAlarms" />
<editConfigureDeviceAlarm ref="editConfigureDeviceAlarms" @editObject="editObject" />
</template>
<script lang="ts">
import { ref, createVNode } from 'vue';
import { http } from '/nerv-lib/util';
import data from '../notificationManagementMock.json';
import { NsMessage, NsModal } from '/nerv-lib/component';
import editConfigureDeviceAlarm from '../equipmentAlarm/editConfigureDeviceAlarm.vue';
import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { device } from '/@/api/deviceManage';
export default {
components: { editConfigureDeviceAlarm },
@ -42,7 +38,10 @@
const tableConfig = ref({});
const mainRef = ref({});
const editConfigureDeviceAlarms = ref({});
const mockData = ref(data.listData);
//
const orgId = ref('');
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result;
const clickSwitch = (data: any) => {
NsModal.confirm({
title: '启用状态',
@ -50,7 +49,7 @@
content: '确定' + (data.record.enableRules === 1 ? '关闭' : '启用') + '吗?',
onOk: () => {
http
.post(deviceAlarms.addOrUpNewData, {
.post(deviceAlarms.configAddOrUpNewData, {
id: data.record.id,
enableRules: data.record.enableRules === 1 ? 0 : 1,
})
@ -61,6 +60,10 @@
},
});
};
//
const editObject = () => {
mainRef.value?.nsTableRef.reload();
};
const doWnload = (url: any) => {
const a = document.createElement('a');
document.body.appendChild(a);
@ -75,15 +78,14 @@
show.value = true;
tableConfig.value = {
title: '告警规则',
api: deviceAlarms.getTableList,
value: mockData.value,
api: deviceAlarms.configGetTableList,
headerActions: [
{
label: '新增',
name: 'RoleTypeAdd',
type: 'primary',
handle: () => {
editConfigureDeviceAlarms.value.toggle();
editConfigureDeviceAlarms.value.toggle(null, configureDeviceAlarmsData.value);
},
},
{
@ -113,16 +115,26 @@
},
{
label: '批量删除',
name: 'groupTemDownload',
type: 'primary',
name: 'userBatchDel',
confirm: true,
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
confirm: true,
isReload: true,
isClearCheck: true,
// api: origanizemanage.batchDel,
dynamicParams: { userIds: 'userId[]' },
handle: (data: any) => {
let ids = [];
data.list.forEach((item) => {
ids.push(item.id);
});
data.list = [];
http.post(deviceAlarms.configDel, { ids: ids.toString() }).then(() => {
NsMessage.success('告警规则删除成功');
//
mainRef.value.nsTableRef.clearCheck();
//
mainRef.value?.nsTableRef.reload();
});
},
},
],
columns: [
@ -139,20 +151,19 @@
},
{
title: '设备信息',
dataIndex: 'equipmentInfo',
dataIndex: 'deviceInfo',
},
{
title: '告警点位',
dataIndex: 'devicePoint',
dataIndex: 'devicePointName',
},
{
title: '判断条件',
dataIndex: 'ruleType',
dataIndex: 'conditionalJudgment',
},
{
title: '取值类型',
dataIndex: 'valueType',
textEllipsis: true,
},
{
title: '异常描述',
@ -172,7 +183,7 @@
name: 'FeedBackDetail',
dynamicParams: ['uuid', 'appealType'],
handle: (data: any) => {
editConfigureDeviceAlarms.value.toggle(data);
editConfigureDeviceAlarms.value.toggle(data, configureDeviceAlarmsData);
},
},
{
@ -181,8 +192,10 @@
dynamicParams: ['uuid', 'appealType'],
confirm: true,
handle: () => {
// mockData.value.splice(0, 1);
console.log(data, 'xxxxxxx');
http.post(deviceAlarms.configDel, { ids: data.id }).then(() => {
NsMessage.success('操作成功');
mainRef.value?.nsTableRef.reload();
});
},
},
],
@ -191,60 +204,73 @@
title: value.errorCode,
schemas: [
{
field: 'provider',
field: 'deviceName',
label: '设备名称',
component: 'NsInput',
component: 'nsSelectApi',
componentProps: {
placeholder: '请输入设备名称',
api: device.queryDevicePage,
allowClear: true,
params: {
orgId: orgId.value,
pageNum: 1,
pageSize: 99,
},
placeholder: '请选择设备点位',
resultField: 'data.records',
labelField: 'deviceName',
valueField: 'id',
autoAddLink: true, //
},
},
{
field: 'provider',
field: 'devicePoint',
label: '设备点位',
component: 'nsSelectApi',
dynamicParams: {
id: 'deviceName', //
},
componentProps: {
api: '/api/community/objs/DictItem',
params: {
pageSize: 100,
code: 'MZ',
},
placeholder: '请选择设备点位',
api: device.queryDevicePoint,
allowClear: true,
resultField: 'data',
labelField: 'dictName',
valueField: 'dictValue',
immediate: true,
autoSelectFirst: false,
placeholder: '请选择设备点位',
labelField: 'code',
valueField: 'id',
dependency: 'deviceName',
},
},
{
field: 'payWay',
field: 'enableRules',
label: '启用状态',
component: 'NsSelect',
componentProps: {
placeholder: '请选择启用状态',
allowClear: true,
options: [
{
label: '启用',
value: '1',
value: 1,
},
{
label: '关闭',
value: '0',
value: 0,
},
],
},
},
{
field: 'provider',
field: 'abnormalDescription',
label: '异常描述',
component: 'NsInput',
componentProps: {
allowClear: true,
placeholder: '请输入异常描述关键字',
},
},
],
},
params: { id: value.id },
params: { equipmentAlarmId: value.id },
// pagination: { pageSizeOptions: false },
rowKey: 'id',
};
@ -255,6 +281,9 @@
clickSwitch,
doWnload,
tableConfig,
orgId,
mainRef,
editObject,
editConfigureDeviceAlarms,
setconfigureDeviceAlarmsData,
};

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

@ -6,7 +6,8 @@
:footer-style="{ textAlign: 'right' }"
:ok="btnClick"
:cancel="handleClose"
placement="right">
placement="right"
@close="handleClose">
<div style="padding: 18px; width: 100%; overflow: hidden">
<a-form ref="formRef" :model="infoObject" :rules="rules">
<a-form-item ref="site" label="站点" name="site">
@ -18,8 +19,13 @@
placeholder="请选择站点"
allow-clear
tree-default-expand-all
:tree-data="zdTreeData"
tree-node-filter-prop="label" />
:field-names="{
children: 'linkList',
label: 'orgName',
value: 'orgId',
}"
:tree-data="siteDataTree"
tree-node-filter-prop="orgName" />
</a-form-item>
<a-form-item label="设备类型" name="deviceType">
<a-cascader
@ -30,7 +36,7 @@
label: 'deviceType',
value: 'id',
}"
:show-search="{ filter }"
:show-search="{ filterDeviceType }"
@change="selectDeviceType"
placeholder="请选择设备类型" />
</a-form-item>
@ -54,14 +60,12 @@
v-model:value="infoObject.devicePoint"
show-search
placeholder="请选择设备点位"
:disabled="!infoObject?.deviceName"
style="width: 100%"
:options="dwOptions"
:filter-option="filterOption"
@focus="handleFocus"
@change="handleChange" />
:disabled="!infoObject?.deviceName"
:options="devicePointData"
:filter-option="filterDevicePoint" />
</a-form-item>
<a-form-item label="启用规则" name="enableRules">
<a-form-item label="启用规则">
<a-switch
:checked="infoObject.enableRules === 1 ? true : false"
:class="{
@ -73,11 +77,9 @@
<a-form-item label="取值类型" name="valueType">
<a-select
v-model:value="infoObject.valueType"
show-search
placeholder="请选择取值类型"
style="width: 100%"
:options="qzOptions"
:filter-option="filterOption"
@change="handleQzChange" />
</a-form-item>
<a-form-item label="异常描述" name="abnormalDescription">
@ -107,8 +109,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"
@ -124,8 +125,8 @@
</div>
<div
v-if="
infoObject.alarmList[index - 1].num === null ||
infoObject.alarmList[index - 1].logic === null
infoObject.alarmList[index - 1]?.num === null ||
infoObject.alarmList[index - 1]?.logic === null
"
style="width: 100%; color: #ff4d4f; text-align: center; margin-bottom: 5px">
请选择正确的逻辑{{ index }} 输入正确的数值{{ index }}
@ -145,19 +146,22 @@
</template>
<script lang="ts" setup>
import { NsMessage } from '/nerv-lib/component';
import { ref, toRaw, watch } from 'vue';
import type { CascaderProps, TreeSelectProps, SelectProps } from 'ant-design-vue';
import { ref, toRaw } from 'vue';
import type { SelectProps } from 'ant-design-vue';
import type { ShowSearchType } from 'ant-design-vue/es/cascader';
import { device } from '/@/api/deviceManage';
import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms';
import { http } from '/nerv-lib/util';
import type { Rule } from 'ant-design-vue/es/form';
import { async } from '@antv/x6/lib/registry/marker/async';
const visible = ref(false);
//
const equipmentAlarm = ref({});
//
const infoObject = ref({
id: null,
site: null,
ruleType: null,
abnormalDescription: null,
@ -166,7 +170,7 @@
valueType: null,
deviceName: null,
enableRules: 0,
alarmList: [{ id: null, alarm: null, number: null, isDelete: '0' }],
alarmList: [{ logic: null, num: null, isDelete: 0 }],
});
//
const delAlarmList = ref([]);
@ -176,18 +180,8 @@
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result;
//
const zdTreeData = ref<TreeSelectProps['treeData']>([
{
label: '铁路总局(T01)',
value: 'T01',
children: [
{
label: '济阳站(T0101)',
value: 'T0101',
},
],
},
]);
const siteDataTree = ref([]);
//
let deviceTypeTreeData = ref([]);
//
@ -216,62 +210,44 @@
};
//
const getDevicePoint = (value: any) => {
devicePointData.value = [];
http.post(device.queryDevicePoint, value).then((res) => {
if (res.msg === 'success') {
console.log(res, '数据');
res.data.forEach((item: any) => {
devicePointData.value.push({
value: item.id,
label: item.code + ' ( ' + item.unit + ' ) ',
});
});
}
});
};
//
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 filter: ShowSearchType['filter'] = (inputValue: any, path: any) => {
const devicePointData = ref([]);
//
const filterDevicePoint = (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
};
//
const filterDeviceType: ShowSearchType['filter'] = (inputValue: any, path: any) => {
return path.some(
(option: any) => option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1,
(option: any) => option.deviceType.toLowerCase().indexOf(inputValue.toLowerCase()) > -1,
);
};
//
const qzOptions = ref<SelectProps['options']>([
{ value: '实时值', label: '实时值', code: '1' },
{ value: '平均值', label: '平均值', code: '2' },
{ value: 1, label: '实时值', code: '1' },
{ value: 2, label: '平均值', code: '2' },
]);
//
const ljOptions = ref<SelectProps['options']>([
{ value: '1', label: '≥' },
{ value: '2', label: '>' },
{ value: '3', label: '≤' },
{ value: '4', label: '<' },
{ value: '5', label: '=' },
{ value: 0, label: '≥' },
{ value: 1, label: '>' },
{ value: 2, label: '≤' },
{ 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 handleFocus = () => {
console.log('点击');
};
const handleChange = (value: string) => {
console.log(`selected ${value}`);
console.log('选择', infoObject.value.devicePoint);
//code
dwOptions.value.forEach((item) => {
if (item.value === value) {
console.log('符合', item.code);
}
});
};
const handleQzChange = (value: string) => {
//code
qzOptions.value.forEach((item) => {
if (item.value === value) {
console.log('符合', item.code);
}
});
};
//
const clickSwitch = () => {
if (infoObject.value.enableRules === 1) {
@ -313,7 +289,9 @@
return null; // null
};
//
const toggle = async (value: any) => {
const toggle = async (value: any, info: any) => {
equipmentAlarm.value = info;
//
await http
.post(device.queryDeviceTree, { orgId: orgId.value, pageNum: 1, pageSize: 10 })
@ -322,21 +300,36 @@
deviceTypeTreeData.value = res.data;
}
});
//
http.post('/carbon-smart/user/login/logInInfo', {}).then((res) => {
if (res.msg === 'success') {
siteDataTree.value = res.data.linkList;
}
});
//
if (value) {
infoObject.value = value;
//
let selectDevice = ref([value.deviceType]);
findNodeById(deviceTypeTreeData.value, value.deviceType);
//
getDevicePoint({ id: 1 });
//
findParentIds(deviceTypeTreeData.value, value.deviceType, selectDevice.value);
infoObject.value.deviceType = selectDevice.value;
//
await http.post(deviceAlarms.configFindById, { id: value.id }).then((res) => {
if (res.msg === 'success') {
infoObject.value = res.data;
//
let selectDevice = ref([Number(infoObject.value.deviceType)]);
findNodeById(deviceTypeTreeData.value, Number(infoObject.value.deviceType));
//
getDevicePoint({ id: infoObject.value.deviceName });
//
findParentIds(deviceTypeTreeData.value, infoObject.value.deviceType, selectDevice.value);
infoObject.value.alarmList = infoObject.value.hxAlarmRuleLogicList || [];
delete infoObject.value.hxAlarmRuleLogicList;
infoObject.value.deviceType = selectDevice;
infoObject.value.ruleType = infoObject.value.ruleType + '';
console.log(infoObject.value, '数据');
}
});
} else {
//
infoObject.value = {
id: null,
site: null,
ruleType: null,
abnormalDescription: null,
@ -345,14 +338,14 @@
valueType: null,
deviceName: null,
enableRules: 0,
alarmList: [{ id: null, alarm: null, number: null, isDelete: '0' }],
alarmList: [{ logic: null, num: null, isDelete: 0 }],
};
}
visible.value = !visible.value;
};
//
const rules: infoObject<string, Rule[]> = {
const rules = {
site: [{ required: true, message: '请选择站点', trigger: 'change' }],
deviceType: [{ required: true, message: '请选择设备类型', trigger: 'change' }],
enableRules: [{ required: true, message: '请选择启用规则', trigger: 'change' }],
@ -360,20 +353,27 @@
devicePoint: [{ required: true, message: '请选择设备点位', trigger: 'change' }],
valueType: [{ required: true, message: '请选择取值类型', trigger: 'change' }],
ruleType: [{ required: true, message: '请选择规则类型', trigger: 'change' }],
abnormalDescription: [{ required: true, message: '请输入异常描述', trigger: 'blur' }],
abnormalDescription: [
{
required: true,
message: '请输入异常描述',
trigger: 'blur',
validator: (rules: any, abnormalDescription: any, cbfn: any) => {
if (abnormalDescription.trim() !== '') {
cbfn();
} else {
cbfn('告警标题不能为空');
}
},
},
],
alarm: [{ required: true, message: '请选择逻辑', trigger: 'blur' }],
number: [{ required: true, message: '请输入数值', trigger: 'blur' }],
};
//
const changeSwitch = () => {
console.log(infoObject.value.selectSwitch, '开关');
};
//
const btnClick = () => {
console.log(infoObject.value, '数据');
infoObject.value.alarmList.forEach((item) => {
if (item.logic === null || item.num === null) {
// NsMessage.error('');
return;
}
});
@ -383,51 +383,70 @@
}
//
formRef.value.validate().then(() => {
console.log('values', infoObject.value);
let data = toRaw(infoObject);
//
data.alarmList = [...infoObject.value.alarmList, ...delAlarmList.value];
// id
let data = { ...infoObject.value };
// id
data.equipmentAlarmId = equipmentAlarm.value.id;
//
data.hxAlarmRuleLogicList = [...infoObject.value.alarmList, ...delAlarmList.value];
data.hxAlarmRuleLogicList.forEach((item) => {
const num = Number(item.num);
if (!isNaN(num)) {
item.num = Number(num.toFixed(2));
} else {
item.num = 0; // 0
}
});
// id
data.deviceType = infoObject.value.deviceType[infoObject.value.deviceType.length - 1];
delAlarmList.value = [];
data.ruleType = Number(data.ruleType);
data.errorCode = equipmentAlarm.value.errorCode;
delete data.alarmList;
// HTTP POST
http
.post(deviceAlarms.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 = () => {
//
formRef.value.resetFields();
siteDataTree.value = [];
//
infoObject.value = {
id: null,
site: null,
ruleType: null,
abnormalDescription: null,
deviceType: [],
devicePoint: null,
enableRules: 0,
alarmList: [{ id: null, alarm: null, number: null, isDelete: '0' }],
alarmList: [{ logic: null, num: null, isDelete: 0 }],
};
visible.value = false;
//
delAlarmList.value = [];
};
//
const addAlarmList = () => {
if (infoObject.value.alarmList) {
infoObject.value.alarmList.push({ logic: null, num: null });
infoObject.value.alarmList.push({ logic: null, num: null, isDelete: 0 });
} else {
infoObject.value.alarmList = [{ logic: null, num: null }];
infoObject.value.alarmList = [{ logic: null, num: null, isDelete: 0 }];
}
};
//
@ -437,18 +456,15 @@
const alarmItemToDelete = infoObject.value.alarmList[index];
if (alarmItemToDelete?.id) {
// delAlarmList
delAlarmList.value.push({ ...alarmItemToDelete, isDelete: '1' });
delAlarmList.value.push({ ...alarmItemToDelete, isDelete: 1 });
}
// infoObject
infoObject.value.alarmList.splice(index, 1);
} else {
console.error('Invalid index: ', index);
}
};
defineExpose({
toggle,
handleClose,
dwOptions,
formRef,
});
</script>

20
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/editeEquipmentAlarm.vue

@ -2,11 +2,12 @@
<ns-drawer
v-model:visible="visible"
width="520"
:title="infoObject?.id ? '修改设备告警' : '新增设备告警'"
:title="infoObject?.id ? '编辑告警' : '新增告警'"
:footer-style="{ textAlign: 'right' }"
:ok="btnClick"
:cancel="handleClose"
placement="right">
placement="right"
@close="handleClose">
<ns-form ref="formRef" :schemas="schemas" :model="infoObject" formLayout="vertical" />
<div style="margin-left: 52px">
应用规则:
@ -67,6 +68,13 @@
required: true,
message: '告警标题不能为空',
trigger: 'change',
validator: (rules: any, alarmTitle: any, cbfn: any) => {
if (alarmTitle && alarmTitle.trim() !== '') {
cbfn();
} else {
cbfn('告警标题不能为空');
}
},
},
],
componentProps: {
@ -207,7 +215,11 @@
formRef.value.triggerSubmit().then(() => {
//
http.post(deviceAlarms.addOrUpNewData, infoObject.value).then(() => {
NsMessage.success('操作成功');
if (infoObject.value.id) {
NsMessage.success('告警编辑成功');
} else {
NsMessage.success('告警创建成功');
}
visible.value = false;
emit('editObject', null);
});
@ -216,9 +228,7 @@
const handleClose = () => {
//
formRef.value.formElRef.clearValidate();
console.log(infoObject.value);
visible.value = false;
NsMessage.success('操作成功');
};
defineExpose({
toggle,

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

@ -1,6 +1,6 @@
<template>
<div class="box">
<a-tabs default-active-key="1" @change="callback">
<a-tabs default-active-key="1">
<a-tab-pane key="1" tab="通知管理">
<ns-view-list-table v-bind="notificationConfig" ref="mainRef">
<template #bodyCell="{ record, column }">
@ -11,11 +11,14 @@
'blue-background': record.enableRules === 1 ? true : false,
'grey-background': record.enableRules === 1 ? false : true,
}"
@change="clickSwitch({ enableRules: record.enableRules, record: record })" />
@change="
clickSwitch({ type: 1, enableRules: record.enableRules, record: record })
" />
</template>
</template>
</ns-view-list-table>
<!-- 联系方式 -->
<notificationManagement ref="notificationManagements" @editObject="editObject" />
</a-tab-pane>
<a-tab-pane key="2" tab="设备告警" force-render>
<ns-view-list-table
@ -31,12 +34,14 @@
'blue-background': record.enableRules === 1 ? true : false,
'grey-background': record.enableRules === 1 ? false : true,
}"
@change="clickSwitch({ enableRules: record.enableRules, record: record })" />
@change="
clickSwitch({ type: 2, enableRules: record.enableRules, record: record })
" />
</template>
<template v-if="column.dataIndex === 'monitor'">
{{
record?.monitorTime && record?.monitorTimeUnit
? record?.monitorTime + record?.monitorTimeUnit
? record?.monitorTime + '' + record?.monitorTimeUnit
: '-'
}}
</template>
@ -45,7 +50,7 @@
<a-button
v-if="!equipmentAlarm"
type="primary"
style="position: absolute; right: 130px; z-index: 99; top: 80px; height: 30px"
style="position: absolute; right: 130px; z-index: 3; top: 80px; height: 30px"
@click="backequipmentAlarm"
>返回</a-button
>
@ -68,19 +73,21 @@
'blue-background': record.enableRules === 1 ? true : false,
'grey-background': record.enableRules === 1 ? false : true,
}"
@click="clickSwitch({ enableRules: record.enableRules, record: record })" />
@click="
clickSwitch({ type: 2, enableRules: record.enableRules, record: record })
" />
</template>
</template>
</ns-view-list-table>
<a-button
v-if="!energyAlarm"
type="primary"
style="position: absolute; right: 130px; z-index: 99; top: 80px; height: 30px"
style="position: absolute; right: 130px; z-index: 3; top: 80px; height: 30px"
@click="backenergyAlarm"
>返回</a-button
>
<!-- 新增 编辑 能源告警 -->
<editeEnergyAlarm ref="editeEnergyAlarm" @editObject="editObject" />
<editeEnergyAlarm ref="editeEnergyAlarm" @editObject="editeEnergyAlarmInfo" />
<!-- 配置能源告警-->
<configureEnergyAlarms v-show="!energyAlarm" ref="configureEnergyAlarms" />
</a-tab-pane>
@ -96,6 +103,7 @@
import { NsMessage, NsModal } from '/nerv-lib/component';
import editeEquipmentAlarm from './equipmentAlarm/editeEquipmentAlarm.vue';
import editeEnergyAlarm from './energyAlarm/editeEnergyAlarm.vue';
import notificationManagement from './notificationManagement/index.vue';
import configureEnergyAlarms from './energyAlarm/configureEnergyAlarms.vue';
import configureDeviceAlarms from './equipmentAlarm/configureDeviceAlarms.vue';
import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms';
@ -107,6 +115,7 @@
editeEquipmentAlarm,
configureDeviceAlarms,
configureEnergyAlarms,
notificationManagement,
editeEnergyAlarm,
},
setup() {
@ -114,12 +123,13 @@
const mainRefEquipmentAlarm = ref();
const mainEnergyAlarmConfig = ref();
const editEquipmentAlarm = ref();
const notificationManagements = ref();
const editeEnergyAlarm = ref();
const configureDeviceAlarms = ref();
const configureEnergyAlarms = ref();
const equipmentAlarm = ref(true);
const energyAlarm = ref(true);
const notificationConfig = notificationtableConfig(null, mainEnergyAlarmConfig, null);
const notificationConfig = notificationtableConfig(notificationManagements);
//
const energyAlarmConfig = energyAlarmConfigs(
editeEnergyAlarm,
@ -134,9 +144,6 @@
equipmentAlarm,
configureDeviceAlarms,
);
const callback = (key: any) => {
console.log(key);
};
//
const backequipmentAlarm = () => {
equipmentAlarm.value = !equipmentAlarm.value;
@ -147,38 +154,68 @@
configureEnergyAlarms.value.show = false;
};
const clickSwitch = (data: any) => {
console.log(data.record.enableRules === 1 ? '关闭' : '启用');
NsModal.confirm({
title: '启用状态',
icon: createVNode(ExclamationCircleOutlined),
content: '确定' + (data.record.enableRules === 1 ? '关闭' : '启用') + '吗?',
onOk: () => {
http
.post(deviceAlarms.addOrUpNewData, {
id: data.record.id,
enableRules: data.record.enableRules === 1 ? 0 : 1,
})
.then(() => {
NsMessage.success('操作成功');
mainRefEquipmentAlarm.value?.nsTableRef.reload();
});
if (data.type === 1) {
//
http
.post(deviceAlarms.addOrUpNewData, {
id: data.record.id,
enableRules: data.record.enableRules === 1 ? 0 : 1,
})
.then(() => {
NsMessage.success('操作成功');
mainRef.value?.nsTableRef.reload();
});
}
//
if (data.type === 2) {
http
.post(deviceAlarms.addOrUpNewData, {
id: data.record.id,
enableRules: data.record.enableRules === 1 ? 0 : 1,
})
.then(() => {
NsMessage.success('操作成功');
mainRefEquipmentAlarm.value?.nsTableRef.reload();
});
}
//
if (data.type === 3) {
http
.post(deviceAlarms.addOrUpNewData, {
id: data.record.id,
enableRules: data.record.enableRules === 1 ? 0 : 1,
})
.then(() => {
NsMessage.success('操作成功');
mainEnergyAlarmConfig.value?.nsTableRef.reload();
});
}
},
});
};
//
//
const editObject = () => {
mainRefEquipmentAlarm.value?.nsTableRef.reload();
// console.log(newList.value.formFinish, '');
};
//
const editeEnergyAlarmInfo = () => {
mainEnergyAlarmConfig.value?.nsTableRef.reload();
};
return {
callback,
notificationConfig,
energyAlarmConfig,
equipmentAlarmConfig,
editObject,
editeEnergyAlarm,
clickSwitch,
editEquipmentAlarm,
editeEnergyAlarm,
notificationManagements,
editeEnergyAlarmInfo,
configureDeviceAlarms,
configureEnergyAlarms,
equipmentAlarm,

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

@ -0,0 +1,246 @@
<template>
<ns-drawer
v-model:visible="visible"
width="520"
:title="' '"
:ok="btnClick"
:cancel="handleClose"
placement="right"
:footer-style="{ textAlign: 'right' }"
@close="handleClose">
<div style="padding: 18px; width: 100%; overflow: hidden">
<a-form ref="formRef" :model="infoObject" :rules="rules">
<a-form-item ref="notification" label="通知方式" name="notification">
<a-select
ref="select"
v-model:value="infoObject.notification"
style="width: 100%"
mode="multiple"
:options="devicePointData"
show-search
:allowClear="true"
placeholder="请选择通知方式"
:filter-option="filterDevicePoint" />
</a-form-item>
<a-form-item label="启用规则" name="enableRules">
<a-switch
:checked="infoObject.enableRules === 1 ? true : false"
:class="{
'blue-background': infoObject.enableRules === 1 ? true : false,
'grey-background': infoObject.enableRules === 1 ? false : true,
}"
@click="clickSwitch" />
</a-form-item>
<a-form-item label="通知用户" name="user">
<a-cascader
v-model:value="infoObject.user"
style="width: 100%"
multiple
:max-tag-count="1"
:options="options"
:load-data="loadData"
placeholder="请选择通知用户"
:show-checked-strategy="Cascader.SHOW_CHILD" />
</a-form-item>
</a-form>
<a-table :dataSource="dataSource" :columns="columns" :pagination="false" />
</div>
</ns-drawer>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { Cascader } from 'ant-design-vue';
import { NsMessage } from '/nerv-lib/component';
import { http } from '/nerv-lib/util';
// import { deviceAlarms } from '/@/api/alarmSettings/deviceAlarms';
//table
const columns = [
{
title: '序号',
dataIndex: 'address',
customRender: (text: any) => {
return text.index + 1;
},
},
{
title: '通知名单',
dataIndex: 'name',
key: 'name',
},
];
const dataSource = [
{
name: '运维>运维1部>张三',
},
{
name: '运维>运维1部>李四',
},
];
const visible = ref(false);
//
const infoObject = ref({
enableRules: 0,
});
//
const filterDevicePoint = (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
};
//
const clickSwitch = () => {
if (infoObject.value.enableRules === 1) {
infoObject.value.enableRules = 0;
} else {
infoObject.value.enableRules = 1;
}
};
//
const devicePointData = ref([
{ label: '站内信息', value: 1 },
{ label: '邮件', value: 2 },
]);
//
const options = ref([
{
value: 1,
label: 'Zhejiang',
isLeaf: false,
},
{
value: 2,
label: 'Jiangsu',
isLeaf: false,
},
]);
//
const loadData = (selectedOptions: any) => {
const targetOption = selectedOptions[selectedOptions.length - 1];
targetOption.loading = true;
// load options lazily
setTimeout(() => {
targetOption.loading = false;
console.log(targetOption, '数据');
targetOption.children = [
{
label: `${targetOption.label} Dynamic 1`,
value: 3,
isLeaf: false,
},
{
label: `${targetOption.label} Dynamic 2`,
value: 4,
isLeaf: false,
},
];
options.value = [...options.value];
}, 1000);
};
const rules = {
notification: [{ required: true, message: '请选择站点', trigger: 'change' }],
enableRules: [{ required: true, message: '请选择启用规则', trigger: 'change' }],
user: [{ required: true, message: '请选择通知人', trigger: 'change' }],
abnormalDescription: [
{
required: true,
message: '请输入异常描述',
trigger: 'blur',
validator: (rules: any, abnormalDescription: any, cbfn: any) => {
if (abnormalDescription.trim() !== '') {
cbfn();
} else {
cbfn('告警标题不能为空');
}
},
},
],
alarm: [{ required: true, message: '请选择逻辑', trigger: 'blur' }],
number: [{ required: true, message: '请输入数值', trigger: 'blur' }],
};
const formRef = ref();
const emit = defineEmits(['editObject']);
const toggle = (value: any) => {
//
if (value) {
// infoObject.value = value;
infoObject.value = {};
} else {
infoObject.value = {
enableRules: 0,
};
}
visible.value = !visible.value;
};
const btnClick = () => {
console.log(infoObject.value);
//
formRef.value.validate().then(() => {
//
// http.post(deviceAlarms.addOrUpNewData, infoObject.value).then(() => {
// NsMessage.success('');
// visible.value = false;
// emit('editObject', null);
// });
});
};
const handleClose = () => {
//
formRef.value.resetFields();
visible.value = false;
options.value = [
{
value: 'zhejiang',
label: 'Zhejiang',
isLeaf: false,
},
{
value: 'jiangsu',
label: 'Jiangsu',
isLeaf: false,
},
];
};
defineExpose({
toggle,
handleClose,
formRef,
});
</script>
<style scoped lang="less">
.drawerContainer {
height: 100%;
display: flex;
justify-content: space-between;
}
.blue-background.ant-switch-checked {
background-color: linear-gradient(
180deg,
rgba(1, 206, 255, 1) 0%,
rgba(0, 150, 229, 1) 100%
) !important;
}
.grey-background.ant-switch {
background-color: grey !important;
}
.blue-background.ant-switch-checked .ant-switch-handle {
background-color: linear-gradient(
180deg,
rgba(1, 206, 255, 1) 0%,
rgba(0, 150, 229, 1) 100%
) !important;
}
.grey-background.ant-switch .ant-switch-handle {
background-color: grey !important;
}
/deep/ .ant-form-item-label {
z-index: 20;
text-align: right;
width: 23%;
}
</style>

6
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/ts/equipmentAlarmConfig.ts

@ -123,7 +123,7 @@ export const equipmentAlarmTableConfig = (
confirm: true,
handle: (data: any) => {
http.post(deviceAlarms.del, { id: data.id }).then(() => {
NsMessage.success('操作成功');
NsMessage.success('告警删除成功');
mainRefEquipmentAlarm.value?.nsTableRef.reload();
});
},
@ -139,6 +139,7 @@ export const equipmentAlarmTableConfig = (
component: 'NsSelect',
componentProps: {
placeholder: '请选择告警优先级',
allowClear: true,
options: [
{
label: '紧急',
@ -160,6 +161,7 @@ export const equipmentAlarmTableConfig = (
label: '告警标题',
component: 'NsInput',
componentProps: {
allowClear: true,
placeholder: '请输入告警标题关键字',
},
},
@ -168,6 +170,7 @@ export const equipmentAlarmTableConfig = (
label: '错误码',
component: 'NsInput',
componentProps: {
allowClear: true,
placeholder: '请输入错误码关键字',
},
},
@ -177,6 +180,7 @@ export const equipmentAlarmTableConfig = (
component: 'NsSelect',
componentProps: {
placeholder: '请选择启用状态',
allowClear: true,
options: [
{
label: '启用',

4
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/ts/notificationManagementConfig.ts

@ -41,7 +41,7 @@ const tableKeyMap = [
},
];
const mockData = ref(data.listData);
export const notificationtableConfig = (el) => {
export const notificationtableConfig = (notificationManagements: any) => {
return {
title: '告警规则',
// api: '/carbon_emission/device/getDeviceList',
@ -57,7 +57,7 @@ export const notificationtableConfig = (el) => {
name: 'FeedBackDetail',
dynamicParams: ['uuid', 'appealType'],
handle: (data: any) => {
console.log(data, '联系方式');
notificationManagements.value.toggle(data);
},
},
],

Loading…
Cancel
Save