el-table 合集行合并

1.模板中

复制代码
              <el-table :data="form.guestList1" show-summary :summary-method="getSummaries" :span-method="arraySpanMethod" ref="tableSumRef1">
                <el-table-column label="姓名" prop="name" align="center">
                </el-table-column>
                <el-table-column label="国籍" align="center" prop="nationality">
                </el-table-column>
                <el-table-column label="总片酬(万元)" align="center" prop="totalRemuneration">
                </el-table-column>
                <el-table-column label="参与期数" align="center" prop="participation">
                </el-table-column>
              </el-table>

2.js中

2.1计算合计

复制代码
    /**  计算合计*/
    getSummaries(param) {
      const {
        columns,
        data
      } = param;
      const sums = [];
      columns.forEach((column, index) => {
        const values = data.map(item => Number(item[column.property]))
        if (index === 2) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr)
            if (!isNaN(value)) {
              return prev + curr
            } else {
              return prev
            }
          }, 0)
          sums[index] = "合计:" + sums[index] + " 万元"
        }
      })
      return sums
    },

2.2合并最后一行

复制代码
    arraySpanMethod() {
      setTimeout(() => {
        if (this.$refs.tableSumRef1) {
          let current = this.$refs.tableSumRef1.$el
            .querySelector(".el-table__footer-wrapper")
            .querySelector(".el-table__footer");
          let cell = current.rows[0].cells;

          cell[0].style.display = "none";
          cell[1].style.display = "none";
          cell[2].colSpan = "4";
        }
      }, 50);
    },
相关推荐
fthux15 小时前
RenoPit 能为普通业主做什么?看懂图纸、审查合同,提前发现装修坑
javascript·人工智能·ai·开源·github·chrome扩展·open source·edge扩展·firefox扩展
仿生狮子16 小时前
✂️ Nuxt 最简单的字体裁剪工具:Fontize
javascript·vue.js·nuxt.js
魔力女仆19 小时前
分享一个 JS 鼠标跟随贪吃蛇背景库
开发语言·javascript·计算机外设
别惊醒渔人21 小时前
Vue3 Diff 优化:最长递增子序列 LIS
前端·javascript·vue.js
Larcher21 小时前
从“加载模型”界面到端侧推理:拆解一个 React + WebGPU 大模型 Demo
javascript·后端
Larcher1 天前
从状态快照到惰性初始化:读懂 React useState 的三个关键场景
javascript·人工智能·后端
Hilaku1 天前
工作 5 年后,决定你薪资上限的究竟是什么?
前端·javascript·程序员
weixin_BYSJ19871 天前
springboot校园自习室管理小程序---附源码32142
java·javascript·spring boot·python·django·flask·php
gis开发之家1 天前
《Vue3 从入门到大神40篇》Vue3 源码详解(十):diff 算法全解析 —— 为什么 Vue3 比 Vue2 更快?
javascript·算法·typescript·前端框架·vue3·vue3源码
用户83134859306981 天前
Vue+Three.js实现PCB电路板3D交互:元器件点击高亮、部件显隐、模型自动旋转
vue.js·webgl·three.js