From 53ac383f5b7dfd478eb682d81b2d509ae7b1e156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BD=A6=E5=8E=98=E5=AD=90?= Date: Fri, 18 Nov 2022 00:30:36 +0800 Subject: [PATCH] =?UTF-8?q?fix=F0=9F=9B=A0=EF=B8=8F:=20data=20transfer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/index.ts | 6 +++--- src/pages/Home/Home.tsx | 6 +++--- src/pages/Record/Record.tsx | 16 ++++++++-------- src/store/index.ts | 10 +++++----- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/model/index.ts b/src/model/index.ts index 50ccdaa..3ad14e1 100644 --- a/src/model/index.ts +++ b/src/model/index.ts @@ -1,8 +1,8 @@ import dayjs from 'dayjs' export enum BillType { - consume = 0, - income, + CONSUME = 0, + INCOME, } export interface IBill { @@ -21,7 +21,7 @@ export function EmptyBill(): IBill { return { date: dayjs().format("YYYY-MM-DD"), money: 0, - type: BillType.consume, + type: BillType.CONSUME, cls: "", label: "", options: "", diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx index 90db489..7c96d14 100644 --- a/src/pages/Home/Home.tsx +++ b/src/pages/Home/Home.tsx @@ -53,10 +53,10 @@ const Home = () => { } const typeOpt = [ - { label: '支出', value: BillType.consume }, - { label: '收入', value: BillType.income }, + { label: '支出', value: BillType.CONSUME }, + { label: '收入', value: BillType.INCOME }, ]; - const [billType, setBillType] = useState(BillType.consume) + const [billType, setBillType] = useState(BillType.CONSUME) // 点击bar弹出当天pie const [isModalOpen, setIsModalOpen] = useState(false); diff --git a/src/pages/Record/Record.tsx b/src/pages/Record/Record.tsx index 8a8561c..49314cb 100644 --- a/src/pages/Record/Record.tsx +++ b/src/pages/Record/Record.tsx @@ -50,7 +50,7 @@ function Record() { title: "金额", key: "money", render: (_: any, record: IBill) => { - const isConsume = record.type === BillType.consume + const isConsume = record.type === BillType.CONSUME const color = isConsume ? "red" : "green" const flag = isConsume ? "-" : "+" return {flag}{record.money} @@ -79,8 +79,8 @@ function Record() { const [datasource, setDataSource] = useState([]) const typeOpt = [ - {label: '支出', value: BillType.consume}, - {label: '收入', value: BillType.income}, + {label: '支出', value: BillType.CONSUME}, + {label: '收入', value: BillType.INCOME}, ]; // 提交到表格 @@ -93,7 +93,7 @@ function Record() { bill.money = Number(money) bill.options = options const checkBill = () => { - return bill.cls !== '' && (billType === BillType.income || bill.label !== '') && bill.money > 0 + return bill.cls !== '' && (billType === BillType.INCOME || bill.label !== '') && bill.money > 0 } const reset = () => { setCls("") @@ -132,10 +132,10 @@ function Record() { let classData: string[] = [] switch (billType) { - case BillType.consume: + case BillType.CONSUME: classData = Object.keys(cls2label.consume) break - case BillType.income: + case BillType.INCOME: classData = cls2label.income break } @@ -170,14 +170,14 @@ function Record() { value={cls === "" ? null : cls} onChange={c => { setCls(c) - if (billType === BillType.consume) setLabel(cls2label.consume[c][0]) + if (billType === BillType.CONSUME) setLabel(cls2label.consume[c][0]) }} > { classData.map(c => {c}) } - {billType === BillType.consume && ( + {billType === BillType.CONSUME && (