feat(cps): 群/活动列表加删除按钮(Popconfirm 二次确认)

- 群操作列 + 删除;活动列表新增操作列含删除
- 确认弹窗说明影响(已发链接仍可用 / 淘宝活动删后落地页用默认图)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-17 21:43:35 +08:00
parent ecbce54e70
commit b1923c3133
+56 -3
View File
@@ -12,6 +12,7 @@ import {
Input,
InputNumber,
Modal,
Popconfirm,
Select,
Space,
Statistic,
@@ -246,6 +247,16 @@ function GroupsTab() {
const [createOpen, setCreateOpen] = useState(false);
const [linkGroup, setLinkGroup] = useState<CpsGroup | null>(null);
const delGroup = async (g: CpsGroup) => {
try {
await api.delete(`/admin/api/cps/groups/${g.id}`);
message.success('已删除群');
reload();
} catch (e) {
message.error(errMsg(e));
}
};
const columns: ColumnsType<CpsGroup> = [
{ title: 'ID', dataIndex: 'id', width: 60 },
{ title: '群名', dataIndex: 'name', width: 160, ellipsis: true },
@@ -268,11 +279,22 @@ function GroupsTab() {
title: '操作',
key: 'op',
fixed: 'right',
width: 150,
width: 200,
render: (_, g) => (
<Space onClick={(e) => e.stopPropagation()}>
{canManage && <a onClick={() => setLinkGroup(g)}></a>}
{canManage && <a onClick={() => setEditing(g)}></a>}
{canManage && (
<Popconfirm
title="删除这个群?"
description="已发出的链接仍可用,但该群不再计入统计。"
okText="删除"
okButtonProps={{ danger: true }}
onConfirm={() => delGroup(g)}
>
<a style={{ color: '#cf1322' }}></a>
</Popconfirm>
)}
</Space>
),
},
@@ -308,7 +330,7 @@ function GroupsTab() {
showTotal: (t) => `${t} 个群`,
onChange,
}}
scroll={{ x: 1040 }}
scroll={{ x: 1090 }}
/>
<GroupFormModal open={createOpen} group={null} onClose={() => setCreateOpen(false)} onDone={reload} />
@@ -535,6 +557,16 @@ function ActivitiesTab() {
const canManage = canDo(['operator']);
const [createOpen, setCreateOpen] = useState(false);
const delActivity = async (a: CpsActivity) => {
try {
await api.delete(`/admin/api/cps/activities/${a.id}`);
message.success('已删除活动');
reload();
} catch (e) {
message.error(errMsg(e));
}
};
const columns: ColumnsType<CpsActivity> = [
{ title: 'ID', dataIndex: 'id', width: 60 },
{
@@ -575,6 +607,27 @@ function ActivitiesTab() {
render: (s: string) => <Tag color={s === 'active' ? 'green' : 'default'}>{s}</Tag>,
},
{ title: '创建时间', dataIndex: 'created_at', width: 150, render: (v: string) => formatUtcTime(v) },
...(canManage
? ([
{
title: '操作',
key: 'op',
fixed: 'right' as const,
width: 80,
render: (_: unknown, a: CpsActivity) => (
<Popconfirm
title="删除这个活动?"
description="已生成的链接仍可用;淘宝活动删除后其落地页改用默认图。"
okText="删除"
okButtonProps={{ danger: true }}
onConfirm={() => delActivity(a)}
>
<a style={{ color: '#cf1322' }}></a>
</Popconfirm>
),
},
] as ColumnsType<CpsActivity>)
: []),
];
return (
@@ -599,7 +652,7 @@ function ActivitiesTab() {
showTotal: (t) => `${t} 个活动`,
onChange,
}}
scroll={{ x: 1080 }}
scroll={{ x: 1160 }}
/>
<ActivityFormModal open={createOpen} onClose={() => setCreateOpen(false)} onDone={reload} />
</div>