Browse Source

Merge branch 'master' of http://39.97.59.228:8013/hrx/mky-vent-base

bobo04052021@163.com 4 weeks ago
parent
commit
41ad957ccc
1 changed files with 15 additions and 1 deletions
  1. 15 1
      src/views/vent/home/configurable/belt/components/ModuleCommon.vue

+ 15 - 1
src/views/vent/home/configurable/belt/components/ModuleCommon.vue

@@ -10,7 +10,7 @@
       </template>
       <template #container>
         <slot>
-          <Header :deviceType="deviceType" :moduleData="moduleData" :data="data" @select="selectedData = $event"></Header>
+          <Header :deviceType="deviceType" :moduleData="moduleData" :data="data" @select="handleSelect" />
           <Content
             :style="{ height: header.show ? 'calc(100% - 30px)' : '100%' }"
             :moduleData="moduleData"
@@ -84,11 +84,25 @@ function redirectTo() {
   openWindow(getFormattedText(props.data, to));
 }
 
+function handleSelect(selectedItem: any) {
+  if (!selectedItem) return;
+
+  if (selectedItem.id !== undefined && selectedItem.id !== null) {
+    // 确保这个 ID 在当前的 options 里存在
+    const isValid = options.value.some((opt) => opt.value === selectedItem.id);
+    if (isValid) {
+      selectedDeviceID.value = selectedItem.id;
+    }
+  }
+}
+
 watch(
   () => props.data,
   (d) => {
     init(d);
     if (!selectedDeviceID.value) {
+      console.log(selectedDeviceID.value, '------');
+
       selectedDeviceID.value = options.value[0]?.value;
     }
   },