elementUI el-table 合计行 滚动条放在下方样式与合计行统计方法

CSS

/*table一条合计行滚动条样式*/
.el-table{
    overflow: auto;
}
.el-table .el-table__body-wrapper,
.el-table .el-table__header-wrapper,
.el-table .el-table__footer-wrapper{
    overflow: visible;
}
.el-table::after{
    position:relative !important;
}

  合计行统计方法:

getSummaries(param) {
                const { columns, data } = param;
                const sums = [];
                columns.forEach((column, index) => {
                    if (index === 0) {
                        sums[index] = '合计';
                        return;
                    }
                    const values = data.map(item => {
                        return Number(item[column.property])
                    });
                    const flag = values.every(value => {
                        if(index == 3){ // if(column.property == 'money'){}
                            return true
                        }else{
                            return isNaN(value)
                        }
                    })
                    if (!flag) {
                        sums[index] = values.reduce((prev, curr) => {
                            const value = Number(curr);
                            if (!isNaN(value)) {
                                return prev + curr;
                            } else {
                                return prev;
                            }
                        }, 0);
                        sums[index] += '';
                    }
                });

                return sums;
            },

  

posted @ 2019-07-31 15:40  董七  阅读(7925)  评论(0编辑  收藏  举报