优化一下: let num=0; let amount = 0 resdatamapitem = num = num+itemnum amount = amount+itemamount 转账成功 已完成
let num = 0; let amount = 0; res.data.forEach(item => { num += item.num; amount += item.amount;
const status = item.status; const title = this.statusList.find(statusItem => statusItem.id === status)?.title || '';
switch (status) { case this.batchBatchRule.checkSuccess: this.transferStatisticsData[4] = { ...item, title }; break; case this.batchBatchRule.transFail: this.transferStatisticsData[3] = { ...item, title }; break; case this.batchBatchRule.transSuccess: this.transferStatisticsData[2] = { ...item, title }; break; case this.batchBatchRule.checkFail: this.transferStatisticsData[1] = { ...item, title }; break; default: break; } });
if (res.data.length > 1) { this.transferStatisticsData[0] = { num, amount, status: [0, 1, 2, 3], title: '' };
原文地址: http://www.cveoy.top/t/topic/hvSL 著作权归作者所有。请勿转载和采集!