<el-table
ref="tableRef"
:data="tableData"
:default-expand-all="expand"
size="small"
:span-method="objectSpanMethod"
>
<el-table-column
v-if="objDispose.selection"
align="center"
type="selection"
width="55"
>
</el-table-column>
</el-table>
方法:
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 0) {
if (rowIndex > 0 && row.orderId === this.tableData[rowIndex - 1].orderId) {
return {
rowspan: 0,
colspan: 0,
};
} else {
const count = this.tableData.filter(item => item.orderId === row.orderId).length;
return {
rowspan: count,
colspan: 1,
};
}
}
},