From 45792b3776cda2e1ada31755ffc226a663f90b48 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期三, 19 三月 2025 15:32:23 +0800
Subject: [PATCH] 锁屏功能

---
 src/components/Table/lims-table.vue |   65 +++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 15 deletions(-)

diff --git a/src/components/Table/lims-table.vue b/src/components/Table/lims-table.vue
index 9b35d19..e293a94 100644
--- a/src/components/Table/lims-table.vue
+++ b/src/components/Table/lims-table.vue
@@ -4,6 +4,8 @@
     <el-table
       ref="multipleTable"
       v-loading="tableLoading"
+      element-loading-text="鍔犺浇涓�..."
+      element-loading-spinner="el-icon-loading"
       :border="border"
       :data="tableData"
       :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }"
@@ -12,7 +14,7 @@
       :row-class-name="rowClassName"
       :row-style="rowStyle"
       :row-key="rowKey"
-      :span-method="spanMethod"
+      :span-method="finalSpanMethod"
       :stripe="stripe"
       style="width: 100%"
       tooltip-effect="dark"
@@ -52,10 +54,8 @@
         "
         :sortable="item.sortable ? true : false"
         :type="item.type"
-        :width="
-          item.dataType === 'action' ? getWidth(item.operation) : item.width
-        "
         align="center"
+        :width="item.dataType == 'action' ? btnWidth : item.width"
       >
         <!-- <div class="123" v-if="item.type == ''"> -->
         <template
@@ -134,7 +134,10 @@
           </div>
 
           <!-- 鎸夐挳 -->
-          <div v-else-if="item.dataType == 'action'">
+          <div
+            v-else-if="item.dataType == 'action'"
+            :style="`width:${getWidth(item.operation, scope.row)}`"
+          >
             <template v-for="(o, key) in item.operation">
               <el-button
                 v-show="o.type != 'upload'"
@@ -151,10 +154,7 @@
                 {{ o.name }}
               </el-button>
               <el-upload
-                :action="
-                  javaApi +
-                  o.url
-                "
+                :action="javaApi + o.url"
                 size="mini"
                 ref="upload"
                 :multiple="o.multiple ? o.multiple : false"
@@ -166,9 +166,11 @@
                 "
                 v-if="o.type == 'upload' && o.url"
                 style="display: inline-block; width: 50px"
-                v-show="o.showHide ? o.showHide(scope.row) : true"
                 :data="o.data ? o.data(scope.row) : {}"
-                :before-upload="o.beforeUpload ? o.beforeUpload(scope.row) : () => true"
+                :before-upload="
+                  o.beforeUpload ? o.beforeUpload(scope.row) : () => true
+                "
+                v-show="o.showHide ? o.showHide(scope.row) : true"
                 :headers="uploadHeader"
                 :on-error="onError"
                 :on-exceed="onExceed"
@@ -317,9 +319,13 @@
     },
   },
   props: {
+    parentSpanMethod: {
+      type: Function,
+      default: () => {},
+    },
     isSelection: {
       type: Boolean,
-      default: false,
+      default: undefined,
     },
     height: {
       type: String,
@@ -387,7 +393,7 @@
     },
     rowKey: {
       type: String,
-      default: undefined,
+      default: "id",
     },
     page: {
       type: Object,
@@ -404,21 +410,49 @@
   data() {
     return {
       spanList: [],
+      btnWidth: "120px",
     };
+  },
+  watch: {
+    // column(val) {
+    //   this.doLayout();
+    // },
+  },
+  updated() {
+    this.$nextTick(() => {
+      this.$refs.multipleTable.doLayout();
+    });
+  },
+  computed: {
+    finalSpanMethod() {
+      if(this.parentSpanMethod) {
+        console.log('鐖剁粍浠剁殑鍚堝苟鏂规硶');
+        return this.parentSpanMethod;
+      }else{
+        console.log('瀛愮粍浠剁殑鍚堝苟鏂规硶');
+        return this.spanMethod;
+      }
+    },
   },
   mounted() {
     this.calculateSpanInfo();
   },
   methods: {
-    getWidth(row) {
+    doLayout() {
+      this.$nextTick(() => {
+        this.$refs.multipleTable && this.$refs.multipleTable.doLayout();
+      });
+    },
+    getWidth(row, row0) {
       let count = 0;
       row.forEach((a) => {
-        if (a.showHide !== undefined && a.showHide()) {
+        if (a.showHide !== undefined && a.showHide(row0)) {
           count += a.name.length;
         } else if (!a.showHide) {
           count += a.name.length;
         }
       });
+      this.btnWidth = count * 15 + 70 + "px";
       return count * 15 + 70 + "px";
     },
     iconFn(row) {
@@ -480,6 +514,7 @@
       if (!linkEvent) {
         return this.$message.warning("璇烽厤缃甽ingk浜嬩欢");
       }
+      console.log(linkEvent);
       linkEvent.vueComponent[linkEvent.method](row);
     },
     // 鍚堝苟鍗曞厓鏍�

--
Gitblit v1.9.3