Преглед на файлове

[Feat 0000] 保德新接口对接

houzekong преди 3 седмици
родител
ревизия
af86a543a4

+ 1 - 2
src/views/vent/home/configurable/components/ModuleBD.vue

@@ -61,13 +61,12 @@
     moduleName: string;
     deviceType: string;
     visible: boolean;
-    pageType: string;
   }>();
   const emit = defineEmits(['close', 'select']);
 
   const { header } = props.moduleData;
 
-  const { selectedDeviceID, selectedDevice, options, fetchDevices } = useInitDevicesBD(props.deviceType, props.pageType, props.moduleData);
+  const { selectedDeviceID, selectedDevice, options, fetchDevices } = useInitDevicesBD(props.deviceType, props.moduleData);
 
   const style = computed(() => {
     const size = props.showStyle.size;

+ 2 - 3
src/views/vent/home/configurable/components/ModuleBDDual.vue

@@ -79,7 +79,6 @@
     deviceTypeB: string;
     showStyle: ShowStyle;
     visible: boolean;
-    pageType: string;
   }>();
   const emit = defineEmits(['close', 'select']);
 
@@ -93,13 +92,13 @@
     selectedDevice: selectedDeviceA,
     options: optionsA,
     fetchDevices: fetchDevicesA,
-  } = useInitDevicesBD(props.deviceTypeA, props.pageType, props.moduleDataA);
+  } = useInitDevicesBD(props.deviceTypeA, props.moduleDataA);
   const {
     selectedDeviceID: selectedDeviceIDB,
     selectedDevice: selectedDeviceB,
     options: optionsB,
     fetchDevices: fetchDevicesB,
-  } = useInitDevicesBD(props.deviceTypeB, props.pageType, props.moduleDataB);
+  } = useInitDevicesBD(props.deviceTypeB, props.moduleDataB);
 
   const style = computed(() => {
     const size = props.showStyle.size;

+ 37 - 0
src/views/vent/home/configurable/configurable.api.ts

@@ -3,6 +3,7 @@ import { defHttp } from '/@/utils/http/axios';
 enum Api {
   list = '/safety/ventanalyDevice/homedata2',
   getHomeData = '/safety/ventanalyDevice/homedata',
+  getDisHome = '/ventanaly-device/monitor/disaster/getDisHome',
   getBDDustData = '/ventanaly-device/monitor/disaster/getDisDustHome',
   getBDFireData = '/ventanaly-device/monitor/disaster/getDisFireHome',
 }
@@ -57,6 +58,7 @@ export const getHomeData = (params) => {
     return res;
   });
 };
+
 export const getBDDustData = (params) => {
   const key = `${Api.getBDDustData}?${JSON.stringify(params)}`;
   if (!cache.has(key)) {
@@ -69,6 +71,7 @@ export const getBDDustData = (params) => {
   }
   return cache.get(key) as Promise<any>;
 };
+
 export const getBDFireData = (params) => {
   const key = `${Api.getBDFireData}?${JSON.stringify(params)}`;
   if (!cache.has(key)) {
@@ -98,3 +101,37 @@ export const getBDFireData = (params) => {
     return res;
   });
 };
+
+export const getDisHome = (params) => {
+  const key = `${Api.getDisHome}?${JSON.stringify(params)}`;
+  if (!cache.has(key)) {
+    cache.set(
+      key,
+      defHttp.post({ url: Api.getDisHome, params }).finally(() => {
+        cache.delete(key);
+      })
+    );
+  }
+  return (cache.get(key) as Promise<any>).then((res) => {
+    if (res.pdArray) {
+      res.pdArray.forEach((e) => {
+        e.arrayFiber.forEach((j) => {
+          j.fibreTemperatureArr = JSON.parse(j.fibreTemperature);
+        });
+      });
+    }
+    if (res.sgGxObj) {
+      res.sgGxObj.devGxcw.forEach((e) => {
+        e.fibreTemperatureArr = JSON.parse(e.fibreTemperature);
+      });
+      res.sgGxObj.devSgjc.forEach((e) => {
+        e.o2val = e.o2Val || 0;
+        e.coval = e.coVal || 0;
+        e.gasval = e.gasVal || 0;
+        e.ch2val = e.ch2Val || 0;
+        e.chval = e.chVal || 0;
+      });
+    }
+    return res;
+  });
+};

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

@@ -23,7 +23,7 @@
         </div>
         <div class="tcontent-c">
           <div style="margin-bottom: 15px; color: #009bff; font-size: 24px; font-weight: bolder; letter-spacing: 10px">
-            {{ homedata.allMineWarn }}
+            {{ homedata.dustAllMineWarn }}
           </div>
           <!-- <div style="color: #fff; font-size: 12px">自燃倾向性等级 : 容易自燃</div> -->
         </div>
@@ -51,7 +51,6 @@
       :module-name="cfg.moduleName"
       :device-type="cfg.deviceType"
       :visible="true"
-      :page-type="pageType"
     />
     <div style="width: 1000px; height: 570px; position: absolute; left: calc(50% - 500px); top: 60px">
       <VentModal />
@@ -65,7 +64,7 @@
   import { useInitConfigs } from './hooks/useInit';
   import ModuleBD from './components/ModuleBD.vue';
   import VentModal from '/@/components/vent/micro/ventModal.vue';
-  import { getBDDustData } from './configurable.api';
+  import { getDisHome } from './configurable.api';
   // import { getToken } from '/@/utils/auth';
 
   // const iframeUrl = ref(
@@ -84,7 +83,7 @@
   // }
   onMounted(() => {
     // configs.value = testConfigB;
-    getBDDustData({}).then((r) => {
+    getDisHome({ dataList: 'dustAllMineWarn' }).then((r) => {
       homedata.value = r;
     });
     fetchConfigs(pageType);

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

@@ -23,7 +23,7 @@
         </div>
         <div class="tcontent-c">
           <div style="margin-bottom: 15px; color: #009bff; font-size: 24px; font-weight: bolder; letter-spacing: 10px">
-            {{ homedata.allMineWarn }}
+            {{ homedata.fireAllMineWarn }}
           </div>
           <div style="color: #fff; font-size: 12px">自燃倾向性等级 : 自燃</div>
         </div>
@@ -78,7 +78,7 @@
   import ModuleBDDual from './components/ModuleBDDual.vue';
   // import { testConfigBDFire } from './configurable.data';
   import VentModal from '/@/components/vent/micro/ventModal.vue';
-  import { getBDFireData } from './configurable.api';
+  import { getDisHome } from './configurable.api';
   // import { getToken } from '/@/utils/auth';
 
   // import FramePage from '/@/views/sys/iframe/index.vue';
@@ -114,7 +114,7 @@
   onMounted(() => {
     // configs.value = testConfigB;
 
-    getBDFireData({}).then((r) => {
+    getDisHome({ dataList: 'fireAllMineWarn' }).then((r) => {
       homedata.value = r;
     });
     fetchConfigs(pageType);

+ 34 - 25
src/views/vent/home/configurable/hooks/useInit.ts

@@ -2,7 +2,7 @@ import { computed, ref } from 'vue';
 import { list as cfgList } from '@/views/vent/deviceManager/configurationTable/configuration.api';
 // import { list } from '@/views/vent/deviceManager/deviceTable/device.api';
 import { Config } from '@/views/vent/deviceManager/configurationTable/types';
-import { getBDDustData, getBDFireData, getHomeData } from '../configurable.api';
+import { getDisHome, getHomeData } from '../configurable.api';
 import { getFormattedText } from '../../../deviceManager/configurationTable/adapters';
 import { get } from 'lodash-es';
 // import mapComponent from './components/3Dmap/index.vue';
@@ -23,6 +23,7 @@ import { get } from 'lodash-es';
 //   };
 // }
 
+/** 初始化配置以及根据配置获取数据 */
 export function useInitConfigs() {
   const configs = ref<Config[]>([]);
   const isOriginal = computed(() => {
@@ -44,6 +45,7 @@ export function useInitConfigs() {
   function fetchConfigs(pageType?: string) {
     return cfgList({ pageType }).then(({ records }) => {
       configs.value = records;
+      return records;
     });
   }
 
@@ -126,7 +128,7 @@ export function useInitDevices(devicekind: string, config: Config['moduleData'])
 }
 
 /** 保德专用-初始化设备信息,包含了适配了 header config 的下拉框选项、已选择设备的各个详细子项等,如果模块不需要展示 header 那么会将全部信息提供给已选择设备以供消费 */
-export function useInitDevicesBD(devicekind: string, pageType: string, config: Config['moduleData']) {
+export function useInitDevicesBD(devicekind: string, config: Config['moduleData']) {
   const { header, mock } = config;
   const devices = ref<Record<string, any>[]>([]);
   const options = ref<{ label: string; value: string }[]>([]);
@@ -152,11 +154,7 @@ export function useInitDevicesBD(devicekind: string, pageType: string, config: C
   // 获取设备数据,赋值并以选项格式返回给 Header 消费
   function fetchDevices({ init = false } = {}) {
     const { value } = header.selector;
-    const apiMap = {
-      BD_dust: getBDDustData,
-      BD_fire: getBDFireData,
-    };
-    const promise = mock ? Promise.resolve(mock) : apiMap[pageType]();
+    const promise = mock ? Promise.resolve(mock) : getDisHome({ dataList: devicekind.split('.')[0] });
     return promise.then((result) => {
       if (header.show && header.showSelector) {
         // 如果配置里指明需要 header,检验后初始化设备信息
@@ -198,21 +196,32 @@ export function useInitDevicesBD(devicekind: string, pageType: string, config: C
   };
 }
 
-export function useInitScene(scenekind: string) {
-  const scene = ref<Record<string, any>[]>([]);
-
-  // 获取设备数据,赋值并以选项格式返回给 Header 消费
-  function fetchScene() {
-    return getHomeData({}).then((result) => {
-      if (!result[scenekind]) return;
-      // 如果数据只有一条,转为数据
-      const records: { strinstallpos: string; id: string }[] = result[scenekind];
-      scene.value = records;
-    });
-  }
-
-  return {
-    fetchScene,
-    scene,
-  };
-}
+/**
+ * 根据模块的配置初始化基准 Module 组件需要的数据,包括选择框、设备等信息
+ * @param apidata api 返回的数据
+ * @param config 本模块的配置
+ */
+// export function useInitModule(moduleData: Config['moduleData'], apidata?: any) {
+//   const { header, mock } = moduleData;
+//   const data = mock || apidata;
+//   const devices = ref<Record<string, any>[]>([]);
+//   const options = ref<{ label: string; value: string }[]>([]);
+//   const selectedDeviceID = ref<string>('');
+
+//   const selectedDevice = computed(() => {
+//     return (
+//       devices.value.find((e) => {
+//         return e.id === selectedDeviceID.value;
+//       }) || {}
+//     );
+//   });
+//   const selectedDeviceLabel = computed(() => {
+//     const res = options.value.find((e) => {
+//       return e.value === selectedDeviceID.value;
+//     });
+//     return res ? res.label : '';
+//   });
+//   const selectedDeviceSlot = computed(() => {
+//     return getFormattedText(selectedDevice.value, header.slot.value);
+//   });
+// }