Jelajahi Sumber

修改物联设备信息页面查询逻辑

jingyuanchao 1 tahun lalu
induk
melakukan
f7ab54ce6e
1 mengubah file dengan 24 tambahan dan 12 penghapusan
  1. 24 12
      src/views/iot/sensorData/index.vue

+ 24 - 12
src/views/iot/sensorData/index.vue

@@ -50,17 +50,18 @@
                   />
                 </el-select>
               </el-form-item>
-              <el-form-item label="设备类型" prop="deviceType">
+              <el-form-item label="设备类型" prop="deviceTypeList">
                 <el-select
-                  v-model="queryParams.deviceType"
+                  v-model="queryParams.deviceTypeList"
                   clearable
+                  multiple
                   placeholder="请选择设备类型"
                 >
                   <el-option
-                    v-for="dict in dict.type.sensor_device_type"
-                    :key="dict.value"
-                    :label="dict.label"
-                    :value="dict.value"
+                    v-for="dict in deviceTypeList"
+                    :key="dict.code"
+                    :label="dict.name"
+                    :value="dict.code"
                   />
                 </el-select>
               </el-form-item>
@@ -195,7 +196,7 @@ export default {
         pageSize: 10,
         dateRange: [],
         checkSub: true,
-        deviceType: null,
+        deviceTypeList: [],
         state: null,
       },
       // 表单参数
@@ -211,17 +212,28 @@ export default {
   },
   created() {
     this.queryParams.orgId = this.$store.getters.orgId;
+    this.initDeviceTypeList();
   },
   computed: {
     ...mapGetters(["orgId"]),
   },
   methods: {
     initDeviceTypeList(){
-      deviceTypeList("FSU").then((r) => {
-        r.filter((item) => {
-          this.deviceTypeList.push({ label: item.name, value: item.code });
-        }
-      }
+      deviceTypeList("FSU")
+        .then((r) => {
+          // 使用 map 而不是 filter 进行数据转换
+          const transformedList = r.map((item) => ({
+            name: item.name,
+            code: item.code,
+          }));
+
+          // 将转换后的数据推送到 this.deviceTypeList
+          this.deviceTypeList.push(...transformedList);
+        })
+        .catch((error) => {
+          // 处理错误
+          console.error('Error fetching device type list:', error);
+        });
     },
     /** 查询列表 */
     getList() {