废话不多说,直接上代码:
注:在合并前,需要先对数据进行处理,需要合并项放一起,否则会导致table表格格式问题
{
title: "标题",
dataIndex: "oneFactorName",
width: 80,
ellipsis: true,
align: "center",
customRender: (text, row, index) => {
//这里是控制显示和合并与否的参数
let obj = {
children: text,
attrs: {},
};
//this.dataSource是我们拿到的所有数据
let arr = this.dataSource.filter((res) => {
//这里gpsNumber是我需要判断的字段名(相同就合并)
return res.oneFactorName == row.oneFactorName;
});
if (index == 0 || this.dataSource[index - 1].oneFactorName != row.oneFactorName) {
obj.attrs.rowSpan = arr.length;
} else {
obj.attrs.rowSpan = 0;
}
return obj;
},
},