From 1b0a3d7e887e31ae37dcfa9ba8e0ae77a9bfa5a6 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 12 三月 2025 17:07:59 +0800
Subject: [PATCH] 设备搬迁-设备使用记录联调

---
 src/components/Table/lims-table.vue |   53 +++++++++++++++++++++++++++++++++--------------------
 1 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/src/components/Table/lims-table.vue b/src/components/Table/lims-table.vue
index 9f948f0..198e6ee 100644
--- a/src/components/Table/lims-table.vue
+++ b/src/components/Table/lims-table.vue
@@ -13,7 +13,7 @@
       :row-style="rowStyle"
       :row-key="rowKey"
       :span-method="spanMethod"
-      stripe
+      :stripe="stripe"
       style="width: 100%"
       tooltip-effect="dark"
       @row-click="rowClick"
@@ -52,10 +52,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 +132,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,16 +152,10 @@
                 {{ o.name }}
               </el-button>
               <el-upload
-                :action="
-                  javaApi +
-                  o.url +
-                  '?id=' +
-                  (o.uploadIdFun ? o.uploadIdFun(scope.row) : scope.row.id)
-                "
+                :action="javaApi + o.url"
                 size="mini"
                 ref="upload"
                 :multiple="o.multiple ? o.multiple : false"
-                :limit="1"
                 :disabled="o.disabled ? o.disabled(scope.row) : false"
                 :accept="
                   o.accept
@@ -169,6 +164,10 @@
                 "
                 v-if="o.type == 'upload' && o.url"
                 style="display: inline-block; width: 50px"
+                :data="o.data ? o.data(scope.row) : {}"
+                :before-upload="
+                  o.beforeUpload ? o.beforeUpload(scope.row) : () => true
+                "
                 v-show="o.showHide ? o.showHide(scope.row) : true"
                 :headers="uploadHeader"
                 :on-error="onError"
@@ -217,11 +216,13 @@
           <!-- 鍙偣鍑荤殑鏂囧瓧 -->
           <div
             v-else-if="item.dataType == 'link'"
-            class="cell link"
+            class="cell"
             style="width: 100%"
-            @click="goLink(scope.row, item.linkMethod)"
+            @click="goLink(scope.row, item.linkEvent)"
           >
-            <span v-if="!item.formatData">{{ scope.row[item.prop] }}</span>
+            <span class="link" v-if="!item.formatData">
+              {{ scope.row[item.prop] }}
+            </span>
           </div>
           <!-- 榛樿绾睍绀烘暟鎹� -->
           <div v-else class="cell" style="width: 100%">
@@ -354,6 +355,10 @@
       type: Boolean,
       default: false,
     },
+    stripe: {
+      type: Boolean,
+      default: false,
+    },
     headerCellStyle: {
       type: Object,
       default: () => {
@@ -399,21 +404,28 @@
   data() {
     return {
       spanList: [],
+      btnWidth: "120px",
     };
+  },
+  watch: {
+    column(val) {
+      this.doLayout();
+    },
   },
   mounted() {
     this.calculateSpanInfo();
   },
   methods: {
-    getWidth(row) {
+    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) {
@@ -453,6 +465,7 @@
           this.$message.success("涓婁紶鎴愬姛");
         }
       }
+      this.$refs.upload.clearFiles();
     },
     onError(err, file, fileList) {
       this.$message.error("涓婁紶澶辫触");
@@ -470,11 +483,11 @@
       return (this.page.current - 1) * this.page.size + index + 1;
     },
     // 鐐瑰嚮鍗曞厓鏍糽ink浜嬩欢
-    goLink(row, linkMethod) {
-      if (!linkMethod) {
+    goLink(row, linkEvent) {
+      if (!linkEvent) {
         return this.$message.warning("璇烽厤缃甽ingk浜嬩欢");
       }
-      this.$parent[linkMethod](row);
+      linkEvent.vueComponent[linkEvent.method](row);
     },
     // 鍚堝苟鍗曞厓鏍�
     calculateSpanInfo() {

--
Gitblit v1.9.3