From a9f45e334d409a62b05322c053a7dacc939ab438 Mon Sep 17 00:00:00 2001 From: ZJYHX Date: Thu, 29 May 2025 16:48:03 +0800 Subject: [PATCH] =?UTF-8?q?perf:=E5=AE=A2=E8=BF=90-=E8=80=81=E5=AE=A2?= =?UTF-8?q?=E6=88=B7:=E8=AE=A2=E5=8D=95=E6=95=B0=E5=8D=A0=E6=AF=94?= =?UTF-8?q?=E3=80=81=E6=AF=9B=E5=88=A9=E5=8D=A0=E6=AF=94=E5=80=BC=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E5=B0=8F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/charts/Customer_care_regular.jsx | 4 ++-- src/stores/CustomerStore.js | 6 +++--- src/utils/commons.js | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/charts/Customer_care_regular.jsx b/src/charts/Customer_care_regular.jsx index 7ad9575..373d6d0 100644 --- a/src/charts/Customer_care_regular.jsx +++ b/src/charts/Customer_care_regular.jsx @@ -90,7 +90,7 @@ const Customer_care_regular = () => { title: '订单数占比', dataIndex: 'OrderRate', key: 'OrderRate', - render: (text) => typeof text === 'number'?{Math.round(text * 100)}%:text, + render: (text) => typeof text === 'number'?{parseFloat((text * 100).toFixed(2))}%:text, }, { title: '成行数', @@ -112,7 +112,7 @@ const Customer_care_regular = () => { title: '毛利占比', dataIndex: 'OrderMLRate', key: 'OrderMLRate', - render: (text) => typeof text === 'number'?{Math.round(text * 100)}%:text, + render: (text) => typeof text === 'number'?{parseFloat((text * 100).toFixed(2))}%:text, }, { title: '人数(含成人+儿童)', diff --git a/src/stores/CustomerStore.js b/src/stores/CustomerStore.js index 0165b2a..10cf824 100644 --- a/src/stores/CustomerStore.js +++ b/src/stores/CustomerStore.js @@ -2,7 +2,7 @@ import {makeAutoObservable, runInAction} from "mobx"; import { fetchJSON } from '../utils/request'; import * as config from "../config"; import { groupsMappedByKey, sitesMappedByCode, pivotBy } from './../libs/ht'; -import { sortBy, show_vs_tag, formatPercent, groupBy, isEmpty, uniqWith } from "../utils/commons"; +import { sortBy, show_vs_tag, formatPercent, groupBy, isEmpty, uniqWith, formatPercentToFloat } from "../utils/commons"; import moment from 'moment'; /** @@ -242,13 +242,13 @@ class CustomerStore { SUCOrderNum: show_vs_tag(formatPercent((item1.SUCOrderNum-item2.SUCOrderNum)/(item2.SUCOrderNum===0?1:item2.SUCOrderNum)), item1.SUCOrderNum-item2.SUCOrderNum,item1.SUCOrderNum,item2.SUCOrderNum), OrderRate: show_vs_tag(formatPercent((item1.OrderRate-item2.OrderRate)/item2.OrderRate), - formatPercent(item1.OrderRate-item2.OrderRate),formatPercent(item1.OrderRate),formatPercent(item2.OrderRate)), + formatPercentToFloat(item1.OrderRate-item2.OrderRate),formatPercentToFloat(item1.OrderRate),formatPercentToFloat(item2.OrderRate)), SUCRate: show_vs_tag(formatPercent((item1.SUCRate-item2.SUCRate)/(item2.SUCRate===0?1:item2.SUCRate)), formatPercent(item1.SUCRate-item2.SUCRate),formatPercent(item1.SUCRate),formatPercent(item2.SUCRate)), ML: show_vs_tag(formatPercent((item1.ML-item2.ML)/(item2.ML===0?1:item2.ML)), (item1.ML-item2.ML).toFixed(2),item1.ML,item2.ML), OrderMLRate: show_vs_tag(formatPercent((item1.OrderMLRate-item2.OrderMLRate)/item2.OrderMLRate), - formatPercent(item1.OrderMLRate-item2.OrderMLRate),formatPercent(item1.OrderMLRate),formatPercent(item2.OrderMLRate)), + formatPercentToFloat(item1.OrderMLRate-item2.OrderMLRate),formatPercentToFloat(item1.OrderMLRate),formatPercentToFloat(item2.OrderMLRate)), PersonNum: show_vs_tag(formatPercent((item1.PersonNum-item2.PersonNum)/(item2.PersonNum===0?1:item2.PersonNum)), item1.PersonNum-item2.PersonNum,item1.PersonNum,item2.PersonNum), }); diff --git a/src/utils/commons.js b/src/utils/commons.js index 86b4b7a..a66419b 100644 --- a/src/utils/commons.js +++ b/src/utils/commons.js @@ -72,6 +72,10 @@ export function formatPercent(number) { return Math.round(number * 100) + "%"; } +export function formatPercentToFloat(number) { + return parseFloat((number * 100).toFixed(2)) + "%"; +} + export function percentToDecimal(number) { return parseFloat(number) / 100; }