fix(ui): 完善界面交互与开发配置
This commit is contained in:
@@ -19,8 +19,15 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button, Card, Empty, Input, Select, Table } from 'antd';
|
||||
import { Search } from 'lucide-react';
|
||||
import { Button, Empty, Input, Select } from 'antd';
|
||||
import { Table } from '@/components/ui';
|
||||
import { Search } from '@/components/common/icons/ActionIcons';
|
||||
import {
|
||||
ConsoleCard,
|
||||
ConsoleSearchBar,
|
||||
ConsoleSearchActions,
|
||||
ConsoleTabs,
|
||||
} from '../../components/console/ConsolePrimitives';
|
||||
import { filterCommissionRows, matchesStatus } from './listFilters';
|
||||
|
||||
export default function ListPanel({
|
||||
@@ -115,41 +122,43 @@ export default function ListPanel({
|
||||
setPage(1);
|
||||
server?.onChange({ ...draft, status, page: 1 });
|
||||
};
|
||||
const reset = () => {
|
||||
setDraft({ query: '', type: '', partner: '' });
|
||||
setFilters({});
|
||||
setStatus('all');
|
||||
server?.onChange({ status: 'all', page: 1 });
|
||||
setScopedIds(null);
|
||||
setPage(1);
|
||||
};
|
||||
const [filtersOpen, setFiltersOpen] = useState(false);
|
||||
return (
|
||||
<Card
|
||||
className={`commission-card commission-list commission-list--${section}`}
|
||||
>
|
||||
<div className={`commission-list commission-list--${section}`}>
|
||||
{tabSets[section] && (
|
||||
<div
|
||||
<ConsoleTabs
|
||||
className='commission-list-tabs'
|
||||
role='tablist'
|
||||
aria-label={t('状态筛选')}
|
||||
>
|
||||
{tabSets[section].map(([key, label]) => (
|
||||
<button
|
||||
key={key}
|
||||
type='button'
|
||||
role='tab'
|
||||
aria-selected={status === key}
|
||||
className={status === key ? 'is-active' : ''}
|
||||
onClick={() => {
|
||||
setStatus(key);
|
||||
setPage(1);
|
||||
server?.onChange({ ...filters, status: key, page: 1 });
|
||||
}}
|
||||
>
|
||||
{t(label)}
|
||||
activeKey={status}
|
||||
onChange={(key) => {
|
||||
setStatus(key);
|
||||
setPage(1);
|
||||
server?.onChange({ ...filters, status: key, page: 1 });
|
||||
}}
|
||||
items={tabSets[section].map(([key, label]) => ({
|
||||
key,
|
||||
label: (
|
||||
<span>
|
||||
{server
|
||||
? server.counts[
|
||||
{ enabled: 'active', scheduled: 'pending' }[key] || key
|
||||
] || 0
|
||||
: rows.filter((row) => matchesStatus(row, key, section))
|
||||
.length}
|
||||
{t(label)}{' '}
|
||||
<span className='commission-tab-count'>
|
||||
{server
|
||||
? server.counts[
|
||||
{ enabled: 'active', scheduled: 'pending' }[key] || key
|
||||
] || 0
|
||||
: rows.filter((row) => matchesStatus(row, key, section))
|
||||
.length}
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
),
|
||||
}))}
|
||||
/>
|
||||
)}
|
||||
{scopedIds && (
|
||||
<div className='commission-context-filter'>
|
||||
@@ -166,79 +175,109 @@ export default function ListPanel({
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<div className='commission-filter-bar'>
|
||||
<Input
|
||||
prefix={<Search size={16} aria-hidden />}
|
||||
value={draft.query}
|
||||
onChange={(event) => set('query', event.target.value)}
|
||||
onPressEnter={query}
|
||||
allowClear
|
||||
placeholder={t(placeholders[section])}
|
||||
aria-label={t(placeholders[section])}
|
||||
/>
|
||||
{typeOptions && (
|
||||
<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),
|
||||
})),
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
{section === 'partners' && (
|
||||
<Select
|
||||
aria-label={t('状态筛选')}
|
||||
value={draft.status || ''}
|
||||
onChange={(value) => set('status', value)}
|
||||
options={['', 'draft', 'active', 'suspended', 'terminated'].map(
|
||||
(value, i) => ({
|
||||
value,
|
||||
label: t(['全部状态', '草稿', '生效中', '已暂停', '已终止'][i]),
|
||||
}),
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
{['assignments', 'bills', 'adjustments'].includes(section) && (
|
||||
<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 })),
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
<Button type='primary' onClick={query}>
|
||||
{t('查询')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setDraft({ query: '', type: '', partner: '' });
|
||||
setFilters({});
|
||||
setStatus('all');
|
||||
server?.onChange({ status: 'all', page: 1 });
|
||||
setScopedIds(null);
|
||||
setPage(1);
|
||||
<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();
|
||||
}}
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
<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>
|
||||
<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) => ({
|
||||
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>
|
||||
<ConsoleCard className='commission-card commission-list-card'>
|
||||
<div className='commission-filter-end'>
|
||||
<span>
|
||||
{t('共 {{count}} 条', {
|
||||
@@ -255,35 +294,41 @@ export default function ListPanel({
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<Table
|
||||
rowKey='id'
|
||||
loading={server?.busy}
|
||||
columns={columns}
|
||||
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 }),
|
||||
}}
|
||||
locale={{
|
||||
emptyText: (
|
||||
<Table
|
||||
rowKey='id'
|
||||
loading={server?.busy}
|
||||
columns={columns.map((column) => ({
|
||||
width: 160,
|
||||
...column,
|
||||
...(/(?:_uyuan|_yuan|_bps|amount|count|quantity)$/.test(
|
||||
column.dataIndex || '',
|
||||
)
|
||||
? { align: 'right' }
|
||||
: {}),
|
||||
}))}
|
||||
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 }),
|
||||
}}
|
||||
empty={
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={t('暂无数据')}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
}
|
||||
/>
|
||||
</ConsoleCard>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user