在列表中加入该属性
/* 合并行*/
objectSpanMethod2({ row, column, rowIndex, columnIndex }) {
// columnIndex: 需要合并的列序号
if (columnIndex === 1) {
// this.tableData 1修改
// this.healthItemList:表格数据
const _row = (this.flitterData2(this.healthItemList).one)[rowIndex]
const _col = _row > 0 ? 1 : 0
return {
rowspan: _row,
colspan: _col
}
}
},
flitterData2() {
const spanOneArr = []
let concatOne = 0
this.healthItemList.forEach((item, index) => { // 循环后端查询出来的数据(tableData2)
if (index === 0) {
spanOneArr.push(1)
} else {
// name 修改
if (item.priceType === this.healthItemList[index - 1].priceType) { // 第一列需合并相同内容的字段
spanOneArr[concatOne] += 1
spanOneArr.push(0)
} else {
spanOneArr.push(1)
concatOne = index
}
}
})
return {
one: spanOneArr
// two:spanOneArr1
}
},