ソースを参照

[Mod 0000] 场景类历史数据组件更新表头处理方式

houzekong 9 ヶ月 前
コミット
4c0dff19bb

+ 18 - 17
src/views/vent/comment/history/HistoryTable.vue

@@ -25,9 +25,10 @@
   //
   // 1、配置设备字段(参考公司端综合设备管理-设备字段管理)
   // 以压风机为例,设压风机设备的历史数据编码为forcFan_history。
-  // 那么字段code中加$的字段将允许动态展示数据,例子如下:
+  // 那么字段code中需要把所有字段悉数配置,例子如下:
   //  显示字段    字段code
-  //   温度        $Temp
+  //   温度     forcFan1Temp
+  //   温度     forcFan2Temp
   //  安装位置      name
   //
   // 2、配置数据字典(参考系统管理-数据字典),为上述设备配置子设备
@@ -41,10 +42,10 @@
   // 同以压风机为例,需使用device-code(forcFan)、dict-code(forcFan_dict)。
   //
   // 4、其他内容说明
-  // 同以压风机为例,当子设备没有数据,此时展示的数据是:
-  //  温度    安装位置
-  // 取Temp    取name
-  // 同以压风机为例,当子设备选择压风机1时,此时展示的数据是:
+  // 同以压风机为例,当子设备没有数据时,不进行过滤,此时展示的数据是:
+  //      温度    安装位置
+  // 取forcFan2Temp    取name
+  // 同以压风机为例,当子设备选择压风机1时,过滤压风机1相关的表头,此时展示的数据是:
   //      温度        安装位置
   // 取forcFan1Temp    取name
   import { onMounted, ref, shallowRef } from 'vue';
@@ -101,7 +102,7 @@
       const cols = getTableHeaderColumns(code);
       if (cols.length) {
         originColumns = cols;
-        setColumns(cols);
+        updateColumns(dictOptions[0].value);
         break;
       }
     }
@@ -118,16 +119,16 @@
    * 更新表头,表头默认情况下需要和子设备联动
    * @param prefix 子设备的值,即为表头取数据时字段的前缀
    */
-  function updateColumns(prefix: string) {
-    const cols = originColumns.map((col) => {
-      const di = col.dataIndex as string;
-      if (di && di.includes('$')) {
-        return {
-          ...col,
-          dataIndex: di.replace('$', prefix),
-        };
+  function updateColumns(prefix?: string) {
+    if (!prefix) return;
+    // 如果有子设备信息,筛选符合规范的表头
+    const cols = originColumns.filter(({ dataIndex }) => {
+      // 获取到子设备编码的前缀,如 forcFan 之于 forcFan1,如果表头以该前缀打头则进行过滤,否则放行
+      const [_, pfx] = prefix.match(/([A-Za-z]+)([0-9]+)/) || [];
+      if ((dataIndex as string).startsWith(pfx)) {
+        return (dataIndex as string).startsWith(prefix);
       }
-      return col;
+      return true;
     });
     setColumns(cols);
   }
@@ -203,7 +204,7 @@
     }) as Record<string, unknown>;
     const code = (deviceInfo.value.deviceType || props.deviceCode.concat('*')) as string;
     await fetchData(formData, code, deviceInfo.value);
-    updateColumns(formData.deviceNum || '');
+    updateColumns(formData.deviceNum);
   }
 
   onMounted(async () => {

+ 9 - 1
src/views/vent/home/billboard/billboard.data.ts

@@ -150,7 +150,7 @@ export const GAS_STATUS_HEADER_CONFIG = [
 export const SUMMARY_HEADER_CONFIG = [
   {
     label: '风险分析',
-    prop: 'gasWarnLevel',
+    prop: 'level',
     type: 'to-bottom-right',
   },
 ];
@@ -220,6 +220,14 @@ export const DEFAULT_TEST_DATA = {
     xufengliang: 0, //总需风量
     zongjinfeng: '/', //总进风
   },
+  sys_warndata: {
+    levels: 0,
+    fire: '0',
+    sb: '0',
+    ws: '0',
+    fc: '0',
+    tf: '0',
+  },
   orgname: '/',
   orgcode: '/',
   ip: 'localhost',