@ -19,7 +19,13 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
import { CITY_OPTIONS } from '@/constants/city' ;
import { TIME_FORMAT } from '@/constants/global' ;
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 } ) = > {
return {
@ -36,40 +42,13 @@ const useStyles = createStyles(({ token }) => {
} ;
} ) ;
const MIN_GROUP_SIZE = 20 ;
export enum P roductSpecId {
GroupBatchPublish20 = 'GROUP_BATCH_PUSH_20' ,
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 calcPrice = ( productSpecId : string , specList : API.ProductSpecListItem [ ] ) = > {
const product = specList . find ( o = > o . productSpecId === p roductSpecId) ;
return { price : product?.showPrice , originalPrice : product?.originalPrice , sendCount : product?.count } ;
} ;
const TableList : React.FC = ( ) = > {
const [ updateModalOpen , handleUpdateModalOpen ] = useState < boolean > ( false ) ;
const [ specList , setSpecList ] = useState < API.ProductSpecListItem [ ] > ( [ ] ) ;
const [ currentRow , setCurrentRow ] = useState < API.CityOperatorListItem > ( ) ;
const actionRef = useRef < ActionType > ( ) ;
const formRef = useRef < ProFormInstance > ( ) ;
@ -78,6 +57,14 @@ const TableList: React.FC = () => {
return staffOptions . find ( it = > it . isDefault ) || staffOptions [ 0 ] ;
} , [ staffOptions ] ) ;
const { styles } = useStyles ( ) ;
const specOptions = useMemo (
( ) = >
specList . map ( it = > ( {
value : it.productSpecId ,
label : it.title ,
} ) ) ,
[ specList ] ,
) ;
const getAllStaffOptions = async ( ) = > {
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 ) = > {
await deleteCityOperator ( id ) ;
message . success ( '操作成功' ) ;
@ -105,6 +97,7 @@ const TableList: React.FC = () => {
} ;
useEffect ( ( ) = > {
getAllStaffOptions ( ) ;
getAllSpectList ( ) ;
} , [ ] ) ;
const columns : ProColumns < API.CityOperatorListItem > [ ] = [
@ -167,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 : '操作' ,
@ -257,9 +251,8 @@ const TableList: React.FC = () => {
cityCode : formData.city.value ,
cityName : formData.city.label ,
groupLink : formData.groupLink ,
sendCount : formData.sendCount ,
groupQrCode : formData.qrCode [ 0 ] . xhr . responseURL ,
price : calcPrice ( formData . sendCount ) . price ,
productSpecId : formData.productSpecId ,
groupQrCode : formData.qrCode [ 0 ] . xhr ? formData . qrCode [ 0 ] . xhr.responseURL : formData.qrCode [ 0 ] . url ,
} ;
console . log ( 'update confirm' , formData , params ) ;
try {
@ -299,16 +292,16 @@ const TableList: React.FC = () => {
/ >
< ProFormSelect
mode = "single"
name = "sendCount "
name = "productSpecId "
label = "可群发数量"
options = { GROUP_OPTIONS }
options = { specOptions }
rules = { [ { required : true , message : '必填项' } ] }
/ >
< ProFormDependency name = { [ 'sendCount ' ] } >
{ ( { sendCount } ) = >
sendCount ? (
< ProFormDependency name = { [ 'productSpecId ' ] } >
{ ( { productSpecId } ) = >
productSpecId ? (
< div >
价 格 : { calcPrice ( sendCoun t) . price } ( 原 价 : { calcPrice ( sendCoun t) . originalPrice } )
价 格 : { calcPrice ( productSpecId , specLis t) . price } ( 原 价 : { calcPrice ( productSpecId , specLis t) . originalPrice } )
< / div >
) : null
}