element表格合并行
- UI框架
- 2023-05-26
- 32 热度
- 0 评论
// 获取相同编号的数组
getAuditPhaseNumber() {
const auditPhaseObj = {};
this.checkData3.forEach((item, index) => {
item.rowIndex = index;
if (auditPhaseObj[item.auditPhase]) {
auditPhaseObj[item.auditPhase].push(index);
} else {
auditPhaseObj[item.auditPhase] = [];
auditPhaseObj[item.auditPhase].push(index);
}
});
for (const k in auditPhaseObj) {
if (auditPhaseObj[k].length > 1) {
this.auditPhaseIndexArr.push(auditPhaseObj[k]);
}
}
},
// 合并表格
mergeRow({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 1) {
for (let i = 0; i < this.auditPhaseIndexArr.length; i++) {
const merge = this.auditPhaseIndexArr[i];
for (let j = 0; j < merge.length; j++) {
const index = merge[j];
if (rowIndex === index) {
if (j === 0) {
return {
rowspan: merge.length,
colspan: 1
};
} else if (j !== 0) {
return {
rowspan: 0,
colspan: 0
};
}
}
}
}
}
}
示例图片