沐若清辰
人生如茶,浓也好,淡也好,各有味道
// 合并
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      let $rowIndex = rowIndex;
      let fields = ["rectificationNo"]; //需要合并的字段
      let cellValue = row[column.property];
      let data = this.tableData; // 表格的所有数据,
      if (cellValue && fields.includes(column.property)) {
        let prevRow = data[$rowIndex - 1];
        let nextRow = data[$rowIndex + 1];
        if (prevRow && prevRow[column.property] === cellValue) {
          return { rowspan: 0, colspan: 0 };
        } else {
          let countRowspan = 1;
          while (nextRow && nextRow[column.property] === cellValue) {
            nextRow = data[++countRowspan + $rowIndex];
          }
          if (countRowspan > 1) {
            return { rowspan: countRowspan, colspan: 1 };
          }
        }
      }
    },

  在el-table 表格上添加:span-method="objectSpanMethod"

posted on 2021-06-22 12:22  沐若清辰  阅读(165)  评论(0编辑  收藏  举报