fix(ui): 完善控制台列表并优化企业中心与个人操作
This commit is contained in:
+113
-111
@@ -5,13 +5,10 @@ import {
|
||||
|
||||
import { Trans } from 'react-i18next';
|
||||
import {
|
||||
Ban as ActionBan,
|
||||
ShieldCheck as ActionShieldCheck,
|
||||
CalendarClock as ActionCalendarClock,
|
||||
Pencil as ActionPencil,
|
||||
Plus as ActionPlus,
|
||||
CreditCard as ActionCreditCard,
|
||||
} from '@/components/common/icons/ActionIcons';
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import {
|
||||
ConsoleFilterField,
|
||||
ConsoleFilterGrid,
|
||||
@@ -37,7 +34,6 @@ import {
|
||||
Input,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Tag,
|
||||
@@ -50,6 +46,11 @@ import { isAdmin, showError, showSuccess } from '../../helpers';
|
||||
import { renderQuota } from '../../helpers/render';
|
||||
import QuotaInput from '../../components/common/ui/QuotaInput';
|
||||
|
||||
const membershipFormLayout = {
|
||||
width: 575,
|
||||
style: { maxWidth: 'calc(100% - 32px)' },
|
||||
};
|
||||
|
||||
const statusColorMap = {
|
||||
active: 'green',
|
||||
expired: 'grey',
|
||||
@@ -150,6 +151,8 @@ const Subscription = () => {
|
||||
const [editVisible, setEditVisible] = useState(false);
|
||||
const [createVisible, setCreateVisible] = useState(false);
|
||||
const [detailVisible, setDetailVisible] = useState(false);
|
||||
const [grantRow, setGrantRow] = useState(null);
|
||||
const [grantSubmitting, setGrantSubmitting] = useState(false);
|
||||
const [currentRow, setCurrentRow] = useState(null);
|
||||
const [membershipPlans, setMembershipPlans] = useState([]);
|
||||
const [plansLoading, setPlansLoading] = useState(false);
|
||||
@@ -338,22 +341,27 @@ const Subscription = () => {
|
||||
setRefreshToken((prev) => prev + 1);
|
||||
};
|
||||
|
||||
const doGrant = async (row) => {
|
||||
const doGrant = async () => {
|
||||
if (!grantRow || grantSubmitting) return;
|
||||
setGrantSubmitting(true);
|
||||
try {
|
||||
const res = await API.post(
|
||||
`/api/user/membership/manage/subscriptions/${row.id}/grant`,
|
||||
`/api/user/membership/manage/subscriptions/${grantRow.id}/grant`,
|
||||
{
|
||||
reason: '管理员手动补发',
|
||||
},
|
||||
);
|
||||
if (res.data.success) {
|
||||
showSuccess(t('补发成功'));
|
||||
setGrantRow(null);
|
||||
setRefreshToken((key) => key + 1);
|
||||
} else {
|
||||
showError(res.data.message);
|
||||
}
|
||||
} catch (err) {
|
||||
showError(err.message);
|
||||
} finally {
|
||||
setGrantSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -426,82 +434,61 @@ const Subscription = () => {
|
||||
title: t('每日额度'),
|
||||
dataIndex: 'daily_quota',
|
||||
width: 110,
|
||||
align: 'right',
|
||||
render: (v) => renderQuota(v, 2),
|
||||
},
|
||||
{
|
||||
title: t('支付金额'),
|
||||
dataIndex: 'price_paid',
|
||||
width: 100,
|
||||
align: 'right',
|
||||
render: (v) => (v != null ? formatCurrency(v) : '-'),
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
key: 'actions',
|
||||
width: 300,
|
||||
width: 126,
|
||||
fixed: 'right',
|
||||
render: (_, r) => (
|
||||
<Space spacing={4} wrap>
|
||||
<Button size='small' theme='borderless' onClick={() => openDetail(r)}>
|
||||
{t('详情')}
|
||||
</Button>
|
||||
{admin && r.status !== 'banned' && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
type='danger'
|
||||
icon={<ActionBan size={12} />}
|
||||
onClick={() => openBan(r)}
|
||||
>
|
||||
{t('封禁')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && r.status === 'banned' && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
type='primary'
|
||||
icon={<ActionShieldCheck size={12} />}
|
||||
onClick={() => openUnban(r)}
|
||||
>
|
||||
{t('解封')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && r.status !== 'canceled' && r.status !== 'banned' && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<ActionCalendarClock size={12} />}
|
||||
onClick={() => openExtend(r)}
|
||||
>
|
||||
{t('延长')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<ActionPencil size={12} />}
|
||||
onClick={() => openEdit(r)}
|
||||
>
|
||||
render: (_, row) => {
|
||||
if (!admin) {
|
||||
return (
|
||||
<AntButton type='link' size='small' onClick={() => openDetail(row)}>
|
||||
{t('详情')}
|
||||
</AntButton>
|
||||
);
|
||||
}
|
||||
|
||||
const items = [
|
||||
{ key: 'detail', label: t('详情'), onClick: () => openDetail(row) },
|
||||
row.status !== 'canceled' &&
|
||||
row.status !== 'banned' && {
|
||||
key: 'extend',
|
||||
label: t('延长'),
|
||||
onClick: () => openExtend(row),
|
||||
},
|
||||
row.status === 'active' && {
|
||||
key: 'grant',
|
||||
label: t('补发'),
|
||||
onClick: () => setGrantRow(row),
|
||||
},
|
||||
row.status === 'banned'
|
||||
? { key: 'unban', label: t('解封'), onClick: () => openUnban(row) }
|
||||
: {
|
||||
key: 'ban',
|
||||
label: t('封禁'),
|
||||
danger: true,
|
||||
onClick: () => openBan(row),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<TableRowActions items={items}>
|
||||
<AntButton type='link' size='small' onClick={() => openEdit(row)}>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && r.status === 'active' && (
|
||||
<Popconfirm
|
||||
title={t('确认手动补发今日额度?')}
|
||||
onConfirm={() => doGrant(r)}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<Sparkles size={12} />}
|
||||
>
|
||||
{t('补发')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
</AntButton>
|
||||
</TableRowActions>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -603,47 +590,49 @@ const Subscription = () => {
|
||||
</ConsoleFilterField>
|
||||
</ConsoleFilterGrid>
|
||||
}
|
||||
tableTitle={t('会员列表')}
|
||||
tableActionsOffset
|
||||
actionsArea={
|
||||
<div className='console-list-tools'>
|
||||
<div
|
||||
className='console-list-quick-filters'
|
||||
role='group'
|
||||
aria-label={t('快捷筛选')}
|
||||
>
|
||||
{[
|
||||
['expiring3', t('3 天内到期')],
|
||||
['expiring7', t('7 天内到期')],
|
||||
['overdue', t('已过期未处理')],
|
||||
].map(([key, label]) => (
|
||||
<AntButton
|
||||
key={key}
|
||||
type={quickFilter === key ? 'primary' : 'default'}
|
||||
aria-pressed={quickFilter === key}
|
||||
onClick={() => applyQuickFilter(key)}
|
||||
>
|
||||
{label}
|
||||
</AntButton>
|
||||
))}
|
||||
</div>
|
||||
{admin && (
|
||||
<div className='console-list-tool-actions'>
|
||||
<Button
|
||||
icon={<ActionCreditCard size={16} />}
|
||||
onClick={() => navigate('/console/setting?tab=membership')}
|
||||
>
|
||||
{t('会员管理')}
|
||||
</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
icon={<ActionPlus size={16} />}
|
||||
onClick={openCreate}
|
||||
>
|
||||
{t('新建会员')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className='console-list-quick-filters'
|
||||
role='group'
|
||||
aria-label={t('快捷筛选')}
|
||||
>
|
||||
{[
|
||||
['expiring3', t('3 天内到期')],
|
||||
['expiring7', t('7 天内到期')],
|
||||
['overdue', t('已过期未处理')],
|
||||
].map(([key, label]) => (
|
||||
<AntButton
|
||||
key={key}
|
||||
type={quickFilter === key ? 'primary' : 'default'}
|
||||
aria-pressed={quickFilter === key}
|
||||
onClick={() => applyQuickFilter(key)}
|
||||
>
|
||||
{label}
|
||||
</AntButton>
|
||||
))}
|
||||
</div>
|
||||
}
|
||||
tableActions={
|
||||
admin && (
|
||||
<div className='console-list-tool-actions'>
|
||||
<Button
|
||||
icon={<ActionCreditCard size={16} />}
|
||||
onClick={() => navigate('/console/setting?tab=membership')}
|
||||
>
|
||||
{t('会员管理')}
|
||||
</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
icon={<ActionPlus size={16} />}
|
||||
onClick={openCreate}
|
||||
>
|
||||
{t('新建会员')}
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
paginationArea={createCardProPagination({
|
||||
preservePage: true,
|
||||
currentPage: page,
|
||||
@@ -725,6 +714,18 @@ const Subscription = () => {
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<Modal
|
||||
title={t('确认手动补发今日额度?')}
|
||||
visible={Boolean(grantRow)}
|
||||
onCancel={() => {
|
||||
if (!grantSubmitting) setGrantRow(null);
|
||||
}}
|
||||
onOk={doGrant}
|
||||
okText={t('确定')}
|
||||
cancelText={t('取消')}
|
||||
confirmLoading={grantSubmitting}
|
||||
/>
|
||||
|
||||
{/* 详情抽屉 */}
|
||||
<DetailDrawer
|
||||
visible={detailVisible}
|
||||
@@ -850,11 +851,11 @@ const CreateMembershipModal = ({
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={submit}
|
||||
okText={t('确认开通')}
|
||||
okText={t('确定')}
|
||||
cancelText={t('取消')}
|
||||
confirmLoading={submitting}
|
||||
okButtonProps={{ disabled: plansLoading || enabledPlans.length === 0 }}
|
||||
width={560}
|
||||
{...membershipFormLayout}
|
||||
>
|
||||
<div className='space-y-4'>
|
||||
<div className='rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-700/40 dark:bg-amber-900/20 dark:text-amber-200'>
|
||||
@@ -1292,9 +1293,10 @@ const EditModal = ({ visible, row, onCancel, onDone, t }) => {
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={submit}
|
||||
okText={t('保存')}
|
||||
okText={t('确定')}
|
||||
cancelText={t('取消')}
|
||||
confirmLoading={submitting}
|
||||
{...membershipFormLayout}
|
||||
>
|
||||
{row && (
|
||||
<div className='space-y-3'>
|
||||
|
||||
Reference in New Issue
Block a user