element-ui合并行单元格

这段代码展示了如何在JavaScript中处理数据循环,通过比较相邻元素来决定是否合并表格单元格。它使用了`spanArr`存储合并信息,并调用`objectSpanMethod`进行合并操作,主要针对前9列和第3列的数据进行处理。
摘要由CSDN通过智能技术生成
数据先循环
for (var i = 0; i < this.list.length; i++) {
            if (i === 0) {
              this.spanArr.push(1)
              this.pos = 0
            } else {
              // 判断当前元素与上一个元素是否相同(第1和第2列)
              if (this.list[i].shipmentNo === this.list[i - 1].shipmentNo) {
                this.spanArr[this.pos] += 1
                this.spanArr.push(0)
              } else {
                this.spanArr.push(1)
                this.pos = i
              }
            }
          }
调用合并方法
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex < 9) {
合并前9行
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      } else if (columnIndex === 3) {
        const _row = this.contentSpanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          rowspan: _row,
          colspan: _col
        }
      }
    },

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值