diff --git a/apps/admin-web/src/components/AdminStorePackagesSection.tsx b/apps/admin-web/src/components/AdminStorePackagesSection.tsx index 0a01a41..dd1166a 100644 --- a/apps/admin-web/src/components/AdminStorePackagesSection.tsx +++ b/apps/admin-web/src/components/AdminStorePackagesSection.tsx @@ -1,5 +1,6 @@ import { useEffect, useState } from 'react'; import { Alert, Button, Form, Input, InputNumber, Space, Typography, message } from 'antd'; +import { DownOutlined, UpOutlined } from '@ant-design/icons'; import type { StorePackageItemDto } from '@dukang/shared-types'; import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types'; import { request } from '../lib/api'; @@ -12,6 +13,7 @@ function emptyRow(index = 0): PackageRow { export default function AdminStorePackagesSection({ storeId }: { storeId: string }) { const [items, setItems] = useState([emptyRow()]); + const [collapsed, setCollapsed] = useState>({}); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); @@ -40,6 +42,19 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string function removeAt(index: number) { setItems((prev) => prev.filter((_, i) => i !== index).map((item, i) => ({ ...item, sortOrder: i }))); + setCollapsed((prev) => { + const next: Record = {}; + Object.entries(prev).forEach(([k, v]) => { + const i = Number(k); + if (i < index) next[i] = v; + else if (i > index) next[i - 1] = v; + }); + return next; + }); + } + + function toggleCollapse(index: number) { + setCollapsed((prev) => ({ ...prev, [index]: !prev[index] })); } async function save() { @@ -100,74 +115,89 @@ export default function AdminStorePackagesSection({ storeId }: { storeId: string message={`总部直存立即生效,无需审核。同一门店最多 ${STORE_PACKAGE_MAX_COUNT} 条套餐。`} /> - {items.map((item, index) => ( -
- - - 套餐 {index + 1} - - {items.length > 1 ? ( - + {items.length > 1 ? ( + + ) : null} + + + {!isCollapsed ? ( + <> + + updateAt(index, { name: e.target.value })} + /> + + + + updateAt(index, { price: v != null ? String(v) : '' })} + /> + + + + updateAt(index, { dishes: e.target.value })} + /> + + + + updateAt(index, { usableTime: e.target.value })} + /> + + + + updateAt(index, { otherNotes: e.target.value })} + /> + + ) : null} - - - - updateAt(index, { name: e.target.value })} - /> - - - - updateAt(index, { price: v != null ? String(v) : '' })} - /> - - - - updateAt(index, { dishes: e.target.value })} - /> - - - - updateAt(index, { usableTime: e.target.value })} - /> - - - - updateAt(index, { otherNotes: e.target.value })} - /> - -
- ))} + + ); + })} {items.length < STORE_PACKAGE_MAX_COUNT ? ( + {!disabled && list.length > 1 ? ( + + ) : null} + + + {!isCollapsed ? ( + <> +
+ +
+ restaurant + updateAt(index, { name: e.target.value })} + /> +
+
+ +
+ +
+ payments + updateAt(index, { price: e.target.value })} + /> +
+
+ +
+ +