fix(ui): 统一表格筛选分页和用量明细,升级 ESLint
This commit is contained in:
@@ -18,7 +18,11 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import { formatIdReference } from '../../helpers/safeDisplay';
|
||||
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import { ConsoleCollectionSearch } from '@/components/console/ConsoleCollection';
|
||||
import {
|
||||
ConsoleFilterField,
|
||||
ConsoleFilterGrid,
|
||||
} from '@/components/console/ConsolePrimitives';
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
@@ -44,6 +48,8 @@ import {
|
||||
} from '@/components/ui';
|
||||
import {
|
||||
ArrowLeft as ActionArrowLeft,
|
||||
Download,
|
||||
Search,
|
||||
RefreshCw as ActionRefresh,
|
||||
} from '@/components/common/icons/ActionIcons';
|
||||
import {
|
||||
@@ -148,6 +154,9 @@ export default function PartnerPortal({
|
||||
const [customerStatus, setCustomerStatus] = useState('all');
|
||||
const [billMonth, setBillMonth] = useState('all');
|
||||
const [billStatus, setBillStatus] = useState('all');
|
||||
const [billPage, setBillPage] = useState(1);
|
||||
const [customerPage, setCustomerPage] = useState(1);
|
||||
const [detailPage, setDetailPage] = useState(1);
|
||||
const loadVersion = useRef(0);
|
||||
const detailVersion = useRef(0);
|
||||
const selectedId = useRef(null);
|
||||
@@ -252,6 +261,7 @@ export default function PartnerPortal({
|
||||
setDetailLoading(true);
|
||||
setError('');
|
||||
setQuery('');
|
||||
setDetailPage(1);
|
||||
setAction(null);
|
||||
setReason('');
|
||||
setActionError('');
|
||||
@@ -496,25 +506,9 @@ export default function PartnerPortal({
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 175,
|
||||
width: 230,
|
||||
render: (_, row) => (
|
||||
<TableRowActions
|
||||
items={[
|
||||
{
|
||||
key: 'export',
|
||||
label: t('导出'),
|
||||
disabled: exportingId !== null || mutationLoading,
|
||||
onClick: () => exportStatement(row),
|
||||
},
|
||||
row.status === 'pending_confirmation' && {
|
||||
key: 'reject',
|
||||
label: t('驳回'),
|
||||
danger: true,
|
||||
disabled: mutationLoading,
|
||||
onClick: () => open(row, 'reject'),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<div className='partner-portal-row-actions'>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
@@ -524,57 +518,119 @@ export default function PartnerPortal({
|
||||
{t('查看')}
|
||||
</Button>
|
||||
{row.status === 'pending_confirmation' && (
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
disabled={mutationLoading}
|
||||
onClick={() => open(row, 'confirm')}
|
||||
>
|
||||
{t('确认')}
|
||||
</Button>
|
||||
<>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
disabled={mutationLoading}
|
||||
onClick={() => open(row, 'confirm')}
|
||||
>
|
||||
{t('确认')}
|
||||
</Button>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
danger
|
||||
disabled={mutationLoading}
|
||||
onClick={() => open(row, 'reject')}
|
||||
>
|
||||
{t('驳回')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</TableRowActions>
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
disabled={exportingId !== null || mutationLoading}
|
||||
loading={exportingId === row.id}
|
||||
onClick={() => exportStatement(row)}
|
||||
>
|
||||
{t('导出')}
|
||||
</Button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const refreshButton = (
|
||||
<Button
|
||||
icon={<ActionRefresh size={16} />}
|
||||
disabled={mutationLoading || detailLoading}
|
||||
loading={loading}
|
||||
onClick={() => {
|
||||
load();
|
||||
if (selected) open(selected);
|
||||
}}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
);
|
||||
|
||||
const renderBills = () => (
|
||||
<>
|
||||
<ConsoleCollectionSearch>
|
||||
<ConsoleFilterGrid
|
||||
onReset={() => {
|
||||
setBillMonth('all');
|
||||
setBillStatus('all');
|
||||
setBillPage(1);
|
||||
}}
|
||||
onSearch={() => setBillPage(1)}
|
||||
>
|
||||
<ConsoleFilterField label={t('账期')} id='partner-bill-month'>
|
||||
<Select
|
||||
id='partner-bill-month'
|
||||
value={billMonth}
|
||||
onChange={(value) => {
|
||||
setBillMonth(value);
|
||||
setBillPage(1);
|
||||
}}
|
||||
optionList={[
|
||||
{ value: 'all', label: t('全部账期') },
|
||||
...Array.from(new Set(rows.map((row) => row.statement_month)))
|
||||
.sort()
|
||||
.reverse()
|
||||
.map((value) => ({ value, label: value })),
|
||||
]}
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
<ConsoleFilterField label={t('状态')} id='partner-bill-status'>
|
||||
<Select
|
||||
id='partner-bill-status'
|
||||
value={billStatus}
|
||||
onChange={(value) => {
|
||||
setBillStatus(value);
|
||||
setBillPage(1);
|
||||
}}
|
||||
optionList={[
|
||||
{ value: 'all', label: t('全部状态') },
|
||||
...Array.from(new Set(rows.map((row) => row.status))).map(
|
||||
(value) => ({
|
||||
value,
|
||||
label: commissionLabel(t, 'status', value),
|
||||
}),
|
||||
),
|
||||
]}
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
</ConsoleFilterGrid>
|
||||
</ConsoleCollectionSearch>
|
||||
<Card className='commission-card partner-portal-card'>
|
||||
<div className='partner-portal-filters'>
|
||||
<Select
|
||||
value={billMonth}
|
||||
onChange={setBillMonth}
|
||||
optionList={[
|
||||
{ value: 'all', label: t('全部账期') },
|
||||
...Array.from(new Set(rows.map((row) => row.statement_month)))
|
||||
.sort()
|
||||
.reverse()
|
||||
.map((value) => ({ value, label: value })),
|
||||
]}
|
||||
/>
|
||||
<Select
|
||||
value={billStatus}
|
||||
onChange={setBillStatus}
|
||||
optionList={[
|
||||
{ value: 'all', label: t('全部状态') },
|
||||
...Array.from(new Set(rows.map((row) => row.status))).map(
|
||||
(value) => ({
|
||||
value,
|
||||
label: commissionLabel(t, 'status', value),
|
||||
}),
|
||||
),
|
||||
]}
|
||||
/>
|
||||
<div className='console-list-tools commission-filter-end'>
|
||||
<Text type='secondary'>
|
||||
{t('共 {{count}} 张账单', { count: visibleBills.length })}
|
||||
</Text>
|
||||
<div className='console-list-tool-actions'>{refreshButton}</div>
|
||||
</div>
|
||||
<Table
|
||||
rowKey='id'
|
||||
dataSource={visibleBills}
|
||||
columns={billColumns}
|
||||
pagination={visibleBills.length > 0 ? { pageSize: 10 } : false}
|
||||
pagination={
|
||||
visibleBills.length > 0
|
||||
? { pageSize: 10, current: billPage, onChange: setBillPage }
|
||||
: false
|
||||
}
|
||||
scroll={{ x: 1120 }}
|
||||
empty={
|
||||
<Empty
|
||||
@@ -697,19 +753,46 @@ export default function PartnerPortal({
|
||||
<Card className='commission-card partner-portal-card'>
|
||||
<Tabs defaultActiveKey='usage' key={selected.id}>
|
||||
<Tabs.TabPane tab={t('单笔消耗明细')} itemKey='usage'>
|
||||
<Input
|
||||
className='partner-portal-detail-search'
|
||||
value={query}
|
||||
onChange={setQuery}
|
||||
placeholder={t('搜索客户、模型、计费记录或档位')}
|
||||
showClear
|
||||
/>
|
||||
<ConsoleCollectionSearch>
|
||||
<ConsoleFilterGrid
|
||||
onReset={() => {
|
||||
setQuery('');
|
||||
setDetailPage(1);
|
||||
}}
|
||||
onSearch={() => setDetailPage(1)}
|
||||
>
|
||||
<ConsoleFilterField
|
||||
label={t('搜索关键字')}
|
||||
id='partner-bill-detail-query'
|
||||
>
|
||||
<Input
|
||||
id='partner-bill-detail-query'
|
||||
prefix={<Search size={16} />}
|
||||
value={query}
|
||||
onChange={(value) => {
|
||||
setQuery(value);
|
||||
setDetailPage(1);
|
||||
}}
|
||||
placeholder={t('搜索客户、模型、计费记录或档位')}
|
||||
showClear
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
</ConsoleFilterGrid>
|
||||
</ConsoleCollectionSearch>
|
||||
<Table
|
||||
rowKey='id'
|
||||
dataSource={detailItems}
|
||||
columns={BillingColumns(t, money, formatDateTime)}
|
||||
scroll={{ x: 1800 }}
|
||||
pagination={detailItems.length > 0 ? { pageSize: 10 } : false}
|
||||
pagination={
|
||||
detailItems.length > 0
|
||||
? {
|
||||
pageSize: 10,
|
||||
current: detailPage,
|
||||
onChange: setDetailPage,
|
||||
}
|
||||
: false
|
||||
}
|
||||
empty={
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
@@ -922,96 +1005,136 @@ export default function PartnerPortal({
|
||||
);
|
||||
|
||||
const renderCustomers = () => (
|
||||
<Card className='commission-card partner-portal-card'>
|
||||
<Alert
|
||||
showIcon
|
||||
type='info'
|
||||
description={t(
|
||||
'仅展示本伙伴保护期及正式归属期间的信息。转移或终止后的客户消费不在可见范围内。',
|
||||
)}
|
||||
/>
|
||||
<div className='partner-portal-filters'>
|
||||
<Input
|
||||
value={customerQuery}
|
||||
onChange={setCustomerQuery}
|
||||
showClear
|
||||
placeholder={t('搜索客户名称或编号')}
|
||||
<>
|
||||
<Card className='commission-card partner-portal-card'>
|
||||
<Alert
|
||||
showIcon
|
||||
type='info'
|
||||
description={t(
|
||||
'仅展示本伙伴保护期及正式归属期间的信息。转移或终止后的客户消费不在可见范围内。',
|
||||
)}
|
||||
/>
|
||||
<Select
|
||||
value={customerStatus}
|
||||
onChange={setCustomerStatus}
|
||||
optionList={[
|
||||
{ value: 'all', label: t('全部状态') },
|
||||
...Array.from(new Set(customers.map((row) => row.status))).map(
|
||||
(value) => ({
|
||||
value,
|
||||
label: commissionLabel(t, 'status', value),
|
||||
}),
|
||||
),
|
||||
</Card>
|
||||
<ConsoleCollectionSearch>
|
||||
<ConsoleFilterGrid
|
||||
onReset={() => {
|
||||
setCustomerQuery('');
|
||||
setCustomerStatus('all');
|
||||
setCustomerPage(1);
|
||||
}}
|
||||
onSearch={() => setCustomerPage(1)}
|
||||
>
|
||||
<ConsoleFilterField
|
||||
label={t('搜索关键字')}
|
||||
id='partner-customer-query'
|
||||
>
|
||||
<Input
|
||||
id='partner-customer-query'
|
||||
prefix={<Search size={16} />}
|
||||
value={customerQuery}
|
||||
onChange={(value) => {
|
||||
setCustomerQuery(value);
|
||||
setCustomerPage(1);
|
||||
}}
|
||||
showClear
|
||||
placeholder={t('搜索客户名称或编号')}
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
<ConsoleFilterField label={t('状态')} id='partner-customer-status'>
|
||||
<Select
|
||||
id='partner-customer-status'
|
||||
value={customerStatus}
|
||||
onChange={(value) => {
|
||||
setCustomerStatus(value);
|
||||
setCustomerPage(1);
|
||||
}}
|
||||
optionList={[
|
||||
{ value: 'all', label: t('全部状态') },
|
||||
...Array.from(new Set(customers.map((row) => row.status))).map(
|
||||
(value) => ({
|
||||
value,
|
||||
label: commissionLabel(t, 'status', value),
|
||||
}),
|
||||
),
|
||||
]}
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
</ConsoleFilterGrid>
|
||||
</ConsoleCollectionSearch>
|
||||
<Card className='commission-card partner-portal-card'>
|
||||
<div className='console-list-tools commission-filter-end'>
|
||||
<Text type='secondary'>
|
||||
{t('共 {{count}} 条归属记录', { count: visibleCustomers.length })}
|
||||
</Text>
|
||||
<div className='console-list-tool-actions'>{refreshButton}</div>
|
||||
</div>
|
||||
<Table
|
||||
rowKey='id'
|
||||
dataSource={visibleCustomers}
|
||||
pagination={
|
||||
visibleCustomers.length > 0
|
||||
? {
|
||||
pageSize: 10,
|
||||
current: customerPage,
|
||||
onChange: setCustomerPage,
|
||||
}
|
||||
: false
|
||||
}
|
||||
scroll={{ x: 1100 }}
|
||||
empty={
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={t('暂无客户')}
|
||||
/>
|
||||
}
|
||||
columns={[
|
||||
{
|
||||
title: t('客户'),
|
||||
render: (_, row) => (
|
||||
<b>
|
||||
{row.customer_name ||
|
||||
row.subject_name ||
|
||||
`${commissionLabel(t, 'subjectType', row.subject_type)} #${row.subject_id}`}
|
||||
</b>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('类型'),
|
||||
dataIndex: 'subject_type',
|
||||
render: (value) => commissionLabel(t, 'subjectType', value),
|
||||
},
|
||||
{ title: t('归属状态'), dataIndex: 'status', render: tag },
|
||||
{
|
||||
title: t('正式归属起点'),
|
||||
dataIndex: 'formal_at',
|
||||
render: formatDateTime,
|
||||
},
|
||||
{ title: t('保护期开始'), dataIndex: 'started_at', render: date },
|
||||
{
|
||||
title: t('保护期至'),
|
||||
render: (_, row) => date(protectionUntil(row)),
|
||||
},
|
||||
{
|
||||
title: t('保护期剩余天数'),
|
||||
render: (_, row) =>
|
||||
PROTECTED.includes(row.status)
|
||||
? Math.max(
|
||||
0,
|
||||
Math.ceil(
|
||||
(protectionUntil(row) - Date.now() / 1000) / 86400,
|
||||
),
|
||||
)
|
||||
: '—',
|
||||
},
|
||||
{
|
||||
title: t('归属结束'),
|
||||
dataIndex: 'ended_at',
|
||||
render: formatDateTime,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Text type='secondary'>
|
||||
{t('共 {{count}} 条归属记录', { count: visibleCustomers.length })}
|
||||
</Text>
|
||||
</div>
|
||||
<Table
|
||||
rowKey='id'
|
||||
dataSource={visibleCustomers}
|
||||
pagination={visibleCustomers.length > 0 ? { pageSize: 10 } : false}
|
||||
scroll={{ x: 1100 }}
|
||||
empty={
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={t('暂无客户')}
|
||||
/>
|
||||
}
|
||||
columns={[
|
||||
{
|
||||
title: t('客户'),
|
||||
render: (_, row) => (
|
||||
<b>
|
||||
{row.customer_name ||
|
||||
row.subject_name ||
|
||||
`${commissionLabel(t, 'subjectType', row.subject_type)} #${row.subject_id}`}
|
||||
</b>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('类型'),
|
||||
dataIndex: 'subject_type',
|
||||
render: (value) => commissionLabel(t, 'subjectType', value),
|
||||
},
|
||||
{ title: t('归属状态'), dataIndex: 'status', render: tag },
|
||||
{
|
||||
title: t('正式归属起点'),
|
||||
dataIndex: 'formal_at',
|
||||
render: formatDateTime,
|
||||
},
|
||||
{ title: t('保护期开始'), dataIndex: 'started_at', render: date },
|
||||
{
|
||||
title: t('保护期至'),
|
||||
render: (_, row) => date(protectionUntil(row)),
|
||||
},
|
||||
{
|
||||
title: t('保护期剩余天数'),
|
||||
render: (_, row) =>
|
||||
PROTECTED.includes(row.status)
|
||||
? Math.max(
|
||||
0,
|
||||
Math.ceil(
|
||||
(protectionUntil(row) - Date.now() / 1000) / 86400,
|
||||
),
|
||||
)
|
||||
: '—',
|
||||
},
|
||||
{
|
||||
title: t('归属结束'),
|
||||
dataIndex: 'ended_at',
|
||||
render: formatDateTime,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
|
||||
const renderEstimate = () => (
|
||||
@@ -1055,7 +1178,7 @@ export default function PartnerPortal({
|
||||
className='partner-portal-estimate-table'
|
||||
rowKey='statement_month'
|
||||
dataSource={realtime}
|
||||
pagination={false}
|
||||
pagination={realtime.length ? { pageSize: 10 } : false}
|
||||
empty={
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
@@ -1266,6 +1389,7 @@ export default function PartnerPortal({
|
||||
{selected && (
|
||||
<>
|
||||
<Button
|
||||
icon={<Download size={16} />}
|
||||
disabled={detailLoading || mutationLoading}
|
||||
onClick={() =>
|
||||
exportDetails(items, adjustments, selected, t)
|
||||
@@ -1301,17 +1425,10 @@ export default function PartnerPortal({
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<Button
|
||||
icon={<ActionRefresh size={16} />}
|
||||
disabled={mutationLoading || detailLoading}
|
||||
loading={loading}
|
||||
onClick={() => {
|
||||
load();
|
||||
if (selected) open(selected);
|
||||
}}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
{(selected ||
|
||||
!loaded ||
|
||||
!['bills', 'customers'].includes(active)) &&
|
||||
refreshButton}
|
||||
</div>
|
||||
</div>
|
||||
{error && <Alert showIcon type='error' description={error} />}
|
||||
|
||||
Reference in New Issue
Block a user