From 70c9de9de216bcc5dbf830de4ae446df611b2b35 Mon Sep 17 00:00:00 2001 From: zch Date: Sat, 24 May 2025 23:32:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(ems):=20=E6=9B=B4=E6=96=B0=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=91=8A=E8=AD=A6=E8=A7=84=E5=88=99=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E6=81=A2=E5=A4=8D=E7=BB=84=E4=BB=B6=E6=AF=8F=E5=88=86?= =?UTF-8?q?=E9=92=9F=E8=BD=AE=E8=AF=A2=E5=BC=82=E5=B8=B8=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除触发规则相关代码 - 更新计量设备相关功能,使用下拉框选择设备 - 添加监测字段选择功能 - 修改触发阈值量相关逻辑 - 更新表格列显示内容 - 优化新增和修改功能,支持设备类型和监测字段的动态显示 --- src/layout/components/Navbar.vue | 2 +- .../ems/record/recordAlarmRule/index.vue | 180 +++++++++++------- 2 files changed, 110 insertions(+), 72 deletions(-) diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 2771ee4..a4d364c 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -158,7 +158,7 @@ export default { mounted() { // 定时获取提示路由信息 this.getAlarmData() - // setInterval(() => this.getAlarmData(), 1000 * 60); + setInterval(() => this.getAlarmData(), 1000 * 60); }, components: { Breadcrumb, diff --git a/src/views/ems/record/recordAlarmRule/index.vue b/src/views/ems/record/recordAlarmRule/index.vue index 1f1997d..18c740f 100644 --- a/src/views/ems/record/recordAlarmRule/index.vue +++ b/src/views/ems/record/recordAlarmRule/index.vue @@ -9,7 +9,7 @@ @keyup.enter.native="handleQuery" /> - + @@ -34,41 +34,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + 新增 + + + + 修改 + + + + 删除 + + - + @@ -138,15 +138,19 @@ - + - + - + + + + @@ -159,7 +163,7 @@ - + + + + + - - - - - + + @@ -201,10 +207,11 @@ import { addRecordAlarmRule, updateRecordAlarmRule } from '@/api/ems/record/recordAlarmRule' +import {listBaseMonitorInfo} from "@/api/ems/base/baseMonitorInfo"; export default { name: 'RecordAlarmRule', - dicts: ['trigger_rule'], + dicts: ['trigger_rule', 'monitor_field'], data() { return { // 遮罩层 @@ -225,6 +232,9 @@ export default { title: '', // 是否显示弹出层 open: false, + // 设备列表 + monitorList: [], + selectedMonitorType: null, // 新增:用于存储选中设备的 monitorType // 查询参数 queryParams: { pageNum: 1, @@ -234,10 +244,10 @@ export default { monitorId: null, collectTime: null, energyType: null, - triggerRule: null, - triggerNumber: null, + triggerRule: 0, + monitorField: null, timeRange: null, - deviceOfflineTime: null, + triggerValue: null, notifyUser: null, cause: null }, @@ -251,19 +261,19 @@ export default { }, columns: [ { key: 0, label: `自增标识`, visible: false }, - { key: 1, label: `规则编号`, visible: true }, + { key: 1, label: `规则编号`, visible: false }, { key: 2, label: `规则名称`, visible: true }, - { key: 3, label: `计量设备编号`, visible: false }, + { key: 3, label: `计量设备`, visible: true }, { key: 4, label: `记录时间`, visible: false }, { key: 5, label: `能源类型`, visible: false }, - { key: 6, label: `触发规则`, visible: true }, + { key: 6, label: `触发规则`, visible: false }, { key: 7, label: `触发阈值次数`, visible: false }, { key: 8, label: `时间范围(分)`, visible: false }, - { key: 9, label: `设备离线时间(分钟)`, visible: true }, + { key: 9, label: `触发阈值量`, visible: true }, { key: 10, label: `通知用户`, visible: false }, { key: 11, label: `备注`, visible: true }, { key: 12, label: `创建人`, visible: false }, - { key: 13, label: `创建时间`, visible: false }, + { key: 13, label: `创建时间`, visible: true }, { key: 14, label: `更新人`, visible: false }, { key: 15, label: `更新时间`, visible: false } ] @@ -271,6 +281,7 @@ export default { }, created() { this.getList() + this.getMonitorList() }, methods: { /** 查询异常告警规则列表 */ @@ -296,10 +307,10 @@ export default { monitorId: null, collectTime: null, energyType: null, - triggerRule: null, - triggerNumber: null, + triggerRule: 0, + monitorField: null, timeRange: null, - deviceOfflineTime: null, + triggerValue: null, notifyUser: null, cause: null, createBy: null, @@ -307,6 +318,7 @@ export default { updateBy: null, updateTime: null } + this.selectedMonitorType = null; // 重置时清空 this.resetForm('form') }, /** 搜索按钮操作 */ @@ -333,10 +345,15 @@ export default { }, /** 修改按钮操作 */ handleUpdate(row) { - this.reset() + this.reset(); const objId = row.objId || this.ids getRecordAlarmRule(objId).then(response => { this.form = response.data + // 当修改时,需要根据 form.monitorId(实际是monitorCode)初始化 selectedMonitorType + const selectedMonitor = this.monitorList.find(m => m.monitorCode === this.form.monitorId); + if (selectedMonitor) { + this.selectedMonitorType = selectedMonitor.monitorType; + } this.open = true this.title = '修改异常告警规则' }) @@ -377,7 +394,28 @@ export default { this.download('ems/record/recordAlarmRule/export', { ...this.queryParams }, `recordAlarmRule_${new Date().getTime()}.xlsx`) - } + }, + //获取设备列表用来下拉框 + getMonitorList() { + listBaseMonitorInfo().then(response => { + this.monitorList = response.data; + }) + }, + // 当选择的设备变化时触发 + handleMonitorChange(monitorId) { + // monitorId这里实际传入的是monitorCode值 + const selectedMonitor = this.monitorList.find(m => m.monitorCode === monitorId); + if (selectedMonitor) { + this.selectedMonitorType = selectedMonitor.monitorType; + // 如果设备类型不是6或10,则清空已选的监测字段 + if (this.selectedMonitorType !== 6 && this.selectedMonitorType !== 10) { + this.form.monitorField = null; + } + } else { + this.selectedMonitorType = null; + this.form.monitorField = null; // 如果找不到设备,也清空 + } + }, } }