fix(store): 修复门店商品管理页多项显示与编辑问题
- 将商品状态Tab标签「出售中」修改为「已上架」,与后端定义一致 - 调整商品参数注释,更新status状态枚举说明 - 编辑弹窗新增会员价(dealerPrice)输入框,完善编辑表单数据绑定与提交 - 分类选择改为传递参数方式避免闭包旧值,解决需点击两次才生效的问题 - 更新商品列表加载逻辑,支持分类ID参数即时生效
This commit is contained in:
@@ -153,6 +153,6 @@ export interface ShopGoodsParam extends PageParam {
|
||||
stock?: number;
|
||||
keywords?: string;
|
||||
recommend?: number;
|
||||
// 0上架 1下架(以实际后端约定为准)
|
||||
// 0上架 1待上架 2待审核 3审核不通过
|
||||
status?: number;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ type TabKey = 'all' | 'on_sale' | 'pending' | 'sold_out'
|
||||
|
||||
const TABS: { key: TabKey; label: string; param: Partial<ShopGoodsParam> }[] = [
|
||||
{ key: 'all', label: '全部', param: {} },
|
||||
{ key: 'on_sale', label: '出售中', param: { status: 0 } },
|
||||
{ key: 'on_sale', label: '已上架', param: { status: 0 } },
|
||||
{ key: 'pending', label: '待上架', param: { status: 1 } },
|
||||
{ key: 'sold_out', label: '已售罄', param: { stock: 0 } },
|
||||
]
|
||||
@@ -54,6 +54,7 @@ export default function StoreGoodsPage() {
|
||||
const [editForm, setEditForm] = useState({
|
||||
price: '',
|
||||
salePrice: '',
|
||||
dealerPrice: '',
|
||||
stock: '',
|
||||
sortNumber: '',
|
||||
comments: '',
|
||||
@@ -64,7 +65,7 @@ export default function StoreGoodsPage() {
|
||||
const loadingRef = useRef(false)
|
||||
|
||||
/** 加载商品列表 */
|
||||
const loadGoods = useCallback(async (tab: TabKey, pageNo: number = 1, append = false) => {
|
||||
const loadGoods = useCallback(async (tab: TabKey, pageNo: number = 1, append = false, categoryId?: number) => {
|
||||
if (loadingRef.current) return
|
||||
loadingRef.current = true
|
||||
setLoading(true)
|
||||
@@ -79,7 +80,8 @@ export default function StoreGoodsPage() {
|
||||
limit: pageSize,
|
||||
}
|
||||
if (keyword) params.keywords = keyword
|
||||
if (selectedCategory) params.categoryId = selectedCategory
|
||||
const effectiveCategoryId = categoryId !== undefined ? categoryId : selectedCategory
|
||||
if (effectiveCategoryId) params.categoryId = effectiveCategoryId
|
||||
|
||||
const res = await pageShopGoods(params)
|
||||
const list = res?.list || []
|
||||
@@ -133,7 +135,7 @@ export default function StoreGoodsPage() {
|
||||
const handleSelectCategory = (cat: ShopGoodsCategory | undefined) => {
|
||||
setSelectedCategory(cat?.categoryId)
|
||||
setShowCategoryPicker(false)
|
||||
loadGoods(activeTab, 1)
|
||||
loadGoods(activeTab, 1, false, cat?.categoryId)
|
||||
}
|
||||
|
||||
/** 快速上架/下架 */
|
||||
@@ -178,6 +180,7 @@ export default function StoreGoodsPage() {
|
||||
setEditForm({
|
||||
price: goods.price || '',
|
||||
salePrice: goods.salePrice || '',
|
||||
dealerPrice: goods.dealerPrice || '',
|
||||
stock: String(goods.stock ?? ''),
|
||||
sortNumber: String(goods.sortNumber ?? ''),
|
||||
comments: goods.comments || '',
|
||||
@@ -213,6 +216,7 @@ export default function StoreGoodsPage() {
|
||||
...editGoods,
|
||||
price: editForm.price,
|
||||
salePrice: editForm.salePrice || undefined,
|
||||
dealerPrice: editForm.dealerPrice || undefined,
|
||||
stock,
|
||||
sortNumber: parseInt(editForm.sortNumber, 10) || 0,
|
||||
comments: editForm.comments || undefined,
|
||||
@@ -495,6 +499,17 @@ export default function StoreGoodsPage() {
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View className='mb-4'>
|
||||
<Text className='text-sm text-gray-600 mb-2 block'>会员价 (¥)</Text>
|
||||
<Input
|
||||
className='bg-gray-50 rounded-lg px-4 py-3 text-sm'
|
||||
type='digit'
|
||||
placeholder='VIP/经销商专享价'
|
||||
value={editForm.dealerPrice}
|
||||
onInput={(e) => setEditForm(prev => ({ ...prev, dealerPrice: e.detail.value }))}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View className='mb-4'>
|
||||
<Text className='text-sm text-gray-600 mb-2 block'>库存</Text>
|
||||
<Input
|
||||
|
||||
Reference in New Issue
Block a user