diff --git a/apps/web/src/api/health/points.ts b/apps/web/src/api/health/points.ts index 8cfd248..c0216ad 100644 --- a/apps/web/src/api/health/points.ts +++ b/apps/web/src/api/health/points.ts @@ -322,10 +322,11 @@ export const pointsApi = { }, updateProduct: async (id: string, req: Partial & { is_active?: boolean; version: number }) => { + const { version, ...fields } = req; const { data } = await client.put<{ success: boolean; data: PointsProduct; - }>(`/health/admin/points/products/${id}`, req); + }>(`/health/admin/points/products/${id}`, { data: fields, version }); return data.data; }, diff --git a/apps/web/src/pages/health/PointsProductList.tsx b/apps/web/src/pages/health/PointsProductList.tsx index c9330b0..b60a920 100644 --- a/apps/web/src/pages/health/PointsProductList.tsx +++ b/apps/web/src/pages/health/PointsProductList.tsx @@ -318,51 +318,57 @@ export default function PointsProductList() { title: '展示设置', fields: ( <> - - - - - { - try { - const result = await uploadFile(file); - form.setFieldValue('image_url', result.url); - message.success('图片上传成功'); - } catch { - message.error('图片上传失败'); - } - return false; - }} - > - - - - - prev.image_url !== cur.image_url}> - {({ getFieldValue }) => { - const url: string | undefined = getFieldValue('image_url'); - if (!url) return null; + + prev.image_url !== cur.image_url}> + {({ getFieldValue, setFieldValue }) => { + const imageUrl: string | undefined = getFieldValue('image_url'); return ( -
- 商品图片预览 { (e.target as HTMLImageElement).style.display = 'none'; }} - /> -
+ <> + + setFieldValue('image_url', e.target.value || undefined)} + placeholder="输入 URL 或从媒体库选择" + style={{ flex: 1 }} + /> + + { + try { + const result = await uploadFile(file); + setFieldValue('image_url', result.url); + message.success('图片上传成功'); + } catch { + message.error('图片上传失败'); + } + return false; + }} + > + + + + {imageUrl && ( +
+ 商品图片预览 { (e.target as HTMLImageElement).style.display = 'none'; }} + /> +
+ )} + ); }}