From bc44c8e3c9d85691ce3fa73ef1300a6fae46e365 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期二, 18 三月 2025 19:07:08 +0800
Subject: [PATCH] Merge branch 'dev' of http://114.132.189.42:9002/r/center-lims-before-ruoyi into dev

---
 src/components/Table/lims-table.vue |  249 +++++++++++++++++++++++--------------------------
 1 files changed, 118 insertions(+), 131 deletions(-)

diff --git a/src/components/Table/lims-table.vue b/src/components/Table/lims-table.vue
index b267378..e293a94 100644
--- a/src/components/Table/lims-table.vue
+++ b/src/components/Table/lims-table.vue
@@ -14,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"
@@ -45,6 +45,7 @@
         :filter-multiple="item.filterMultiple"
         :filtered-value="item.filteredValue"
         :filters="item.filters"
+        :fixed="item.fixed"
         :label="item.label"
         :min-width="item.minWidth"
         :prop="item.prop"
@@ -53,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
@@ -133,6 +132,89 @@
               >{{ scope.row[item.prop] | formatters(item.formatData) }}</el-tag
             >
           </div>
+
+          <!-- 鎸夐挳 -->
+          <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'"
+                size="mini"
+                v-if="o.showHide ? o.showHide(scope.row) : true"
+                :disabled="o.disabled ? o.disabled(scope.row) : false"
+                :icon="iconFn(o)"
+                :plain="o.plain"
+                :style="{ color: o.name === '鍒犻櫎' ? '#f56c6c' : o.color }"
+                :type="o.type | typeFn(scope.row)"
+                @click="o.clickFun(scope.row)"
+                :key="key"
+              >
+                {{ o.name }}
+              </el-button>
+              <el-upload
+                :action="javaApi + o.url"
+                size="mini"
+                ref="upload"
+                :multiple="o.multiple ? o.multiple : false"
+                :disabled="o.disabled ? o.disabled(scope.row) : false"
+                :accept="
+                  o.accept
+                    ? o.accept
+                    : '.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar'
+                "
+                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"
+                :on-exceed="onExceed"
+                :on-success="handleSuccessUp"
+                :show-file-list="false"
+                :key="key"
+              >
+                <el-button
+                  :size="o.size ? o.size : 'small'"
+                  type="text"
+                  :disabled="o.disabled ? o.disabled(scope.row) : false"
+                  >{{ o.name }}</el-button
+                >
+              </el-upload>
+              <el-upload
+                action="#"
+                :on-change="
+                  (file, fileList) => o.clickFun(scope.row, file, fileList)
+                "
+                :multiple="o.multiple ? o.multiple : false"
+                :limit="o.limit ? o.limit : 1"
+                :disabled="o.disabled ? o.disabled(scope.row) : false"
+                :accept="
+                  o.accept
+                    ? o.accept
+                    : '.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar'
+                "
+                v-if="o.type == 'upload' && !o.url"
+                style="display: inline-block; width: 50px"
+                v-show="o.showHide ? o.showHide(scope.row) : true"
+                :auto-upload="false"
+                :on-exceed="onExceed"
+                :show-file-list="false"
+                :key="key"
+              >
+                <el-button
+                  :size="o.size ? o.size : 'small'"
+                  type="text"
+                  :disabled="o.disabled ? o.disabled(scope.row) : false"
+                  >{{ o.name }}</el-button
+                >
+              </el-upload>
+            </template>
+          </div>
           <!-- 鍙偣鍑荤殑鏂囧瓧 -->
           <div
             v-else-if="item.dataType == 'link'"
@@ -151,107 +233,6 @@
               scope.row[item.prop] | formatters(item.formatData)
             }}</span>
           </div>
-        </template>
-      </el-table-column>
-      <!-- 鎿嶄綔鍒� -->
-      <el-table-column
-        v-if="table.operator"
-        :label="(table.operatorConfig && table.operatorConfig.label) || '鎿嶄綔'"
-        :width="
-          table.operatorConfig &&
-          (table.operatorConfig.width
-            ? table.operatorConfig.width
-            : calcOperationWidth())
-        "
-        :min-width="
-          (table.operatorConfig && table.operatorConfig.width) ||
-          table.operatorConfig.minWidth ||
-          100
-        "
-        align="center"
-        :fixed="table.operatorConfig ? table.operatorConfig.fixed : 'right'"
-        :show-overflow-tooltip="true"
-      >
-        <template slot-scope="scope">
-          <template v-for="(o, index) in table.operator">
-            <el-button
-              :key="index"
-              v-if="o.type != 'upload'"
-              @click.stop="o.clickFun(scope.row)"
-              :type="o.type || 'text'"
-              :icon="o.icon"
-              :size="o.size || 'small'"
-              :disabled="o.disabled ? o.disabled(scope.row) : false"
-              v-show="o.showFun ? o.showFun(scope.row) : true"
-              :class="[
-                'commonButton',
-                {
-                  del: o.name === '鍒犻櫎' || o.name === '浣滃簾',
-                },
-              ]"
-              >{{ o.name }}
-            </el-button>
-            <el-upload
-              :action="javaApi + o.url"
-              size="mini"
-              ref="upload"
-              :multiple="o.multiple ? o.multiple : false"
-              :disabled="o.disabled ? o.disabled(scope.row) : false"
-              :accept="
-                o.accept
-                  ? o.accept
-                  : '.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar'
-              "
-              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
-              "
-              :headers="uploadHeader"
-              :on-error="onError"
-              :on-exceed="onExceed"
-              :on-success="handleSuccessUp"
-              :show-file-list="false"
-              :key="index"
-            >
-              <el-button
-                :size="o.size ? o.size : 'small'"
-                type="text"
-                :disabled="o.disabled ? o.disabled(scope.row) : false"
-                >{{ o.name }}</el-button
-              >
-            </el-upload>
-            <el-upload
-              action="#"
-              :on-change="
-                (file, fileList) => o.clickFun(scope.row, file, fileList)
-              "
-              :multiple="o.multiple ? o.multiple : false"
-              :limit="o.limit ? o.limit : 1"
-              :disabled="o.disabled ? o.disabled(scope.row) : false"
-              :accept="
-                o.accept
-                  ? o.accept
-                  : '.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar'
-              "
-              v-if="o.type == 'upload' && !o.url"
-              style="display: inline-block; width: 50px"
-              v-show="o.showHide ? o.showHide(scope.row) : true"
-              :auto-upload="false"
-              :on-exceed="onExceed"
-              :show-file-list="false"
-              :key="index"
-            >
-              <el-button
-                :size="o.size ? o.size : 'small'"
-                type="text"
-                :disabled="o.disabled ? o.disabled(scope.row) : false"
-                >{{ o.name }}</el-button
-              >
-            </el-upload>
-          </template>
         </template>
       </el-table-column>
     </el-table>
@@ -338,9 +319,13 @@
     },
   },
   props: {
+    parentSpanMethod: {
+      type: Function,
+      default: () => {},
+    },
     isSelection: {
       type: Boolean,
-      default: false,
+      default: undefined,
     },
     height: {
       type: String,
@@ -386,18 +371,11 @@
         return {};
       },
     },
-    // column: {
-    //   type: Array,
-    //   default() {
-    //     return [];
-    //   },
-    // },
-    table: {
-      type: Object,
+    column: {
+      type: Array,
       default() {
-        return {};
+        return [];
       },
-      required: true,
     },
     rowClassName: {
       type: Function,
@@ -415,7 +393,7 @@
     },
     rowKey: {
       type: String,
-      default: undefined,
+      default: "id",
     },
     page: {
       type: Object,
@@ -432,41 +410,49 @@
   data() {
     return {
       spanList: [],
-      column: [],
+      btnWidth: "120px",
     };
   },
   watch: {
-    table(val) {
-      this.doLayout();
+    // 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();
-    this.column = this.table.column;
   },
   methods: {
-    //璁$畻鎿嶄綔鍒楃殑瀹藉害
-    calcOperationWidth() {
-      let width = 0;
-      this.table.operator.forEach((item) => {
-        width += item.name.length * 15 + 15;
-      });
-      return width;
-    },
     doLayout() {
       this.$nextTick(() => {
         this.$refs.multipleTable && this.$refs.multipleTable.doLayout();
       });
     },
-    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) {
@@ -528,6 +514,7 @@
       if (!linkEvent) {
         return this.$message.warning("璇烽厤缃甽ingk浜嬩欢");
       }
+      console.log(linkEvent);
       linkEvent.vueComponent[linkEvent.method](row);
     },
     // 鍚堝苟鍗曞厓鏍�

--
Gitblit v1.9.3