fix🛠️: data transfer

This commit is contained in:
车厘子 2022-11-18 00:30:36 +08:00
parent b2ce1fe392
commit 53ac383f5b
4 changed files with 19 additions and 19 deletions

View File

@ -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: "",

View File

@ -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);

View File

@ -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 <Tag color={color}>{flag}{record.money}</Tag>
@ -79,8 +79,8 @@ function Record() {
const [datasource, setDataSource] = useState<IBill[]>([])
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 => <Select.Option key={c} value={c}>{c}</Select.Option>)
}
</Select>
{billType === BillType.consume && (
{billType === BillType.CONSUME && (
<Select
style={{width: 120}}
// showSearch

View File

@ -73,7 +73,7 @@ export class Bill {
(s: number) => s.toFixed(2),
R.sum,
R.map((bill: IBill) => bill.money),
R.filter((bill: IBill) => bill.type === BillType.consume),
R.filter((bill: IBill) => bill.type === BillType.CONSUME),
)
return functions(this._bills)
}
@ -84,16 +84,16 @@ export class Bill {
(s: number) => s.toFixed(2),
R.sum,
R.map((bill: IBill) => bill.money),
R.filter((bill: IBill) => bill.type === BillType.income),
R.filter((bill: IBill) => bill.type === BillType.INCOME),
)
return functions(this._bills)
}
getTotalMoney(type?: BillType) {
switch (type) {
case BillType.income:
case BillType.INCOME:
return this.incomeMoney
case BillType.consume:
case BillType.CONSUME:
return this.consumeMoney
default:
return this.totalMoney
@ -121,7 +121,7 @@ export class Bill {
this._bills = data.map((data: any) => {
return {
id: data.id,
type: data.type.toLowerCase() === 'income' ? BillType.income : BillType.consume,
type: data.type.toUpperCase === 'INCOME' ? BillType.INCOME : BillType.CONSUME,
date: data.date,
money: data.money,
cls: data.cls,