feat(ops): v4.0.4 开发任务多行与版本状态同步、合伙人/门店删除、账单合伙人列
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
@@ -7,6 +8,7 @@ import {
|
||||
Input,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
@@ -42,6 +44,7 @@ type PartnerRow = {
|
||||
districtCodes?: string[] | null;
|
||||
orderCommissionRate?: number;
|
||||
redeemCommissionRate?: number;
|
||||
storeCount?: number;
|
||||
accountCount: number;
|
||||
createdAt: string;
|
||||
};
|
||||
@@ -121,6 +124,7 @@ export default function CityPartnersPanel({
|
||||
maxPartnerCommissionRate = 0.05,
|
||||
onChanged,
|
||||
}: Props) {
|
||||
const navigate = useNavigate();
|
||||
const [editForm] = Form.useForm();
|
||||
const [createForm] = Form.useForm();
|
||||
const [subForm] = Form.useForm();
|
||||
@@ -204,6 +208,31 @@ export default function CityPartnersPanel({
|
||||
}
|
||||
}
|
||||
|
||||
async function deletePartner(row: { id: string; storeCount?: number }) {
|
||||
if ((row.storeCount ?? 0) > 0) {
|
||||
Modal.warning({
|
||||
title: '请先删除门店',
|
||||
content: `该城市合伙人下还有 ${row.storeCount} 家门店,请先删除门店后再删除合伙人。`,
|
||||
okText: '查看门店',
|
||||
onOk: () => navigate(`/stores?partnerId=${row.id}`),
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await request(`/admin/partners/${row.id}`, { method: 'DELETE' });
|
||||
message.success('城市合伙人已删除');
|
||||
if (detail?.id === row.id) {
|
||||
setDrawerOpen(false);
|
||||
setDetail(null);
|
||||
}
|
||||
void loadPartners();
|
||||
onChanged?.();
|
||||
} catch (e) {
|
||||
const msg = formatApiError(e);
|
||||
if (msg) message.error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteSubAccount(subId: string) {
|
||||
await request(`/admin/partner-accounts/${subId}`, { method: 'DELETE' });
|
||||
message.success('子账号已删除');
|
||||
@@ -237,11 +266,24 @@ export default function CityPartnersPanel({
|
||||
{ title: '创建', dataIndex: 'createdAt', width: 150, render: fmtTime },
|
||||
{
|
||||
title: '操作',
|
||||
width: 80,
|
||||
width: 140,
|
||||
render: (_, row) => (
|
||||
<Button type="link" size="small" onClick={() => void openPartner(row.id)}>
|
||||
管理
|
||||
</Button>
|
||||
<Space size={0}>
|
||||
<Button type="link" size="small" onClick={() => void openPartner(row.id)}>
|
||||
管理
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title="确认删除该城市合伙人?"
|
||||
description="若有门店需先删除门店;账号下有订单或核销单将禁止删除。"
|
||||
okText="删除"
|
||||
okButtonProps={{ danger: true }}
|
||||
onConfirm={() => void deletePartner(row)}
|
||||
>
|
||||
<Button type="link" size="small" danger>
|
||||
删除
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
@@ -272,7 +314,22 @@ export default function CityPartnersPanel({
|
||||
width={640}
|
||||
open={drawerOpen}
|
||||
onClose={() => setDrawerOpen(false)}
|
||||
extra={<Button type="primary" onClick={() => void savePartner()}>保存</Button>}
|
||||
extra={
|
||||
<Space>
|
||||
{detail ? (
|
||||
<Popconfirm
|
||||
title="确认删除该城市合伙人?"
|
||||
description="若有门店需先删除门店;账号下有订单或核销单将禁止删除。"
|
||||
okText="删除"
|
||||
okButtonProps={{ danger: true }}
|
||||
onConfirm={() => void deletePartner(detail)}
|
||||
>
|
||||
<Button danger>删除</Button>
|
||||
</Popconfirm>
|
||||
) : null}
|
||||
<Button type="primary" onClick={() => void savePartner()}>保存</Button>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
{detail && (
|
||||
<Tabs
|
||||
|
||||
Reference in New Issue
Block a user