Compare commits
5 Commits
bab3770337
...
trunk
| Author | SHA1 | Date | |
|---|---|---|---|
| 89d2bcdf29 | |||
| ab9c034a72 | |||
| 17be93115d | |||
| b142751b69 | |||
| aabb89b5f5 |
@ -43,4 +43,5 @@ export enum AdminAPI {
|
|||||||
GIVE_VIP = '/api/bo/giveVip/give',
|
GIVE_VIP = '/api/bo/giveVip/give',
|
||||||
// 产品列表
|
// 产品列表
|
||||||
PRODUCT_LIST = '/api/bo/product/listByType/{productType}',
|
PRODUCT_LIST = '/api/bo/product/listByType/{productType}',
|
||||||
|
GET_PRODUCT_SPEC = '/api/bo/product/getBySpecId/{productSpecId}'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,13 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|||||||
import { CITY_OPTIONS } from '@/constants/city';
|
import { CITY_OPTIONS } from '@/constants/city';
|
||||||
import { TIME_FORMAT } from '@/constants/global';
|
import { TIME_FORMAT } from '@/constants/global';
|
||||||
import { uploadFileWx } from '@/services/file';
|
import { uploadFileWx } from '@/services/file';
|
||||||
import { deleteCityOperator, getAllStaffList, getCityOpratorList, updateCityOperator } from '@/services/list';
|
import {
|
||||||
|
deleteCityOperator,
|
||||||
|
getAllStaffList,
|
||||||
|
getCityOpratorList,
|
||||||
|
getProductList,
|
||||||
|
updateCityOperator,
|
||||||
|
} from '@/services/list';
|
||||||
|
|
||||||
const useStyles = createStyles(({ token }) => {
|
const useStyles = createStyles(({ token }) => {
|
||||||
return {
|
return {
|
||||||
@ -36,40 +42,13 @@ const useStyles = createStyles(({ token }) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const MIN_GROUP_SIZE = 20;
|
const calcPrice = (productSpecId: string, specList: API.ProductSpecListItem[]) => {
|
||||||
export enum ProductSpecId {
|
const product = specList.find(o => o.productSpecId === productSpecId);
|
||||||
GroupBatchPublish20 = 'GROUP_BATCH_PUSH_20',
|
return { price: product?.showPrice, originalPrice: product?.originalPrice, sendCount: product?.count };
|
||||||
GroupBatchPublish50 = 'GROUP_BATCH_PUSH_50',
|
|
||||||
GroupBatchPublish60 = 'GROUP_BATCH_PUSH_60',
|
|
||||||
GroupBatchPublish80 = 'GROUP_BATCH_PUSH_80',
|
|
||||||
GroupBatchPublish100 = 'GROUP_BATCH_PUSH_100',
|
|
||||||
GroupBatchPublish150 = 'GROUP_BATCH_PUSH_150',
|
|
||||||
GroupBatchPublish300 = 'GROUP_BATCH_PUSH_300',
|
|
||||||
GroupBatchPublish500 = 'GROUP_BATCH_PUSH_500',
|
|
||||||
GroupBatchPublish750 = 'GROUP_BATCH_PUSH_750',
|
|
||||||
GroupBatchPublish800 = 'GROUP_BATCH_PUSH_800',
|
|
||||||
GroupBatchPublish1000 = 'GROUP_BATCH_PUSH_1000',
|
|
||||||
}
|
|
||||||
const GROUP_OPTIONS = [
|
|
||||||
{ value: MIN_GROUP_SIZE, productSpecId: ProductSpecId.GroupBatchPublish20, label: '20', price: 18 },
|
|
||||||
{ value: 50, productSpecId: ProductSpecId.GroupBatchPublish50, label: '50', price: 40 },
|
|
||||||
{ value: 60, productSpecId: ProductSpecId.GroupBatchPublish60, label: '60', price: 48 },
|
|
||||||
{ value: 80, productSpecId: ProductSpecId.GroupBatchPublish80, label: '80', price: 58 },
|
|
||||||
{ value: 100, productSpecId: ProductSpecId.GroupBatchPublish100, label: '100', price: 68 },
|
|
||||||
{ value: 150, productSpecId: ProductSpecId.GroupBatchPublish150, label: '150', price: 98 },
|
|
||||||
{ value: 300, productSpecId: ProductSpecId.GroupBatchPublish300, label: '300', price: 128 },
|
|
||||||
{ value: 500, productSpecId: ProductSpecId.GroupBatchPublish500, label: '500', price: 168 },
|
|
||||||
{ value: 750, productSpecId: ProductSpecId.GroupBatchPublish750, label: '750', price: 188 },
|
|
||||||
{ value: 800, productSpecId: ProductSpecId.GroupBatchPublish800, label: '800', price: 198 },
|
|
||||||
{ value: 1000, productSpecId: ProductSpecId.GroupBatchPublish1000, label: '1000', price: 288 },
|
|
||||||
];
|
|
||||||
const calcPrice = (sendCount: number) => {
|
|
||||||
const originalPrice = sendCount * 1;
|
|
||||||
const price = GROUP_OPTIONS.find(o => o.value === sendCount)?.price || 18;
|
|
||||||
return { price, originalPrice };
|
|
||||||
};
|
};
|
||||||
const TableList: React.FC = () => {
|
const TableList: React.FC = () => {
|
||||||
const [updateModalOpen, handleUpdateModalOpen] = useState<boolean>(false);
|
const [updateModalOpen, handleUpdateModalOpen] = useState<boolean>(false);
|
||||||
|
const [specList, setSpecList] = useState<API.ProductSpecListItem[]>([]);
|
||||||
const [currentRow, setCurrentRow] = useState<API.CityOperatorListItem>();
|
const [currentRow, setCurrentRow] = useState<API.CityOperatorListItem>();
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
const formRef = useRef<ProFormInstance>();
|
const formRef = useRef<ProFormInstance>();
|
||||||
@ -78,6 +57,14 @@ const TableList: React.FC = () => {
|
|||||||
return staffOptions.find(it => it.isDefault) || staffOptions[0];
|
return staffOptions.find(it => it.isDefault) || staffOptions[0];
|
||||||
}, [staffOptions]);
|
}, [staffOptions]);
|
||||||
const { styles } = useStyles();
|
const { styles } = useStyles();
|
||||||
|
const specOptions = useMemo(
|
||||||
|
() =>
|
||||||
|
specList.map(it => ({
|
||||||
|
value: it.productSpecId,
|
||||||
|
label: it.title,
|
||||||
|
})),
|
||||||
|
[specList],
|
||||||
|
);
|
||||||
|
|
||||||
const getAllStaffOptions = async () => {
|
const getAllStaffOptions = async () => {
|
||||||
try {
|
try {
|
||||||
@ -94,6 +81,11 @@ const TableList: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getAllSpectList = async () => {
|
||||||
|
const list = await getProductList('GROUP_BATCH_PUSH');
|
||||||
|
setSpecList(list);
|
||||||
|
};
|
||||||
|
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
await deleteCityOperator(id);
|
await deleteCityOperator(id);
|
||||||
message.success('操作成功');
|
message.success('操作成功');
|
||||||
@ -105,6 +97,7 @@ const TableList: React.FC = () => {
|
|||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getAllStaffOptions();
|
getAllStaffOptions();
|
||||||
|
getAllSpectList();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const columns: ProColumns<API.CityOperatorListItem>[] = [
|
const columns: ProColumns<API.CityOperatorListItem>[] = [
|
||||||
@ -167,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: '操作',
|
||||||
@ -257,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.responseURL,
|
groupQrCode: formData.qrCode[0].xhr ? formData.qrCode[0].xhr.responseURL : formData.qrCode[0].url,
|
||||||
price: calcPrice(formData.sendCount).price,
|
|
||||||
};
|
};
|
||||||
console.log('update confirm', formData, params);
|
console.log('update confirm', formData, params);
|
||||||
try {
|
try {
|
||||||
@ -299,16 +292,16 @@ const TableList: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
mode="single"
|
mode="single"
|
||||||
name="sendCount"
|
name="productSpecId"
|
||||||
label="可群发数量"
|
label="可群发数量"
|
||||||
options={GROUP_OPTIONS}
|
options={specOptions}
|
||||||
rules={[{ required: true, message: '必填项' }]}
|
rules={[{ required: true, message: '必填项' }]}
|
||||||
/>
|
/>
|
||||||
<ProFormDependency name={['sendCount']}>
|
<ProFormDependency name={['productSpecId']}>
|
||||||
{({ sendCount }) =>
|
{({ productSpecId }) =>
|
||||||
sendCount ? (
|
productSpecId ? (
|
||||||
<div>
|
<div>
|
||||||
价格:{calcPrice(sendCount).price}(原价:{calcPrice(sendCount).originalPrice})
|
价格:{calcPrice(productSpecId, specList).price}(原价:{calcPrice(productSpecId, specList).originalPrice})
|
||||||
</div>
|
</div>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
|
|||||||
@ -157,7 +157,7 @@ const TableList: React.FC = () => {
|
|||||||
id: currentRow?.id,
|
id: currentRow?.id,
|
||||||
isDefault: currentRow?.isDefault || 0,
|
isDefault: currentRow?.isDefault || 0,
|
||||||
staffName: formData?.staffName,
|
staffName: formData?.staffName,
|
||||||
staffQrCode: formData.qrCode[0].xhr.responseURL,
|
staffQrCode: formData.qrCode[0].xhr ? formData.qrCode[0].xhr.responseURL : formData.qrCode[0].url,
|
||||||
};
|
};
|
||||||
console.log('update confirm', formData, params);
|
console.log('update confirm', formData, params);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -327,3 +327,9 @@ export async function getProductList(productType: API.ProductType) {
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getProductSpec(productSpecId: API.ProductType) {
|
||||||
|
return request<API.ProductSpecListItem>(buildUrl(AdminAPI.GET_PRODUCT_SPEC, {productSpecId}), {
|
||||||
|
method: 'GET',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
7
src/services/typings.d.ts
vendored
7
src/services/typings.d.ts
vendored
@ -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;
|
||||||
}
|
}
|
||||||
@ -411,6 +409,7 @@ declare namespace API {
|
|||||||
productSpecId: string;
|
productSpecId: string;
|
||||||
productType: ProductType;
|
productType: ProductType;
|
||||||
productName: string;
|
productName: string;
|
||||||
|
count: number;
|
||||||
title: string;
|
title: string;
|
||||||
priceText: string;
|
priceText: string;
|
||||||
payPrice: number;
|
payPrice: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user