update query params
This commit is contained in:
parent
e489897bd2
commit
f899760a86
@ -1,10 +1,9 @@
|
|||||||
import {Button, Col, Form, Row} from "@douyinfe/semi-ui";
|
import {Button, Col, Form, Row} from "@douyinfe/semi-ui";
|
||||||
import React, {useMemo} from "react";
|
import React, {useMemo} from "react";
|
||||||
import {Card} from "@/components/card";
|
|
||||||
import {useTranslation} from "react-i18next";
|
|
||||||
import {BillQueryParams} from "@/service/api/bill.ts";
|
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import useAuth from "@/hooks/useAuth.ts";
|
import {useTranslation} from "react-i18next";
|
||||||
|
import {Card} from "@/components/card";
|
||||||
|
import {BillQueryParams} from "@/service/api/bill.ts";
|
||||||
|
|
||||||
type SearchFormProps = {
|
type SearchFormProps = {
|
||||||
onSearch?: (params: BillQueryParams) => void;
|
onSearch?: (params: BillQueryParams) => void;
|
||||||
@ -23,11 +22,8 @@ type SearchFormFields = {
|
|||||||
apply_status?: string;
|
apply_status?: string;
|
||||||
}
|
}
|
||||||
const SearchForm: React.FC<SearchFormProps> = (props) => {
|
const SearchForm: React.FC<SearchFormProps> = (props) => {
|
||||||
const {user} = useAuth();
|
|
||||||
const formSubmit = (value: SearchFormFields) => {
|
const formSubmit = (value: SearchFormFields) => {
|
||||||
const params: BillQueryParams = {
|
const params: BillQueryParams = {}
|
||||||
department: user?.department == 'RO' ? 'RO' : 'FO',
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value.dateRange && value.dateRange.length == 2) {
|
if (value.dateRange && value.dateRange.length == 2) {
|
||||||
params.start_date = dayjs(value.dateRange[0]).format('YYYY-MM-DD');
|
params.start_date = dayjs(value.dateRange[0]).format('YYYY-MM-DD');
|
||||||
@ -47,7 +43,7 @@ const SearchForm: React.FC<SearchFormProps> = (props) => {
|
|||||||
if (value.bill_status) {
|
if (value.bill_status) {
|
||||||
params.status = value.bill_status;
|
params.status = value.bill_status;
|
||||||
}
|
}
|
||||||
if(props.showApply){
|
if(!props.showApply){
|
||||||
params.status = 'PAID'
|
params.status = 'PAID'
|
||||||
}
|
}
|
||||||
// 支付方式
|
// 支付方式
|
||||||
|
@ -1,20 +1,25 @@
|
|||||||
import {BillList} from "@/components/bill/list.tsx";
|
|
||||||
import {Button, Modal, Notification, Popconfirm, Space} from "@douyinfe/semi-ui";
|
import {Button, Modal, Notification, Popconfirm, Space} from "@douyinfe/semi-ui";
|
||||||
import {useState} from "react";
|
import {useState} from "react";
|
||||||
import {useRequest} from "ahooks";
|
import {useRequest} from "ahooks";
|
||||||
import {useTranslation} from "react-i18next";
|
import {useTranslation} from "react-i18next";
|
||||||
import * as Sentry from "@sentry/react";
|
import * as Sentry from "@sentry/react";
|
||||||
|
|
||||||
|
import {BillList} from "@/components/bill/list.tsx";
|
||||||
import SearchForm from "@/components/bill/search-form.tsx";
|
import SearchForm from "@/components/bill/search-form.tsx";
|
||||||
import BillDetail from "@/components/bill/detail.tsx";
|
import BillDetail from "@/components/bill/detail.tsx";
|
||||||
import {billList, BillQueryParams, cancelBill} from "@/service/api/bill.ts";
|
import {billList, BillQueryParams, cancelBill} from "@/service/api/bill.ts";
|
||||||
import {BillStatus} from "@/service/types.ts";
|
import {BillStatus} from "@/service/types.ts";
|
||||||
import {useDownloadReceiptPDF} from "@/service/generate-pdf.ts";
|
import {useDownloadReceiptPDF} from "@/service/generate-pdf.ts";
|
||||||
|
import useAuth from "@/hooks/useAuth.ts";
|
||||||
|
|
||||||
const BillQuery = () => {
|
const BillQuery = () => {
|
||||||
|
const {user} = useAuth();
|
||||||
const [showBill, setShowBill] = useState<BillModel>()
|
const [showBill, setShowBill] = useState<BillModel>()
|
||||||
const [queryParams, setBillQueryParams] = useState<BillQueryParams>({});
|
const [queryParams, setBillQueryParams] = useState<BillQueryParams>({});
|
||||||
const {data, loading, refresh} = useRequest(() => billList(queryParams), {
|
const {data, loading, refresh} = useRequest(() => billList({
|
||||||
|
...queryParams,
|
||||||
|
department: user?.department == 'RO' ? 'RO' : 'FO',
|
||||||
|
}), {
|
||||||
refreshDeps: [queryParams],
|
refreshDeps: [queryParams],
|
||||||
onError: (e) => {
|
onError: (e) => {
|
||||||
Sentry.captureMessage('Error: Query bill error', {
|
Sentry.captureMessage('Error: Query bill error', {
|
||||||
@ -36,6 +41,7 @@ const BillQuery = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
const operation = (bill: BillModel) => {
|
const operation = (bill: BillModel) => {
|
||||||
|
|
||||||
return (<Space>
|
return (<Space>
|
||||||
{bill.status == BillStatus.PENDING && <>
|
{bill.status == BillStatus.PENDING && <>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
|
@ -1,19 +1,27 @@
|
|||||||
import {BillList} from "@/components/bill/list.tsx";
|
|
||||||
import SearchForm from "@/components/bill/search-form.tsx";
|
|
||||||
import {Button, Space, TabPane, Tabs, Notification, Popconfirm} from "@douyinfe/semi-ui";
|
import {Button, Space, TabPane, Tabs, Notification, Popconfirm} from "@douyinfe/semi-ui";
|
||||||
import {billList, BillQueryParams, confirmBills} from "@/service/api/bill.ts";
|
import {useRequest} from "ahooks";
|
||||||
import {useRequest, useSetState} from "ahooks";
|
|
||||||
import {useTranslation} from "react-i18next";
|
import {useTranslation} from "react-i18next";
|
||||||
import {useState} from "react";
|
import {useState} from "react";
|
||||||
|
|
||||||
|
import SearchForm from "@/components/bill/search-form.tsx";
|
||||||
|
import {BillList} from "@/components/bill/list.tsx";
|
||||||
|
import {billList, BillQueryParams, confirmBills} from "@/service/api/bill.ts";
|
||||||
|
import useAuth from "@/hooks/useAuth.ts";
|
||||||
|
|
||||||
const BillReconciliation = () => {
|
const BillReconciliation = () => {
|
||||||
const {t} = useTranslation()
|
const {t} = useTranslation()
|
||||||
const [queryParams, setBillQueryParams] = useSetState<BillQueryParams>({
|
const {user} = useAuth();
|
||||||
status:'PAID'
|
const [queryParams, setBillQueryParams] = useState<BillQueryParams>({
|
||||||
|
apply_status:'UNCHECKED'
|
||||||
});
|
});
|
||||||
const {data, loading,refresh} = useRequest(() => billList(queryParams), {
|
const {data, loading, refresh} = useRequest(() => billList({
|
||||||
|
...queryParams,
|
||||||
|
status: 'PAID',
|
||||||
|
department: user?.department == 'RO' ? 'RO' : 'FO',
|
||||||
|
}), {
|
||||||
refreshDeps: [queryParams]
|
refreshDeps: [queryParams]
|
||||||
})
|
})
|
||||||
|
|
||||||
const [selectKeys, setSelectedKeys] = useState<(string | number)[]>([])
|
const [selectKeys, setSelectedKeys] = useState<(string | number)[]>([])
|
||||||
const confirmBill = (records: number[]) => {
|
const confirmBill = (records: number[]) => {
|
||||||
if (records.length == 0) {
|
if (records.length == 0) {
|
||||||
@ -40,12 +48,21 @@ const BillReconciliation = () => {
|
|||||||
|
|
||||||
return (<div>
|
return (<div>
|
||||||
|
|
||||||
<SearchForm searchHeader={(
|
<SearchForm
|
||||||
<Tabs className={'no-border'} onChange={(apply_status) => setBillQueryParams({apply_status})}>
|
searchHeader={(
|
||||||
|
<Tabs className={'no-border'} onChange={(apply_status) => setBillQueryParams({
|
||||||
|
apply_status,
|
||||||
|
status: 'PAID'
|
||||||
|
})}>
|
||||||
<TabPane tab={<span>{t('bill.reconciliation_status_pending')}</span>} itemKey="UNCHECKED"/>
|
<TabPane tab={<span>{t('bill.reconciliation_status_pending')}</span>} itemKey="UNCHECKED"/>
|
||||||
<TabPane tab={<span>{t('bill.reconciliation_status_submitted')}</span>} itemKey="CHECKED"/>
|
<TabPane tab={<span>{t('bill.reconciliation_status_submitted')}</span>} itemKey="CHECKED"/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
)} loading={loading} onSearch={setBillQueryParams}/>
|
)}
|
||||||
|
loading={loading}
|
||||||
|
onSearch={(params) => {
|
||||||
|
setBillQueryParams({...params, apply_status: queryParams.apply_status})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<BillList
|
<BillList
|
||||||
source={data} type={'reconciliation'}
|
source={data} type={'reconciliation'}
|
||||||
operationRender={queryParams.apply_status == 'CHECKED' ? undefined : operation}
|
operationRender={queryParams.apply_status == 'CHECKED' ? undefined : operation}
|
||||||
@ -53,7 +70,10 @@ const BillReconciliation = () => {
|
|||||||
setSelectedKeys(keys);
|
setSelectedKeys(keys);
|
||||||
}}
|
}}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onPageChange={(page_number) => setBillQueryParams({page_number})}
|
onPageChange={(page_number) => setBillQueryParams({
|
||||||
|
...queryParams,
|
||||||
|
page_number
|
||||||
|
})}
|
||||||
tableFooter={queryParams.apply_status != 'CHECKED' && selectKeys?.length > 0 && (
|
tableFooter={queryParams.apply_status != 'CHECKED' && selectKeys?.length > 0 && (
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title={'Notice'}
|
title={'Notice'}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user