Blogger Information
Blog 47
fans 0
comment 2
visits 102684
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
iview的table合并相同的单元格
拾一枝樱花的博客
Original
2424 people have browsed it

handleSpan ({ row, column, rowIndex, columnIndex })
{
 //合并第二列,这里columnIndex==1 根据具体业务要在前端写死
 if (columnIndex == 1) {
   console.log()
   //计算合并的行数列数
   let x = row.num == 0 ? 0:row.num
   let y = row.num == 0 ? 0:1
   console.log(x,y)
   return [x, y]
 }

 if (columnIndex == 2) {
   //计算合并的行数列数
   let x = row.agenum == 0 ? 0:row.agenum
   let y = row.agenum == 0 ? 0:1
   console.log(x,y)
   return [x, y]
 }
},
assembleData(data){
 // 数据处理算法,处理后,便于单元格的合并
 for(var i=0; i<data.length;i++){
   if(data[i].already!==1){
     if(data[i+1]){
       data[i].num=1
       for(var a =i+1 ;a<data.length-i;a++){
         if(data[i].name === data[a].name) {
           data[i].num++
           data[a].num = 0
           data[a].already = 1
         }else{
           break
         }
       }
     }
   }
 }

 for(var j=0; j<data.length;j++){
   //  > 1 表示name 有合并  需要在name合并的row中 再合并age
   if(data[j].num>1){


     for(var k = 0; k < data[j].num ; k++) {

       if(data[j+k].agealready !== 1) {

         if(k+1 < data[j].num){
           data[j+k].agenum = 1
           for(var b =k+1;b<data[j].num;b++){

             if(data[j+k].age === data[j+b].age) {
               data[j+k].agenum ++
               data[j+b].agenum = 0
               data[j+b].agealready = 1
             }else{
               break
             }

           }
           console.log(888888)
           console.log(data[j+k].agenum)
         }

       }

     }
   }
 }

 //将整理后的数据交给表格渲染
 this.data5 = data
 console.log(this.data5)
},

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post