fixed: export need sso
This commit is contained in:
parent
6741e61e13
commit
69c067bd9d
@ -1,8 +1,8 @@
|
||||
import {BillDetailItems} from "@/components/bill";
|
||||
import {Button, Col, Form, Modal, Notification, Row, Space, Toast} from "@douyinfe/semi-ui";
|
||||
import {Button, Col, Form, Modal, Row, Space, Toast} from "@douyinfe/semi-ui";
|
||||
import React from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {finishBill, modifyBillStatus} from "@/service/api/bill.ts";
|
||||
import {finishBill} from "@/service/api/bill.ts";
|
||||
import {BizError} from "@/service/types.ts";
|
||||
import {useSetState} from "ahooks";
|
||||
|
||||
@ -18,48 +18,29 @@ export const BillPaidModal: React.FC<BillPaidModalProps> = (props) => {
|
||||
const [state, setState] = useSetState<{
|
||||
loading?: boolean
|
||||
}>({})
|
||||
const onConfirmPaid = () => {
|
||||
const onSubmit = (values: BillUpdateParams) => {
|
||||
if (!props.bill) return;
|
||||
setState({
|
||||
loading: true
|
||||
})
|
||||
modifyBillStatus(props.bill.id, 'PAID').then(() => {
|
||||
setState({loading: false})
|
||||
Notification.success({title: 'Notice', content: t('base.operate_success')})
|
||||
props.onConfirm()
|
||||
}).catch((e: BizError) => {
|
||||
setState({loading: false})
|
||||
Toast.error({
|
||||
content: `${t('base.operate_fail')}:${e.message}`,
|
||||
duration: 3
|
||||
finishBill({bill: props.bill, param: values})
|
||||
.then(() => {
|
||||
setState({loading: false})
|
||||
props.onConfirm()
|
||||
})
|
||||
.catch((e: BizError) => {
|
||||
setState({loading: false})
|
||||
Toast.error({
|
||||
content: `${t('base.operate_fail')}:${e.message}`,
|
||||
duration: 3
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
const onSubmit = (values: BillUpdateParams) => {
|
||||
if (!props.bill) return;
|
||||
finishBill({bill: props.bill, param: values}).then(props.onConfirm)
|
||||
// setState({
|
||||
// loading: true
|
||||
// })
|
||||
// modifyBillStatus(props.bill.id, 'PAID', values).then(() => {
|
||||
// setState({loading: false})
|
||||
// Notification.success({title: 'Notice', content: t('base.operate_success')})
|
||||
// props.onConfirm()
|
||||
// }).catch((e: BizError) => {
|
||||
// setState({loading: false})
|
||||
// Toast.error({
|
||||
// content: `${t('base.operate_fail')}:${e.message}`,
|
||||
// duration: 3
|
||||
// })
|
||||
// })
|
||||
}
|
||||
return <Modal
|
||||
title={t('bill.set_bill_paid') + ` - ${props.bill?.id}`}
|
||||
visible={props.open}
|
||||
closeOnEsc={true}
|
||||
onCancel={props.onCancel}
|
||||
confirmLoading={state.loading}
|
||||
onOk={onConfirmPaid}
|
||||
footer={null}
|
||||
width={600}
|
||||
okText={t('base.confirm_paid')}
|
||||
@ -88,22 +69,6 @@ export const BillPaidModal: React.FC<BillPaidModalProps> = (props) => {
|
||||
</Form.Select>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
{/*<Form.AutoComplete*/}
|
||||
{/* rules={[*/}
|
||||
{/* {required: true, message: 'required error'},*/}
|
||||
{/* ]}*/}
|
||||
{/* placeholder={t('base.please_select')} style={{width: '100%'}}*/}
|
||||
{/* data={[*/}
|
||||
{/* {value:'card',label:'Card(VISA,MasterCard,UnionPay,JCB...)'},*/}
|
||||
{/* {value:'wechat',label:'Wechat'},*/}
|
||||
{/* {value:'alipay',label:'Alipay'},*/}
|
||||
{/* {value:'other',label:'Other'},*/}
|
||||
{/* ]}*/}
|
||||
{/* // renderItem={()=>{*/}
|
||||
{/* //*/}
|
||||
{/* // }}*/}
|
||||
{/* showClear field="payment_method" label={t('bill.title_pay_method')}*/}
|
||||
{/*/>*/}
|
||||
<Form.Select
|
||||
rules={[
|
||||
{required: true, message: 'required error'},
|
||||
|
@ -2,12 +2,11 @@ import {Button, Divider, Modal, Notification, Popconfirm, Toast} from "@douyinfe
|
||||
import {useState} from "react";
|
||||
import {useRequest, useSetState} from "ahooks";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {stringify} from "qs"
|
||||
|
||||
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, modifyBillStatus} from "@/service/api/bill.ts";
|
||||
import {billList, BillQueryParams, exportBillList, modifyBillStatus} from "@/service/api/bill.ts";
|
||||
import {BillStatus, BizError} from "@/service/types.ts";
|
||||
import {useDownloadReceiptPDF} from "@/service/generate-pdf.ts";
|
||||
import {BillDetailItems} from "@/components/bill";
|
||||
@ -31,6 +30,7 @@ const BillQuery = () => {
|
||||
updateBill?: BillModel
|
||||
confirmBill?: BillModel
|
||||
updateLoading?: boolean
|
||||
exporting?: boolean
|
||||
confirmBillId: number
|
||||
}>({confirmBillId: 0})
|
||||
const [showBill, setShowBill] = useState<BillModel>()
|
||||
@ -87,8 +87,22 @@ const BillQuery = () => {
|
||||
</div>)
|
||||
}
|
||||
const onExportExcel = ()=>{
|
||||
const downloadUrl = `${AppConfig.API_PREFIX || '/api'}/bills/export?${stringify(queryParams)}`
|
||||
saveAs(downloadUrl, 'bill-result-excel.xlsx')
|
||||
// const downloadUrl = `${AppConfig.API_PREFIX || '/api'}/bills/export?${stringify(queryParams)}`
|
||||
//
|
||||
//
|
||||
// saveAs(downloadUrl, 'bill-result-excel.xlsx')
|
||||
setState({
|
||||
exporting:true
|
||||
})
|
||||
exportBillList(queryParams).then(ret=>{
|
||||
console.log(ret)
|
||||
const blob = new Blob([ret], {type:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
|
||||
saveAs(blob, 'bill-result-excel.xlsx')
|
||||
}).finally(()=>{
|
||||
setState({
|
||||
exporting:false
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return (<div>
|
||||
@ -96,7 +110,7 @@ const BillQuery = () => {
|
||||
<BillList
|
||||
type={'query'} loading={loading} source={data}
|
||||
operationRender={operation} operationRenderWidth={180}
|
||||
beforeTotalAmount={<Button onClick={onExportExcel} theme={'solid'} type={'secondary'}>{t('bill.export_excel')}</Button>}
|
||||
beforeTotalAmount={<Button loading={state.exporting} onClick={onExportExcel} theme={'solid'} type={'secondary'}>{t('bill.export_excel')}</Button>}
|
||||
onPageChange={(page_number) => {
|
||||
setBillQueryParams({
|
||||
...queryParams,
|
||||
|
@ -1,5 +1,7 @@
|
||||
import {get, post, put} from "@/service/request.ts";
|
||||
import dayjs from "dayjs";
|
||||
import {getAuthToken} from "@/hooks/useAuth.ts";
|
||||
import {stringify} from "qs";
|
||||
|
||||
export type BillQueryResult = {
|
||||
result: BillModel[];
|
||||
@ -29,6 +31,18 @@ export async function billList(params: BillQueryParams) {
|
||||
return formatBillQueryResult(params, result);
|
||||
}
|
||||
|
||||
export function exportBillList(params: BillQueryParams) {
|
||||
const token = getAuthToken();
|
||||
const headers = new Headers({
|
||||
'Token': token || ''
|
||||
});
|
||||
|
||||
return fetch(`${AppConfig.API_PREFIX || '/api'}/bills/export?${stringify(params)}`,{
|
||||
headers,
|
||||
method:'GET'
|
||||
}).then(r=>r.blob())
|
||||
// return get<Blob>('/bills/export', params,true)
|
||||
}
|
||||
//现场支付创建账单接口
|
||||
export function createManualBill(params: ManualCreateBillParam) {
|
||||
return post<BillModel>('/manual_payment', params)
|
||||
@ -53,7 +67,7 @@ export function modifyBillStatus(id: number,status: BillStatus) {
|
||||
}
|
||||
|
||||
export function confirmBillType({id,type}: {id:number,type: string}) {
|
||||
return post<BillModel>(`/bill/detail/${id}/confirm`, {type})
|
||||
return post<BillModel>(`/bill/detail/${id}/confirm`, {confirm_type:type})
|
||||
}
|
||||
|
||||
export function confirmBills(bill_ids: number[]) {
|
||||
@ -81,6 +95,7 @@ x&cardIssuingCountry=HK&channelType=SPC&`
|
||||
|
||||
return ret?.toLowerCase() == 'ok'
|
||||
}
|
||||
|
||||
export async function finishFlywire({bill,param}: BillUpdateFormParams){
|
||||
const eventData = {
|
||||
"event_type": "guaranteed",
|
||||
|
@ -28,8 +28,8 @@ export default defineConfig(({mode}) => {
|
||||
port:10086,
|
||||
proxy: {
|
||||
'/api': {
|
||||
// target: 'https://test-payment-be.hkchc.team', //
|
||||
target: 'http://127.0.0.1:50000', //
|
||||
target: 'https://test-payment-be.hkchc.team', //
|
||||
// target: 'http://127.0.0.1:50000', //
|
||||
changeOrigin: true,
|
||||
//rewrite: (path) => path.replace(/^\/api/, '')
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user