<el-table
:data="tableData"
border
stripe
size="small"
ref="spantable"
:span-method="objectSpanMethod"
:max-height="tableHeight"
v-loading="loading"
@row-dblclick="handledbrow"
>
reArr(data) {
for (var i = 0; i < data.length; i++) {
if (i === 0) {
this.spanArr.push(1)
this.pos = 0
} else {
// 判断当前元素与上一个元素是否相同,
if (data[i].projectId === data[i - 1].projectId) {
this.spanArr[this.pos] += 1
this.spanArr.push(0)
} else {
this.spanArr.push(1)
this.pos = i
}
}
}
}
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 0 || columnIndex === 1) {
const _row = this.spanArr[rowIndex]
const _col = _row > 0 ? 1 : 0
return {
rowspan: _row,
colspan: _col
}
}
},