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'
		                  }
		                  
		              }
		          }
		      })
    }
相关推荐
命运之光1 天前
【最新】ChromeDriver最新版本下载安装教程,ChromeDriver版本与Chrome不匹配问题
前端·chrome
星离~1 天前
Vue响应式原理详解:从零实现一个迷你Vue
前端·javascript·vue.js
梦6501 天前
React 简介
前端·react.js·前端框架
一只小阿乐1 天前
react 中的判断显示
前端·javascript·vue.js·react.js·react
光影少年1 天前
useMemo 和 React.memo区别
前端·react.js·前端框架
小沐°1 天前
React-页码组件
前端·javascript·react.js
消失的旧时光-19431 天前
Flutter 与 React/Vue 为什么思想一致?——声明式 UI 体系的深度对比(超清晰版)
vue.js·flutter·react.js
零一科技1 天前
Vue3学习第三课: ref 与 reactive 选择指南
前端·vue.js
余杭子曰1 天前
播放状态与播放序列的关系(999篇一线博客第107篇)
前端
e***U8201 天前
前端路由懒加载实现,React.lazy与Suspense
前端·react.js·前端框架