element table 分组表
没找到el-table不定行的合并表格 文档里只有固定的 又不想用插件 这样我就要自己写代码了 而且写完分页发现 第二页不会分组了
// 获取相同编号的数组 getOrderNumber: function() { var OrderObj = {}; var pageData = []; this.OrderIndexArr = []; var pag = this.pagesize * this.currentPage; var ini = (this.currentPage - 1) * this.pagesize; for (var i = ini; i < pag; i++) { if (this.tableData[i]) { pageData.push(this.tableData[i]); } } pageData.forEach(function(element, index) { element.rowIndex = index; if (OrderObj[element.order_number]) { OrderObj[element.order_number].push(index); //521: Array(2) } else { OrderObj[element.order_number] = []; OrderObj[element.order_number].push(index); } }, this); for (var k in OrderObj) { if (OrderObj[k].length > 1) { this.OrderIndexArr.push(OrderObj[k]); //重复的数组长度 } } console.log(this.OrderIndexArr); }, //合并单元格 objectSpanMethod({ row, column, rowIndex, columnIndex }) { if (columnIndex === 0) { for (var i = 0; i < this.OrderIndexArr.length; i++) { var element = this.OrderIndexArr[i]; for (var j = 0; j < element.length; j++) { var item = element[j]; // var itemL = item - this.pagesize * (this.currentPage - 1); if (rowIndex == item) { console.log(item); console.log(element.length); //当前行 if (j == 0) { return { rowspan: element.length, colspan: 1 }; } else if (j != 0) { return { rowspan: 0, colspan: 0 }; } } } } } },
然后在切换的时候调用就可以了