解决在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
},