elementui 合并行

在获取数据后做处理

// 
// let mapSet = res.data.map(item=> item.areaName)
// for(let i=0; i
//   this.areaNameGroup.add(mapSet[i])
// }
//
/**
* 根据相同的区域名做合并
*/
 this.areaNameGroup = new Map()
 for(let i = 0; i<res.data.records.length; i++) {
   if(this.areaNameGroup.has(res.data.records[i].areaName)) {
     let count = this.areaNameGroup.get(res.data.records[i].areaName) + 1
     this.areaNameGroup.set(res.data.records[i].areaName, count)
   } else {
     this.areaNameGroup.set(res.data.records[i].areaName, 1)
   }
 }
 for(let i = 0; i<res.data.records.length; i++) {
   if(this.areaNameGroup.has(res.data.records[i].areaName)) {
     res.data.records[i].rowSpan = {
       rowspan: this.areaNameGroup.get(res.data.records[i].areaName),
       colspan: 1
     }
     this.areaNameGroup.delete(res.data.records[i].areaName)
   } else {
     res.data.records[i].rowSpan = {
       rowspan: 0,
       colspan: 0
     }
   }
 }

你可能感兴趣的:(elementui,前端,javascript)