From f9761015c30f469b66b6ba355ef00de6cb890398 Mon Sep 17 00:00:00 2001 From: callmeyan Date: Sat, 25 May 2024 23:46:13 +0800 Subject: [PATCH] :sparkles: confirm --- src/components/bill/list.tsx | 34 +++++++++++------ src/components/bill/search-form.tsx | 2 +- src/i18n/translations/en.json | 5 +++ src/i18n/translations/sc.json | 5 +++ src/i18n/translations/tc.json | 5 +++ src/pages/bill/query.tsx | 1 - src/pages/bill/reconciliation.tsx | 57 ++++++++++++++++++++++------- 7 files changed, 82 insertions(+), 27 deletions(-) diff --git a/src/components/bill/list.tsx b/src/components/bill/list.tsx index a3430b4..96cc4f7 100644 --- a/src/components/bill/list.tsx +++ b/src/components/bill/list.tsx @@ -11,9 +11,10 @@ import './bill.less' type BillListProps = { type: 'query' | 'reconciliation'; operationRender?: (record: BillModel) => React.ReactNode; - onRowSelection?: (selectedRowKeys?: (string | number)[]) => void; + onRowSelection?: (selectedRowKeys: (string | number)[]) => void; source?: RecordList; - onPageChange: () => void; + onPageChange: (pageIndex:number) => void; + tableFooter?: React.ReactNode; loading?: boolean; } @@ -93,6 +94,7 @@ export const BillList: React.FC = (props) => { dataIndex: 'pay_amount', width: 150, render: (_, record) => { + if (record.service_charge && record.service_charge > 0) { return

@@ -101,7 +103,7 @@ export const BillList: React.FC = (props) => {
} - return (
HK$ {_}
) + return (
) }, }, { @@ -114,16 +116,18 @@ export const BillList: React.FC = (props) => { title: t('bill.title_pay_method'), dataIndex: 'pay_method', width: 120, - render: (_, {payment_method, payment_channel}) => (
- {payment_channel}
- - ({payment_method}) - -
), + render: (_, {payment_method, payment_channel}) => (payment_channel?( +
+ {payment_channel}
+ + ({payment_method}) + +
+ ):'N/A'), }, { title: t('bill.title_bill_status'), - dataIndex: 'bill_status', + dataIndex: 'status', width: 150, // render: value => dayjs(value).format('YYYY-MM-DD'), }, @@ -141,7 +145,7 @@ export const BillList: React.FC = (props) => { title: '', dataIndex: 'operate', fixed: 'right', - width: 300, + width: props.type == 'reconciliation'?120:300, render: (_, record) => props.operationRender?.(record), }) } @@ -177,12 +181,18 @@ export const BillList: React.FC = (props) => { pageSize: props.source?.pagination.pageSize, total: props.source?.pagination.total, onPageChange: props.onPageChange, + formatPageText: (params) => ( +
+ {props.tableFooter} + 显示第 {params?.currentStart} 条 - 第 {params?.currentEnd} 条,共 {params?.total} 条 +
+ ) }} loading={props.loading} rowSelection={props.onRowSelection ? { fixed: true, onChange: (selectedRowKeys) => { - props.onRowSelection?.(selectedRowKeys) + selectedRowKeys && props.onRowSelection?.(selectedRowKeys) } } : undefined} /> diff --git a/src/components/bill/search-form.tsx b/src/components/bill/search-form.tsx index 1c189e3..49c0046 100644 --- a/src/components/bill/search-form.tsx +++ b/src/components/bill/search-form.tsx @@ -66,7 +66,7 @@ const SearchForm: React.FC = (props) => { onSubmit={formSubmit}> - diff --git a/src/i18n/translations/en.json b/src/i18n/translations/en.json index fa440e8..b92b6c5 100644 --- a/src/i18n/translations/en.json +++ b/src/i18n/translations/en.json @@ -7,7 +7,12 @@ "student_number": "Student Number" }, "bill": { + "bill_date": "Date", "bill_number": "Bill Number", + "confirm": "Confirm", + "confirm_batch": "Batch Confirm", + "confirm_select_empty": "Require confirm bill data", + "confirmed": "Confirmed", "download_receipt": "Download receipt", "pay_status": "Bill Status", "pay_status_canceled": "Canceled", diff --git a/src/i18n/translations/sc.json b/src/i18n/translations/sc.json index 4b42b42..f29e712 100644 --- a/src/i18n/translations/sc.json +++ b/src/i18n/translations/sc.json @@ -7,7 +7,12 @@ "student_number": "学号" }, "bill": { + "bill_date": "日期", "bill_number": "账单编号", + "confirm": "对账", + "confirm_batch": "批量对账", + "confirm_select_empty": "对账账单为空", + "confirmed": "已对账", "download_receipt": "下载收据", "pay_status": "账单状态", "pay_status_canceled": "已作废", diff --git a/src/i18n/translations/tc.json b/src/i18n/translations/tc.json index b598191..270174f 100644 --- a/src/i18n/translations/tc.json +++ b/src/i18n/translations/tc.json @@ -7,7 +7,12 @@ "student_number": "学号" }, "bill": { + "bill_date": "日期", "bill_number": "账单编号", + "confirm": "对账", + "confirm_batch": "批量对账", + "confirm_select_empty": "对账账单为空", + "confirmed": "已对账", "download_receipt": "下载收据", "pay_status": "账单状态", "pay_status_canceled": "已作废", diff --git a/src/pages/bill/query.tsx b/src/pages/bill/query.tsx index 840f66c..9506efb 100644 --- a/src/pages/bill/query.tsx +++ b/src/pages/bill/query.tsx @@ -9,7 +9,6 @@ import {useRequest} from "ahooks"; import {billList, BillQueryParams} from "@/service/api/bill.ts"; const BillQuery = () => { - // const [data, ] = useState>(); const [showBill, setShowBill] = useState() const [queryParams, setBillQueryParams] = useState({}); const {data, loading} = useRequest(() => billList(queryParams), { diff --git a/src/pages/bill/reconciliation.tsx b/src/pages/bill/reconciliation.tsx index 068671f..06a3d13 100644 --- a/src/pages/bill/reconciliation.tsx +++ b/src/pages/bill/reconciliation.tsx @@ -1,23 +1,54 @@ import {BillList} from "@/components/bill/list.tsx"; -import {useState} from "react"; import SearchForm from "@/components/bill/search-form.tsx"; -import {TabPane, Tabs } from "@douyinfe/semi-ui"; +import {Button, Space, TabPane, Tabs,Notification} from "@douyinfe/semi-ui"; +import {billList, BillQueryParams} from "@/service/api/bill.ts"; +import {useRequest, useSetState} from "ahooks"; +import {useTranslation} from "react-i18next"; +import {useState} from "react"; const BillReconciliation = () => { - const [data, ] = useState>({ - list: [], pagination: {current: 0, pageSize: 0, total: 0} + const {t} = useTranslation() + const [queryParams, setBillQueryParams] = useSetState({}); + const {data, loading} = useRequest(() => billList(queryParams), { + refreshDeps: [queryParams] }) + const [selectKeys,setSelectedKeys] = useState<(string|number)[]>([]) + const confirmBill = (records: (string|number)[]) => { + if(records.length == 0) { + Notification.error({title:'Notice',content:t('bill.confirm_select_empty')}) + return + } + console.log(records) + } + const operation = (_record: BillModel) => { + return ( + + ) + } + return (
- - 未对账} itemKey="1" /> - 已对账} itemKey="2" /> - } /> - { - console.log('xxx', keys); - }} onPageChange={function (): void { - throw new Error("Function not implemented."); - }} /> + setBillQueryParams({apply_status})}> + {t('bill.reconciliation_status_pending')}} itemKey="pending"/> + {t('bill.reconciliation_status_submitted')}} itemKey="confirmed"/> + + )} loading={loading} onSearch={setBillQueryParams}/> + { + setSelectedKeys(keys); + }} + loading={loading} + onPageChange={(page_number) => setBillQueryParams({page_number})} + tableFooter={queryParams.apply_status == 'confirmed' ? undefined : ( + + )} + />
) } export default BillReconciliation \ No newline at end of file