From 0286939336746905caeadf2f31748ecbd4aee9b4 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期一, 10 四月 2023 16:45:18 +0800
Subject: [PATCH] 1.基础设置下模块下的动态列渲染完成

---
 src/views/deviceManager/deviceList.vue |  376 +++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 277 insertions(+), 99 deletions(-)

diff --git a/src/views/deviceManager/deviceList.vue b/src/views/deviceManager/deviceList.vue
index a232cba..7936d4c 100644
--- a/src/views/deviceManager/deviceList.vue
+++ b/src/views/deviceManager/deviceList.vue
@@ -126,8 +126,13 @@
       </div>
 
       <div class="elTableDiv" style="margin-top: 0;">
+        <TableColumnSettings
+          :list1="tableColumnSettingsArray"
+          @tableColumnUpdate="tableColumnUpdate"
+        />
         <el-table
           ref="tableDataRef"
+          :key="tableTimeStampKey"
           :data="tableData"
           border
           class="tableFixed"
@@ -139,111 +144,141 @@
           :cell-style="this.$cellStyle"
           @sort-change="sortChange"
         >
+
+          <el-table-column
+            v-for="item in tableColumnSettingsArray"
+            v-if="item.show"
+            :key="item.id"
+            :sortable="item.sortable"
+            :prop="item.prop"
+            :min-width="item.minWidth"
+            :label="item.label"
+            :width="item.width"
+            show-tooltip-when-overflow
+            :fixed="item.fixed?(item.fixed==='left'?'left':'right'):false"
+          >
+            <template slot-scope="{row}">
+              <div v-if="!row[item.prop]">/</div>
+              <div v-else-if="item.prop==='input_date'">{{ row[item.prop]? row[item.prop].substring(0,11):'' }}</div>
+              <div v-else-if="item.prop==='enable'">
+                <div v-if="row.enable==='Y'">
+                  <i class="el-icon-success" :style="{color:$store.state.settings.theme}" style="margin-right: 2px" />
+                  鏄�
+                </div>
+                <div v-if="row.enable==='N'">
+                  <i class="el-icon-info" style="margin-right: 2px" />
+                  鍚�
+                </div>
+              </div>
+              <div v-else>{{ row[item.prop] }}</div>
+            </template>
+          </el-table-column>
+
           <!--          <el-table-column-->
           <!--            type="selection"-->
           <!--            width="50"-->
           <!--          />-->
-          <el-table-column
-            prop="RowNum"
-            width="50"
-            label="搴忓彿"
-            fixed
-          />
-          <el-table-column
-            prop="code"
-            label="璁惧缂栫爜"
-            min-width="110"
-            sortable="custom"
-            show-tooltip-when-overflow
-          />
-          <el-table-column
-            prop="name"
-            label="璁惧鍚嶇О"
-            min-width="110"
-            sortable="custom"
-            show-tooltip-when-overflow
-          />
-          <el-table-column
-            prop="eqptype_name"
-            label="璁惧绫诲瀷"
-            min-width="110"
-            sortable="custom"
-            show-tooltip-when-overflow
-          />
-          <el-table-column
-            prop="eqpgroup_name"
-            label="璁惧缁�"
-            show-tooltip-when-overflow
-            min-width="110"
-            sortable="custom"
-          />
-          <el-table-column
-            prop="enable"
-            label="浣跨敤鐘舵��"
-            sortable="custom"
-            show-tooltip-when-overflow
-            width="120"
-          >
-            <template slot-scope="{row}">
-              <div v-if="row.enable==='Y'">
-                <i class="el-icon-success" :style="{color:$store.state.settings.theme}" style="margin-right: 2px" />
-                鏄�
-              </div>
-              <div v-if="row.enable==='N'">
-                <i class="el-icon-info" style="margin-right: 2px" />
-                鍚�
-              </div>
-            </template>
-          </el-table-column>
-          <el-table-column
-            prop="input_date"
-            label="鎶曞叆鏃ユ湡"
-            show-tooltip-when-overflow
-            sortable="custom"
-            width="120"
-          >
-            <template slot-scope="{row}">
-              <div>{{ row.input_date.substring(0, 10) }}</div>
-            </template>
-          </el-table-column>
-          <el-table-column
-            prop="wksp_name"
-            label="鐢熶骇杞﹂棿"
-            sortable="custom"
-            show-tooltip-when-overflow
-            min-width="120"
-          />
           <!--          <el-table-column-->
-          <!--            prop="Line_name"-->
-          <!--            label="鎵�灞炰骇绾�"-->
+          <!--            prop="RowNum"-->
+          <!--            width="50"-->
+          <!--            label="搴忓彿"-->
+          <!--            fixed-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="code"-->
+          <!--            label="璁惧缂栫爜"-->
+          <!--            min-width="110"-->
+          <!--            sortable="custom"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="name"-->
+          <!--            label="璁惧鍚嶇О"-->
+          <!--            min-width="110"-->
+          <!--            sortable="custom"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="eqptype_name"-->
+          <!--            label="璁惧绫诲瀷"-->
+          <!--            min-width="110"-->
+          <!--            sortable="custom"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="eqpgroup_name"-->
+          <!--            label="璁惧缁�"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            min-width="110"-->
           <!--            sortable="custom"-->
           <!--          />-->
-          <el-table-column
-            prop="operation_ration"
-            label="绋煎姩鐜�"
-            show-tooltip-when-overflow
-            sortable="custom"
-            width="100"
-          >
-            <template slot-scope="{row}">
-              <div v-if=" parseFloat(row.operation_ration)===0">/</div>
-              <div v-else>{{ row.operation_ration }}%</div>
-            </template>
-          </el-table-column>
-          <el-table-column
-            prop="lm_user"
-            label="鍒涘缓浜哄憳"
-            sortable="custom"
-            width="120"
-            show-tooltip-when-overflow
-          />
-          <el-table-column
-            prop="lm_date"
-            width="160"
-            label="鍒涘缓鏃堕棿"
-            show-tooltip-when-overflow
-            sortable="custom"
-          />
+          <!--          <el-table-column-->
+          <!--            prop="enable"-->
+          <!--            label="浣跨敤鐘舵��"-->
+          <!--            sortable="custom"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            width="120"-->
+          <!--          >-->
+          <!--            <template slot-scope="{row}">-->
+          <!--              <div v-if="row.enable==='Y'">-->
+          <!--                <i class="el-icon-success" :style="{color:$store.state.settings.theme}" style="margin-right: 2px" />-->
+          <!--                鏄�-->
+          <!--              </div>-->
+          <!--              <div v-if="row.enable==='N'">-->
+          <!--                <i class="el-icon-info" style="margin-right: 2px" />-->
+          <!--                鍚�-->
+          <!--              </div>-->
+          <!--            </template>-->
+          <!--          </el-table-column>-->
+          <!--          <el-table-column-->
+          <!--            prop="input_date"-->
+          <!--            label="鎶曞叆鏃ユ湡"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            sortable="custom"-->
+          <!--            width="120"-->
+          <!--          >-->
+          <!--            <template slot-scope="{row}">-->
+          <!--              <div>{{ row.input_date.substring(0, 10) }}</div>-->
+          <!--            </template>-->
+          <!--          </el-table-column>-->
+          <!--          <el-table-column-->
+          <!--            prop="wksp_name"-->
+          <!--            label="鐢熶骇杞﹂棿"-->
+          <!--            sortable="custom"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            min-width="120"-->
+          <!--          />-->
+          <!--          &lt;!&ndash;          <el-table-column&ndash;&gt;-->
+          <!--          &lt;!&ndash;            prop="Line_name"&ndash;&gt;-->
+          <!--          &lt;!&ndash;            label="鎵�灞炰骇绾�"&ndash;&gt;-->
+          <!--          &lt;!&ndash;            sortable="custom"&ndash;&gt;-->
+          <!--          &lt;!&ndash;          />&ndash;&gt;-->
+          <!--          <el-table-column-->
+          <!--            prop="operation_ration"-->
+          <!--            label="绋煎姩鐜�"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            sortable="custom"-->
+          <!--            width="100"-->
+          <!--          >-->
+          <!--            <template slot-scope="{row}">-->
+          <!--              <div v-if=" parseFloat(row.operation_ration)===0">/</div>-->
+          <!--              <div v-else>{{ row.operation_ration }}%</div>-->
+          <!--            </template>-->
+          <!--          </el-table-column>-->
+          <!--          <el-table-column-->
+          <!--            prop="lm_user"-->
+          <!--            label="鍒涘缓浜哄憳"-->
+          <!--            sortable="custom"-->
+          <!--            width="120"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="lm_date"-->
+          <!--            width="160"-->
+          <!--            label="鍒涘缓鏃堕棿"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--            sortable="custom"-->
+          <!--          />-->
           <el-table-column
             label="鎿嶄綔"
             fixed="right"
@@ -657,11 +692,12 @@
 import ImportPicker from '@/components/ImportPicker'
 import elDragDialog from '@/directive/el-drag-dialog'
 import waves from '@/directive/waves'
+import TableColumnSettings from '@/components/TableColumnSettings'
 
 export default {
   name: 'SBQD',
   components: {
-    Pagination, ImportPicker
+    Pagination, ImportPicker, TableColumnSettings
   },
   directives: { elDragDialog, waves },
   data() {
@@ -691,6 +727,141 @@
       DeviceGroupArr: [], // 璁惧缁勬暟缁�
       total: 10,
       tableData: [],
+      tableColumnSettingsArray: [
+        { minWidth: false, width: 55, prop: 'id', label: 'id', id: 1, show: false, fixed: false, sortable: false }, // 闅愯棌鍒�  show: false闅愯棌锛宼rue鏄剧ず
+        { minWidth: false, width: 55, prop: 'RowNum', label: '搴忓彿', id: 2, show: true, fixed: 'left', sortable: false }, // custom
+        {
+          minWidth: false,
+          width: 110,
+          prop: 'code',
+          label: '璁惧缂栫爜',
+          id: 3,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: 110,
+          width: false,
+          prop: 'name',
+          label: '璁惧鍚嶇О',
+          id: 4,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: false,
+          width: 130,
+          prop: 'eqptype_code',
+          label: '璁惧绫诲瀷缂栫爜',
+          id: 5,
+          show: false,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: 110,
+          width: false,
+          prop: 'eqptype_name',
+          label: '璁惧绫诲瀷',
+          id: 6,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: false,
+          width: 120,
+          prop: 'eqpgroup_code',
+          label: '璁惧缁勭紪鐮�',
+          id: 7,
+          show: false,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: 110,
+          width: false,
+          prop: 'eqpgroup_name',
+          label: '璁惧缁�',
+          id: 8,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: false,
+          width: 110,
+          prop: 'enable',
+          label: '浣跨敤鐘舵��',
+          id: 9,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: false,
+          width: 110,
+          prop: 'input_date',
+          label: '鎶曞叆鏃ユ湡',
+          id: 10,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: false,
+          width: 130,
+          prop: 'wksp_code',
+          label: '鐢熶骇杞﹂棿缂栫爜',
+          id: 11,
+          show: false,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: 110,
+          width: false,
+          prop: 'wksp_name',
+          label: '鐢熶骇杞﹂棿',
+          id: 12,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: false,
+          width: 110,
+          prop: 'operation_ration',
+          label: '绋煎姩鐜�',
+          id: 13,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: false,
+          width: 110,
+          prop: 'lm_user',
+          label: '鍒涘缓浜哄憳',
+          id: 14,
+          show: true,
+          fixed: false,
+          sortable: true
+        },
+        {
+          minWidth: false,
+          width: 160,
+          prop: 'lm_date',
+          label: '鍒涘缓鏃堕棿',
+          id: 15,
+          show: true,
+          fixed: false,
+          sortable: true
+        }
+      ],
+      tableTimeStampKey: new Date().getTime(), // 琛ㄦ牸key
       dialogVisible: false,
       dialogForm: {
         id: '',
@@ -772,6 +943,13 @@
     this.getHeight()
   },
   methods: {
+    tableColumnUpdate(val, isCopyTrue) {
+      if (isCopyTrue) {
+        this.tableColumnSettingsArray = val
+      }
+      this.tableTimeStampKey = new Date().getTime()
+      this.$refs.tableDataRef.doLayout()
+    },
     // 璁惧娓呭崟瀵煎叆
     upload() {
       this.shows = true

--
Gitblit v1.9.3