methods: {
//查询数据类型分类
queryDataType(){
queryDataType({}).then((res)=>{
if(res.data.statetrue) {
console.log("===>>>>>>"+JSON.stringify(res.data.data))
this.dataTypeList=res.data.data
//以下为动态合并行处理每次调用清空数据
this.spanArr = [];
this.position = 0
this.dataTypeList.forEach((item, index) => {
if (index === 0) {
this.spanArr.push(1);
this.position = 0;
} else {
// id 为需要合并查询的项
if (this.dataTypeList[index].porgnaName === this.dataTypeList[index - 1].porgnaName) {
this.spanArr[this.position] += 1;
this.spanArr.push(0);
} else {
this.spanArr.push(1);
this.position = index;
}
}
})
}
});
},
//表格行合并
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
if (columnIndex === 0) {
const _row = this.spanArr[rowIndex];
const _col = _row > 0 ? 1 : 0;
return {
rowspan: _row,
colspan: _col
}
}
}
}
Element UI --table 动态合并行
最新推荐文章于 2023-10-30 17:00:11 发布