Commit e7495c67 authored by tjy's avatar tjy

merge

parents 0a0039c0 0b886ba3
......@@ -2,7 +2,7 @@
* @Author: LeeJiancong
* @Date: 2020-08-10 14:41:27
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-08-11 09:36:29
* @LastEditTime: 2020-08-11 16:24:57
*/
/**
* 用于在项目开始前获取所有的配置
......@@ -41,6 +41,10 @@ const serviceConfig = {
payInitializeConfig:{
url:'/pay/initialize/config',
method: 'post'
},
payPlatformPayConfig:{
url:'/pay/platform/pay/config',
method:'post'
}
}
}
......
......@@ -53,8 +53,21 @@ export interface PayInitializeConfig {
payWayResponses: PayWayResponse[];
}
export interface PayWayResponse {
id: number;
payType: number;
way: string;
isPitchOn: number;
}
export interface PayPlatformPayConfig {
payType: number;
payWayResponses: PayWayResponse[];
}
export interface PayConfig {
payInitializeConfig: PayInitializeConfig[];
payPlatformPayConfig: PayPlatformPayConfig[];
}
export interface CountryList {
......
......@@ -3,12 +3,14 @@ import {Card,Button} from 'antd'
import { PlusOutlined, SaveOutlined } from '@ant-design/icons'
import { PageHeaderWrapper} from '@ant-design/pro-layout'
import EyePreview from '@/components/EyePreview'
import {createFormActions} from '@formily/antd'
import {createFormActions, FormEffectHooks,useFormEffects} from '@formily/antd'
import PayForm from '../components/PayForm'
import {TabSetting} from '../schema'
import SettingModal from '../components/PayForm/components/settingModal'
import { PublicApi } from '@/services/api'
import { action } from 'mobx'
const payActions = createFormActions()
const { onFieldValueChange$} = FormEffectHooks
const PaySetting: React.FC<{}> = () => {
const ref = useRef<any>({})
const [visible, setvisible] = useState<boolean>(false)
......@@ -64,6 +66,14 @@ const PaySetting: React.FC<{}> = () => {
}
}, [])
const useTabEffects = () => {
// useFormEffects(($, { setFieldState }) => {
// onFieldValueChange$('PAY_TABS').subscribe(fieldState => {
// console.log(fieldState)
// })
// })
}
return (
<PageHeaderWrapper
extra={
......@@ -79,9 +89,10 @@ const PaySetting: React.FC<{}> = () => {
tableColumns,
tableAddButton1,
tableAddButton2,
cardTableColumns
cardTableColumns,
}}
schema={TabSetting(infoData)}
effects={() => useTabEffects()}
/>
<SettingModal
id={id}
......
......@@ -7,9 +7,11 @@ import {ColumnType} from 'antd/lib/table/interface'
import EyePreview from '@/components/EyePreview'
import {createFormActions,ISchema} from '@formily/antd'
import PayForm from '../components/PayForm'
import {useInitValue} from '@/formSchema/effects/useInitValue'
import {strategyDetailTab} from '../schema'
import {usePageStatus} from '@/hooks/usePageStatus'
import { useRowSelectionTable} from '@/hooks/useRowSelectionTable'
import {history} from 'umi'
import {findItemAndDelete} from '@/utils'
import { GlobalConfig } from '@/global/config'
import { PublicApi } from '@/services/api'
......@@ -25,7 +27,8 @@ const PaySetting: React.FC<{}> = () => {
const [visibleChannelMember, setVisibleChannelMember] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable()
const [optionType, setoptionType] = useState(0)
const {preview,pageStatus} = usePageStatus()
// const initValue = useInitValue(PublicApi.getPayPayMemberTacticsDetails)
const columnsSetMember: ColumnType<any>[] = [
{
title: 'ID',
......@@ -90,9 +93,9 @@ const PaySetting: React.FC<{}> = () => {
// 弹出会员
const handleAddMemberBtn = () => {
// const checkBoxs = payActions.getFieldValue('applyMember')
// memberRowCtl.setSelectedRowKeys(checkBoxs.map(v => v.memberId))
// memberRowCtl.setSelectRow(checkBoxs)
const checkBoxs = payActions.getFieldValue('applyMember')
memberRowCtl.setSelectedRowKeys(checkBoxs.map(v => v.memberId))
memberRowCtl.setSelectRow(checkBoxs)
setvisible(true)
console.log(visibleChannelMember)
}
......@@ -127,11 +130,22 @@ const PaySetting: React.FC<{}> = () => {
}
]
useEffect(() => {
console.log(usePageStatus().pageStatus,'状态')
PublicApi.getPayPayMemberTacticsDetails({id: usePageStatus().id}).then(res => {
let list = res.data
// setinfoData(list)
})
if(usePageStatus().id){
PublicApi.getPayPayMemberTacticsDetails({id: usePageStatus().id}).then(res => {
if(res.code === 1000){
let {data} = res
console.log('结果',res.data)
payActions.setFieldValue('paymentPolicyName',data.paymentPolicyName)
data.paymentPolicyPayWayRequests.forEach((item,index) => {
payActions.setFieldValue(`ruleConfigurationId-${index}`,item.ruleConfigurationId)
payActions.setFieldValue(`payWayIds-${index}`,item.payWayIds)
})
payActions.setFieldValue('isSelected',data.isSelected)
// payActions.setFieldValue('applyMember', data.memberIds)
}
})
}
return () => {
}
......@@ -151,24 +165,60 @@ const PaySetting: React.FC<{}> = () => {
// 整体表单提交
const handleSubmit = (values:any) => {
let baseList: any = GlobalConfig.payConfig.payInitializeConfig
console.log('values',values)
let list:any = []
baseList.forEach((item:any,index:number) => {
let payWayIds = `payWayIds-${index}`, ruleConfigurationId = `ruleConfigurationId-${index}`
list.push({
payType: item.payType,
['payWayIds']: values[payWayIds],
['ruleConfigurationId']:values[ruleConfigurationId]
})
});
let params:any = {
paymentPolicyName: values.paymentPolicyName,
paymentPolicyPayWayRequests: list ,
isSelected: values.isSelected
}
if(values.isSelected === 0 ){
// params.memberIdRoleIds = {
// memberIds: memberRowCtl.selectRow.map(v=>v.memberId),
// roleId:memberRowCtl.selectRow.map(v=>v.memberId),
// }
let memberIdRoleIds :any = []
memberRowCtl.selectRow.forEach((v=> {
memberIdRoleIds.push({
memberId: v.memberId,
roleId: v.roleId
})
}))
params.memberIdRoleIds = memberIdRoleIds
}
//新增
if(!usePageStatus().id){
let list:any = []
baseList.forEach((item:any,index:number) => {
let payWayIds = `payWayIds-${index}`, ruleConfigurationId = `ruleConfigurationId-${index}`
list.push({
payType: item.payType,
['payWayIds']: values[payWayIds],
['ruleConfigurationId']:values[ruleConfigurationId]
})
});
console.log(list)
console.log('params',params)
PublicApi.postPayPayMemberTacticsAdd({...params}).then(res => {
if(res.code === 1000){
setTimeout(() => {
history.goBack()
},1500)
}
})
}else{
params.paymentPolicyId = usePageStatus().id
PublicApi.postPayPayMemberTacticsUpdate({...params}).then(res => {
if(res.code === 1000){
setTimeout(() => {
history.goBack()
},1500)
}
})
}
}
return (
<PageHeaderWrapper
extra={
usePageStatus().pageStatus !== 2 &&
<Button type="primary" onClick={() => payActions.submit()} icon={<SaveOutlined/>}>
保存
</Button>
......@@ -180,6 +230,7 @@ const PaySetting: React.FC<{}> = () => {
tableColumns,
tableAddButton
}}
// editable={usePageStatus().pageStatus === 2 ?false: true}
onSubmit={handleSubmit}
actions={payActions}
schema={strategyDetailTab(infoData,usePageStatus)}
......@@ -205,7 +256,6 @@ const PaySetting: React.FC<{}> = () => {
rowKey: 'memberId'
}}
>
</StandardTable>
</Modal>
</PageHeaderWrapper>
......
/*
* @Author: LeeJiancong
* @Date: 2020-08-06 19:07:32
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-08-11 16:19:10
*/
import React, { useEffect,useState, useRef } from 'react';
import {Card,Row,Col,Space,Button,Popconfirm} from 'antd'
import {history} from 'umi'
......@@ -32,7 +38,7 @@ const List: React.FC<{}> = () => {
title:'策略名称',
dataIndex:'strategyName',
key:'strategyName',
align:'center',
align:'left',
render:(text:any,record: any) => (
<EyePreview url={`/ruleSettingManager/payStrategyDetail?id=${record.id}&preview=1`}>
{text}
......@@ -65,23 +71,16 @@ const List: React.FC<{}> = () => {
key:'options',
align:'center',
render: (_: any, record: any) => {
const status = record.status === 0?'启用':'停用'
const status = record.state === 0?'启用':'停用'
const title = `确定要${status}吗?`
return (
<>
<Popconfirm title={title} okText="是" cancelText="否" onConfirm={() => handleChangeStatus(record.id,record.status)}>
<Button type='link'>
{ record.status === 0?'启用':'停用'}
</Button>
</Popconfirm>
{
record.status === 0 ?
record.state === 0 ?
<>
<Button type='link' onClick={() => history.push(`/memberCenter/logisticsAbility/logistics/list/templateForm?id=${record.id}`)}>编辑</Button>
<Button type='link' onClick={() => history.push(`/ruleSettingManager/payStrategyDetail?id=${record.id}`)}>编辑</Button>
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={() =>handleDelete(record.id)}>
<Button type='link'>
删除
</Button>
<Button type='link'>删除</Button>
</Popconfirm>
</> : ''
}
......@@ -91,15 +90,18 @@ const List: React.FC<{}> = () => {
}
]
const handleChangeStatus = (id,record) => {
}
const handleModify = (record: any) => {
const handleModify = async (record: any) => {
await PublicApi.postPayPaymentPolicyUpdateState({
id: record.id,
state: record.state === 1? 0: 1
})
ref.current.reload()
}
const handleDelete = (id:number) => {
//删除
const handleDelete = async (id:number) => {
await PublicApi.postPayPaymentPolicyDelete({id:id})
ref.current.reload()
}
const handleToAdd = () => {
history.push('/ruleSettingManager/payStrategyDetail')
......
......@@ -2,7 +2,7 @@
* @Author: LeeJiancong
* @Date: 2020-08-06 11:12:18
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-08-10 20:41:41
* @LastEditTime: 2020-08-11 17:53:58
*/
import React, { Component } from 'react'
import { ISchema } from '@formily/antd'
......@@ -15,18 +15,6 @@ export const strategyDetailTab = (props: any, usePageStatus: any) => {
//新增时候就初始化
let baseList: any = GlobalConfig.payConfig.payInitializeConfig
baseList.forEach((v, i) => {
let ruleList = [], payWayList = []
v.ruleConfigurations.forEach((child: any, childindex: number) => {
let ruleObj = {}
child['label'] = child.id
child['value'] = child.platformWayName
})
v.payWayResponses.forEach((child, childindex) => {
child['value'] = child.id
child['label'] = child.way
})
})
console.log('baseList', baseList)
let tabItem = {}, Tab1 = {},arr=[]
......@@ -225,6 +213,8 @@ export const paySetting: ISchema = {
//会员支付参数配置
export const TabSetting = (props: any[]) => {
let list = GlobalConfig.payConfig.payPlatformPayConfig
console.log('初始哈',list)
let tabItem = {}
props.forEach((v, i) => {
tabItem[`tab-${i + 1}`] = {
......@@ -237,7 +227,7 @@ export const TabSetting = (props: any[]) => {
"isPitchOn": {
type: 'RadioGroud',
title: `是否开启${v.way}`,
// required: true
required: true
},
"alipayTitle": {
type: 'Text',
......@@ -290,7 +280,7 @@ export const TabSetting = (props: any[]) => {
type: 'object',
"x-component": 'tab',
"x-component-props": {
type: 'card'
type: 'card',
},
properties: { ...tabItem }
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment