Commit c44e3c3d authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents 98a07448 214ce818
......@@ -2,7 +2,7 @@
* @Author: LeeJiancong
* @Date: 2020-08-04 16:21:48
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-08-07 14:03:12
* @LastEditTime: 2020-08-13 09:52:00
*/
const router = {
path: '/ruleSettingManager',
......@@ -25,7 +25,7 @@ const router = {
{
path: '/ruleSettingManager/paySetting',
name: 'paySetting',
component: '@/pages/ruleSettingManage/paySetting',
component: '@/pages/ruleSettingManage/paySetting/settingIndex',
hidePageHeader: true
}
]
......
......@@ -3,10 +3,10 @@
"scripts": {
"api": "god-ytt",
"start:analyze": "ANALYZE=1 umi dev",
"start:dev": "umi dev",
"scripts:build": "node scripts/run",
"start": "yarn api && yarn scripts:build && umi dev",
"build": "yarn api && yarn scripts:build && umi build",
"start": "yarn scripts:build && umi dev",
"start:dev": "umi dev",
"build": "umi build",
"build:analyze": "ANALYZE=1 umi build",
"postinstall": "umi generate tmp",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
......
{
"name": "god-template",
"scripts": {
"api": "god-ytt",
"start:analyze": "ANALYZE=1 umi dev",
"start:dev": "umi dev",
"scripts:build": "node scripts/run",
"start": "yarn api && yarn scripts:build && umi dev",
"build": "yarn api && yarn scripts:build && umi build",
"build:analyze": "ANALYZE=1 umi build",
"postinstall": "umi generate tmp",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
"test": "umi-test",
"test:coverage": "umi-test --coverage"
},
"lint-staged": {
"*.{js,jsx,less,md,json}": [
"prettier --write"
],
"*.ts?(x)": [
"prettier --parser=typescript --write"
]
},
"license": "MIT",
"dependencies": {
"@ant-design/icons": "^4.2.1",
"@ant-design/pro-layout": "^5.0.12",
"@formily/antd": "^1.2.11",
"@formily/antd-components": "^1.2.11",
"@umijs/hooks": "^1.9.3",
"@umijs/preset-react": "1.x",
"@umijs/test": "^3.2.0",
"braft-editor": "^2.3.9",
"classnames": "^2.2.6",
"core-js": "^3.6.5",
"god": "0.1.17",
"lint-staged": "^10.0.7",
"mobx": "^5.15.4",
"mobx-react": "^6.2.2",
"prettier": "^1.19.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"umi": "^3.2.0",
"yorkie": "^2.0.0"
},
"devDependencies": {
"axios": "^0.19.2",
"god-yapi2ts": "^1.6.0",
"gulp": "^4.0.2",
"json2ts": "^0.0.7",
"ora": "^4.0.4"
}
}
......@@ -8,6 +8,7 @@ const RadioGroud = (props:any) => {
className='radio-group-box'
size="small"
defaultValue={0}
value={props.value}
buttonStyle="solid"
options={options}
optionType="button"
......
import React, { Component, useState, useEffect } from 'react';
import { Modal, Button, Form } from 'antd'
import { Modal, Button, Form,Radio } from 'antd'
import {
SchemaForm, SchemaMarkupField as Field,
createFormActions,
FormEffectHooks
} from '@formily/antd'
import { Input, Radio, FormMegaLayout } from '@formily/antd-components'
import { Input, FormMegaLayout } from '@formily/antd-components'
import { PublicApi } from '@/services/api'
export interface Params {
id?: number | string;
id?: any,
mode:number,
type?: number|string,
dialogVisible: boolean;
onCancel: Function;
onOK?: Function;
initialValues?: any;
dontReceive?: boolean; //默认展示
}
const actions = createFormActions()
const { onFieldChange$ } = FormEffectHooks
const comfirmDialog: React.FC<Params> = (props) => {
console.log(props.dialogVisible)
const handleCancel = () => {
}
const handletOk = (values: any) => {
let value = { ...values }
if(props.id){
value.type = props.id
if(props.type){
value.type = props.type
}
PublicApi.postPayCollectionParametersAdd(value).then(res => {
if (res.code === 1000) {
props.onOK()
}
})
console.log('列表',value)
props.onOK(value)
}
useEffect(() => {
......@@ -46,17 +45,18 @@ const comfirmDialog: React.FC<Params> = (props) => {
return (
<>
<Modal
title={ props.type == 0 ?'新增参数配置':'编辑参数配置'}
title={ props.mode === 0 ?'新增参数配置':'编辑参数配置'}
width={800}
visible={props.dialogVisible}
onOk={() => actions.submit()}
onCancel={() => props.onCancel()}
destroyOnClose
afterClose={() => actions.reset()}
okText='确定'
okText={`确定`}
cancelText='取消'
>
<SchemaForm
labelCol={3}
components={{
Input, Radio: Radio.Group, TextArea: Input.TextArea
......@@ -64,8 +64,9 @@ const comfirmDialog: React.FC<Params> = (props) => {
actions={actions}
effects={() => useFormEffects()}
onSubmit={(values) => handletOk(values)}
initialValues={{
}}
initialValues={
props.initialValues
}
>
<Field
name='code'
......@@ -117,7 +118,7 @@ const comfirmDialog: React.FC<Params> = (props) => {
}
comfirmDialog.defaultProps = {
dontReceive: true,
id:1 //1.支付宝 2.支付宝转账到银行卡参数配置 3.微信
type:1 //1.支付宝 2.支付宝转账到银行卡参数配置 3.微信
}
export default comfirmDialog
\ No newline at end of file
import React, { useEffect , useState,useRef } from 'react'
import {Card,Button} from 'antd'
import React, { useEffect, useState, useRef } from 'react'
import { Card, Button } from 'antd'
import { PlusOutlined, SaveOutlined } from '@ant-design/icons'
import { PageHeaderWrapper} from '@ant-design/pro-layout'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import EyePreview from '@/components/EyePreview'
import {createFormActions, FormEffectHooks,useFormEffects} from '@formily/antd'
import PayForm from '../components/PayForm'
import {TabSetting} from '../schema'
import { createFormActions, FormEffectHooks,useFormEffects } from '@formily/antd'
import PayForm from '../components/PayForm'
import Setting, { TabSetting, exportId } from '../schema'
import SettingModal from '../components/PayForm/components/settingModal'
import { PublicApi } from '@/services/api'
import {history} from 'umi'
import { action } from 'mobx'
const payActions = createFormActions()
const { onFieldValueChange$} = FormEffectHooks
const { onFieldValueChange$ } = FormEffectHooks
const PaySetting: React.FC<{}> = () => {
const ref = useRef<any>({})
const [mode, setmord] = useState<number>(0)
const [visible, setvisible] = useState<boolean>(false)
const [optionType, setoptionType] = useState(0)
const [infoData, setinfoData] = useState<any>([])
const [id, setid] = useState<any>('')
const [type, settype] = useState<any>(null)
const [tabid, settabid] = useState<any>(1)
let currentTab = exportId()
let [tabOption, settabOption] = useState({
tab: 1,
type: 1
})
const handleAddMemberBtn = (type:number) => {
setid(type)
// useEffect(() => {
// setCurrentTab(exportId())
// }, [exportId()])
const handleAddMemberBtn = (type: number) => {
settype(type)
setvisible(true)
}
const handleDeleteTable = (id:number) => {
const handleDeleteTable = (id: number) => {
}
const handleModalOK = () => {
const handleModalOK = (obj:any) => {
console.log('选项卡:',exportId(),'弹窗id:',type)
setvisible(false)
ref.current.reload()
currentTab = !exportId() ? 1: exportId()
console.log('选项卡:',exportId(),'数据',obj)
console.log(payActions.getFieldValue("payParametersListResponses1"))
if(type == 1){
let list:any = []
list.push(obj)
let old = payActions.getFieldValue("payParametersListResponses1")
// list.map(v=> v['key']= v.code)
payActions.setFieldValue("payParametersListResponses1", [...old,...list])
}
if(type == 2){
let list:any = []
list.push(obj)
let old = payActions.getFieldValue(`payParametersList${currentTab}`)
// list.map(v=> v['key']= v.code)
payActions.setFieldValue(`payParametersList${currentTab}`, [...old,...list])
}
//微信
if(type == 3){
let list:any = []
list.push(obj)
let old = payActions.getFieldValue("payParametersListResponses2")
// list.map(v=> v['key']= v.code)
payActions.setFieldValue("payParametersListResponses2", [...old,...list])
payActions.setFieldValue("payParametersListResponses2", [...old,...list])
}
// ref.current.reload()
}
const tableAddButton = <Button style={{marginBottom: 16}} block icon={<PlusOutlined/>} onClick={() =>handleAddMemberBtn(1)} type='dashed'>新增参数配置1</Button>
const tableAddButton2 = <Button style={{marginBottom: 16}} block icon={<PlusOutlined/>} onClick={() =>handleAddMemberBtn(2)} type='dashed'>新增参数配置2</Button>
const tableAddButton3 = <Button style={{marginBottom: 16}} block icon={<PlusOutlined/>} onClick={() =>handleAddMemberBtn(3)} type='dashed'>新增参数配置3</Button>
const tableAddButton = <Button style={{ marginBottom: 16 }} block icon={<PlusOutlined />} onClick={() => handleAddMemberBtn(1)} type='dashed'>新增参数配置1</Button>
const tableAddButton2 = <Button style={{ marginBottom: 16 }} block icon={<PlusOutlined />} onClick={() => handleAddMemberBtn(2)} type='dashed'>新增参数配置2</Button>
const tableAddButton3 = <Button style={{ marginBottom: 16 }} block icon={<PlusOutlined />} onClick={() => handleAddMemberBtn(3)} type='dashed'>新增参数配置3</Button>
const tableColumns = [
{ dataIndex: 'code', title: '参数代码', align: 'center' },
{ dataIndex: 'value', align: 'center', title: '参数值', render: (_, record) => <EyePreview url={`/memberCenter/memberAbility/manage/addMember?id=${record.memberId}&preview=1`}>{_}</EyePreview> },
{ dataIndex: 'describe', title: '参数描述', align: 'center' },
{ dataIndex: 'ctl', title: '操作', align: 'center', render: (_, record) =>
<>
<Button type='link' onClick={() =>{
setvisible(true),
setoptionType(1)
}}>编辑</Button>
<Button type='link' onClick={() => handleDeleteTable(record.id)}>删除</Button>
</>
{
dataIndex: 'ctl', title: '操作', align: 'center', render: (_, record) =>
<>
<Button type='link' onClick={() => {
setvisible(true),
setoptionType(1)
}}>编辑</Button>
<Button type='link' onClick={() => handleDeleteTable(record.id)}>删除</Button>
</>
}
}
]
const cardTableColumns = [
{ dataIndex: 'code', title: '参数代码', align: 'center' },
......@@ -57,48 +100,84 @@ const PaySetting: React.FC<{}> = () => {
{ dataIndex: 'describe', title: '参数描述', align: 'center' },
{ dataIndex: 'ctl', title: '操作', align: 'center', render: (_, record) => <Button type='link' onClick={() => handleDeleteTable(record.id)}>删除</Button> }
]
useEffect(() => {
PublicApi.getPayQueryPlatformDetails().then(res => {
let list = res.data
// setinfoData(list)
console.log('当前',currentTab)
PublicApi.getPayQueryPlatformDetails({id:exportId()}).then(res => {
if(res.code === 1000){
let {id,isPitchOn,payParametersList,payParametersListResponses} = res.data
payActions.setFieldValue(`isPitchOn${id}`,isPitchOn)
payActions.setFieldValue(`payParametersList${id}`,payParametersList)
payActions.setFieldValue(`payParametersListResponses${id}`,payParametersListResponses)
}
})
return () => {
}
}, [])
const useTabEffects = () => {
// useFormEffects(($, { setFieldState }) => {
// onFieldValueChange$('PAY_TABS').subscribe(fieldState => {
// console.log(fieldState)
// })
// useFormEffects(($, { setFieldState }) => {
// onFieldValueChange$('PAY_TABS').subscribe(fieldState => {
// console.log(fieldState)
// })
// })
}
// })
}
const handleSubmit = (values) => {
console.log('当前id',currentTab)
console.log(values)
let list:any = []
let parametersList:any = [],payParametersListResponses:any = []
parametersList = payActions.getFieldValue(`payParametersList${currentTab}`)
payParametersListResponses = payActions.getFieldValue(`payParametersListResponses${currentTab}`)
if(exportId() == 1){
list = [...parametersList,...payParametersListResponses]
}else{
list = [...payParametersListResponses]
}
console.log(list)
// return
PublicApi.postPayCollectionParametersAdd({
payWayId: currentTab,
isPitchOn: values.isPitchOn,
payParameters: list
}).then(res=>{
if(res.code === 1000){
history.push('/home')
}
})
}
return (
<PageHeaderWrapper
extra={
<Button type="primary" onClick={() => payActions.submit()} icon={<SaveOutlined/>}>
<Button type="primary" onClick={() => payActions.submit()} icon={<SaveOutlined />} >
保存
</Button>
}
>
<Card>
<PayForm
expressionScope={{
tableColumns,
tableAddButton,
tableAddButton2,
tableAddButton3,
cardTableColumns,
}}
schema={TabSetting(infoData)}
actions={payActions}
schema={TabSetting()}
effects={() => useTabEffects()}
onSubmit={(values) => handleSubmit(values)}
/>
<SettingModal
id={id}
type={optionType}
mode={mode}
id={exportId()}
type={type}
dialogVisible={visible}
onCancel={() => setvisible(false)}
onOK = {() =>handleModalOK}
onOK={(list) => handleModalOK(list)}
/>
</Card>
</PageHeaderWrapper>
......
This diff is collapsed.
......@@ -2,14 +2,16 @@
* @Author: LeeJiancong
* @Date: 2020-08-06 11:12:18
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-08-11 20:48:22
* @LastEditTime: 2020-08-12 20:32:03
*/
import React, { Component } from 'react'
import React, { useState, useEffect } from 'react'
import { ISchema } from '@formily/antd'
import { FORM_FILTER_PATH } from '@/formSchema/const'
import { GlobalConfig } from '@/global/config'
import { AreaChartOutlined } from '@ant-design/icons'
let payType = ['', '线上支付', '线下支付', '授信额度支付', '货到付款支付']
let currentTab;
//会员支付策略
export const strategyDetailTab = (props: any, usePageStatus: any) => {
......@@ -17,7 +19,7 @@ export const strategyDetailTab = (props: any, usePageStatus: any) => {
let baseList: any = GlobalConfig.payConfig.payInitializeConfig
console.log('baseList', baseList)
let tabItem = {}, Tab1 = {},arr=[]
let tabItem = {}, Tab1 = {}, arr = []
baseList.map((item, index) => {
Tab1[`MEGA_LAYOUT_LINE${index}`] = {
type: 'Text',
......@@ -209,90 +211,106 @@ export const paySetting: ISchema = {
}
}
}
let TabID: any = 1
function getID(val?) {
TabID = val
console.log('id', TabID)
}
//会员支付参数配置
export const TabSetting = (props: any[]) => {
let list =// GlobalConfig.payConfig.payPlatformPayConfig
[{
id: 1,
isPitchOn: 1,
payType: 1,
way: "支付宝支付",
},
{
id: 2,
isPitchOn: 1,
payType: 1,
way: "微信",
},
{
id: 3,
isPitchOn: 1,
payType: 2,
way: "线上线下",
}
]
console.log('初始哈',list)
export const TabSetting = (props?: any[]) => {
let list = GlobalConfig.payConfig.payPlatformPayConfig
// [{
// id: 1,
// isPitchOn: 1,
// payType: 1,
// way: "支付宝支付",
// },
// {
// id: 2,
// isPitchOn: 1,
// payType: 1,
// way: "微信",
// },
// {
// id: 3,
// isPitchOn: 1,
// payType: 2,
// way: "线上线下",
// }
// ]
console.log('初始哈', list)
let tabItem = {}
list.forEach((v, i) => {
tabItem[`${v.id}`] = {
if (i == 0) {
currentTab = v.id
}
tabItem[`tab-${v.id}`] = {
"type": 'object',
"x-component": 'tabpane',
"x-component-props": {
tab: v.way
},
properties: {
"isPitchOn": {
type: 'RadioGroud',
title: `是否开启${v.way}`,
required: true,
"x-linkages": [
{
type: 'value:visible',
target: 'megaLayout',
"condition": "{{!!$value}}"
}
]
},
megaLayout: {
[`MeGALOYOUT`]: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
},
properties: {
"alipayTitle": {
visible: v.payType != 2,
type: 'Text',
title: <div style={{ borderLeft: '2px solid #00B37A', padding: '1px 5px' }}>{v.way}参数配置</div>,
},
"payParametersList": {
visible: v.payType != 2,
type: 'array:number',
"x-component": 'PayTable',
"x-component-props": {
rowKey: 'id',
columns: "{{tableColumns}}",
suffix: "{{tableAddButton}}"
}
},
"cardTitle": {
visible: v.payType != 2 && v.id != 2,
type: 'Text',
title: <div style={{ borderLeft: '2px solid #00B37A', padding: '1px 5px' }}>{v.way}转账到银行卡参数配置</div>,
[`isPitchOn${v.id}`]: {
type: 'RadioGroud',
title: `是否开启${v.way}`,
required: false,
"x-linkages": [
{
type: 'value:visible',
target: `megaLayout${v.id}`,
"condition": "{{!!$value}}"
}
]
},
"payParametersListResponses": {
visible: v.payType != 2 && v.id != 2,
type: 'array:number',
"x-component": 'PayTable',
[`megaLayout${v.id}`]: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
rowKey: 'id',
columns: "{{cardTableColumns}}",
suffix: "{{tableAddButton}}"
},
properties: {
"alipayTitle": {
visible: v.payType != 2,
type: 'Text',
title: <div style={{ borderLeft: '2px solid #00B37A', padding: '1px 5px' }}>{v.way}参数配置</div>,
},
[`payParametersListResponses${v.id}`]: {
visible: v.payType != 2 ,
type: 'array:number',
"x-component": 'PayTable',
"x-component-props": {
rowKey: 'code',
columns: "{{tableColumns}}",
suffix: v.id === 1 ? "{{tableAddButton}}" : "{{tableAddButton3}}"
}
},
"cardTitle": {
visible: v.payType != 2 && v.id != 2,
type: 'Text',
title: <div style={{ borderLeft: '2px solid #00B37A', padding: '1px 5px' }}>{v.way}转账到银行卡参数配置</div>,
},
[`payParametersList${v.id}`]: {
visible: v.payType != 2 && v.id != 2,
type: 'array:number',
"x-component": 'PayTable',
"x-component-props": {
rowKey: 'code',
columns: "{{cardTableColumns}}",
suffix: "{{tableAddButton2}}",
}
}
}
}
}
......@@ -322,20 +340,25 @@ export const TabSetting = (props: any[]) => {
"x-component": 'tab',
"x-component-props": {
type: 'card',
onChange: file => console.log(file),
onTabClick: file => console.log(file)
onTabClick: (tab) => {
currentTab = tab.split('-')[1]
}
},
properties: { ...tabItem }
}
}
}
console.log('结构',tabItem)
return payTabSetting
}
export const exportId = () => {
return currentTab
}
export default {
getTabId: () => getID()
}
......
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