需求:动态合并单元格
工具:avue(基于element封装的) + vue
实现方法:
html
<avue-curd :option=“option" :data="tabledata" :span-method="getSpanMethod"><avue-curd>
js
mounted(){
this.spanAgg.companyCode = this.setRowSpan('companycode')
this.spanAgg.rightsType = this.setRowSpan('rightsType')
}
methods:{
//合并
setRowSpan(value){
let rowAgg = {
spanArr = [],
position:0
}
this.tableData.forEarch((item,index) =>{
if(index === 0){
rowAgg.spanArr.push(1)
rowAgg.position = 0
}else{
if(this.tableData[index][value] === this.tableData[index -1][value]){
rowAgg.spanArr[rowAgg.position] +=1;
rowAgg.spanArr.push(1)
}else{
rowAgg.spanArr.push(1)
rowAgg.position = index
}
})
},
getSpanMethod({row,column,rowIndex,columnIndex}){
if(columenIndex==0){
const _row = this.spanAgg.companyCode.s