lxp
2025-03-12 969d515ea19e01e20836d2862651f76e14b91e82
src/components/Table/lims-table.vue
@@ -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"
@@ -405,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) {
@@ -459,6 +465,7 @@
          this.$message.success("上传成功");
        }
      }
      this.$refs.upload.clearFiles();
    },
    onError(err, file, fileList) {
      this.$message.error("上传失败");