瀏覽代碼

[Mod 0000] 瓦斯看板可折叠表格支持数据排序及分项可折叠功能

houzekong 10 小時之前
父節點
當前提交
44fa69e267

+ 2 - 0
src/views/vent/home/billboard/billboard.data.ts

@@ -563,6 +563,8 @@ export const DEFAULT_TEST_DATA = {
         warnLevel: '/',
         warnLevel: '/',
         num: '/',
         num: '/',
         typeName: '/',
         typeName: '/',
+        maxValueInstallPos: null,
+        maxValue: null,
       },
       },
     ],
     ],
   },
   },

+ 11 - 3
src/views/vent/home/billboard/components/CollapseTable.vue

@@ -4,7 +4,12 @@
       <div class="label-t" v-for="(item, index) in columns" :key="`svvhbcth-${index}`" :style="{ flexBasis }">{{ item.name }}</div>
       <div class="label-t" v-for="(item, index) in columns" :key="`svvhbcth-${index}`" :style="{ flexBasis }">{{ item.name }}</div>
     </div>
     </div>
     <Collapse v-model:activeKey="avtiveCollapse" ghost class="table__content_list" :style="{ height: contentHeight }">
     <Collapse v-model:activeKey="avtiveCollapse" ghost class="table__content_list" :style="{ height: contentHeight }">
-      <CollapsePanel v-for="(item, index) in data" :key="`svvhbct-${index}`" class="table__content_list_row" :showArrow="showArrow">
+      <CollapsePanel
+        v-for="(item, index) in data"
+        :key="`svvhbct-${index}`"
+        class="table__content_list_row"
+        :showArrow="item.hideCollapses ? false : showArrow"
+      >
         <template #header>
         <template #header>
           <div v-for="(t, i) in columns" :key="`svvhbctr-${i}`" :style="{ flexBasis }">
           <div v-for="(t, i) in columns" :key="`svvhbctr-${i}`" :style="{ flexBasis }">
             <slot :name="t.prop" :scope="item">
             <slot :name="t.prop" :scope="item">
@@ -12,7 +17,7 @@
             </slot>
             </slot>
           </div>
           </div>
         </template>
         </template>
-        <template #default>
+        <template v-if="!item.hideCollapses" #default>
           <p v-for="(t, i) in collapses" :key="`svvhbctc-${i}`" class="table__content_list_collapse"> {{ t.name }}:{{ get(item, t.prop) }} </p>
           <p v-for="(t, i) in collapses" :key="`svvhbctc-${i}`" class="table__content_list_collapse"> {{ t.name }}:{{ get(item, t.prop) }} </p>
         </template>
         </template>
       </CollapsePanel>
       </CollapsePanel>
@@ -21,7 +26,7 @@
 </template>
 </template>
 <script lang="ts" setup>
 <script lang="ts" setup>
   import { computed, defineProps, ref } from 'vue';
   import { computed, defineProps, ref } from 'vue';
-  import _ from 'lodash-es';
+  import _ from 'lodash';
   import { Collapse, CollapsePanel } from 'ant-design-vue';
   import { Collapse, CollapsePanel } from 'ant-design-vue';
 
 
   let props = withDefaults(
   let props = withDefaults(
@@ -33,6 +38,8 @@
       defaultValue: string;
       defaultValue: string;
       contentHeight: string;
       contentHeight: string;
       showArrow: boolean;
       showArrow: boolean;
+      /** 是否自动过滤折叠展开后无有效内容的项 */
+      filterNil: boolean;
     }>(),
     }>(),
     {
     {
       columns: () => [],
       columns: () => [],
@@ -41,6 +48,7 @@
       defaultValue: '/',
       defaultValue: '/',
       contentHeight: '220px',
       contentHeight: '220px',
       showArrow: true,
       showArrow: true,
+      filterNil: false,
     }
     }
   );
   );
 
 

+ 14 - 9
src/views/vent/home/billboard/components/GasStatus.vue

@@ -7,15 +7,15 @@
         <LargeBoard :label="item.label" :value="headerData[item.prop]" :type="item.type" />
         <LargeBoard :label="item.label" :value="headerData[item.prop]" :type="item.type" />
       </Col>
       </Col>
     </Row>
     </Row>
-    <CommonTable class="mt-10px" :columns="GAS_STATUS_COLUMN" :data="tableData" content-height="160px" />
+    <CollapseTable class="mt-10px" :columns="GAS_STATUS_COLUMN" :data="tableData" :collapses="GAS_COLLAPSES" content-height="160px" />
   </template>
   </template>
 </template>
 </template>
 <script lang="ts" setup>
 <script lang="ts" setup>
   import { Row, Col, Result } from 'ant-design-vue';
   import { Row, Col, Result } from 'ant-design-vue';
-  import { GAS_STATUS_HEADER_CONFIG, GAS_STATUS_COLUMN, BillboardType } from '../billboard.data';
+  import { GAS_STATUS_HEADER_CONFIG, GAS_STATUS_COLUMN, GAS_COLLAPSES, BillboardType } from '../billboard.data';
   import LargeBoard from './LargeBoard.vue';
   import LargeBoard from './LargeBoard.vue';
   import { computed } from 'vue';
   import { computed } from 'vue';
-  import CommonTable from './CommonTable.vue';
+  import CollapseTable from './CollapseTable.vue';
   import { get } from '../utils';
   import { get } from '../utils';
   // import mapComponent from './components/3Dmap/index.vue';
   // import mapComponent from './components/3Dmap/index.vue';
 
 
@@ -35,12 +35,17 @@
   });
   });
   const tableData = computed(() => {
   const tableData = computed(() => {
     const info = props.data.gasInfo;
     const info = props.data.gasInfo;
-    return get(info, 'gasTypeList', []).map((e) => {
-      return {
-        ...e,
-        warnLevelStr: trans[e.warnLevel],
-      };
-    });
+    return get(info, 'gasTypeList', [])
+      .map((e) => {
+        return {
+          ...e,
+          hideCollapses: !e[GAS_COLLAPSES[0].prop],
+          warnLevelStr: trans[e.warnLevel],
+        };
+      })
+      .sort((a) => {
+        return a.hideCollapses ? 1 : -1;
+      });
   });
   });
 
 
   const riskTrans = {
   const riskTrans = {