首页 > 其他分享 >Element-table表格末尾按指定列合计的实现方法

Element-table表格末尾按指定列合计的实现方法

时间:2023-06-26 16:03:33浏览次数:39  
标签:index const column sums value Element return table 末尾

getSummaries(param) {
      const { columns, data } = param
      const sums = []
      columns.forEach((column, index) => {
        if (index === 1) {
          sums[index] = '合计'
          return
        }
        const values = data.map(item => Number(item[column.property]))
        console.log(column.property)
        if (!values.every(value => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr)
            if (!isNaN(value)) {
              return prev + curr
            } else {
              return prev
            }
          }, 0)
      //通过column.property指定列 switch(column.property){ case 'product_count': sums[index] = toThousandslsFilter(sums[index]) break; case 'sum': sums[index] = toThousandslsFilter(sums[index]) break; default: sums[index] = '' } } else { sums[index] = '' } }) return [sums] }

 

标签:index,const,column,sums,value,Element,return,table,末尾
From: https://www.cnblogs.com/webwangjie/p/17505869.html

相关文章