fix(ui): 修复登录与并发请求并统一表格、主题和页面展示
验证:868 项单测、ESLint、Prettier、UI 依赖审计和差异检查通过。
This commit is contained in:
+116
-128
@@ -16,24 +16,21 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import { formatUserReference } from '../../helpers/safeDisplay';
|
||||
|
||||
import { Trans } from 'react-i18next';
|
||||
import {
|
||||
Eye as ActionEye,
|
||||
Check as ActionCheck,
|
||||
X as ActionX,
|
||||
Ban as ActionBan,
|
||||
RotateCw as ActionRotateCw,
|
||||
} from '@/components/common/icons/ActionIcons';
|
||||
import {
|
||||
ConsoleCard,
|
||||
ConsoleSearchBar,
|
||||
ConsoleSearchActions,
|
||||
ConsoleFilterField,
|
||||
ConsoleFilterGrid,
|
||||
ConsoleListTable,
|
||||
} from '../../components/console/ConsolePrimitives';
|
||||
import ConsoleCollection from '../../components/console/ConsoleCollection';
|
||||
import { TableRowActions } from '../../components/common/table/TableToolbar';
|
||||
import { useIsMobile } from '../../hooks/common/useIsMobile';
|
||||
import { createCardProPagination } from '../../helpers/utils';
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Table,
|
||||
Button,
|
||||
Input,
|
||||
Tag,
|
||||
@@ -63,6 +60,7 @@ const paymentMethodMap = {
|
||||
|
||||
const AdminInvoice = () => {
|
||||
const { t, i18n } = useTranslation();
|
||||
const isMobile = useIsMobile();
|
||||
const [invoices, setInvoices] = useState([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -118,6 +116,13 @@ const AdminInvoice = () => {
|
||||
setSearchKeyword(keyword);
|
||||
};
|
||||
|
||||
const handleReset = () => {
|
||||
setPage(1);
|
||||
setKeyword('');
|
||||
setSearchKeyword('');
|
||||
setStatusFilter('');
|
||||
};
|
||||
|
||||
const handleStatusFilterChange = (value) => {
|
||||
setPage(1);
|
||||
setStatusFilter(value || '');
|
||||
@@ -301,138 +306,118 @@ const AdminInvoice = () => {
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 200,
|
||||
key: 'actions',
|
||||
width: 140,
|
||||
fixed: 'right',
|
||||
render: (_, record) => (
|
||||
<div className='flex items-center gap-1 flex-wrap'>
|
||||
<TableRowActions
|
||||
items={[
|
||||
record.status === INVOICE_STATUS.PENDING && {
|
||||
key: 'approve',
|
||||
label: t('通过'),
|
||||
onClick: () => {
|
||||
setApproveId(record.id);
|
||||
setApproveVisible(true);
|
||||
},
|
||||
},
|
||||
record.status === INVOICE_STATUS.PENDING && {
|
||||
key: 'reject',
|
||||
label: t('拒绝'),
|
||||
danger: true,
|
||||
onClick: () => {
|
||||
setRejectId(record.id);
|
||||
setRejectVisible(true);
|
||||
},
|
||||
},
|
||||
record.status === INVOICE_STATUS.FAILED && {
|
||||
key: 'retry',
|
||||
label: t('重试'),
|
||||
onClick: () => handleRetry(record.id),
|
||||
},
|
||||
[
|
||||
INVOICE_STATUS.APPROVED,
|
||||
INVOICE_STATUS.INVOICING,
|
||||
INVOICE_STATUS.FAILED,
|
||||
].includes(record.status) && {
|
||||
key: 'cancel',
|
||||
label: t('取消'),
|
||||
danger: true,
|
||||
onClick: () => handleFailCancel(record.id),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<ActionEye size={14} />}
|
||||
onClick={() => handleViewDetail(record.id)}
|
||||
/>
|
||||
{record.status === INVOICE_STATUS.PENDING && (
|
||||
<>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
type='primary'
|
||||
icon={<ActionCheck size={14} />}
|
||||
onClick={() => {
|
||||
setApproveId(record.id);
|
||||
setApproveVisible(true);
|
||||
}}
|
||||
>
|
||||
{t('通过')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
type='danger'
|
||||
icon={<ActionX size={14} />}
|
||||
onClick={() => {
|
||||
setRejectId(record.id);
|
||||
setRejectVisible(true);
|
||||
}}
|
||||
>
|
||||
{t('拒绝')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{(record.status === INVOICE_STATUS.APPROVED ||
|
||||
record.status === INVOICE_STATUS.INVOICING) && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
type='danger'
|
||||
icon={<ActionBan size={14} />}
|
||||
onClick={() => handleFailCancel(record.id)}
|
||||
>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
)}
|
||||
{record.status === INVOICE_STATUS.FAILED && (
|
||||
<>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<ActionRotateCw size={14} />}
|
||||
onClick={() => handleRetry(record.id)}
|
||||
>
|
||||
{t('重试')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
type='danger'
|
||||
icon={<ActionBan size={14} />}
|
||||
onClick={() => handleFailCancel(record.id)}
|
||||
>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
>
|
||||
{t('详情')}
|
||||
</Button>
|
||||
</TableRowActions>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='console-content'>
|
||||
{/* 筛选区:标题与筛选项同行 */}
|
||||
<ConsoleSearchBar formProps={{ layout: 'inline' }}>
|
||||
<div className='console-search-fields'>
|
||||
<Input
|
||||
prefix={<Search size={14} />}
|
||||
placeholder={t('搜索抬头/税号/订单号/用户')}
|
||||
value={keyword}
|
||||
onChange={setKeyword}
|
||||
onEnterPress={handleSearch}
|
||||
style={{ width: 240 }}
|
||||
/>
|
||||
<Select
|
||||
placeholder={t('状态')}
|
||||
value={statusFilter || undefined}
|
||||
onChange={handleStatusFilterChange}
|
||||
style={{ width: 120 }}
|
||||
allowClear
|
||||
optionList={[
|
||||
{ label: t('待审核'), value: '1' },
|
||||
{ label: t('审核通过'), value: '2' },
|
||||
{ label: t('已拒绝'), value: '3' },
|
||||
{ label: t('开票中'), value: '4' },
|
||||
{ label: t('已开票'), value: '5' },
|
||||
{ label: t('已取消'), value: '6' },
|
||||
{ label: t('开票失败'), value: '7' },
|
||||
]}
|
||||
/>
|
||||
<ConsoleSearchActions onSearch={handleSearch} loading={loading} />
|
||||
</div>
|
||||
</ConsoleSearchBar>
|
||||
|
||||
{/* 表格 */}
|
||||
<ConsoleCard>
|
||||
<Table
|
||||
<ConsoleCollection
|
||||
searchArea={
|
||||
<ConsoleFilterGrid
|
||||
onReset={handleReset}
|
||||
onSearch={handleSearch}
|
||||
loading={loading}
|
||||
>
|
||||
<ConsoleFilterField label={t('搜索关键字')} id='invoice-keyword'>
|
||||
<Input
|
||||
id='invoice-keyword'
|
||||
prefix={<Search size={14} />}
|
||||
placeholder={t('搜索抬头/税号/订单号/用户')}
|
||||
value={keyword}
|
||||
onChange={setKeyword}
|
||||
onEnterPress={handleSearch}
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
<ConsoleFilterField label={t('状态')} id='invoice-status'>
|
||||
<Select
|
||||
id='invoice-status'
|
||||
placeholder={t('状态')}
|
||||
value={statusFilter || undefined}
|
||||
onChange={handleStatusFilterChange}
|
||||
allowClear
|
||||
optionList={[
|
||||
{ label: t('待审核'), value: '1' },
|
||||
{ label: t('审核通过'), value: '2' },
|
||||
{ label: t('已拒绝'), value: '3' },
|
||||
{ label: t('开票中'), value: '4' },
|
||||
{ label: t('已开票'), value: '5' },
|
||||
{ label: t('已取消'), value: '6' },
|
||||
{ label: t('开票失败'), value: '7' },
|
||||
]}
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
</ConsoleFilterGrid>
|
||||
}
|
||||
paginationArea={createCardProPagination({
|
||||
currentPage: page,
|
||||
pageSize,
|
||||
total,
|
||||
onPageChange: setPage,
|
||||
onPageSizeChange: (size) => {
|
||||
setPage(1);
|
||||
setPageSize(size);
|
||||
},
|
||||
isMobile,
|
||||
t,
|
||||
})}
|
||||
>
|
||||
<ConsoleListTable
|
||||
columns={columns}
|
||||
dataSource={invoices}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
total,
|
||||
pageSize,
|
||||
onPageChange: setPage,
|
||||
onPageSizeChange: (size) => {
|
||||
setPage(1);
|
||||
setPageSize(size);
|
||||
},
|
||||
showTotal: true,
|
||||
}}
|
||||
scroll={{ x: 1100 }}
|
||||
size='middle'
|
||||
empty={t('暂无发票数据')}
|
||||
pagination={false}
|
||||
/>
|
||||
</ConsoleCard>
|
||||
</ConsoleCollection>
|
||||
|
||||
{/* 审核通过弹窗 */}
|
||||
<Modal
|
||||
@@ -510,7 +495,10 @@ const AdminInvoice = () => {
|
||||
<div>
|
||||
{detailData.display_name ||
|
||||
detailData.username ||
|
||||
`User#${detailData.user_id}`}
|
||||
formatUserReference(
|
||||
detailData.display_name || detailData.username,
|
||||
detailData.user_id,
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user