Procházet zdrojové kódy

告警中心下拉框动态加载优化

humingshi-7@163.com před 1 rokem
rodič
revize
5845f630d8
2 změnil soubory, kde provedl 36 přidání a 84 odebrání
  1. 7 1
      src/api/iot/alarmRule.js
  2. 29 83
      src/views/warn/index.vue

+ 7 - 1
src/api/iot/alarmRule.js

@@ -98,4 +98,10 @@ export function dealAlarm(data) {
   });
 }
 
-
+//告警类型下拉框
+export function deviceTypeList(type) {
+  return request({
+    url: `/iot/iot_alarm_data/deviceTypeList?${type}`,
+    method: 'get',
+  })
+}

+ 29 - 83
src/views/warn/index.vue

@@ -55,7 +55,7 @@
                 >
                   <el-option
                     v-for="item in deviceTypes"
-                    v-if="!queryParams.dataType || item.type === queryParams.dataType"
+                    v-if="!queryParams.dataType || item.type.indexOf(queryParams.dataType) > -1"
                     :key="item.value"
                     :label="item.label"
                     :value="item.value">
@@ -272,7 +272,7 @@ import dayjs from "dayjs";
 import DialogInfo from "./dialog.info";
 import DialogDealAlarm from "./dialog.dealAlarm.vue";
 import {mapGetters} from "vuex";
-import {alarmList} from "@/api/iot/alarmRule";
+import {alarmList,deviceTypeList} from "@/api/iot/alarmRule";
 
 
 export default {
@@ -285,89 +285,18 @@ export default {
       alarmTypes:[
         {
           value: '0',
-          label: '动环告警'
+          label: '动环主机告警'
         },
         {
           value: '1',
-          label: '其他告警'
-        }
-      ],
-      deviceTypes: [{
-        value: '4184',
-        label: '水浸告警',
-        type: '0',
-      }, {
-        value: '4183',
-        label: '温湿度告警',
-        type: '0',
-      }, {
-        value: '4182',
-        label: '烟感告警',
-        type: '0',
-      }, {
-        value: '4181',
-        label: '红外告警',
-        type: '0',
-      }, {
-        value: '41885',
-        label: '燃气告警',
-        type: '0',
-      }, {
-        value: '41881',
-        label: '盗情告警',
-        type: '0',
-      }
-      , {
-        value: '4188',
-        label: '门磁告警',
-        type: '0',
-      }
-      , {
-        value: '1001',
-        label: '信号丢失告警',
-          type: '1',
-      }
-      , {
-        value: '1002',
-        label: '遮挡告警',
-          type: '1',
-      }
-      , {
-        value: '1003',
-        label: '亮度告警',
-          type: '1',
-      }
-      , {
-        value: '1004',
-        label: '偏色告警',
-          type: '1',
-      }
-      , {
-        value: '1005',
-        label: '雪花告警',
-          type: '1',
-      }
-      , {
-        value: '1006',
-        label: '条纹告警',
-          type: '1',
-      }
-      , {
-        value: '1007',
-        label: '对比度告警',
-          type: '1',
-      }
-      , {
-        value: '1008',
-        label: '模糊告警',
-          type: '1',
-      }
-      , {
-        value: '1009',
-        label: '硬盘告警',
-          type: '1',
-      }
+          label: '监控主机告警'
+        },
+         {
+           value: '2',
+           label: '报警主机告警'
+         }
       ],
+      deviceTypes: [],
       // 遮罩层
       loading: false,
       // 选中数组
@@ -414,7 +343,7 @@ export default {
   },
   created() {
     this.queryParams.orgId = this.$store.getters.orgId;
-    this.getList();
+    this.initDeviceTypeList();
   },
   computed: {
     ...mapGetters(["orgId", "orgName"]),
@@ -430,6 +359,24 @@ export default {
         this.queryParams.isDo=null;
       }
     },
+    initDeviceTypeList(){
+          deviceTypeList("")
+            .then((r) => {
+              // 使用 map 而不是 filter 进行数据转换
+              const transformedList = r.map((item) => ({
+                value: item.value,
+                label: item.label,
+                type: item.type,
+              }));
+
+              // 将转换后的数据推送到 this.deviceTypeList
+              this.deviceTypes.push(...transformedList);
+            })
+            .catch((error) => {
+              // 处理错误
+              console.error('Error fetching device type list:', error);
+            });
+    },
     /** 查询监控调阅任务列表 */
     getList() {
       alarmList(this.queryParams).then((response) => {
@@ -507,7 +454,6 @@ export default {
     },
     /** 重置按钮操作 */
     resetQuery() {
-      console.log("123")
       this.resetForm("queryForm");
       this.queryParams.orgId = this.orgId;
       this.selectedOrgName = this.orgName;