diff --git a/src/components/layout/index.module.scss b/src/components/layout/index.module.scss index 9a32379..be315ad 100644 --- a/src/components/layout/index.module.scss +++ b/src/components/layout/index.module.scss @@ -17,6 +17,7 @@ .content { flex: 1 1; padding: 10px; + overflow: auto; } .footer { } diff --git a/src/hooks/useBill.ts b/src/hooks/useBill.ts index fbb76de..2aa23cb 100644 --- a/src/hooks/useBill.ts +++ b/src/hooks/useBill.ts @@ -1,10 +1,10 @@ export const useBill = () => { - // const [bills, setBills] = useState([]) + // const [_bills, setBills] = useState([]) // // useEffect(() => { // getBills().then(setBills).catch(console.dir) // }, []) // return { - // bills, + // _bills, // } } \ No newline at end of file diff --git a/src/pages/Record/Record.module.scss b/src/pages/Record/Record.module.scss index ae52429..2e89d64 100644 --- a/src/pages/Record/Record.module.scss +++ b/src/pages/Record/Record.module.scss @@ -1,2 +1,14 @@ .record { -} \ No newline at end of file + height: 100%; + display: flex; + flex-direction: column; + justify-content: start; +} + +.new { +} + +.table { + flex: 1 1; + overflow: auto; +} diff --git a/src/pages/Record/Record.tsx b/src/pages/Record/Record.tsx index 1a8fcce..2470d21 100644 --- a/src/pages/Record/Record.tsx +++ b/src/pages/Record/Record.tsx @@ -6,15 +6,21 @@ import { message, Radio, Select, - Space + Space, Table } from "antd"; +import { + ArrowDownOutlined, + CloudUploadOutlined, DeleteOutlined, +} from "@ant-design/icons"; import {useContext, useEffect, useRef, useState} from "react"; -import {BillType, EmptyBill} from "../../model"; +import {BillType, EmptyBill, IBill} from "../../model"; import moment from "moment/moment"; import {BillContext} from "../../store"; import {observer} from "mobx-react-lite"; import styles from "./Record.module.scss" import {BaseSelectRef} from "rc-select/lib/BaseSelect"; +import {createBill} from "../../api/bills"; + function Record() { @@ -35,12 +41,56 @@ function Record() { }, [clsRef]) + // table + const columns = [ + { + title: "日期", + dataIndex: "date", + key: "date", + }, + { + title: "类别", + dataIndex: "cls", + key: "cls", + }, + { + title: "标签", + dataIndex: "label", + key: "label", + }, + { + title: "金额", + dataIndex: "money", + key: "money", + }, + { + title: "备注", + dataIndex: "options", + key: "options", + }, + { + title: "操作", + key: 'action', + render: (_: any, record: any) => ( + + + > + 提交 + -
+
+
+ +
) } diff --git a/src/store/index.ts b/src/store/index.ts index 329b8ff..1ae7063 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -8,25 +8,28 @@ import * as R from "ramda" * 仅存储一个月的数据 */ export class Bill { - bills: IBill[] = []; + private _bills: IBill[] = []; // _cls2label: IClass = {consume: new Map(), income: []} - _cls2label: { consume: Record, income: [] } = {consume: {}, income: []} + private _cls2label: { consume: Record, income: [] } = {consume: {}, income: []} constructor() { makeAutoObservable(this) this.fetchClass().then() } + get bills() { + return this._bills + } get cls2label() { return this._cls2label } get listAllByDate() { - return R.groupBy((bill: IBill) => bill.date)(this.bills) + return R.groupBy((bill: IBill) => bill.date)(this._bills) } get listAllByClass() { - return R.groupBy((bill: IBill) => bill.cls)(this.bills) + return R.groupBy((bill: IBill) => bill.cls)(this._bills) } get listDailyMoney() { @@ -40,7 +43,7 @@ export class Bill { R.sum, R.map((bill: IBill) => bill.money) ) - return functions(this.bills) + return functions(this._bills) } get meanMoneyByDate() { @@ -54,14 +57,14 @@ export class Bill { const {id} = await createBill(bill) bill.id = id runInAction(() => { - this.bills.push(bill); + this._bills.push(bill); }) } async fetch(year: number, month: number) { const data = await getBills(year, month) runInAction(() => { - this.bills = data + this._bills = data }) }