Browse Source

[Feat 0000] 更新可配置首页hooks,添加了设备类型为null时的支持

houzekong 1 week ago
parent
commit
57caa2e971

+ 1 - 0
src/views/vent/deviceManager/configurationTable/configuration.api.ts

@@ -59,5 +59,6 @@ export const saveOrUpdate = (formData: Record<string, number | string | undefine
   const url = isUpdate ? Api.edit : Api.save;
   const params = parseFormDataToParams(formData);
   console.log('debug', params);
+  // return Promise.reject();
   return defHttp.post({ url: url, params });
 };

+ 3 - 9
src/views/vent/home/configurable/dustBD.vue

@@ -69,7 +69,7 @@
   // import { testConfigBDDust } from './configurable.data.bd';
   // import { getToken } from '/@/utils/auth';
 
-  const { configs, fetchConfigs } = useInitConfigs();
+  const { configs, devicesTypes, fetchConfigs } = useInitConfigs();
   const { mainTitle, data, updateData } = useInitPage('保德煤矿粉尘灾害预警系统');
   let interval: number | undefined;
   // function hideLoading() {
@@ -80,18 +80,12 @@
       // configs.value = testConfigBDDust;
 
       getDisHome({
-        dataList: configs.value
-          .map((e) => e.deviceType)
-          .concat('dustAllMineWarn')
-          .join(','),
+        dataList: devicesTypes.value.concat('dustAllMineWarn').join(','),
       }).then(updateData);
     });
     setInterval(() => {
       getDisHome({
-        dataList: configs.value
-          .map((e) => e.deviceType)
-          .concat('dustAllMineWarn')
-          .join(','),
+        dataList: devicesTypes.value.concat('dustAllMineWarn').join(','),
       }).then(updateData);
     }, 60000);
   });

+ 3 - 9
src/views/vent/home/configurable/fireBD.vue

@@ -95,7 +95,7 @@
       return index === 4;
     })
   );
-  const { configs, fetchConfigs } = useInitConfigs();
+  const { configs, devicesTypes, fetchConfigs } = useInitConfigs();
   const { mainTitle, data, updateData } = useInitPage('保德煤矿火灾预警系统');
   let interval: number | undefined;
   // function hideLoading() {
@@ -106,18 +106,12 @@
       // configs.value = testConfigBDFire;
 
       getDisHome({
-        dataList: configs.value
-          .map((e) => e.deviceType)
-          .concat('fireAllMineWarn')
-          .join(','),
+        dataList: devicesTypes.value.concat('fireAllMineWarn').join(','),
       }).then(updateData);
     });
     setInterval(() => {
       getDisHome({
-        dataList: configs.value
-          .map((e) => e.deviceType)
-          .concat('fireAllMineWarn')
-          .join(','),
+        dataList: devicesTypes.value.concat('fireAllMineWarn').join(','),
       }).then(updateData);
     }, 60000);
   });

+ 3 - 9
src/views/vent/home/configurable/fireWZ.vue

@@ -69,7 +69,7 @@
   import { testConfigWZFire } from './configurable.data.wz';
   // import { getToken } from '/@/utils/auth';
 
-  const { configs } = useInitConfigs();
+  const { configs, devicesTypes } = useInitConfigs();
   const { mainTitle, data, updateData, updateEnhancedConfigs } = useInitPage('王庄煤矿火灾智能监测系统');
   let interval: number | undefined;
   // function hideLoading() {
@@ -81,18 +81,12 @@
     updateEnhancedConfigs(configs.value);
 
     getDisHome({
-      dataList: configs.value
-        .map((e) => e.deviceType)
-        .concat('fireAllMineWarn')
-        .join(','),
+      dataList: devicesTypes.value.concat('fireAllMineWarn').join(','),
     }).then(updateData);
     // });
     setInterval(() => {
       getDisHome({
-        dataList: configs.value
-          .map((e) => e.deviceType)
-          .concat('fireAllMineWarn')
-          .join(','),
+        dataList: devicesTypes.value.concat('fireAllMineWarn').join(','),
       }).then(updateData);
     }, 60000);
   });

+ 9 - 1
src/views/vent/home/configurable/hooks/useInit.ts

@@ -3,7 +3,7 @@ import { list as cfgList } from '@/views/vent/deviceManager/configurationTable/c
 // import { list } from '@/views/vent/deviceManager/deviceTable/device.api';
 import { Config } from '@/views/vent/deviceManager/configurationTable/types';
 import { getData, getFormattedText } from './helper';
-import { get } from 'lodash-es';
+import { get, isNil } from 'lodash-es';
 
 interface EnhancedConfig extends Config {
   visible: boolean;
@@ -45,6 +45,13 @@ export function useInitConfigs() {
       return c.showStyle.version === '保德';
     });
   });
+  const devicesTypes = computed(() => {
+    return configs.value
+      .map((e) => e.deviceType)
+      .filter((e) => {
+        return !isNil(e);
+      });
+  });
 
   function fetchConfigs(pageType?: string) {
     return cfgList({ pageType }).then(({ records }) => {
@@ -56,6 +63,7 @@ export function useInitConfigs() {
   return {
     fetchConfigs,
     configs,
+    devicesTypes,
     isOriginal,
     isCommon,
     isBD,