From 3c65054da319394908e2e0dcfe6b29525a04d705 Mon Sep 17 00:00:00 2001 From: clz Date: Mon, 5 Sep 2022 09:34:15 +0800 Subject: [PATCH] =?UTF-8?q?feat=F0=9F=94=AB:=20=E6=90=AD=E5=BB=BA=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=EF=BC=8C=E5=AE=8C=E6=88=90bill=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/index.ts | 8 ++++ src/pages/Home/Home.module.scss | 12 ++++++ src/pages/Home/Home.tsx | 63 +++++++++++++++++++++++++++++ src/pages/Record/Record.module.scss | 0 src/pages/Record/Record.tsx | 9 +++++ 5 files changed, 92 insertions(+) create mode 100644 src/model/index.ts create mode 100644 src/pages/Home/Home.module.scss create mode 100644 src/pages/Home/Home.tsx create mode 100644 src/pages/Record/Record.module.scss create mode 100644 src/pages/Record/Record.tsx diff --git a/src/model/index.ts b/src/model/index.ts new file mode 100644 index 0000000..c17271b --- /dev/null +++ b/src/model/index.ts @@ -0,0 +1,8 @@ +export interface IBill { + _id?: string, + date: string, + money: number, + cls: string, + label: string, + options?: string +} \ No newline at end of file diff --git a/src/pages/Home/Home.module.scss b/src/pages/Home/Home.module.scss new file mode 100644 index 0000000..9540947 --- /dev/null +++ b/src/pages/Home/Home.module.scss @@ -0,0 +1,12 @@ +.home { + height: 100%; + display: flex; + flex-direction: column; + .total { + display: flex; + flex-direction: row; + justify-content: flex-start; + gap: 10px; + align-items: flex-start; + } +} diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx new file mode 100644 index 0000000..5fd9ae6 --- /dev/null +++ b/src/pages/Home/Home.tsx @@ -0,0 +1,63 @@ +import styles from "./Home.module.scss" +import * as R from 'ramda' +import { IBill } from "../../model" +import Bar from "../../components/charts/bar" +import { useContext, useEffect, useState } from "react"; +import { BillContext } from "../../store"; +import { observer } from "mobx-react-lite"; +import Pie from "../../components/charts/pie"; +import { Card, ConfigProvider, DatePicker } from "antd"; +import moment from 'moment'; +import 'moment/locale/zh-cn'; +import locale from 'antd/es/locale/zh_CN'; + +const Home = () => { + const billStore = useContext(BillContext) + + const transformer = (record: Record) => { + return R.map((key: string) => { + const moneys = record[key].map(bill => bill.money) + return { + x: key, + y: Number(R.sum(moneys).toFixed(2)), + } + })(R.keys(record)) + } + + const now = new Date(); + const [year, setYear] = useState(now.getFullYear()) + const [month, setMonth] = useState(now.getMonth() + 1) + + useEffect(() => { + billStore.fetch(year, month) + }, [year, month]) + + const changeDate = (date: moment.Moment | null, datestring: string) => { + const d = date?.toDate() ?? new Date() + setYear(d.getFullYear()) + setMonth(d.getMonth() + 1) + } + + const TotalMoney = () => + {"总金额"} + ¥{billStore.totalMoney} + + + return ( +
+
+ + +
+ + +
+ ) +} + + +export default observer(Home) \ No newline at end of file diff --git a/src/pages/Record/Record.module.scss b/src/pages/Record/Record.module.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/Record/Record.tsx b/src/pages/Record/Record.tsx new file mode 100644 index 0000000..b221065 --- /dev/null +++ b/src/pages/Record/Record.tsx @@ -0,0 +1,9 @@ +import styles from "./Record.module.scss" + + +export default function Record() { + + return ( + <> + ) +} \ No newline at end of file