sync: 同步 monkey-ai@weiyuan(ddc5b9443) 的 web/ 到 ui-optimization
- 合入 weiyuan 新功能前端:分佣 V2 / 伙伴工作台、智能路由、企业资金与分析、官网设置与预约演示等, semi-ui 已全部迁移到 antd 6 / @/components/ui,不重新引入 Semi - 分佣二级菜单与页头去重、伙伴入口探测(企业伙伴走企业中心「企业分佣」)、超管侧栏入口恢复 - 适配层 DatePicker / TimePicker 统一 onChange(Date|Date[]|null, 文本) 契约;生产构建剔除调试日志 - 图片链接刷新:同任务请求复用、后台刷新不弹全局错误、离页停止批量请求 - 恢复 bun.lock(与 package-lock.json 共存);docs 规范与 CHANGELOG 更新 - 停止跟踪 .env.playwright.local(本地登录凭据,已加入 .gitignore)
This commit is contained in:
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
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 { filterCommissionRows, matchesStatus } from './listFilters';
|
||||
|
||||
export default function ListPanel({
|
||||
section,
|
||||
rows,
|
||||
columns,
|
||||
partners,
|
||||
searchableText,
|
||||
onExport,
|
||||
context,
|
||||
server,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [draft, setDraft] = useState({ query: '', type: '', partner: '' });
|
||||
const [filters, setFilters] = useState({});
|
||||
const [scopedIds, setScopedIds] = useState(context?.ids || null);
|
||||
const [status, setStatus] = useState('all');
|
||||
const [page, setPage] = useState(1);
|
||||
const set = (key, value) =>
|
||||
setDraft((current) => ({ ...current, [key]: value }));
|
||||
const tabSets = {
|
||||
assignments: [
|
||||
['all', '全部'],
|
||||
['protect', '保护中'],
|
||||
['pending_conversion', '待确认转化'],
|
||||
['formal', '正式归属'],
|
||||
['history', '历史归属'],
|
||||
],
|
||||
bills: [
|
||||
['all', '全部'],
|
||||
['estimated', '本月预估'],
|
||||
['checking', '待核对'],
|
||||
['pending_confirmation', '待确认'],
|
||||
['confirmed', '已确认'],
|
||||
['completed', '已完成'],
|
||||
],
|
||||
adjustments: [
|
||||
['all', '全部'],
|
||||
['applied', '已生效'],
|
||||
['voided', '已作废'],
|
||||
],
|
||||
tiers: [
|
||||
['all', '全部档位'],
|
||||
['enabled', '启用中'],
|
||||
['scheduled', '待生效'],
|
||||
['disabled', '已停用'],
|
||||
],
|
||||
};
|
||||
const typeOptions =
|
||||
section === 'partners'
|
||||
? [
|
||||
['company', '企业'],
|
||||
['individual', '个人'],
|
||||
]
|
||||
: section === 'assignments'
|
||||
? [
|
||||
['organization', '企业'],
|
||||
['user', 'C 端'],
|
||||
]
|
||||
: section === 'tiers'
|
||||
? [
|
||||
['level', '等级档位'],
|
||||
['model', '模型档位'],
|
||||
['channel', '渠道档位'],
|
||||
]
|
||||
: null;
|
||||
const placeholders = {
|
||||
partners: '搜索伙伴名称 / 编号 / 协议编号',
|
||||
assignments: '搜索客户名称 / ID',
|
||||
tiers: '搜索档位 / 模型 / 渠道',
|
||||
bills: '搜索伙伴 / 账单号',
|
||||
adjustments: '搜索调整单 / 客户 / 原因',
|
||||
audit: '搜索操作 / 实体 / 操作人',
|
||||
exceptions: '搜索异常码 / 计费事实 / 说明',
|
||||
};
|
||||
const scopedRows = scopedIds
|
||||
? rows.filter((row) => scopedIds.includes(row.id))
|
||||
: rows;
|
||||
const filtered = server
|
||||
? rows
|
||||
: filterCommissionRows(
|
||||
scopedRows,
|
||||
{
|
||||
...filters,
|
||||
status: section === 'partners' ? filters.status : status,
|
||||
},
|
||||
section,
|
||||
searchableText,
|
||||
);
|
||||
const query = () => {
|
||||
setFilters(draft);
|
||||
setPage(1);
|
||||
server?.onChange({ ...draft, status, page: 1 });
|
||||
};
|
||||
return (
|
||||
<Card
|
||||
className={`commission-card commission-list commission-list--${section}`}
|
||||
>
|
||||
{tabSets[section] && (
|
||||
<div
|
||||
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)}
|
||||
<span>
|
||||
{server
|
||||
? server.counts[
|
||||
{ enabled: 'active', scheduled: 'pending' }[key] || key
|
||||
] || 0
|
||||
: rows.filter((row) => matchesStatus(row, key, section))
|
||||
.length}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{scopedIds && (
|
||||
<div className='commission-context-filter'>
|
||||
{t('正在查看工作台待办筛选结果')}
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setScopedIds(null);
|
||||
setPage(1);
|
||||
}}
|
||||
>
|
||||
{t('查看全部')}
|
||||
</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);
|
||||
}}
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
<div className='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>
|
||||
</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: (
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={t('暂无数据')}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user