codeDiffSpanArr: any[] = []//二维数组,用于存放单元格合并规则
// position: number= 0//用于存储相同项的开始index
codeDiffRowspan(colIndex: number, colName: string) {
console.log("rowspan()被调用:" + colName)
this.codeDiffSpanArr[colIndex] = []
let position = 0;
this.codeDiff.forEach((row, index) => {
if (index === 0) {
this.codeDiffSpanArr[colIndex].push(1)
position = 0
} else {
if (this.codeDiff[index][colName] === this.codeDiff[index - 1][colName]) { //当前值和上一条相同时
this.codeDiffSpanArr[colIndex][position] += 1
this.codeDiffSpanArr[colIndex].push(0)
} else {
this.codeDiffSpanArr[colIndex].push(1)
position = index
}
}
})
}
objectSpanMethod(param: { row: any, column: any, rowIndex: number, columnIndex: number }) {
console.log("objectSpanMethod()被调用")
if (isEmpty(param.row))
return
for (let i = 0; i < 2; i++) { //第一二列适用合并规则
if (param.columnIndex === i) {
const _row = this.codeDiffSpanArr[i][param.rowIndex];
const _col = _row > 0 ? 1 : 0;
// console.log('第'+rowIndex+'行','第'+i+'列','rowspan:'+_row,'colspan:'+_col)
return {
rowspan: _row,
colspan: _col
}
}
}
return
}
网友评论