el-table合计功能

合计

头部

show-summary设置为true就会在表格尾部展示合计行, 

:summary-method="getSummaries", getSummaries 对合计进行处理,

 :header-cell-style="{background:'#F5F5F5 !important',height:'0.48rem !important'}"对表格头部进行样式设置。

<el-table show-summary ref="ipstable" :summary-method="getSummaries"
   :data="tableData.slice((currpage - 1) * pagesize,
 currpage * pagesize)" :header-cell-style="{background:'#F5F5F5 
!important',height:'0.48rem !important'}"
style="width: 100%" height="calc(100vh - 3.1rem)" stripe>

对合计进行处理

​
// 合计功能 
            getSummaries(param) {
              const { columns, data } = param;
              const sums = [];
              // console.log(param);
              var that = this;
              columns.forEach((column, index) => {
                if (index === 0) {
                  sums[index] = '合计';
                  return;
                } else if (index === 5 || index === 6 || index === 7) {
                  
                  sums[index] = 0;
                  return;
                } else {
                  sums[index] = ' -- ';
                  return;
                }
              });

              sums[5] = "在线:" + that.total.status;
              sums[6] = "占用:" + that.total.use_status;
              sums[7] = "监控:" + that.total.agent_status;

              return sums;
            },

​

el-table合计行不显示,除页面缩放或者F12

解决方法:在updated生命周期中调用 doLayout

   updated() {
            this.$nextTick(() => {
              this.$refs.ipstable.doLayout();
              // console.log("do layout");
            });
          },

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值