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; // 如果找不到设备,也清空 + } + }, } }