废话少说直接上效果图

实现代码
<el-table
:data="tableData"
style="width: 100%"
:span-method="arraySpanMethodHeatstation"
>
具体想怎么合并根据需求进行字段和行列的判断
const arraySpanMethodHeatstation = ({
row,
column,
rowIndex,
columnIndex,
}: any) => {
if (columnIndex == 0) {
let currentCategory: any = row.heatYear;
let nextRow: any = tableData.value[rowIndex - 1];
if (nextRow && nextRow.heatYear == currentCategory) {
return [0, 0];
} else {
let count = 1;
while (
tableData.value[rowIndex + count] &&
tableData.value[rowIndex + count].heatYear === currentCategory
) {
count++;
}
return [count, 1];
}
}
if (columnIndex == 1) {
let currentCategory: any = row.userType;
let nextRow: any = tableData.value[rowIndex - 1];
if (nextRow && nextRow.userType == currentCategory) {
return [0, 0];
} else {
let count = 1;
while (
tableData.value[rowIndex + count] &&
tableData.value[rowIndex + count].userType === currentCategory
) {
count++;
}
return [count, 1];
}
}
if (columnIndex === 9) {
if (rowIndex % 4 === 0) {
return {
rowspan: 4,
colspan: 1,
};
} else {
return {
rowspan: 0,
colspan: 0,
};
}
}
};

2088

被折叠的 条评论
为什么被折叠?



