@ -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,53 +42,13 @@ const useStyles = createStyles(({ token }) => {
} ;
} ;
} ) ;
} ) ;
const MIN_GROUP_SIZE = 20 ;
const calcPrice = ( productSpecId : string , specList : API.ProductSpecListItem [ ] ) = > {
export enum P roductSpecId {
const product = specList . find ( o = > o . productSpecId === p roductSpecId) ;
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' ,
GroupBatchPublish120 = 'GROUP_BATCH_PUSH_120' ,
GroupBatchPublish150 = 'GROUP_BATCH_PUSH_150' ,
GroupBatchPublish200 = 'GROUP_BATCH_PUSH_200' ,
GroupBatchPublish250 = 'GROUP_BATCH_PUSH_250' ,
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 : 38 ,
originalPrice : 40 ,
} ,
{ value : 50 , productSpecId : ProductSpecId.GroupBatchPublish50 , label : '50' , price : 68 , originalPrice : 100 } ,
{ value : 60 , productSpecId : ProductSpecId.GroupBatchPublish60 , label : '60' , price : 78 , originalPrice : 120 } ,
{ value : 80 , productSpecId : ProductSpecId.GroupBatchPublish80 , label : '80' , price : 88 , originalPrice : 160 } ,
{ value : 100 , productSpecId : ProductSpecId.GroupBatchPublish100 , label : '100' , price : 98 , originalPrice : 200 } ,
{ value : 120 , productSpecId : ProductSpecId.GroupBatchPublish120 , label : '120' , price : 108 , originalPrice : 240 } ,
{ value : 150 , productSpecId : ProductSpecId.GroupBatchPublish150 , label : '150' , price : 128 , originalPrice : 300 } ,
{ value : 200 , productSpecId : ProductSpecId.GroupBatchPublish200 , label : '200' , price : 148 , originalPrice : 200 } ,
{ value : 250 , productSpecId : ProductSpecId.GroupBatchPublish250 , label : '250' , price : 168 , originalPrice : 250 } ,
{ value : 300 , productSpecId : ProductSpecId.GroupBatchPublish300 , label : '300' , price : 168 , originalPrice : 300 } ,
{ value : 500 , productSpecId : ProductSpecId.GroupBatchPublish500 , label : '500' , price : 168 , originalPrice : 500 } ,
{ value : 750 , productSpecId : ProductSpecId.GroupBatchPublish750 , label : '750' , price : 168 , originalPrice : 750 } ,
{ value : 800 , productSpecId : ProductSpecId.GroupBatchPublish800 , label : '800' , price : 168 , originalPrice : 800 } ,
{ value : 1000 , productSpecId : ProductSpecId.GroupBatchPublish1000 , label : '1000' , price : 168 , originalPrice : 1000 } ,
] ;
const calcPrice = ( sendCount : number ) = > {
const price = GROUP_OPTIONS . find ( o = > o . value === sendCount ) ? . price || 18 ;
const originalPrice = GROUP_OPTIONS . find ( o = > o . value === sendCount ) ? . originalPrice || sendCount ;
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 > ( ) ;
@ -91,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 {
@ -107,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 ( '操作成功' ) ;
@ -118,6 +97,7 @@ const TableList: React.FC = () => {
} ;
} ;
useEffect ( ( ) = > {
useEffect ( ( ) = > {
getAllStaffOptions ( ) ;
getAllStaffOptions ( ) ;
getAllSpectList ( ) ;
} , [ ] ) ;
} , [ ] ) ;
const columns : ProColumns < API.CityOperatorListItem > [ ] = [
const columns : ProColumns < API.CityOperatorListItem > [ ] = [
@ -180,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 : '操作' ,
@ -270,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 ) . price ,
} ;
} ;
console . log ( 'update confirm' , formData , params ) ;
console . log ( 'update confirm' , formData , params ) ;
try {
try {
@ -312,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 ( sendCoun t) . price } ( 原 价 : { calcPrice ( sendCoun t) . originalPrice } )
价 格 : { calcPrice ( productSpecId , specLis t) . price } ( 原 价 : { calcPrice ( productSpecId , specLis t) . originalPrice } )
< / div >
< / div >
) : null
) : null
}
}