累加 分类累加

      this.PersonCollect = res.reduce((total, cur, index) => {
        let hasValue = total.findIndex(current => { return current.AccountType === cur.AccountType })
        hasValue === -1 && total.push(cur)
        hasValue !== -1 && (total[hasValue].TotalFee = floatObj.add(total[hasValue].TotalFee, cur.TotalFee));
        hasValue !== -1 && (total[hasValue].Qrt = floatObj.add(total[hasValue].Qrt, cur.Qrt));
        return total
      }, []).map(item => {
        let dataOption = {
          AccountType: item.AccountType,
          AccountTypeName: item.AccountTypeName,
          Qrt: item.Qrt,
          TotalFee: item.TotalFee
        }
        return dataOption;
      })
posted @ 2020-10-12 10:56  龙旋风  阅读(147)  评论(1编辑  收藏  举报