<el-table :data="tableData" stripe :span-method="arraySpanMethod">...</el-table>
tableData: [],
rowSpanValArr: [],
getTableData() {
let that = this
let _data = {
projId: that.projectId,
phaseId: that.phaseId
}
that.$store.dispatch('getActivityItemList', _data).then(res => {
that.tableData = res.data.phaseActivityList
that.rowSpanValArr = []
let _startRowIndex = 0
for (var i = 0; i < that.tableData.length; i++) {
if (i === 0) {
that.rowSpanValArr.push(1)
_startRowIndex = 0
}
else {
if (that.tableData[i].projectActivtyID === that.tableData[i - 1].projectActivtyID) {
that.rowSpanValArr[_startRowIndex] += 1
that.rowSpanValArr.push(0)
}
else {
that.rowSpanValArr.push(1)
_startRowIndex = i
}
}
}
}, err => {
that.$message({
message: err.message,
type: 'error'
})
})
},
arraySpanMethod({
row,
column,
rowIndex,
columnIndex
}) {
if (columnIndex === 0) {
let rowSpan = this.rowSpanValArr[rowIndex]
if (rowSpan === 0) {
return [0, 0]
} else {
return [rowSpan, 1]
}
}
},