其他分享
首页 > 其他分享> > 合并相同列

合并相同列

作者:互联网

            <el-table
              stripe
              v-show="showTable"
              :key="Math.random()"
              v-loading="loading"

        :span-method="objectSpanMethod"
:data="selectTableData"
         border :header-cell-style="{background:'#ffffff',color:'#212529'}" empty-text="请选择一个分析" > <el-table-column prop="contract_id" label="合同号" width="150" />

 



//查找相同列 rowspan() { let position = 0; let spanArr = [] this.selectTableData.forEach((item, index) => { if (index === 0) { spanArr.push(1); } else { if (item.contract_id === this.selectTableData[index - 1].contract_id) { spanArr[position] += 1; spanArr.push(0); } else { spanArr.push(1); position = index; } } }); return {one:spanArr} }, // 合并相同列 objectSpanMethod({row, column, rowIndex, columnIndex}) { //表格合并第一列 if (columnIndex === 0) { const _row = this.rowspan().one[rowIndex]; const _col = _row > 0 ? 1 : 0; return { rowspan: _row, colspan: _col }; } },

 

标签:index,rowspan,相同,spanArr,合并,selectTableData,push,row
来源: https://www.cnblogs.com/ywky/p/16574750.html