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'
		                  }
		                  
		              }
		          }
		      })
    }
相关推荐
PineappleCoder8 小时前
性能数据别再瞎轮询了!PerformanceObserver 异步捕获 LCP/CLS,不卡主线程
前端·性能优化
PineappleCoder8 小时前
告别字体闪烁 / 首屏卡顿!preload 让关键资源 “高优先级” 提前到
前端·性能优化
m0_471199639 小时前
【vue】通俗详解package-lock文件的作用
前端·javascript·vue.js
GIS之路9 小时前
GDAL 读取KML数据
前端
今天不要写bug9 小时前
vue项目基于vue-cropper实现图片裁剪与图片压缩
前端·javascript·vue.js·typescript
用户479492835691510 小时前
记住这张时间线图,你再也不会乱用 useEffect / useLayoutEffect
前端·react.js
汝生淮南吾在北10 小时前
SpringBoot+Vue养老院管理系统
vue.js·spring boot·后端·毕业设计·毕设
咬人喵喵10 小时前
14 类圣诞核心 SVG 交互方案拆解(附案例 + 资源)
开发语言·前端·javascript
问君能有几多愁~10 小时前
C++ 日志实现
java·前端·c++