Преглед изворни кода

[Feat 0000] 添加指标表格对应的配置及组件

houzekong пре 7 месеци
родитељ
комит
9e09257aab

+ 113 - 0
src/views/vent/home/configurable/components/CustomTable.vue

@@ -0,0 +1,113 @@
+<template>
+  <div class="table">
+    <div class="table__content">
+      <div class="table__content_label" :class="`table__content_label_${type}`">
+        <div class="label-t" v-for="(item, index) in columns" :key="`svvhbcth-${index}`" :style="{ flexBasis }">{{ item.name }}</div>
+      </div>
+      <div class="table__content_list" :class="`table__content_list_${type}`">
+        <div class="table__content_list_row" v-for="(item, index) in data" :key="`svvhbct-${index}`">
+          <div v-for="(t, i) in columns" :key="`svvhbctr-${i}`" :style="{ flexBasis }" :class="`table__content__list_item_${type}`">
+            <slot :name="t.prop" :scope="item">
+              <span>{{ get(item, t.prop) }}</span>
+            </slot>
+          </div>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+<script lang="ts" setup>
+  import { computed, defineProps } from 'vue';
+  import _ from 'lodash-es';
+
+  let props = withDefaults(
+    defineProps<{
+      type: string;
+      /** 列表表头配置,每个prop都有其对应的slot来提供定制化功能 */
+      columns: { prop: string; name: string }[];
+      data: any[];
+      defaultValue: string;
+    }>(),
+    {
+      type: 'B',
+      columns: () => [],
+      data: () => [],
+      defaultValue: '/',
+    }
+  );
+
+  const flexBasis = computed(() => {
+    return Math.fround(100 / props.columns.length) + '%';
+  });
+
+  function get(o, p) {
+    const d = _.get(o, p, props.defaultValue);
+    return d === null ? props.defaultValue : d;
+  }
+</script>
+<style lang="less" scoped>
+  @import '@/design/vent/color.less';
+
+  @font-face {
+    font-family: 'douyuFont';
+    src: url('@/assets/font/douyuFont.otf');
+  }
+
+  .table__content {
+    height: 100%;
+    box-sizing: border-box;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+
+    .table__content_label {
+      width: 400px;
+      height: 32px;
+      display: flex;
+      justify-content: space-around;
+      align-items: center;
+      // background: url('@/assets/images/company/content-label.png') no-repeat;
+      .label-t {
+        // color: #3df6ff;
+        text-align: center;
+        font-size: 14px;
+      }
+    }
+    .table__content_label_B {
+      background-image: linear-gradient(to bottom, #04698c, #04698c00);
+      background-size: 100% 100%;
+      background-repeat: no-repeat;
+      color: #31b9ef;
+    }
+
+    .table__content_list {
+      height: calc(100% - 32px);
+      width: 400px;
+      display: flex;
+      flex-direction: column;
+      // justify-content: space-around;
+      justify-content: flex-start;
+      padding: 5px 0px;
+      box-sizing: border-box;
+      overflow-y: auto;
+      .table__content_list_row {
+        width: 100%;
+        height: 28px;
+        display: flex;
+        justify-content: space-around;
+        align-items: flex-start;
+        // background: url('@/assets/images/company/content-text.png') no-repeat;
+        color: #fff;
+        margin-bottom: 5px;
+        span {
+          display: inline-block;
+          text-align: center;
+        }
+      }
+
+      // .table__content__list_item_B {
+      //   border: 1px solid @vent-gas-tab-border;
+      // }
+    }
+  }
+</style>

+ 8 - 0
src/views/vent/home/configurable/components/content.vue

@@ -83,6 +83,13 @@
           :data="tableData"
           class="mt-20px mb-10px text-center flex-grow overflow-auto"
         />
+        <CustomTable
+          v-else
+          :type="config.type"
+          :columns="config.columns"
+          :data="tableData"
+          class="mt-20px mb-10px text-center flex-grow overflow-auto"
+        />
       </template>
       <template v-if="config.key === 'blast_delta'">
         <BlastDelta class="mt-10px mb-10px" :pos-monitor="blastDeltaData" :canvas-size="{ width: 250, height: 147 }" />
@@ -112,6 +119,7 @@
   import MiniBoard from './MiniBoard.vue';
   import TimelineList from './TimelineList.vue';
   import CustomList from './CustomList.vue';
+  import CustomTable from './CustomTable.vue';
   import { getFormattedText } from '../../../deviceManager/configurationTable/adapters';
   import CustomChart from './CustomChart.vue';
   import { get, clone } from 'lodash-es';

+ 1 - 1
src/views/vent/home/configurable/configurable.data.ts

@@ -658,7 +658,7 @@ export const testConfigA: Config[] = [
       preset: [],
       table: [
         {
-          type: 'A',
+          type: 'B',
           readFrom: 'history',
           columns: [
             {