vxe-table 合并单元格

<vxe-table
    @cell-click="handleClickCell"
    :span-method="spanMethods"  //自动合并单元格
    :data="tableData2">

</vxe-table>

spanMethods({row, $rowIndex, column, data}){
     let fields = ["clothtktno", "contactno"]
      let cellValue = row[column.property]
      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}
          }
        }
      }

    },
  

  

posted @ 2022-11-01 11:15  Li_ll  Views(1955)  Comments(0Edit  收藏  举报