<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 }; } },
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/279852.html