table合并单元格函数

// 通用行合并函数(将相同多列数据合并为一行)
            mergeRowMethod ({ row, _rowIndex, column, visibleData }) { 
              const fields = ['key']
              const cellValue = row[column.property]
              if (cellValue && fields.includes(column.property)) {
                const prevRow = visibleData[_rowIndex - 1]
                let nextRow = visibleData[_rowIndex + 1]
                if (prevRow && prevRow[column.property] === cellValue) {
                  return { rowspan: 0, colspan: 0 }
                } else {
                  let countRowspan = 1
                  while (nextRow && nextRow[column.property] === cellValue) {
                    nextRow = visibleData[++countRowspan + _rowIndex]
                  }
                  if (countRowspan > 1) {
                    return { rowspan: countRowspan, colspan: 1 }
                  }
                }
              }
            }

  总体思路就是上一行某个字段数据的与下一行对比是否相等

 

    半年来天天加班到半夜,都没有更新博客了,哎!加油  加油!!!!!

posted @ 2021-10-26 16:52  疾风_剑豪  阅读(145)  评论(0编辑  收藏  举报