Browse Source

[Feat 0000] 开发应用了可配置首页模块的均压场景检测页面

houzekong 1 day ago
parent
commit
a0df2a2481

+ 177 - 0
src/views/vent/monitorManager/balancePressMonitor/components/balancePressHome2.vue

@@ -0,0 +1,177 @@
+<template>
+  <a-spin tip="Loading..." :spinning="loading">
+    <div class="monitor-container">
+      <ModuleCommon
+        v-for="cfg in configs"
+        :key="cfg.deviceType"
+        :show-style="cfg.showStyle"
+        :module-data="cfg.moduleData"
+        :module-name="cfg.moduleName"
+        :device-type="cfg.deviceType"
+        :data="selectData"
+        :visible="true"
+      />
+    </div>
+  </a-spin>
+</template>
+<script setup lang="ts">
+  import { ref, onMounted, onUnmounted, defineProps } from 'vue';
+  import { mountedThree, destroy, setModelType, updateText, play } from '../balancePress.threejs';
+  import { list } from '../balancePress.api';
+  import ModuleCommon from '../../../home/configurable/components/ModuleCommon.vue';
+  import { useInitConfigs } from '../../../home/configurable/hooks/useInit';
+
+  const props = defineProps({
+    deviceId: {
+      type: String,
+      require: true,
+    },
+  });
+
+  const loading = ref(false);
+
+  // 监测数据
+  const selectData = ref();
+
+  // https获取监测数据
+  let timer: any = null;
+  function getMonitor(flag?) {
+    if (Object.prototype.toString.call(timer) === '[object Null]') {
+      timer = setTimeout(
+        async () => {
+          if (props.deviceId) {
+            const data = await getDataSource(props.deviceId);
+            // Object.assign(selectData, data);
+            updateText(selectData);
+            selectData.value = data;
+          }
+          if (timer) {
+            timer = null;
+          }
+          await getMonitor();
+          loading.value = false;
+        },
+        flag ? 0 : 1000
+      );
+    }
+  }
+
+  async function getDataSource(systemID) {
+    const res = await list({ devicetype: 'sys', systemID });
+    const result = Array.from(res.msgTxt).reduce((obj: any, e: any) => {
+      obj[e.type] = e;
+      return obj;
+    }, {});
+
+    console.log('debug', result);
+
+    return result;
+  }
+
+  // const configs: Config[] = [
+  //   {
+  //     deviceType: '',
+  //     moduleName: 'CO与O2监测',
+  //     pageType: '',
+  //     moduleData: {
+  //       header: {
+  //         show: false,
+  //         readFrom: '',
+  //         selector: {
+  //           show: false,
+  //           value: '${strinstallpos}',
+  //         },
+  //         slot: {
+  //           show: false,
+  //           value: '',
+  //         },
+  //       },
+  //       background: {
+  //         show: false,
+  //         type: 'image',
+  //         link: '',
+  //       },
+  //       layout: {
+  //         direction: 'column',
+  //         items: [
+  //           {
+  //             name: 'complex_list',
+  //             basis: '100%',
+  //           },
+  //         ],
+  //       },
+  //       complex_list: [
+  //         {
+  //           type: 'G',
+  //           readFrom: 'fanlocal_steml_zj.datalist',
+  //           mapFromData: true,
+  //           items: [
+  //             {
+  //               title: 'datalist细则',
+  //               contents: [
+  //                 {
+  //                   label: '阀门2开度',
+  //                   value: '${readData.Fan1fI}',
+  //                   color: 'blue',
+  //                 },
+  //                 {
+  //                   label: '阀门3开度',
+  //                   value: '${readData.Fan1fI}',
+  //                   color: 'blue',
+  //                 },
+  //                 {
+  //                   label: '阀门1开度',
+  //                   value: '${readData.Fan1fI}',
+  //                   color: 'blue',
+  //                 },
+  //               ],
+  //             },
+  //           ],
+  //         },
+  //       ],
+  //       chart: [],
+  //       table: [],
+  //       gallery: [],
+  //       list: [],
+  //       gallery_list: [],
+  //       preset: [],
+  //       to: '',
+  //     },
+  //     showStyle: {
+  //       size: 'width:344px;height:490px;',
+  //       version: '原版',
+  //       position: 'top:80px;right:10px;',
+  //     },
+  //   },
+  // ];
+
+  const { configs, fetchConfigs } = useInitConfigs();
+
+  onMounted(() => {
+    // getMonitor()
+    fetchConfigs('balancePressHome');
+    loading.value = true;
+    mountedThree().then(async () => {
+      await setModelType('balancePressBase'); //balancePressBase
+      loading.value = false;
+      timer = null;
+      await getMonitor(true);
+      play('startSmoke', 'top', 30, 'open', 0);
+    });
+  });
+
+  onUnmounted(() => {
+    destroy();
+    if (timer) {
+      clearTimeout(timer);
+    }
+  });
+</script>
+<style lang="less" scoped>
+  @import '/@/design/vent/modal.less';
+  @import '../../comment/less/workFace.less';
+  @ventSpace: zxm;
+  .monitor-container {
+    margin-top: 60px;
+  }
+</style>