import { getInvoiceRecords } from '@/web/support/wallet/bill/invoice/api'; import MyBox from '@fastgpt/web/components/common/MyBox'; import { useTranslation } from 'next-i18next'; import { useState } from 'react'; import { Box, Button, Flex, FormLabel, ModalBody, Table, TableContainer, Tbody, Td, Th, Thead, Tr } from '@chakra-ui/react'; import { usePagination } from '@fastgpt/web/hooks/usePagination'; import { type InvoiceSchemaType } from '@fastgpt/global/support/wallet/bill/type'; import MyIcon from '@fastgpt/web/components/common/Icon'; import dayjs from 'dayjs'; import { formatStorePrice2Read } from '@fastgpt/global/support/wallet/usage/tools'; import MyModal from '@fastgpt/web/components/common/MyModal'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import { downloadFetch } from '@/web/common/system/utils'; const InvoiceTable = () => { const { t } = useTranslation(); const [invoiceDetailData, setInvoiceDetailData] = useState(''); const { data: invoices, isLoading, Pagination, total } = usePagination(getInvoiceRecords, { pageSize: 20 }); return ( {invoices.map((item, i) => ( ))}
# {t('account_bill:time')} {t('account_bill:support_wallet_amount')} {t('account_bill:status')}
{i + 1} {item.createTime ? dayjs(item.createTime).format('YYYY/MM/DD HH:mm:ss') : '-'} {t('account_bill:yuan', { amount: formatStorePrice2Read(item.amount) })} {item.status === 1 ? t('account_bill:submitted') : t('account_bill:completed')}
{total >= 20 && ( )} {!isLoading && invoices.length === 0 && ( {t('account_bill:no_invoice_record_tip')} )}
{!!invoiceDetailData && ( setInvoiceDetailData('')} /> )}
); }; export default InvoiceTable; function InvoiceDetailModal({ invoice, onClose }: { invoice: InvoiceSchemaType; onClose: () => void; }) { const { t } = useTranslation(); const { runAsync: handleDownloadInvoice } = useRequest2(async (id: string) => { await downloadFetch({ url: `/api/proApi/support/wallet/bill/invoice/downloadFile?id=${id}`, filename: `${invoice.teamName}.pdf` }); }); return ( {t('account_bill:invoice_detail')} } > {invoice.status === 2 && ( {t('account_bill:Invoice_document')} handleDownloadInvoice(invoice._id)}> {t('account_bill:click_to_download')} )} ); } function LabelItem({ label, value }: { label: string; value?: string }) { return ( {label} {value || '-'} ); }