feat: update api

This commit is contained in:
chashaobao
2026-01-28 19:47:44 +08:00
parent 17be93115d
commit ab9c034a72
3 changed files with 17 additions and 20 deletions

View File

@ -42,10 +42,9 @@ const useStyles = createStyles(({ token }) => {
}; };
}); });
const calcPrice = (sendCount: number, specList: API.ProductSpecListItem[]) => { const calcPrice = (productSpecId: string, specList: API.ProductSpecListItem[]) => {
const price = specList.find(o => o.count === sendCount)?.showPrice || sendCount; const product = specList.find(o => o.productSpecId === productSpecId);
const originalPrice = specList.find(o => o.count === sendCount)?.originalPrice || sendCount; return { price: product?.showPrice, originalPrice: product?.originalPrice, sendCount: product?.count };
return { price, originalPrice };
}; };
const TableList: React.FC = () => { const TableList: React.FC = () => {
const [updateModalOpen, handleUpdateModalOpen] = useState<boolean>(false); const [updateModalOpen, handleUpdateModalOpen] = useState<boolean>(false);
@ -61,7 +60,7 @@ const TableList: React.FC = () => {
const specOptions = useMemo( const specOptions = useMemo(
() => () =>
specList.map(it => ({ specList.map(it => ({
value: it.count, value: it.productSpecId,
label: it.title, label: it.title,
})), })),
[specList], [specList],
@ -161,16 +160,17 @@ const TableList: React.FC = () => {
}, },
{ {
title: '可群发数量', title: '可群发数量',
dataIndex: 'sendCount', dataIndex: 'productSpecId',
valueType: 'textarea', valueType: 'textarea',
search: false, search: false,
renderText: productSpecId => calcPrice(productSpecId, specList).sendCount || '-',
}, },
{ {
title: '群代发价格', title: '群代发价格',
dataIndex: 'price', dataIndex: 'productSpecId',
valueType: 'textarea', valueType: 'textarea',
search: false, search: false,
renderText: cents => (cents ? (cents / 100).toFixed(0) : '-'), renderText: productSpecId => calcPrice(productSpecId, specList).price || '-',
}, },
{ {
title: '操作', title: '操作',
@ -251,9 +251,8 @@ const TableList: React.FC = () => {
cityCode: formData.city.value, cityCode: formData.city.value,
cityName: formData.city.label, cityName: formData.city.label,
groupLink: formData.groupLink, groupLink: formData.groupLink,
sendCount: formData.sendCount, productSpecId: formData.productSpecId,
groupQrCode: formData.qrCode[0].xhr ? formData.qrCode[0].xhr.responseURL : formData.qrCode[0].url, 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); console.log('update confirm', formData, params);
try { try {
@ -293,16 +292,16 @@ const TableList: React.FC = () => {
/> />
<ProFormSelect <ProFormSelect
mode="single" mode="single"
name="sendCount" name="productSpecId"
label="可群发数量" label="可群发数量"
options={specOptions} options={specOptions}
rules={[{ required: true, message: '必填项' }]} rules={[{ required: true, message: '必填项' }]}
/> />
<ProFormDependency name={['sendCount']}> <ProFormDependency name={['productSpecId']}>
{({ sendCount }) => {({ productSpecId }) =>
sendCount ? ( productSpecId ? (
<div> <div>
{calcPrice(sendCount, specList).price}{calcPrice(sendCount, specList).originalPrice} {calcPrice(productSpecId, specList).price}{calcPrice(productSpecId, specList).originalPrice}
</div> </div>
) : null ) : null
} }

View File

@ -12,7 +12,7 @@ import { IRequestResponse } from './types/http';
* @doc https://umijs.org/docs/max/request#配置 * @doc https://umijs.org/docs/max/request#配置
*/ */
export const requestConfig: RequestConfig = { 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 的错误处理方案。 // 错误处理: umi@3 的错误处理方案。
errorConfig: { errorConfig: {
// 错误抛出 // 错误抛出

View File

@ -363,10 +363,9 @@ declare namespace API {
staffId: number; staffId: number;
cityCode: string; cityCode: string;
groupLink: string; groupLink: string;
sendCount: number; productSpecId: string;
contactQrCode: string; contactQrCode: string;
groupQrCode: string; groupQrCode: string;
price: number;
id: number; id: number;
} }
@ -378,8 +377,7 @@ declare namespace API {
cityCode: string; cityCode: string;
groupLink: string; groupLink: string;
groupQrCode: string; groupQrCode: string;
sendCount?: number; productSpecId?: string;
price?: number;
created?: string; created?: string;
updated?: string; updated?: string;
} }