feat: update api
This commit is contained in:
@ -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<boolean>(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 = () => {
|
||||
/>
|
||||
<ProFormSelect
|
||||
mode="single"
|
||||
name="sendCount"
|
||||
name="productSpecId"
|
||||
label="可群发数量"
|
||||
options={specOptions}
|
||||
rules={[{ required: true, message: '必填项' }]}
|
||||
/>
|
||||
<ProFormDependency name={['sendCount']}>
|
||||
{({ sendCount }) =>
|
||||
sendCount ? (
|
||||
<ProFormDependency name={['productSpecId']}>
|
||||
{({ productSpecId }) =>
|
||||
productSpecId ? (
|
||||
<div>
|
||||
价格:{calcPrice(sendCount, specList).price}(原价:{calcPrice(sendCount, specList).originalPrice})
|
||||
价格:{calcPrice(productSpecId, specList).price}(原价:{calcPrice(productSpecId, specList).originalPrice})
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
|
||||
@ -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: {
|
||||
// 错误抛出
|
||||
|
||||
6
src/services/typings.d.ts
vendored
6
src/services/typings.d.ts
vendored
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user