From ab9c034a72ba5596840e63fcaccd33dc7c21b426 Mon Sep 17 00:00:00 2001 From: chashaobao Date: Wed, 28 Jan 2026 19:47:44 +0800 Subject: [PATCH] feat: update api --- src/pages/table-list/city-operation/index.tsx | 29 +++++++++---------- src/requestConfig.ts | 2 +- src/services/typings.d.ts | 6 ++-- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/pages/table-list/city-operation/index.tsx b/src/pages/table-list/city-operation/index.tsx index a3881ba..b093a2a 100644 --- a/src/pages/table-list/city-operation/index.tsx +++ b/src/pages/table-list/city-operation/index.tsx @@ -42,10 +42,9 @@ const useStyles = createStyles(({ token }) => { }; }); -const calcPrice = (sendCount: number, specList: API.ProductSpecListItem[]) => { - const price = specList.find(o => o.count === sendCount)?.showPrice || sendCount; - const originalPrice = specList.find(o => o.count === sendCount)?.originalPrice || sendCount; - return { price, originalPrice }; +const calcPrice = (productSpecId: string, specList: API.ProductSpecListItem[]) => { + const product = specList.find(o => o.productSpecId === productSpecId); + return { price: product?.showPrice, originalPrice: product?.originalPrice, sendCount: product?.count }; }; const TableList: React.FC = () => { const [updateModalOpen, handleUpdateModalOpen] = useState(false); @@ -61,7 +60,7 @@ const TableList: React.FC = () => { const specOptions = useMemo( () => specList.map(it => ({ - value: it.count, + value: it.productSpecId, label: it.title, })), [specList], @@ -161,16 +160,17 @@ const TableList: React.FC = () => { }, { title: '可群发数量', - dataIndex: 'sendCount', + dataIndex: 'productSpecId', valueType: 'textarea', search: false, + renderText: productSpecId => calcPrice(productSpecId, specList).sendCount || '-', }, { title: '群代发价格', - dataIndex: 'price', + dataIndex: 'productSpecId', valueType: 'textarea', search: false, - renderText: cents => (cents ? (cents / 100).toFixed(0) : '-'), + renderText: productSpecId => calcPrice(productSpecId, specList).price || '-', }, { title: '操作', @@ -251,9 +251,8 @@ const TableList: React.FC = () => { cityCode: formData.city.value, cityName: formData.city.label, groupLink: formData.groupLink, - sendCount: formData.sendCount, + productSpecId: formData.productSpecId, groupQrCode: formData.qrCode[0].xhr ? formData.qrCode[0].xhr.responseURL : formData.qrCode[0].url, - price: calcPrice(formData.sendCount, specList).price, }; console.log('update confirm', formData, params); try { @@ -293,16 +292,16 @@ const TableList: React.FC = () => { /> - - {({ sendCount }) => - sendCount ? ( + + {({ productSpecId }) => + productSpecId ? (
- 价格:{calcPrice(sendCount, specList).price}(原价:{calcPrice(sendCount, specList).originalPrice}) + 价格:{calcPrice(productSpecId, specList).price}(原价:{calcPrice(productSpecId, specList).originalPrice})
) : null } diff --git a/src/requestConfig.ts b/src/requestConfig.ts index 9b84688..e4a7f2f 100644 --- a/src/requestConfig.ts +++ b/src/requestConfig.ts @@ -12,7 +12,7 @@ import { IRequestResponse } from './types/http'; * @doc https://umijs.org/docs/max/request#配置 */ export const requestConfig: RequestConfig = { - baseURL: (window.ENV?.BASE_URL || 'https://neighbourhood.cn') as string, + baseURL: (window.ENV?.BASE_URL || 'https://dev.neighbourhood.cn') as string, // 错误处理: umi@3 的错误处理方案。 errorConfig: { // 错误抛出 diff --git a/src/services/typings.d.ts b/src/services/typings.d.ts index 22bb244..c715b16 100644 --- a/src/services/typings.d.ts +++ b/src/services/typings.d.ts @@ -363,10 +363,9 @@ declare namespace API { staffId: number; cityCode: string; groupLink: string; - sendCount: number; + productSpecId: string; contactQrCode: string; groupQrCode: string; - price: number; id: number; } @@ -378,8 +377,7 @@ declare namespace API { cityCode: string; groupLink: string; groupQrCode: string; - sendCount?: number; - price?: number; + productSpecId?: string; created?: string; updated?: string; }