解决在a-table当中单元格合并(支持分页)

解决在a-table当中单元格合并

changeRowSpan(value, row, index) {
  const obj = {
    children: value,
    attrs: {}
  }
  //计算合并
  let spanArr = []
  let position = 0
  //分页每页十条数据
  let currPage = (this.ipagination.current - 1) * 10
  // this.dataList 数据列表
  let datalist = this.dataList.slice(currPage, currPage + 10)
  datalist.forEach((item, index) => {
    if (index === 0) {
      spanArr.push(1)
      position = 0
    } else {
      //需要合并的地方判断
      if (datalist[index].tbwjbh === datalist[index - 1].tbwjbh) {
        spanArr[position] += 1
        spanArr.push(0)
      } else {
        spanArr.push(1)
        position = index
      }
    }
  })
  const _row = spanArr[index]
  const _col = _row > 0 ? 1 : 0
  obj.attrs = {
    rowSpan: _row,
    colSpan: _col
  }
  return obj
},
    原文作者:Bqiuer
    原文地址: https://blog.csdn.net/weixin_46057095/article/details/121704492
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞