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 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 useAuth from "@/hooks/useAuth.ts";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Card} from "@/components/card";
|
||||
import {BillQueryParams} from "@/service/api/bill.ts";
|
||||
|
||||
type SearchFormProps = {
|
||||
onSearch?: (params: BillQueryParams) => void;
|
||||
@ -23,11 +22,8 @@ type SearchFormFields = {
|
||||
apply_status?: string;
|
||||
}
|
||||
const SearchForm: React.FC<SearchFormProps> = (props) => {
|
||||
const {user} = useAuth();
|
||||
const formSubmit = (value: SearchFormFields) => {
|
||||
const params: BillQueryParams = {
|
||||
department: user?.department == 'RO' ? 'RO' : 'FO',
|
||||
}
|
||||
const params: BillQueryParams = {}
|
||||
|
||||
if (value.dateRange && value.dateRange.length == 2) {
|
||||
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) {
|
||||
params.status = value.bill_status;
|
||||
}
|
||||
if(props.showApply){
|
||||
if(!props.showApply){
|
||||
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 {useState} from "react";
|
||||
import {useRequest} from "ahooks";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import * as Sentry from "@sentry/react";
|
||||
|
||||
import {BillList} from "@/components/bill/list.tsx";
|
||||
import SearchForm from "@/components/bill/search-form.tsx";
|
||||
import BillDetail from "@/components/bill/detail.tsx";
|
||||
import {billList, BillQueryParams, cancelBill} from "@/service/api/bill.ts";
|
||||
import {BillStatus} from "@/service/types.ts";
|
||||
import {useDownloadReceiptPDF} from "@/service/generate-pdf.ts";
|
||||
import useAuth from "@/hooks/useAuth.ts";
|
||||
|
||||
const BillQuery = () => {
|
||||
const {user} = useAuth();
|
||||
const [showBill, setShowBill] = useState<BillModel>()
|
||||
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],
|
||||
onError: (e) => {
|
||||
Sentry.captureMessage('Error: Query bill error', {
|
||||
@ -36,6 +41,7 @@ const BillQuery = () => {
|
||||
})
|
||||
}
|
||||
const operation = (bill: BillModel) => {
|
||||
|
||||
return (<Space>
|
||||
{bill.status == BillStatus.PENDING && <>
|
||||
<Popconfirm
|
||||
|
@ -1,27 +1,35 @@
|
||||
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 {billList, BillQueryParams, confirmBills} from "@/service/api/bill.ts";
|
||||
import {useRequest, useSetState} from "ahooks";
|
||||
import {useRequest} from "ahooks";
|
||||
import {useTranslation} from "react-i18next";
|
||||
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 {t} = useTranslation()
|
||||
const [queryParams, setBillQueryParams] = useSetState<BillQueryParams>({
|
||||
status:'PAID'
|
||||
const {user} = useAuth();
|
||||
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]
|
||||
})
|
||||
const [selectKeys,setSelectedKeys] = useState<(string|number)[]>([])
|
||||
|
||||
const [selectKeys, setSelectedKeys] = useState<(string | number)[]>([])
|
||||
const confirmBill = (records: number[]) => {
|
||||
if(records.length == 0) {
|
||||
Notification.error({title:'Notice',content:t('bill.confirm_select_empty')})
|
||||
if (records.length == 0) {
|
||||
Notification.error({title: 'Notice', content: t('bill.confirm_select_empty')})
|
||||
return
|
||||
}
|
||||
confirmBills(records).then(()=>{
|
||||
Notification.success({title:'Notice',content:t('bill.confirm_success')})
|
||||
confirmBills(records).then(() => {
|
||||
Notification.success({title: 'Notice', content: t('bill.confirm_success')})
|
||||
refresh()
|
||||
})
|
||||
}
|
||||
@ -30,7 +38,7 @@ const BillReconciliation = () => {
|
||||
<Popconfirm
|
||||
title={'Notice'}
|
||||
content={t('bill.confirm_confirm_title')}
|
||||
onConfirm={()=>confirmBill([_record.id])}
|
||||
onConfirm={() => confirmBill([_record.id])}
|
||||
>
|
||||
<Button size={'small'} theme={'solid'}
|
||||
type={'primary'}>{t('bill.confirm')}</Button>
|
||||
@ -40,27 +48,39 @@ const BillReconciliation = () => {
|
||||
|
||||
return (<div>
|
||||
|
||||
<SearchForm searchHeader={(
|
||||
<Tabs className={'no-border'} onChange={(apply_status) => setBillQueryParams({apply_status})}>
|
||||
<TabPane tab={<span>{t('bill.reconciliation_status_pending')}</span>} itemKey="UNCHECKED"/>
|
||||
<TabPane tab={<span>{t('bill.reconciliation_status_submitted')}</span>} itemKey="CHECKED"/>
|
||||
</Tabs>
|
||||
)} loading={loading} onSearch={setBillQueryParams}/>
|
||||
<SearchForm
|
||||
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_submitted')}</span>} itemKey="CHECKED"/>
|
||||
</Tabs>
|
||||
)}
|
||||
loading={loading}
|
||||
onSearch={(params) => {
|
||||
setBillQueryParams({...params, apply_status: queryParams.apply_status})
|
||||
}}
|
||||
/>
|
||||
<BillList
|
||||
source={data} type={'reconciliation'}
|
||||
operationRender={queryParams.apply_status == 'CHECKED' ? undefined : operation}
|
||||
onRowSelection={queryParams.apply_status == 'CHECKED' ? undefined : (keys: (number|string)[]) => {
|
||||
onRowSelection={queryParams.apply_status == 'CHECKED' ? undefined : (keys: (number | string)[]) => {
|
||||
setSelectedKeys(keys);
|
||||
}}
|
||||
loading={loading}
|
||||
onPageChange={(page_number) => setBillQueryParams({page_number})}
|
||||
tableFooter={queryParams.apply_status != 'CHECKED' && selectKeys?.length > 0 && (
|
||||
onPageChange={(page_number) => setBillQueryParams({
|
||||
...queryParams,
|
||||
page_number
|
||||
})}
|
||||
tableFooter={queryParams.apply_status != 'CHECKED' && selectKeys?.length > 0 && (
|
||||
<Popconfirm
|
||||
title={'Notice'}
|
||||
content={`${t('bill.cancel_confirm_bills')}?`}
|
||||
onConfirm={()=>confirmBill(selectKeys as number[])}
|
||||
onConfirm={() => confirmBill(selectKeys as number[])}
|
||||
>
|
||||
<Button style={{marginRight:10}}>
|
||||
<Button style={{marginRight: 10}}>
|
||||
{t('bill.confirm_batch')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
|
Loading…
x
Reference in New Issue
Block a user