Quellcode durchsuchen

[Feat 0000] 保德相关修改

houzekong vor 6 Monaten
Ursprung
Commit
93eeed0298

+ 1 - 1
src/layouts/default/layout.data.ts

@@ -1,5 +1,5 @@
 export const noHeadeLink = ['/micro-vent-3dModal/dashboard/analysis', '/model3D/home', '/fileManager/cad-viewer'];
-export const noSiderLink = ['/fileManager/cad-viewer'];
+export const noSiderLink = ['/fileManager/cad-viewer', '/micro-vent-3dModal/dashboard/bd/fire', '/micro-vent-3dModal/dashboard/bd/dust'];
 export const noContentLink = ['/micro-vent-3dModal/modelchannel/model3D/home'];
 export const ThemeModel = {
   theme5_5: {

+ 11 - 3
src/views/vent/home/configurable/components/ModuleBD.vue

@@ -46,7 +46,7 @@
 
 <script setup lang="ts">
   import Content from './content.vue';
-  import { defineProps, defineEmits, computed, onMounted } from 'vue';
+  import { defineProps, defineEmits, computed, onMounted, onUnmounted } from 'vue';
   import { ModuleData, ShowStyle } from '../../../deviceManager/configurationTable/types';
   import { useInitDevices } from '../hooks/useInit';
 
@@ -61,13 +61,14 @@
 
   const { header } = props.moduleData;
 
-  const { selectedDeviceID, selectedDevice, options, fetchDevices } = useInitDevices(props.deviceType, props.moduleData);
+  const { selectedDeviceID, selectedDevice, options, fetchDevicesBD } = useInitDevices(props.deviceType, props.moduleData);
 
   const style = computed(() => {
     const size = props.showStyle.size;
     const position = props.showStyle.position;
     return size + position;
   });
+  let interval: any = null;
 
   // 根据配置里的定位判断应该使用哪个module组件
   const daneClass = computed(() => {
@@ -97,7 +98,14 @@
   }
 
   onMounted(() => {
-    fetchDevices();
+    fetchDevicesBD({ init: true });
+    interval = setInterval(() => {
+      fetchDevicesBD();
+    }, 600000);
+  });
+
+  onUnmounted(() => {
+    clearInterval(interval);
   });
 </script>
 

+ 10 - 2
src/views/vent/home/configurable/components/header.vue

@@ -37,7 +37,7 @@
   </div>
 </template>
 <script lang="ts" setup>
-  import { onMounted, ref } from 'vue';
+  import { onMounted, onUnmounted, ref } from 'vue';
   import { Config } from '../../../deviceManager/configurationTable/types';
   import { useInitDevices } from '../hooks/useInit';
   import { MenuItem } from 'ant-design-vue';
@@ -55,6 +55,7 @@
     props.deviceType,
     props.moduleData
   );
+  let interval: any = null;
 
   function selectHandler({ key }) {
     selectedDeviceID.value = key;
@@ -62,7 +63,14 @@
   }
 
   onMounted(() => {
-    fetchDevices();
+    fetchDevices({ init: true });
+    interval = setInterval(() => {
+      fetchDevices();
+    }, 600000);
+  });
+
+  onUnmounted(() => {
+    clearInterval(interval);
   });
 </script>
 <style scoped>

+ 8 - 8
src/views/vent/home/configurable/dustBD.vue

@@ -133,15 +133,15 @@
     getHomeData({}).then((r) => {
       homedata.value = r;
     });
-    fetchConfigs().then(() => {
+    fetchConfigs('BD_dust').then(() => {
       configs.value = testConfigBDDust;
-      // configs.value.push(...testConfigBDDust);
-      enhancedConfigs.value = configs.value.map((c) => {
-        return {
-          visible: true,
-          ...c,
-        };
-      });
+      // // configs.value.push(...testConfigBDDust);
+      // enhancedConfigs.value = configs.value.map((c) => {
+      //   return {
+      //     visible: true,
+      //     ...c,
+      //   };
+      // });
     });
   });
 

+ 7 - 8
src/views/vent/home/configurable/fireBD.vue

@@ -134,15 +134,14 @@
     getHomeData({}).then((r) => {
       homedata.value = r;
     });
-    fetchConfigs().then(() => {
+    fetchConfigs('BD_fire').then(() => {
       configs.value = testConfigBDFire;
-      // configs.value.push(...testConfigBDFire);
-      enhancedConfigs.value = configs.value.map((c) => {
-        return {
-          visible: true,
-          ...c,
-        };
-      });
+      // enhancedConfigs.value = configs.value.map((c) => {
+      //   return {
+      //     visible: true,
+      //     ...c,
+      //   };
+      // });
     });
   });
 

+ 40 - 2
src/views/vent/home/configurable/hooks/useInit.ts

@@ -80,7 +80,7 @@ export function useInitDevices(devicekind: string, config: Config['moduleData'])
   });
 
   // 获取设备数据,赋值并以选项格式返回给 Header 消费
-  function fetchDevices() {
+  function fetchDevices({ init = false } = {}) {
     const { value } = header.selector;
     const promise = mock ? Promise.resolve(mock) : getHomeData({});
     return promise.then((result) => {
@@ -99,7 +99,44 @@ export function useInitDevices(devicekind: string, config: Config['moduleData'])
             value: e.id,
           };
         });
-        selectedDeviceID.value = options.value[0]?.value;
+        if (init) {
+          selectedDeviceID.value = options.value[0]?.value;
+        }
+      } else {
+        // 没有的话按默认的,将返回结果直接作为一整个设备信息供模块使用
+        const record = {
+          ...result,
+          id: '00000000',
+        };
+        devices.value = [record];
+        selectedDeviceID.value = record.id;
+      }
+    });
+  }
+
+  // 保德专用-获取设备数据,赋值并以选项格式返回给 Header 消费
+  function fetchDevicesBD({ init = false } = {}) {
+    const { value } = header.selector;
+    const promise = mock ? Promise.resolve(mock) : getHomeData({});
+    return promise.then((result) => {
+      if (header.show && header.showSelector && result[devicekind]) {
+        // 如果配置里指明需要 header,检验后初始化设备信息
+        const records: Record<string, any>[] = result[devicekind];
+        devices.value = records.map((e, i) => {
+          return {
+            id: i,
+            ...e,
+          };
+        });
+        options.value = devices.value.map((e) => {
+          return {
+            label: getFormattedText(e, value),
+            value: e.id,
+          };
+        });
+        if (init) {
+          selectedDeviceID.value = options.value[0]?.value;
+        }
       } else {
         // 没有的话按默认的,将返回结果直接作为一整个设备信息供模块使用
         const record = {
@@ -114,6 +151,7 @@ export function useInitDevices(devicekind: string, config: Config['moduleData'])
 
   return {
     fetchDevices,
+    fetchDevicesBD,
     selectedDevice,
     selectedDeviceID,
     selectedDeviceSlot,