v4.0.9版本更新-门店分类支持多选
CI / verify (pull_request) Waiting to run

This commit is contained in:
2026-09-02 11:12:51 +08:00
parent 77e9917a18
commit fe557c912d
18 changed files with 742 additions and 239 deletions
+6 -3
View File
@@ -8,8 +8,11 @@ export type StoreCreateForm = {
city?: string;
district: string;
districtCode?: string;
/** @deprecated 使用 categoryIds */
categoryParentId?: string;
categoryId: string;
/** @deprecated 使用 categoryIds */
categoryId?: string;
categoryIds: string[];
name: string;
phone: string;
address: string;
@@ -52,7 +55,7 @@ export function validateStoreCreateStep1(
| 'partnerAccountId'
| 'cityId'
| 'regionCodes'
| 'categoryId'
| 'categoryIds'
| 'name'
| 'phone'
| 'address'
@@ -69,7 +72,7 @@ export function validateStoreCreateStep1(
if (!form.partnerAccountId) return '请选择开城合伙人';
if (!form.regionCodes || form.regionCodes.length < 3) return '请选择省 / 市 / 区县';
if (!form.cityId) return '所选地区未匹配到开城城市,请先在「开城 → 城市」配置对应区划';
if (!form.categoryId?.trim()) return '请选择门店分类(细类)';
if (!form.categoryIds?.length) return '请至少选择一个门店分类(细类)';
if (!form.name?.trim()) return '请填写门店名称';
if (!form.phone?.trim()) return '请填写门店手机号';
if (!PHONE_RE.test(form.phone.trim())) return '门店手机号须为11位手机号';
+45 -83
View File
@@ -224,6 +224,7 @@ type StoreRow = {
settlementRate?: number;
sortOrder?: number;
category?: { id: string; name: string; parentId?: string | null } | null;
categories?: { id: string; name: string; parentId?: string | null }[] | null;
};
type PartnerOption = { id: string; companyName?: string | null; name?: string | null; phone?: string | null };
@@ -350,29 +351,17 @@ export default function StoresPage() {
const selectedPartnerId = Form.useWatch('partnerAccountId', createForm);
const selectedRegionCodes = Form.useWatch('regionCodes', createForm);
const selectedCityId = Form.useWatch('cityId', createForm);
const selectedCategoryParentId = Form.useWatch('categoryParentId', createForm);
const editCategoryParentId = Form.useWatch('categoryParentId', editForm);
const categoryParentOptions = useMemo(
() =>
categoryTree
.filter((n) => n.status !== 'INACTIVE')
.map((n) => ({ value: n.id, label: n.name })),
[categoryTree],
);
const categoryChildOptions = useMemo(() => {
const parent = categoryTree.find((n) => n.id === selectedCategoryParentId);
return (parent?.children ?? [])
.filter((n) => n.status !== 'INACTIVE')
.map((n) => ({ value: n.id, label: n.name }));
}, [categoryTree, selectedCategoryParentId]);
const editCategoryChildOptions = useMemo(() => {
const parent = categoryTree.find((n) => n.id === editCategoryParentId);
return (parent?.children ?? [])
.filter((n) => n.status !== 'INACTIVE')
.map((n) => ({ value: n.id, label: n.name }));
}, [categoryTree, editCategoryParentId]);
const categoryLeafOptions = useMemo(() => {
const options: { value: string; label: string }[] = [];
for (const parent of categoryTree) {
if (parent.status === 'INACTIVE') continue;
for (const child of parent.children ?? []) {
if (child.status === 'INACTIVE') continue;
options.push({ value: child.id, label: `${parent.name} / ${child.name}` });
}
}
return options;
}, [categoryTree]);
async function deleteStore(id: string) {
setDeleting(true);
@@ -414,20 +403,14 @@ export default function StoresPage() {
bankBranch?: string | null;
})
: null;
const categoryId = category?.id != null ? String(category.id) : undefined;
let parentId = category?.parentId != null ? String(category.parentId) : undefined;
if (!parentId && categoryId) {
for (const parent of cats) {
if (parent.id === categoryId) {
parentId = parent.id;
break;
}
if ((parent.children ?? []).some((c) => c.id === categoryId)) {
parentId = parent.id;
break;
}
}
}
const categories = Array.isArray(d.categories)
? (d.categories as { id?: string }[])
: [];
const categoryIds = categories.length
? categories.map((c) => String(c.id)).filter(Boolean)
: category?.id != null
? [String(category.id)]
: [];
const loginPhone =
(typeof d.loginPhone === 'string' && d.loginPhone) ||
account?.phone ||
@@ -466,8 +449,7 @@ export default function StoresPage() {
city: d.cityName,
district: d.district,
address: d.address,
categoryParentId: parentId,
categoryId,
categoryIds,
latitude: d.latitude != null ? Number(d.latitude) : undefined,
longitude: d.longitude != null ? Number(d.longitude) : undefined,
settlementRate: d.settlementRate != null ? Number(d.settlementRate) * 100 : 60,
@@ -530,7 +512,7 @@ export default function StoresPage() {
!/^null$/i.test(v.benefitUsageRule.trim())
? v.benefitUsageRule.trim()
: null,
categoryId: v.categoryId,
categoryIds: v.categoryIds,
province: v.province,
city: v.city,
district: v.district,
@@ -661,8 +643,7 @@ export default function StoresPage() {
'partnerAccountId',
'regionCodes',
'cityId',
'categoryParentId',
'categoryId',
'categoryIds',
'name',
'phone',
'address',
@@ -691,7 +672,7 @@ export default function StoresPage() {
body: JSON.stringify({
partnerAccountId: values.partnerAccountId,
cityId: values.cityId,
categoryId: values.categoryId,
categoryIds: values.categoryIds,
province: values.province,
city: values.city,
name: values.name.trim(),
@@ -769,8 +750,14 @@ export default function StoresPage() {
{
key: 'category',
title: '分类',
width: 100,
render: (_, row) => row.category?.name || '—',
width: 140,
render: (_, row) => {
const cats = Array.isArray(row.categories)
? row.categories.map((c: { name?: string }) => c.name).filter(Boolean)
: [];
if (cats.length) return cats.join('、');
return row.category?.name || '—';
},
},
{ key: 'cityName', title: '城市', dataIndex: 'cityName', width: 80 },
{ key: 'phone', title: '登录号', dataIndex: 'phone', width: 120 },
@@ -1156,29 +1143,17 @@ export default function StoresPage() {
<Input placeholder="手机号或座机,如 0379-8888888" />
</Form.Item>
<Form.Item
name="categoryParentId"
label="门店分类(大类"
rules={[{ required: true, message: '请选择门店类' }]}
name="categoryIds"
label="门店分类(细类,可多选"
rules={[{ required: true, message: '请至少选择一个门店类' }]}
>
<Select
mode="multiple"
showSearch
loading={optionsLoading}
optionFilterProp="label"
options={categoryParentOptions}
onChange={() => editForm.setFieldValue('categoryId', undefined)}
/>
</Form.Item>
<Form.Item
name="categoryId"
label="门店分类(细类)"
rules={[{ required: true, message: '请选择门店细类' }]}
>
<Select
showSearch
optionFilterProp="label"
placeholder={editCategoryParentId ? '选择细类' : '请先选大类'}
disabled={!editCategoryParentId}
options={editCategoryChildOptions}
placeholder="选择细类,可多选"
options={categoryLeafOptions}
/>
</Form.Item>
<Form.Item name="coverUrl" label="封面图 / 门头照">
@@ -1457,23 +1432,9 @@ export default function StoresPage() {
<Form.Item name="district" hidden><Input /></Form.Item>
<Form.Item name="districtCode" hidden><Input /></Form.Item>
<Form.Item
name="categoryParentId"
label="门店分类(大类"
rules={[{ required: true, message: '请选择门店类' }]}
>
<Select
showSearch
loading={optionsLoading}
optionFilterProp="label"
placeholder={optionsLoading ? '加载中…' : '选择大类'}
options={categoryParentOptions}
onChange={() => createForm.setFieldValue('categoryId', undefined)}
/>
</Form.Item>
<Form.Item
name="categoryId"
label="门店分类(细类)"
rules={[{ required: true, message: '请选择门店细类' }]}
name="categoryIds"
label="门店分类(细类,可多选"
rules={[{ required: true, message: '请至少选择一个门店类' }]}
extra={
<Typography.Link onClick={() => navigate('/store-categories')}>
@@ -1481,11 +1442,12 @@ export default function StoresPage() {
}
>
<Select
mode="multiple"
showSearch
loading={optionsLoading}
optionFilterProp="label"
placeholder={selectedCategoryParentId ? '选择细类' : '请先选大类'}
disabled={!selectedCategoryParentId}
options={categoryChildOptions}
placeholder={optionsLoading ? '加载中…' : '选择细类,可多选'}
options={categoryLeafOptions}
/>
</Form.Item>
<Form.Item name="name" label="门店名称" rules={[{ required: true, message: '请填写门店名称' }]}>