dengjunjie
2025-04-19 9e579eda4601ed7b492b9d19a24e8146f6ebdf8d
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSClient/src/components/basic/VolTable.vue
@@ -5,7 +5,7 @@
    :class="[
      textInline ? 'text-inline' : '',
      fxRight ? 'fx-right' : '',
      isChrome ? 'chrome' : ''
      isChrome ? 'chrome' : '',
    ]"
  >
    <div class="mask" v-show="loading"></div>
@@ -36,15 +36,8 @@
      :row-class-name="initIndex"
      :cell-style="getCellStyle"
      style="width: 100%"
      :scrollbar-always-on="true"
      :scrollbar-always-on="true"
    >
      <el-table-column
        v-if="columnIndex"
        type="index"
        :fixed="fixed"
        width="55"
      ></el-table-column>
      <el-table-column
        v-if="ck"
        type="selection"
@@ -52,7 +45,14 @@
        :selectable="selectable"
        width="55"
      ></el-table-column>
      <!-- :selectable="selectable" -->
      <el-table-column
        v-if="columnIndex"
        type="index"
        :fixed="fixed"
        label="序号"
        width="55"
      ></el-table-column>
      <!-- 2020.10.10移除table第一行强制排序 -->
      <el-table-column
        v-for="(column, cindex) in filterColumns"
@@ -64,7 +64,7 @@
        :key="column.field + cindex"
        :align="column.align"
        :sortable="column.sort ? 'custom' : false"
        :show-overflow-tooltip="column.showOverflowTooltip"
        :show-overflow-tooltip="true"
      >
        <template #header>
          <span
@@ -135,40 +135,55 @@
          <!-- å¯ç”¨åŒå‡»ç¼–辑功能,带编辑功能的不会渲染下拉框文本背景颜色 -->
          <!-- @click="rowBeginEdit(scope.$index,cindex)" -->
          <!-- 2021.09.21增加编辑时对readonly属性判断 -->
           <template v-else-if="column.edit&&!column.readonly&&['file', 'img','excel'].indexOf(column.edit.type) != -1" >
                <div style="display:flex;align-items: center;" @click.stop>
                  <i style="padding: 3px;margin-right: 10px;color:#8f9293;cursor: pointer;" @click="showUpload(scope.row, column)" class="el-icon-upload"></i>
                   <img
                    v-if="column.edit.type == 'img'"
                    v-for="(file, imgIndex) in getFilePath(
                      scope.row[column.field],
                      column
                    )"
                    :key="imgIndex"
                    :onerror="defaultImg"
                    @click="viewImg(scope.row, column, file.path, $event)"
                    class="table-img"
                    :src="file.path"
                  />
                  <a
                    style="margin-right: 8px"
                    v-else
                    class="t-file"
                    v-for="(file, fIndex) in getFilePath(
                      scope.row[column.field],
                      column
                    )"
                    :key="fIndex"
                    @click="dowloadFile(file)"
                    >{{ file.name }}</a
                  >
                </div>
          <template
            v-else-if="
              column.edit &&
              !column.readonly &&
              ['file', 'img', 'excel'].indexOf(column.edit.type) != -1
            "
          >
            <div style="display: flex; align-items: center" @click.stop>
              <i
                style="
                  padding: 3px;
                  margin-right: 10px;
                  color: #8f9293;
                  cursor: pointer;
                "
                @click="showUpload(scope.row, column)"
                class="el-icon-upload"
              ></i>
              <img
                v-show="column.edit.type == 'img'"
                v-for="(file, imgIndex) in getFilePath(
                  scope.row[column.field],
                  column
                )"
                :key="imgIndex"
                :onerror="defaultImg"
                @click="viewImg(scope.row, column, file.path, $event)"
                class="table-img"
                :src="file.path"
              />
              <a
                style="margin-right: 8px"
                v-show="column.edit.type != 'img'"
                class="t-file"
                v-for="(file, fIndex) in getFilePath(
                  scope.row[column.field],
                  column
                )"
                :key="fIndex"
                @click="dowloadFile(file)"
                >{{ file.name }}</a
              >
            </div>
          </template>
          <div
            v-else-if="
              column.edit &&
                !column.readonly &&
                (column.edit.keep || edit.rowIndex == scope.$index)
              !column.readonly &&
              (column.edit.keep || edit.rowIndex == scope.$index)
            "
            class="edit-el"
          >
@@ -274,7 +289,7 @@
                        ? true
                        : false
                    "
                    :multiple="column.edit.type == 'select' ? false : true"
                    :multiple="column.edit.type == 'select'"
                    :placeholder="column.placeholder || column.title"
                    :autocomplete="column.autocomplete"
                    @change="
@@ -440,231 +455,239 @@
    lazy
  >
    <!-- ä¸Šä¼ å›¾ç‰‡ã€excel或其他文件、文件数量、大小限制都可以,参照volupload组件api -->
    <div style="height: 200px;display: flex;align-items: center;">
    <div style="height: 200px; display: flex; align-items: center">
      <VolUpload
      style="text-align: center; "
      :autoUpload="currentColumn.edit.autoUpload"
      :multiple="currentColumn.edit.multiple"
      :url="uploadUrl"
      :max-file="currentColumn.edit.maxFile"
      :img="currentColumn.edit.type == 'img'"
      :excel="currentColumn.edit.type == 'excel'"
      :fileTypes="currentColumn.edit.fileTypes ? currentColumn.edit.fileTypes : []"
      :fileInfo="fileInfo"
      :upload-after="uploadAfter"
    >
      <div>{{ currentColumn.message}}</div>
    </VolUpload>
        style="text-align: center"
        :autoUpload="currentColumn.edit.autoUpload"
        :multiple="currentColumn.edit.multiple"
        :url="uploadUrl"
        :max-file="currentColumn.edit.maxFile"
        :img="currentColumn.edit.type == 'img'"
        :excel="currentColumn.edit.type == 'excel'"
        :fileTypes="
          currentColumn.edit.fileTypes ? currentColumn.edit.fileTypes : []
        "
        :fileInfo="fileInfo"
        :upload-after="uploadAfter"
      >
        <div>{{ currentColumn.message }}</div>
      </VolUpload>
    </div>
    <template #footer>
        <div style="text-align: center; ">
          <el-button type="default" size="small" @click="uploadModel=false">关闭</el-button >
          <el-button type="primary" size="small" @click="saveUpload" >保存</el-button >
        </div>
      <div style="text-align: center">
        <el-button type="default" size="small" @click="uploadModel = false"
          >关闭</el-button
        >
        <el-button type="primary" size="small" @click="saveUpload"
          >保存</el-button
        >
      </div>
    </template>
  </VolBox>
</template>
<script>
import VolTableRender from './VolTable/VolTableRender';
import VolTableRender from "./VolTable/VolTableRender";
let _errMsg;
import { defineComponent,defineAsyncComponent } from 'vue';
import { defineComponent, defineAsyncComponent } from "vue";
export default defineComponent({
  //https://github.com/element-plus/element-plus/issues/1483
  //没有原先的selection属性了,看issue上使用select/selectall获取
  //监听数组长度,如果删除了数据,现在只能被迫清除所有选中的行
  watch: {
    'tableData.length': {
    "tableData.length": {
      handler(newLen, oldLen) {
        this.watchRowSelectChange(newLen, oldLen);
      }
      },
    },
    'rowData.length': {
    "rowData.length": {
      handler(newLen, oldLen) {
        this.watchRowSelectChange(newLen, oldLen);
      }
    }
      },
    },
  },
  components: { 'table-render': VolTableRender,
  VolUpload: defineAsyncComponent(() =>import("@/components/basic/VolUpload.vue") ),
  VolBox: defineAsyncComponent(() => import("@/components/basic/VolBox.vue")),
},
  components: {
    "table-render": VolTableRender,
    VolUpload: defineAsyncComponent(() =>
      import("@/components/basic/VolUpload.vue")
    ),
    VolBox: defineAsyncComponent(() => import("@/components/basic/VolBox.vue")),
  },
  props: {
    rowKey: {
      // æ ‘形结构的主键字段,如果设置值默认会开启树形table;注意rowKey字段的值必须是唯一(2021.05.02)
      typeof: String,
      default: undefined
      default: undefined,
    },
    loadTreeChildren: {
      // æ ‘形结构加载子节点
      type: Function,
      default: (tree, treeNode, resolve) => {
        return resolve([]);
      }
      },
    },
    textInline: {
      // è¡¨æ ¼å†…容超出后是否换行显示(2020.01.16)
      type: Boolean,
      default: true
      default: true,
    },
    tableData: {
      // è¡¨æ•°æ®æº,配置了url就不用传这个参数了
      type: Array,
      default: () => {
        return [];
      }
      },
    },
    columns: {
      type: Array,
      default: []
      default: [],
    },
    height: {
      type: Number,
      default: 0
      default: 0,
    },
    maxHeight: {
      type: Number,
      default: 0
      default: 0,
    },
    linkView: {
      type: Function,
      default: function() {
      default: function () {
        return 1;
      }
      },
    },
    pagination: {
      type: Object,
      default: function() {
        return { total: 0, size: 30, sortName: '' };
      }
      default: function () {
        return { total: 0, size: 30, sortName: "" };
      },
    },
    url: {
      type: String,
      default: ''
      default: "",
    },
    paginationHide: {
      type: Boolean,
      default: true
      default: true,
    },
    color: {
      type: Boolean,
      default: true
      default: true,
    },
    index: {
      // æ˜¯å¦åˆ›å»ºç´¢å¼•号,如果需要表格编辑功能,这里需要设置为true
      type: Boolean,
      default: false
      default: false,
    },
    allowEmpty: {
      // è¡¨æ ¼æ•°æ®ä¸ºç©ºæ—¶æ˜¯å¦é»˜è®¤ä¸º--
      type: Boolean,
      default: true
      default: true,
    },
    defaultLoadPage: {
      // ä¼ å…¥äº†url,是否默认加载表格数据
      type: Boolean,
      default: true
      default: true,
    },
    loadKey: {
      // æ˜¯å¦è‡ªåŠ¨ä»ŽåŽå°åŠ è½½æ•°æ®æº
      type: Boolean,
      default: true
      default: true,
    },
    single: {
      type: Boolean, // æ˜¯å¦å•选
      default: false
      default: false,
    },
    doubleEdit: {
      type: Boolean, // æ˜¯å¦åŒå‡»å¯ç”¨ç¼–辑功能
      default: true
      default: true,
    },
    beginEdit: {
      // ç¼–辑开始
      type: Function,
      default: function(row, column, index) {
      default: function (row, column, index) {
        return true;
      }
      },
    },
    endEditBefore: {
      // ç»“束编辑前
      type: Function,
      default: function(row, column, index) {
      default: function (row, column, index) {
        return true;
      }
      },
    },
    endEditAfter: {
      // ç»“束编辑前
      type: Function,
      default: function(row, column, index) {
      default: function (row, column, index) {
        return true;
      }
      },
    },
    ck: {
      // æ˜¯å¦æ˜¾ç¤ºcheckbox
      type: Boolean,
      default: true
      default: true,
    },
    columnIndex: {
      // æ˜¯å¦æ˜¾ç¤ºè¡Œå·(2020..11.1)
      type: Boolean,
      default: true
      default: true,
    },
    highlightCurrentRow: {
      //增加选中行高亮显示(2022.10.07)
      type: Boolean,
      default: true
      default: true,
    },
    select2Count: {
      //超出数量显示select2组件
      type: Number,
      default: 500
      default: 500,
    },
    selectable: {
      type: Function,
      default: (row, index) => {
        return true;
      }
    }
      },
    },
  },
  data() {
    return {
      fixed: true, //是固定行号与checkbox
      fixed: false, //是固定行号与checkbox
      clickEdit: true, //2021.07.17设置为点击行结束编辑
      randomTableKey: 1,
      visiblyColumns: [],
      key: '',
      key: "",
      realHeight: 0,
      realMaxHeight: 0,
      enableEdit: false, // æ˜¯å¦å¯è¡¨æ ¼ç”¨ç¼–辑功能
      empty: this.allowEmpty ? '' : '--',
      defaultImg: 'this.src="' + require('@/assets/imgs/error.png') + '"',
      empty: this.allowEmpty ? "" : "--",
      defaultImg: 'this.src="' + require("@/assets/imgs/error.png") + '"',
      loading: false,
      footer: {},
      total: 0,
      formatConfig: {},
      // defaultColor: "",
      // 2020.09.06调整table列数据源的背景颜色
      colors: ['', 'warning', 'success', 'danger', 'info'],
      colors: ["", "warning", "success", "danger", "info"],
      rule: {
        phone: /^[1][3,4,5,6,7,8,9][0-9]{9}$/,
        decimal: /(^[\-0-9][0-9]*(.[0-9]+)?)$/,
        number: /(^[\-0-9][0-9]*([0-9]+)?)$/
        number: /(^[\-0-9][0-9]*([0-9]+)?)$/,
      },
      columnNames: [],
      rowData: [],
      paginations: {
        sort: '',
        order: 'desc',
        Foots: '',
        sort: "",
        order: "desc",
        Foots: "",
        total: 0,
        // 2020.08.29增加自定义分页条大小
        sizes: [30, 60, 100, 120],
        size: 30, // é»˜è®¤åˆ†é¡µå¤§å°
        Wheres: [],
        page: 1,
        rows: 30
        rows: 30,
      },
      errorFiled: '',
      errorFiled: "",
      edit: { columnIndex: -1, rowIndex: -1 }, // å½“前双击编辑的行与列坐标
      editStatus: {},
      summary: false, // æ˜¯å¦æ˜¾ç¤ºåˆè®¡
@@ -679,11 +702,11 @@
      //vol-table带数据源的单元格是否启用tag标签(下拉框等单元格以tag标签显示)
      //2023.04.02更新voltable与main.js
      useTag: true,
      currentRow:{},
      currentColumn:[],
      fileInfo:[],
      uploadUrl:"",
      uploadModel:false
      currentRow: {},
      currentColumn: [],
      fileInfo: [],
      uploadUrl: "",
      uploadModel: false,
    };
  },
  created() {
@@ -702,12 +725,12 @@
    this.realHeight = this.getHeight();
    this.realMaxHeight = this.getMaxHeight();
    this.fxRight = this.columns.some((x) => {
      return x.fixed == 'right';
      return x.fixed == "right";
    });
    //2021.09.21移除强制固定行号与checkbox列
    if (
      this.columns.some((x) => {
        return x.fixed && x.fixed != 'right';
        return x.fixed && x.fixed != "right";
      })
    ) {
      this.fixed = true;
@@ -729,9 +752,9 @@
    // ä»ŽåŽå°åŠ ä¸‹æ‹‰æ¡†çš„[是否启用的]数据源
    let keys = [];
    let columnBind = [];
    this.summaryData.push('合计');
    this.summaryData.push("合计");
    if (this.columnIndex) {
      this.summaryData.push(' ');
      this.summaryData.push(" ");
    }
    this.columns.forEach((x, _index) => {
      if (x.cellStyle) {
@@ -740,7 +763,7 @@
      if (!x.hidden) {
        // this.summaryIndex[x.field] = _index;
        // 2020.10.11修复求和列错位的问题
        this.summaryData.push('');
        this.summaryData.push("");
        this.summaryIndex[x.field] = this.summaryData.length - 1;
      }
      // æ±‚å’Œ
@@ -761,7 +784,7 @@
    });
    if (keys.length > 0) {
      this.http
        .post('/api/Sys_Dictionary/GetVueDictionary', keys)
        .post("/api/Sys_Dictionary/GetVueDictionary", keys)
        .then((dic) => {
          dic.forEach((x) => {
            if (x.data.length > this.select2Count) {
@@ -774,7 +797,7 @@
              // è½¬æ¢æ•°æ®æºçš„类型与列的类型一致(2020.04.04)
              if (
                c.key == x.dicNo &&
                (c.valueTyoe == 'int' || c.valueTyoe == 'sbyte')
                (c.valueTyoe == "int" || c.valueTyoe == "sbyte")
              ) {
                x.data.forEach((d) => {
                  // 2020.09.01增加对数字类型的二次判断
@@ -796,7 +819,7 @@
      this.paginations.rows = this.pagination.size;
    }
    this.enableEdit = this.columns.some((x) => {
      return x.hasOwnProperty('edit');
      return x.hasOwnProperty("edit");
    });
    let keyColumn = this.columns.find((x) => {
      return x.isKey;
@@ -814,7 +837,7 @@
        }
        return !x.hidden;
      });
    }
    },
  },
  methods: {
    watchRowSelectChange(newLen, oldLen) {
@@ -861,29 +884,16 @@
    },
    rowDbClick(row, column, event) {
      //2021.05.23增加双击行事件
      this.$emit('rowDbClick', { row, column, event });
      this.$emit("rowDbClick", { row, column, event });
    },
    rowClick(row, column, event) {
    //   row.selectable = !row.selectable;
    // this.$refs.table.toggleRowSelection(row);
    // if(this.batchDeleteArr.length > 0){
    //     this.checkNum = this.batchDeleteArr.length
    //     this.isCheck = true
    // }else{
    //     this.isCheck = false
    // }
      //2022.02.20增加点击时表格参数判断
      if (!column) {
        return;
      }
      //正在编辑时,禁止出发rowClick事件
      if (this.edit.rowIndex == -1) {
        this.$emit('rowClick', { row, column, event });
        this.$emit("rowClick", { row, column, event });
      }
      // ç‚¹å‡»è¡Œäº‹ä»¶(2020.11.07)
@@ -911,7 +921,7 @@
        //当正在编辑,且点击到其他行时,在原编辑的行结束编辑后,触发新行的rowClick事件
        //正在编辑时,禁止出发rowClick事件
        if (this.edit.rowIndex == -1) {
          this.$emit('rowClick', { row, column, event });
          this.$emit("rowClick", { row, column, event });
        }
      }
      this.rowBeginEdit(row, column);
@@ -921,7 +931,7 @@
        file.path,
        file.name,
        {
          Authorization: this.$store.getters.getToken()
          Authorization: this.$store.getters.getToken(),
        },
        this.http.ipAddress
      );
@@ -935,17 +945,17 @@
        return column.formatter(pathSring);
      }
      let filePath;
      if (column.base64 && pathSring.indexOf('data') != -1) {
        filePath = (',' + pathSring)
          .split(',data')
      if (column.base64 && pathSring.indexOf("data") != -1) {
        filePath = ("," + pathSring)
          .split(",data")
          .filter((x) => {
            return x;
          })
          .map((m) => {
            return 'data' + m;
            return "data" + m;
          });
      } else {
        filePath = pathSring.replace(/\\/g, '/').split(',');
        filePath = pathSring.replace(/\\/g, "/").split(",");
      }
      let fileInfo = [];
@@ -954,17 +964,17 @@
        // 2020.12.19增加base64图片显示
        if (column.base64) {
          fileInfo.push({
            name: '',
            name: "",
            path:
              (file.indexOf('data') == -1 ? 'data:image/png;base64,' : '') +
              file
              (file.indexOf("data") == -1 ? "data:image/png;base64," : "") +
              file,
          });
        } else if (file.indexOf('.') != -1) {
          let splitFile = file.split('/');
        } else if (file.indexOf(".") != -1) {
          let splitFile = file.split("/");
          if (splitFile.length > 0) {
            fileInfo.push({
              name: splitFile[splitFile.length - 1],
              path: this.base.isUrl(file) ? file : this.http.ipAddress + file
              path: this.base.isUrl(file) ? file : this.http.ipAddress + file,
            });
          }
        }
@@ -986,7 +996,7 @@
          this.paginations.wheres.splice(0);
        }
      }
      this.errorFiled = '';
      this.errorFiled = "";
      this.edit.columnIndex = -1;
      this.edit.rowIndex = -1;
    },
@@ -1062,13 +1072,13 @@
        if (
          //不能编辑的字段、switch,点击不开启启编辑功能
          !_row.edit ||
          (_row.edit.keep && _row.edit.type == 'switch')
          (_row.edit.keep && _row.edit.type == "switch")
        ) {
          return;
        }
      }
      if (!this.enableEdit) return;
      _errMsg = '';
      _errMsg = "";
      // ç¼–辑前
      this.columns
        .filter((x) => {
@@ -1076,21 +1086,21 @@
        })
        .forEach((column) => {
          let val = row[column.field];
          if (typeof column.bind.data[0].key == 'string') {
            if (typeof val == 'number') {
              row[column.field] = row[column.field] + '';
          if (typeof column.bind.data[0].key == "string") {
            if (typeof val == "number") {
              row[column.field] = row[column.field] + "";
            }
          } else {
            if (typeof val == 'string' && val) {
            if (typeof val == "string" && val) {
              let _val = val * 1;
              if (_val + '' === val) {
              if (_val + "" === val) {
                row[column.field] = _val;
              }
            }
          }
        });
      if (!this.beginEdit(row, column, row.elementIndex)) return;
      if (row.hasOwnProperty('elementIndex')) {
      if (row.hasOwnProperty("elementIndex")) {
        if (this.edit.rowIndex == row.elementIndex) {
          return;
        }
@@ -1150,16 +1160,16 @@
        this.$message.error(option1.title + _errMsg);
        return false;
      }
      this.errorFiled = '';
      this.errorFiled = "";
      return true;
    },
    validateColum(option, data) {
      if (option.hidden || option.bind) return true;
      let val = data[option.field];
      if (option.require || option.required) {
        if (val != '0' && (val === '' || val === undefined)) {
        if (val != "0" && (val === "" || val === undefined)) {
          if (!this.errorFiled) {
            _errMsg = '不能为空';
            _errMsg = "不能为空";
          }
          return false;
        }
@@ -1169,52 +1179,52 @@
      }
      let editType = option.edit.type;
      // éªŒè¯æ•°å­—
      if (editType == 'int' || editType == 'decimal' || editType == 'number') {
        if (val == '' || val == undefined) return true;
        if (editType == 'decimal') {
      if (editType == "int" || editType == "decimal" || editType == "number") {
        if (val == "" || val == undefined) return true;
        if (editType == "decimal") {
          if (!this.rule.decimal.test(val)) {
            _errMsg = '只能是数字';
            _errMsg = "只能是数字";
            return false;
          }
        } else if (!this.rule.decimal.test(val)) {
          _errMsg = '只能是数字';
          _errMsg = "只能是数字";
          return false;
        }
        if (
          option.edit.min != undefined &&
          typeof option.edit.min === 'number' &&
          typeof option.edit.min === "number" &&
          val < option.edit.min
        ) {
          _errMsg = '不能小于' + option.edit.min;
          _errMsg = "不能小于" + option.edit.min;
          return false;
        }
        if (
          option.edit.max != undefined &&
          typeof option.edit.max === 'number' &&
          typeof option.edit.max === "number" &&
          val > option.edit.max
        ) {
          _errMsg = '不能大于' + option.edit.max;
          _errMsg = "不能大于" + option.edit.max;
          return false;
        }
        return true;
      }
      // éªŒè¯å­—符串
      if (val && (editType == 'text' || editType == 'string')) {
      if (val && (editType == "text" || editType == "string")) {
        if (
          option.edit.min != undefined &&
          typeof option.edit.min === 'number' &&
          typeof option.edit.min === "number" &&
          val.length < option.edit.min
        ) {
          _errMsg = '至少' + option.edit.min + '个字符';
          _errMsg = "至少" + option.edit.min + "个字符";
          return false;
        }
        if (
          option.edit.max != undefined &&
          typeof option.edit.max === 'number' &&
          typeof option.edit.max === "number" &&
          val.length > option.edit.max
        ) {
          _errMsg = '最多' + option.edit.max + '个字符';
          _errMsg = "最多" + option.edit.max + "个字符";
          return false;
        }
      }
@@ -1222,7 +1232,7 @@
    },
    delRow() {
      let rows = this.getSelected();
      if (rows.length == 0) return this.$Message.error('请选择要删除的行!');
      if (rows.length == 0) return this.$Message.error("请选择要删除的行!");
      let data = this.url ? this.rowData : this.tableData;
      let indexArr = this.getSelectedIndex();
@@ -1262,8 +1272,8 @@
        // 2022.05.06 æ·»åŠ è¡Œæ—¶ï¼Œå¦‚æžœåˆ—æœ‰ç¼–è¾‘å±žæ€§ï¼Œè®¾ç½®å¼€å¯ç¼–è¾‘(避免关闭编辑后,无法再次启用编辑)??
        //x.readonly = false;
        if (!row.hasOwnProperty(x.field)) {
          if (x.edit && x.edit.type == 'switch') {
            row[x.field] = x.type == 'bool' ? false : 0;
          if (x.edit && x.edit.type == "switch") {
            row[x.field] = x.type == "bool" ? false : 0;
          } else if (!row.hidden) {
            // 2020.09.06添加行时,设置默认字段
            row[x.field] = undefined;
@@ -1308,7 +1318,7 @@
        let key = column.bind.key;
        let data = [];
        rows.forEach((row) => {
          if (row[column.field] || row[column.field] == '0') {
          if (row[column.field] || row[column.field] == "0") {
            if (data.indexOf(row[column.field]) == -1) {
              data.push(row[column.field]);
            }
@@ -1321,7 +1331,7 @@
      if (remoteInfo.length == 0) return;
      // ha= Object.assign([], ha, hb)
      this.http
        .post('/api/Sys_Dictionary/GetTableDictionary', remoteInfo)
        .post("/api/Sys_Dictionary/GetTableDictionary", remoteInfo)
        .then((dic) => {
          dic.forEach((x) => {
            this.remoteColumns.forEach((column) => {
@@ -1331,7 +1341,7 @@
              }
            });
          });
          this.$emit('dicInited', dic);
          this.$emit("dicInited", dic);
        });
    },
    load(query, isResetPage) {
@@ -1345,7 +1355,7 @@
        rows: this.paginations.rows,
        sort: this.paginations.sort,
        order: this.paginations.order,
        wheres: [] // æŸ¥è¯¢æ¡ä»¶ï¼Œæ ¼å¼ä¸º[{ name: "字段", value: "xx" }]
        wheres: [], // æŸ¥è¯¢æ¡ä»¶ï¼Œæ ¼å¼ä¸º[{ name: "字段", value: "xx" }]
      };
      let status = true;
      // åˆå¹¶æŸ¥è¯¢ä¿¡æ¯(包查询分页、排序、查询条件等)
@@ -1358,7 +1368,7 @@
          callBack(true);
        })
      */
      this.$emit('loadBefore', param, (result) => {
      this.$emit("loadBefore", param, (result) => {
        status = result;
      });
      if (!status) return;
@@ -1378,7 +1388,7 @@
          // æŸ¥è¯¢è¿”回结果后处理
          // 2020.10.30增加查询后返回所有的查询信息
          this.$emit(
            'loadAfter',
            "loadAfter",
            data.rows || [],
            (result) => {
              status = result;
@@ -1406,11 +1416,11 @@
      this.summaryData.splice(0);
      // å¼€å¯äº†è¡Œå·çš„,+1
      if (this.columnIndex) {
        this.summaryData.push('');
        this.summaryData.push("");
      }
      // å¦‚果有checkbox,应该算作是第一行
      if (this.ck) {
        this.summaryData.push('');
        this.summaryData.push("");
      }
      this.columns.forEach((col) => {
@@ -1422,8 +1432,8 @@
          this.getColumnSummaries(col, data);
        }
      });
      if (this.summaryData.length > 0 && this.summaryData[0] == '') {
        this.summaryData[0] = '合计';
      if (this.summaryData.length > 0 && this.summaryData[0] == "") {
        this.summaryData[0] = "合计";
      }
    },
    getColumnSummaries(col, data) {
@@ -1432,12 +1442,12 @@
          let sum = data.summary[col.field];
          if (sum) {
            sum =
              (sum * 1.0).toFixed(col.numberLength || 2).replace('.00', '') *
              (sum * 1.0).toFixed(col.numberLength || 2).replace(".00", "") *
              1.0;
          }
          this.summaryData.push(sum);
        } else {
          this.summaryData.push('');
          this.summaryData.push("");
        }
      }
    },
@@ -1453,7 +1463,7 @@
    },
    sortChange(sort) {
      this.paginations.sort = sort.prop;
      this.paginations.order = sort.order == 'ascending' ? 'asc' : 'desc';
      this.paginations.order = sort.order == "ascending" ? "asc" : "desc";
      this.load();
    },
    resetPage() {
@@ -1467,7 +1477,7 @@
      this.selectRows = selection;
      if (this.single) {
        if (selection.length == 1) {
          this.$emit('rowChange', selection[0]);
          this.$emit("rowChange", selection[0]);
        }
        if (selection.length > 1) {
          let _row = selection[selection.length - 1];
@@ -1476,18 +1486,18 @@
        }
      }
      // å°†selectionchange暴露出去
      this.$emit('selectionChange', selection);
      this.$emit("selectionChange", selection);
    },
    getColor(row, column) {
      let val = row[column.field];
      if (column.getColor && typeof column.getColor === 'function') {
      if (column.getColor && typeof column.getColor === "function") {
        let _color = column.getColor(row, column);
        if (_color) {
          return _color;
        }
      }
      if (!val && val != '0') {
        return '';
      if (!val && val != "0") {
        return "";
      }
      if (!this.formatConfig[column.field]) {
        this.formatConfig[column.field] = [val];
@@ -1498,7 +1508,7 @@
        return this.colors[index];
      }
      if (this.formatConfig[column.field].length > 5) {
        return '';
        return "";
      }
      if (index == -1) {
@@ -1508,38 +1518,45 @@
      return this.colors[index];
    },
    formatterDate(row, column) {
      return (row[column.field] || '').substr(0, 10);
      return (row[column.field] || "").substr(0, 10);
    },
    formatter(row, column, template) {
      if (!template) return row[column.property];
      let val = row[column.field];
      if (!val && val != 0) return val;
      // æ˜¯å¦å€¼
      if (column.edit && column.edit.type == 'switch') {
        return val ? '是' : '否';
      if (column.edit && column.edit.type == "switch") {
        return val ? "是" : "否";
      }
      if (!column.bind || !column.bind.data) {
        return row[column.field];
      }
      if (column.edit && (column.edit.type == 'selectList'||column.edit.type=='treeSelect')) {
      if (
        column.edit &&
        (column.edit.type == "selectList" || column.edit.type == "treeSelect")
      ) {
        if (!Array.isArray(val)) {
          row[column.field] = val.split(',');
          row[column.field] = val.split(",");
        } else {
          val = val.join(',');
          val = val.join(",");
        }
        return this.getSelectFormatter(column, val);
      }
      // ç¼–辑多选table显示
      if (column.bind.type == 'selectList' || column.bind.type == 'checkbox'||column.bind.type=='treeSelect') {
       // if (typeof val === 'string' && val.indexOf(',') != -1) {
          return this.getSelectFormatter(column, val+'');
      //  }
      if (
        column.bind.type == "selectList" ||
        column.bind.type == "checkbox" ||
        column.bind.type == "treeSelect"
      ) {
        // if (typeof val === 'string' && val.indexOf(',') != -1) {
        return this.getSelectFormatter(column, val + "");
        //  }
      }
      let source = column.bind.data.filter((x) => {
        // return x.key != "" && x.key == val;
        // 2020.06.06修复单独使用table组件时,key为数字0时转换成文本失败的问题
        return x.key !== '' && x.key !== undefined && x.key + '' === val + '';
        return x.key !== "" && x.key !== undefined && x.key + "" === val + "";
      });
      if (source && source.length > 0) val = source[0].label || source[0].value;
      return val;
@@ -1548,12 +1565,16 @@
      // ç¼–辑多选table显示
      let valArr = val.split(",");
      for (let index = 0; index < valArr.length; index++) {
        ( column.bind.orginData&&column.bind.orginData.length
          ?column.bind.orginData
          :column.bind.data)
        .forEach((x) => {
        (column.bind.orginData && column.bind.orginData.length
          ? column.bind.orginData
          : column.bind.data
        ).forEach((x) => {
          // 2020.06.06修复数据源为selectList时,key为数字0时不能转换文本的问题
          if (x.key !== "" && x.key !== undefined && x.key + "" == valArr[index] + "") {
          if (
            x.key !== "" &&
            x.key !== undefined &&
            x.key + "" == valArr[index] + ""
          ) {
            valArr[index] = x.label || x.value;
          }
        });
@@ -1582,11 +1603,11 @@
        }
      });
      if (sum) {
        if (column.summary == 'avg') {
        if (column.summary == "avg") {
          sum = sum / (this.rowData.length || this.tableData.length || 1);
        }
        sum =
          (sum * 1.0).toFixed(column.numberLength || 2).replace('.00', '') *
          (sum * 1.0).toFixed(column.numberLength || 2).replace(".00", "") *
          1.0;
      }
      this.summaryData[this.summaryIndex[column.field]] = sum;
@@ -1613,7 +1634,7 @@
      }
      return (
        date1.valueOf() <
        (typeof date2 == 'number' ? date2 : new Date(date2).valueOf())
        (typeof date2 == "number" ? date2 : new Date(date2).valueOf())
      );
    },
    getDateOptions(date, item) {
@@ -1621,9 +1642,9 @@
      if ((!item.min && !item.max) || !date) {
        return false;
      }
      if (item.min && item.min.indexOf(' ') == -1) {
      if (item.min && item.min.indexOf(" ") == -1) {
        //不设置时分秒,后面会自动加上 08:00
        item.min = item.min + ' 00:00:000';
        item.min = item.min + " 00:00:000";
      }
      return (
        this.compareDate(date, item.min) || !this.compareDate(date, item.max)
@@ -1631,19 +1652,19 @@
    },
    getDateFormat(column) {
      //见https://day.js.org/docs/zh-CN/display/format
      return column.edit.type == 'date' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss';
      return column.edit.type == "date" ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm:ss";
    },
    userSelect(selection, row) {
      this.selectRows = selection;
      if (!this.single) {
        this.$emit('rowChange', { row, selection });
        this.$emit("rowChange", { row, selection });
      }
    },
    isEmptyTag(row, column) {
      if (!row[column.field] && row[column.field] != '0') {
        return 'empty-tag';
      if (!row[column.field] && row[column.field] != "0") {
        return "empty-tag";
      }
      return '';
      return "";
    },
    filterChildrenColumn(children) {
      if (!children) {
@@ -1656,33 +1677,40 @@
    initColumnDisabled(row, column) {
      return column.getDisabled && column.getDisabled(row, column);
    },
    showUpload(row,column){
       this.fileInfo = (row[column.field] || '').split(",")
                    .filter(x => { return x })
                    .map(item => {
                       return { path: item, name: "" };
                    })
      this.currentRow=row;
      this.currentColumn=column;
      if (this.currentColumn.edit.autoUpload===undefined) {
        this.currentColumn.edit.autoUpload=true;
    showUpload(row, column) {
      this.fileInfo = (row[column.field] || "")
        .split(",")
        .filter((x) => {
          return x;
        })
        .map((item) => {
          return { path: item, name: "" };
        });
      this.currentRow = row;
      this.currentColumn = column;
      if (this.currentColumn.edit.autoUpload === undefined) {
        this.currentColumn.edit.autoUpload = true;
      }
      if (this.currentColumn.edit.multiple===undefined) {
        this.currentColumn.edit.multiple=false;
      if (this.currentColumn.edit.multiple === undefined) {
        this.currentColumn.edit.multiple = false;
      }
      if (this.currentColumn.edit.url===undefined) {
          this.uploadUrl='api/'+(this.url||'').replace('/api','api').split('/')[1]+'/upload'
      }else{
        this.uploadUrl=this.currentColumn.edit.url;
      if (this.currentColumn.edit.url === undefined) {
        this.uploadUrl =
          "api/" +
          (this.url || "").replace("/api", "api").split("/")[1] +
          "/upload";
      } else {
        this.uploadUrl = this.currentColumn.edit.url;
      }
      this.uploadModel=true;
      this.uploadModel = true;
    },
    uploadAfter(result, files) {
      this.currentColumn.uploadAfter&&this.currentColumn.uploadAfter(result,files);
      this.currentColumn.uploadAfter &&
        this.currentColumn.uploadAfter(result, files);
      return true;
    },
    saveUpload(){
    saveUpload() {
      //生成保存后返回的路径
      let arr = this.fileInfo.map((x) => {
        if (x.path) {
@@ -1694,8 +1722,8 @@
      this.currentRow[this.currentColumn.field] = arr.join(",");
      this.uploadModel = false;
      return true;
    }
  }
    },
  },
});
</script>
<style lang="less" scoped>