Commit 5b66ab80 authored by LeeJiancong's avatar LeeJiancong

完善支付策略

parent 5cdb0772
......@@ -5,6 +5,7 @@
"start:analyze": "ANALYZE=1 umi dev",
"scripts:build": "node scripts/run",
"start": "yarn api && yarn scripts:build && umi dev",
"start:dev": "umi dev",
"build": "yarn api && yarn scripts:build && umi build",
"build:dev": "pm2 start scripts/devServer.js",
"build:analyze": "ANALYZE=1 umi build",
......@@ -50,8 +51,8 @@
"express": "^4.17.1",
"god-yapi2ts": "^1.6.0",
"gulp": "^4.0.2",
"http-proxy-middleware": "^1.0.5",
"json2ts": "^0.0.7",
"ora": "^4.0.4",
"http-proxy-middleware": "^1.0.5"
"ora": "^4.0.4"
}
}
......@@ -2,7 +2,7 @@
* @Author: LeeJiancong
* @Date: 2020-08-10 14:41:27
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-08-11 16:24:57
* @LastEditTime: 2020-08-18 14:55:46
*/
/**
* 用于在项目开始前获取所有的配置
......@@ -40,11 +40,11 @@ const serviceConfig = {
payConfig:{
payInitializeConfig:{
url:'/pay/initialize/config',
method: 'post'
method: 'get'
},
payPlatformPayConfig:{
url:'/pay/platform/pay/config',
method:'post'
method:'get'
}
}
}
......
import React, { ReactText, useRef, useEffect } from 'react'
import {StandardTable} from 'god'
import { IStandardTableProps } from 'god/dist/src/standard-table'
import { Row, Col, Modal } from 'antd'
export interface ModalTableProps extends IStandardTableProps<any> {
width?: number,
modalTitle?: ReactText,
confirm?(),
cancel?(),
visible?: boolean
}
const ModalTable:React.FC<ModalTableProps> = (props) => {
const { width = 704,modalTitle, confirm, cancel, visible, currentRef, ...resetTable } = props
const selfRef = currentRef || useRef<any>({})
useEffect(() => {
if (!visible) {
selfRef.current.resetField && selfRef.current.resetField({
validate: false
})
}
}, [visible, selfRef.current])
return (
<Modal
width={width}
title={modalTitle}
onOk={confirm}
onCancel={cancel}
visible={visible}
>
<StandardTable
tableType='small'
currentRef={selfRef}
formRender={(child, ps) => <Row justify='space-between'>
<Col>{child}</Col>
<Col style={{marginTop: 4}}>{ps}</Col>
</Row>}
{...resetTable}
>
</StandardTable>
</Modal>
)
}
ModalTable.defaultProps = {}
export default ModalTable
\ No newline at end of file
export interface MemberType {
id: number;
typeName: string;
}
export interface BusinessType {
id: number;
typeName: string;
}
export interface UseType {
memberType: MemberType[];
businessType: BusinessType[];
}
export interface UserRegister {
useType: UseType;
useDetail?: any;
}
export interface RuleConfiguration {
value: number;
label: string;
platformType: number;
}
export interface PayWayResponse {
payType: number;
value: number;
label: string;
}
export interface PayInitializeConfig {
payType: number;
ruleConfigurations: RuleConfiguration[];
payWayResponses: PayWayResponse[];
}
export interface PayPlatformPayConfig {
id: number;
payType: number;
way: string;
isPitchOn: number;
}
export interface PayConfig {
payInitializeConfig: PayInitializeConfig[];
payPlatformPayConfig: PayPlatformPayConfig[];
}
export interface CountryList {
name: string;
key: string;
icon: string;
}
export interface Children {
code: string;
}
export interface MenuList {
code: string;
children: Children[];
}
export interface Global {
logo: string;
countryList: CountryList[];
menuList: MenuList[];
}
export interface RootObject {
userRegister: UserRegister;
payConfig: PayConfig;
global: Global;
}
\ No newline at end of file
......@@ -11,7 +11,8 @@ interface useRowSelectionTableCtl {
}
interface useRowSelectionOptions {
type?: 'checkbox' | 'radio'
type?: 'checkbox' | 'radio',
customKey?: string
}
/**
......@@ -19,7 +20,7 @@ interface useRowSelectionOptions {
* @auth xjm
*/
export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [TableRowSelection<any>, useRowSelectionTableCtl] => {
const { type = 'checkbox' } = options
const { type = 'checkbox', customKey = 'id' } = options
const [selectRow, setSelectRow] = useState<any[]>([]) // 模态框选择的行数据
const [selectedRowKeys, setSelectedRowKeys] = useState<any[]>(() => [])
......@@ -33,7 +34,7 @@ export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [Tab
const removeRows = (arr: any[]) => {
return selectRow.filter(v => {
const result = arr.find(item => item.id === v.id)
const result = arr.find(item => item[customKey] === v[customKey])
if (!result) {
return v
}
......@@ -54,9 +55,15 @@ export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [Tab
type,
// 为解决分页情况下, 保存多选的数据
onSelect: (record, selects, selectedRows, nativeEvent) => {
const findIds = selectedRowKeys.indexOf(record.id)
if (type === 'radio') {
// 单选情况下
setSelectedRowKeys([record[customKey]])
setSelectRow([record])
return ;
}
const findIds = selectedRowKeys.indexOf(record[customKey])
if (findIds === -1) {
mergeRowKeys(record.id)
mergeRowKeys(record[customKey])
mergeRow(record)
} else {
setSelectedRowKeys(selectedRowKeys.filter((_, i) => i !== findIds))
......@@ -66,10 +73,10 @@ export const useRowSelectionTable = (options: useRowSelectionOptions = {}): [Tab
onSelectAll: (selected, selectedRows, changeRows) => {
if (selected) {
setSelectedRowKeys(dupliArr([...selectedRowKeys, ...changeRows.map(v => v.id)]))
setSelectRow(mergeArrByKey(selectRow, changeRows, 'id'))
setSelectedRowKeys(dupliArr([...selectedRowKeys, ...changeRows.map(v => v[customKey])]))
setSelectRow(mergeArrByKey(selectRow, changeRows, customKey))
} else {
setSelectedRowKeys(removeRowsKeys(changeRows.map(v => v.id)))
setSelectedRowKeys(removeRowsKeys(changeRows.map(v => v[customKey])))
setSelectRow(removeRows(changeRows))
}
}
......
......@@ -7,14 +7,16 @@ import {ColumnType} from 'antd/lib/table/interface'
import EyePreview from '@/components/EyePreview'
import {createFormActions,ISchema} from '@formily/antd'
import PayForm from '../components/PayForm'
import ModalTable from '@/components/ModalTable'
import {useInitValue} from '@/formSchema/effects/useInitValue'
import {strategyDetailTab} from '../schema'
import {usePageStatus} from '@/hooks/usePageStatus'
import {usePageStatus, PageStatus} 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'
import style from './index.less'
const payActions = createFormActions()
const fetchMemberList = async (params) => {
const res = await PublicApi.getMemberMaintenancePage(params)
......@@ -25,7 +27,10 @@ const PaySetting: React.FC<{}> = () => {
const ref = useRef<any>({})
const [visible, setvisible] = useState<boolean>(false)
const [visibleChannelMember, setVisibleChannelMember] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable()
const [searchParams, setsearchParams] = useState({
memberName: ''
})
const [memberRowSelection, memberRowCtl] = useRowSelectionTable({customKey:'memberId'})
const [optionType, setoptionType] = useState(0)
const {preview,pageStatus} = usePageStatus()
// const initValue = useInitValue(PublicApi.getPayPayMemberTacticsDetails)
......@@ -58,7 +63,7 @@ const PaySetting: React.FC<{}> = () => {
title: '会员等级',
dataIndex: 'levelTag',
align: 'center',
key: 'levelTag',
key: 'levelTag'
}
]
const [infoData, setinfoData] = useState<any>(
......@@ -116,16 +121,16 @@ const PaySetting: React.FC<{}> = () => {
const value = payActions.getFieldValue('applyMember')
payActions.setFieldValue('applyMember', findItemAndDelete(value, id))
}
const tableAddButton = <Button style={{marginBottom: 16}} block icon={<PlusOutlined/>} onClick={() =>handleAddMemberBtn()} type='dashed'>选择指定会员</Button>
const tableAddButton = <Button style={{marginBottom: 16}} disabled={pageStatus === PageStatus.PREVIEW} block icon={<PlusOutlined/>} onClick={() =>handleAddMemberBtn()} type='dashed'>选择指定会员</Button>
const tableColumns = [
{ dataIndex: 'memberId', title: 'ID', align: 'center' },
{ dataIndex: 'name', title: '会员名称',key:'name', align: 'center' },
{ dataIndex: 'memberTypeName', key:'memberTypeName',align: 'center', title: '会员类型', render: (_, record) => <EyePreview url={`/memberCenter/memberAbility/manage/addMember?id=${record.memberId}&preview=1`}>{_}</EyePreview> },
{ dataIndex: 'name', title: '会员名称',key:'name', align: 'left', render: (_, record) => <EyePreview url={`?id=${record.memberId}&preview=1`}>{_}</EyePreview> },
{ dataIndex: 'memberTypeName', key:'memberTypeName',align: 'center', title: '会员类型'},
{ dataIndex: 'roleName', key:'roleName',title: '会员角色', align: 'center' },
{ dataIndex: 'levelTag', key:'levelTag',title: '会员等级', align: 'center' },
{ dataIndex: 'ctl', title: '操作', align: 'center', render: (_, record) =>
<>
<Button type='link' onClick={() => handleDeleteTable(record.id)}>删除</Button>
<Button disabled={pageStatus === PageStatus.PREVIEW} type='link' onClick={() => handleDeleteTable(record.id)}>删除</Button>
</>
}
......@@ -141,8 +146,15 @@ const PaySetting: React.FC<{}> = () => {
payActions.setFieldValue(`ruleConfigurationId-${index}`,item.ruleConfigurationId)
payActions.setFieldValue(`payWayIds-${index}`,item.payWayIds)
})
payActions.setFieldValue('isSelected',data.isSelected)
// payActions.setFieldValue('applyMember', data.memberIds)
payActions.setFieldValue('isSelected',data.isSelected )
}
})
PublicApi.getPayApplyMemberList({id: usePageStatus().id,
...searchParams,current:1,pageSize: 10000
}).then(res => {
if(res.code === 1000){
let {data} = res.data
payActions.setFieldValue('applyMember', data)
}
})
......@@ -227,23 +239,21 @@ const PaySetting: React.FC<{}> = () => {
tableColumns,
tableAddButton
}}
// editable={usePageStatus().pageStatus === 2 ?false: true}
editable={pageStatus !== PageStatus.PREVIEW}
onSubmit={handleSubmit}
actions={payActions}
schema={strategyDetailTab(infoData,usePageStatus)}
/>
</Card>
<Modal
width={704}
title='选择适用会员'
onOk={handleOkAddMember}
onCancel={handleCancelAddMember}
visible={visible}
>
<StandardTable
<ModalTable
modalTitle='选择适用会员'
confirm={handleOkAddMember}
cancel={handleCancelAddMember}
visible={visible}
columns={columnsSetMember}
rowSelection={memberRowSelection}
fetchTableData={params => fetchMemberList(params)}
formilyProps={
{
ctx: { schema: formSearch }
......@@ -252,9 +262,7 @@ const PaySetting: React.FC<{}> = () => {
tableProps={{
rowKey: 'memberId'
}}
>
</StandardTable>
</Modal>
/>
</PageHeaderWrapper>
)
}
......
.levelIcon1 {
width: 100%;
height: 20px;
background: url("/static/imgs/vip1@2x.png") no-repeat center;
background-size: 24px 20px;
}
.levelIcon2 {
width: 100%;
height: 20px;
background: url("/static/imgs/vip2@2x.png") no-repeat center;
background-size: 24px 20px;
}
.levelIcon3 {
width: 100%;
height: 20px;
background: url("/static/imgs/vip3@2x.png") no-repeat center;
background-size: 24px 20px;
}
.levelIcon4 {
width: 100%;
height: 20px;
background: url("/static/imgs/vip4@2x.png") no-repeat center;
background-size: 24px 20px;
}
.levelIcon1 {
width : 100%;
height : 20px;
background : url("/static/imgs/vip1@2x.png") no-repeat center;
background-size: 24px 20px;
}
.levelIcon2 {
width : 100%;
height : 20px;
background : url("/static/imgs/vip2@2x.png") no-repeat center;
background-size: 24px 20px;
}
.levelIcon3 {
width : 100%;
height : 20px;
background : url("/static/imgs/vip3@2x.png") no-repeat center;
background-size: 24px 20px;
}
.levelIcon4 {
width : 100%;
height : 20px;
background : url("/static/imgs/vip4@2x.png") no-repeat center;
background-size: 24px 20px;
}
......@@ -2,7 +2,7 @@
* @Author: LeeJiancong
* @Date: 2020-08-06 19:07:32
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-08-11 16:19:10
* @LastEditTime: 2020-08-18 10:05:03
*/
import React, { useEffect,useState, useRef } from 'react';
import {Card,Row,Col,Space,Button,Popconfirm} from 'antd'
......@@ -146,7 +146,10 @@ const List: React.FC<{}> = () => {
properties: {
name: {
type: 'string',
"x-component": 'search'
"x-component": 'search',
"x-component-props":{
placeholder:'输入策略名称'
}
}
}
}
......
......@@ -2,13 +2,14 @@
* @Author: LeeJiancong
* @Date: 2020-08-06 11:12:18
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-08-12 20:32:03
* @LastEditTime: 2020-08-18 15:21:25
*/
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'
import { json } from 'express'
let payType = ['', '线上支付', '线下支付', '授信额度支付', '货到付款支付']
let currentTab;
......@@ -17,8 +18,9 @@ export const strategyDetailTab = (props: any, usePageStatus: any) => {
//新增时候就初始化
let baseList: any = GlobalConfig.payConfig.payInitializeConfig
console.log('baseList', baseList)
console.log('baseList', JSON.stringify(baseList))
// baseList[2].ruleConfigurations = [{value:1,label:"1",platformType:1}]
let tabItem = {}, Tab1 = {}, arr = []
baseList.map((item, index) => {
Tab1[`MEGA_LAYOUT_LINE${index}`] = {
......@@ -36,14 +38,14 @@ export const strategyDetailTab = (props: any, usePageStatus: any) => {
properties: {
[`ruleConfigurationId-${index}`]: {
type: 'string',
enum: item.ruleConfigurations,
enum: item.ruleConfigurations || [],
'x-component-props': {
},
required: true,
},
[`payWayIds-${index}`]: {
type: 'array:number',
enum: item.payWayResponses,
enum: item.payWayResponses || [],
"x-component": 'checkbox',
'x-component-props': {
},
......@@ -101,7 +103,8 @@ export const strategyDetailTab = (props: any, usePageStatus: any) => {
required: true,
title: '策略名称',
'x-component-props': {
placeholder: '请输入策略名称',
max:24,
placeholder: '平台代收模式-线上支付+线下支付方式',
},
},
...Tab1
......@@ -149,7 +152,11 @@ export const strategyDetailTab = (props: any, usePageStatus: any) => {
"x-component-props": {
rowKey: 'memberId',
columns: "{{tableColumns}}",
prefix: "{{tableAddButton}}"
prefix: "{{tableAddButton}}",
onChange:(val) => {
console.log(val)
}
}
}
}
......
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