From 3ba2b44daa1b60f378f2d2760f19f0acc0dd264d Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 18 Dec 2023 16:51:43 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=96=87=E6=97=85=E5=B1=80=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E4=BA=BA=E6=95=B0:=20=E8=A7=A3=E5=86=B3=E5=B0=8F?= =?UTF-8?q?=E6=95=B0=E7=82=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/FinancialStore.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/stores/FinancialStore.js b/src/stores/FinancialStore.js index 1e61886..abed82d 100644 --- a/src/stores/FinancialStore.js +++ b/src/stores/FinancialStore.js @@ -183,18 +183,27 @@ class FinancialStore { const NotEmptyRows = json.result.filter(ele => ele.groupsLabel !== '' && ele.groupsLabel !== '未知'); const sumNotEmptyRows = sumFun(NotEmptyRows, 'sumNotEmptyRows'); - const result = NotEmptyRows.map((row) => ({...row, ...percentRow(row, sumNotEmptyRows)})).map((row) => { + const result = NotEmptyRows.map((row) => ({...row, ...percentRow(row, sumNotEmptyRows)})).sort(comm.sortBy('orgz')).reverse().map((row) => { const newData = ['orgz', 'orgzPDays', 'hosts', 'hostsPDays'].reduce( (r, skey) => ({ ...r, [skey]: row[`${skey}Percent`] ? row[skey] + comm.fixToInt(sumEmptyResult[skey] * row[`${skey}Percent`]) : row[skey] }), row ); return newData; }); + const sumAfter = sumFun(result, 'sumAfter'); + const diffSum = ['orgz', 'orgzPDays', 'hosts', 'hostsPDays'].reduce((r, skey) => ({ ...r, [skey]: sumResult[skey]-sumAfter[skey]}), {}); + const result0 = ['orgz', 'orgzPDays', 'hosts', 'hostsPDays'].reduce((r, skey) => ({...r, [skey]: (result?.[0]?.[skey] || 0)+(diffSum?.[skey] || 0)}), {}); + result[0] = { ...result[0], ...result0 }; const totalRow = Object.keys(json.resultTotal).length > 1 ? { ...json.resultTotal, groupsKey: `total${mkey}` } : (mkey === 'domestic' ? sumResult : { groupsKey: 'empty'}); const IndividualServiceRow = {orgz: json.resultTotal.IndividualService, groupsKey: `individualService${mkey}`, groupsLabel: '单项服务人数', }; - return { sumResult, result, rawData: [].concat([IndividualServiceRow, totalRow], json.result), NoEmptyData: [].concat([IndividualServiceRow, totalRow], result) }; + return { + sumResult, + result, + rawData: [].concat([IndividualServiceRow, totalRow], json.result.sort(comm.sortBy('orgz')).reverse()), + NoEmptyData: [].concat([IndividualServiceRow, totalRow], result), + }; }; /**