fix(ui): 统一表格筛选分页和用量明细,升级 ESLint

This commit is contained in:
zhanjunhao
2026-11-19 23:09:58 +08:00
parent 7908ed53a3
commit 04cc45bbb7
76 changed files with 2556 additions and 2410 deletions
+116 -120
View File
@@ -21,13 +21,13 @@ import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Button, Empty, Input, Select } from 'antd';
import { Table } from '@/components/ui';
import { Search } from '@/components/common/icons/ActionIcons';
import { Download, Search } from '@/components/common/icons/ActionIcons';
import {
ConsoleCard,
ConsoleSearchBar,
ConsoleSearchActions,
ConsoleFilterGrid,
ConsoleTabs,
} from '../../components/console/ConsolePrimitives';
import { ConsoleCollectionSearch } from '../../components/console/ConsoleCollection';
import { filterCommissionRows, matchesStatus } from './listFilters';
export default function ListPanel({
@@ -37,6 +37,7 @@ export default function ListPanel({
partners,
searchableText,
onExport,
toolbarActions,
context,
server,
}) {
@@ -46,6 +47,7 @@ export default function ListPanel({
const [scopedIds, setScopedIds] = useState(context?.ids || null);
const [status, setStatus] = useState('all');
const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(10);
const set = (key, value) =>
setDraft((current) => ({ ...current, [key]: value }));
const tabSets = {
@@ -130,7 +132,6 @@ export default function ListPanel({
setScopedIds(null);
setPage(1);
};
const [filtersOpen, setFiltersOpen] = useState(false);
return (
<div className={`commission-list commission-list--${section}`}>
{tabSets[section] && (
@@ -175,124 +176,107 @@ export default function ListPanel({
</Button>
</div>
)}
<Button
className='commission-filter-toggle'
aria-expanded={filtersOpen}
onClick={() => setFiltersOpen((value) => !value)}
>
{t(filtersOpen ? '隐藏操作项' : '显示操作项')}
</Button>
<ConsoleSearchBar
className={`commission-filter-card${filtersOpen ? ' is-open' : ''}`}
>
<form
onSubmit={(event) => {
event.preventDefault();
query();
}}
<ConsoleCollectionSearch className='commission-filter-card'>
<ConsoleFilterGrid
onReset={reset}
onSearch={query}
loading={server?.busy}
>
<div className='console-search-fields'>
<label className='console-search-field commission-search-field'>
<span>{t('搜索')}</span>
<Input
prefix={<Search size={16} aria-hidden />}
value={draft.query}
onChange={(event) => set('query', event.target.value)}
allowClear
placeholder={t(placeholders[section])}
aria-label={t(placeholders[section])}
/>
</label>
{typeOptions && (
<label className='console-search-field commission-search-field'>
<span>{t('搜索')}</span>
<Input
prefix={<Search size={16} aria-hidden />}
value={draft.query}
onChange={(event) => set('query', event.target.value)}
allowClear
placeholder={t(placeholders[section])}
aria-label={t(placeholders[section])}
<span>{t('类型筛选')}</span>
<Select
aria-label={t('类型筛选')}
value={draft.type}
onChange={(value) => set('type', value)}
options={[
{
value: '',
label: t(
section === 'assignments'
? '全部客户类型'
: section === 'tiers'
? '全部来源'
: '全部类型',
),
},
...typeOptions.map(([value, label]) => ({
value,
label: t(label),
})),
]}
/>
</label>
{typeOptions && (
<label className='console-search-field commission-search-field'>
<span>{t('类型筛选')}</span>
<Select
aria-label={t('类型筛选')}
value={draft.type}
onChange={(value) => set('type', value)}
options={[
{
value: '',
label: t(
section === 'assignments'
? '全部客户类型'
: section === 'tiers'
? '全部来源'
: '全部类型',
),
},
...typeOptions.map(([value, label]) => ({
value,
label: t(label),
})),
]}
/>
</label>
)}
{section === 'partners' && (
<label className='console-search-field commission-search-field'>
<span>{t('状态筛选')}</span>
<Select
aria-label={t('状态筛选')}
value={draft.status || ''}
onChange={(value) => set('status', value)}
options={[
'',
'draft',
'active',
'suspended',
'terminated',
].map((value, i) => ({
)}
{section === 'partners' && (
<label className='console-search-field commission-search-field'>
<span>{t('状态筛选')}</span>
<Select
aria-label={t('状态筛选')}
value={draft.status || ''}
onChange={(value) => set('status', value)}
options={['', 'draft', 'active', 'suspended', 'terminated'].map(
(value, i) => ({
value,
label: t(
['全部状态', '草稿', '生效中', '已暂停', '已终止'][i],
),
}))}
/>
</label>
)}
{['assignments', 'bills', 'adjustments'].includes(section) && (
<label className='console-search-field commission-search-field'>
<span>{t('合作伙伴筛选')}</span>
<Select
aria-label={t('合作伙伴筛选')}
showSearch={{ optionFilterProp: 'label' }}
value={draft.partner}
onChange={(value) => set('partner', value)}
options={[
{ value: '', label: t('全部合作伙伴') },
...partners.map((row) => ({
value: row.id,
label: row.name,
})),
]}
/>
</label>
)}
</div>
<ConsoleSearchActions
onReset={reset}
searchLabel='查询'
loading={server?.busy}
/>
</form>
</ConsoleSearchBar>
}),
)}
/>
</label>
)}
{['assignments', 'bills', 'adjustments'].includes(section) && (
<label className='console-search-field commission-search-field'>
<span>{t('合作伙伴筛选')}</span>
<Select
aria-label={t('合作伙伴筛选')}
showSearch={{ optionFilterProp: 'label' }}
value={draft.partner}
onChange={(value) => set('partner', value)}
options={[
{ value: '', label: t('全部合作伙伴') },
...partners.map((row) => ({
value: row.id,
label: row.name,
})),
]}
/>
</label>
)}
</ConsoleFilterGrid>
</ConsoleCollectionSearch>
<ConsoleCard className='commission-card commission-list-card'>
<div className='commission-filter-end'>
<div className='console-list-tools commission-filter-end'>
<span>
{t('共 {{count}} 条', {
count: server ? server.total : filtered.length,
})}
</span>
{onExport && (
<Button
loading={server?.exporting}
disabled={!!server?.busy}
onClick={() => onExport(filtered)}
>
{t('导出')}
</Button>
)}
<div className='console-list-tool-actions'>
{onExport && (
<Button
icon={<Download size={16} />}
loading={server?.exporting}
disabled={!!server?.busy}
onClick={() => onExport(filtered)}
>
{t('导出')}
</Button>
)}
{toolbarActions}
</div>
</div>
<Table
rowKey='id'
@@ -309,18 +293,30 @@ export default function ListPanel({
dataSource={filtered}
size='middle'
scroll={{ x: 'max-content' }}
pagination={{
size: 'small',
pageSize: server ? 100 : 10,
total: server ? server.total : filtered.length,
current: server ? server.page : page,
onChange: (next) => {
setPage(next);
server?.onChange({ ...filters, status, page: next });
},
showSizeChanger: false,
showTotal: (total) => t('共 {{total}} 条', { total }),
}}
pagination={
(server ? server.total : filtered.length)
? {
size: 'small',
pageSize: server ? server.pageSize : pageSize,
total: server ? server.total : filtered.length,
currentPage: server ? server.page : page,
onPageChange: (next) => {
setPage(next);
server?.onChange({ ...filters, status, page: next });
},
onPageSizeChange: (nextSize) => {
setPage(1);
setPageSize(nextSize);
server?.onChange({
...filters,
status,
page: 1,
pageSize: nextSize,
});
},
}
: false
}
empty={
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}