合并table表格中的同一行
tableData: [
{
id: "二次硫酸根",
name: "本地",
amount1: "污染1",
amount2: "3.2",
amount3: 10,
},
{
id: "二次硫酸根",
name: "本地",
amount1: "污染2",
amount2: "4.43",
amount3: 12,
},
{
id: "二次硫酸根",
name: "本地",
amount1: "污染3",
amount2: "1.9",
amount3: 9,
},
{
id: "二次硫酸根",
name: "外地",
amount1: "电工",
amount2: "2.2",
amount3: 17,
},
{
id: "二次硫酸根",
name: "外地",
amount1: "电厂",
amount2: "4.1",
amount3: 15,
},
],
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
const dataProvider = this.tableData;
const cellValue = row[column.property];
if (cellValue) {
const prevRow = dataProvider[rowIndex - 1];
let nextRow = dataProvider[rowIndex + 1];
if (prevRow && prevRow[column.property] === cellValue) {
return { rowspan: 0, colspan: 0 };
} else {
let rowspan = 1;
while (nextRow && nextRow[column.property] === cellValue) {
rowspan++;
nextRow = dataProvider[rowspan + rowIndex];
}
if (rowspan > 1) {
return { rowspan, colspan: 1 };
}
}
}
},