Переглянути джерело

fix: 图表文案跟随金额类型切换实时显示

lanjianrong 4 роки тому
батько
коміт
561821aa15

+ 1 - 0
src/enums/index.ts

@@ -0,0 +1 @@
+export * from './invoice'

+ 14 - 0
src/enums/invoice.ts

@@ -0,0 +1,14 @@
+export enum PriceType {
+  /** @name 发票 */
+  INVOICE = 'invoice',
+  /** @name 收款 */
+  RECEIVABLES = 'receivables',
+  /** @name 入账 */
+  CREDIT = 'credit'
+}
+
+export const priceMapToName = {
+  [PriceType.INVOICE]: '发票',
+  [PriceType.RECEIVABLES]: '收款',
+  [PriceType.CREDIT]: '入账'
+}

+ 9 - 6
src/pages/Statistic/Product/InvoiceTrends/index.tsx

@@ -1,5 +1,6 @@
 import BasicTable from '@/components/Table'
 import consts from '@/consts'
+import { priceMapToName, PriceType } from '@/enums'
 import { querySoftInvoiceTrendsList } from '@/services/statistic'
 import { disabledDate } from '@/utils/utils'
 import { DualAxes } from '@ant-design/charts'
@@ -14,7 +15,7 @@ const InvoiceTrends = () => {
     params: {
       optionType: 'singleStaff',
       dataIds: [],
-      priceType: 'invoice',
+      priceType: PriceType.INVOICE,
       startMonth: dayjs(new Date())
     },
     chart: []
@@ -128,7 +129,7 @@ const InvoiceTrends = () => {
     appendPadding: [0, 24, 12, 24],
     meta: {
       price: {
-        alias: '当月开票金额(元)'
+        alias: `当月${priceMapToName[state.params.priceType]}金额(元)`
       },
       ring: {
         alias: '环比增长(%)',
@@ -155,7 +156,9 @@ const InvoiceTrends = () => {
       position: 'top',
       itemName: {
         formatter: (_, item) => {
-          return item.value === 'price' ? '当月开票金额(元)' : '环比增长(%)'
+          return item.value === 'price'
+            ? `当月${priceMapToName[state.params.priceType]}金额(元)`
+            : '环比增长(%)'
         }
       }
     },
@@ -204,9 +207,9 @@ const InvoiceTrends = () => {
                 <Select
                   defaultValue="invoice"
                   options={[
-                    { label: '发票', value: 'invoice' },
-                    { label: '收款', value: 'receivables' },
-                    { label: '入账', value: 'credit' }
+                    { label: '发票', value: PriceType.INVOICE },
+                    { label: '收款', value: PriceType.RECEIVABLES },
+                    { label: '入账', value: PriceType.CREDIT }
                   ]}
                   placeholder="请选择发票类型"
                   onChange={e => setState({ ...state, params: { ...state.params, priceType: e } })}