el-table实现最后一行合计功能并合并指定单元格

效果图如下:

表格代码如下:

bash 复制代码
<el-table 
    width="100%"
    ref="tableRef" 
    style="margin-bottom: 15px;"
    :data="jlData"
    class="tableHeader6"
    header-row-class-name="headerStyleTr6"
    :row-class-name="tableRowClassName"
    show-summary
    :span-method="arraySpanMethod"
    >
        <el-table-column prop="staff_name" label="姓名"></el-table-column>
        <el-table-column prop="staff_id" label="工号"></el-table-column>
        <el-table-column prop="syjlTotal" label="使用量"></el-table-column>
        <el-table-column min-width="125px" prop="xzjlTotal" label="处理报告下载量"></el-table-column>
        <el-table-column min-width="125px" prop="cxbgTotal" label="撤销报告下载量"></el-table-column>
        <el-table-column min-width="110px" prop="lyTotal" label="录音下载量"></el-table-column>
</el-table>


js 复制代码
const arraySpanMethod = ({ row, column, rowIndex, columnIndex }:any)=> {
		     nextTick(()=>{
		          if(tableRef.value.$el){
		              let current = tableRef.value.$el.querySelector(".el-table__footer-wrapper").querySelector(".el-table__footer")
		              // cell[0].innerHTML = '合计数'  修改文本
		              let cell = current.rows[0].cells
		              cell[0].style.textAlign = "center"; // 合计行第一列字段居中显示。
		              cell[1].style.display = "none"; // 隐藏被合并的单元格,不隐藏的话还会占着位置。
		              cell[0].colSpan = "2"; // 合并单元格个数
		              console.log(cell,'cell')
		              
		              //修改单元格的样式
		              for(let i=0;i<cell.length;i++){
		                  console.log(cell[i])
		                  if(i==0){
		                      cell[i].style.color = 'red'
		                  }else{
		                      cell[i].style.color = 'orange'
		                  }
		                  
		              }
		          }
		      })
    }
相关推荐
Bs_MoneyMagnet3 分钟前
基于springboot+vue的生态果园采摘预约系统的设计与实现 源码+文档
java·vue.js·spring boot·后端·毕业设计·计算机毕业设计
wangchunyu1143 分钟前
JavaScript 零基础入门教程
前端
hanchenxing32 分钟前
前端异步任务三方案:Celery vs Redis Stream vs BullMQ 实战对比消息队列
前端·数据库·redis·异步任务·方案对比
默_笙1 小时前
⚓ AI 的"官方答题卡":withStructuredOutput 与结构化输出的终局之战
前端·javascript
掘金挖土1 小时前
前端手摸手跑路之 AI 应用开发(五)
前端·后端
小羊没烦恼!2 小时前
Memory 记忆设计讨论:Agent Memory 的数据模型可以怎么设计
java·开发语言·前端·c++·c#
码上成长2 小时前
Mapbox 围栏编辑踩过的几个坑:key 串了、形状炸了、icon 挡住绿点
前端·前端框架
SGAMERrain2 小时前
做了一个免费的在线绘画网格工具 DrawGrid,聊聊一个小工具是怎么越做越完整的
前端
我家猫叫佩奇2 小时前
🦭 厌倦了千篇一律的线性图标?Naive Icons 正式开源
前端·javascript·css
LEE3 小时前
前端转型全栈 00:AI 时代该学哪些,不该学哪些
前端·后端