Commit 5bc4d6d2 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

Merge branch 'dev' into test

parents aea0a147 fb311c84
/*
* @Author: LeeJiancong
* @Date: 2020-08-19 15:25:54
* @LastEditors: LeeJiancong
* @Copyright: 1549414730@qq.com
* @LastEditTime: 2020-08-21 18:19:53
*/
import React, { useEffect, useState, useRef, Fragment } from 'react'
import { Card, Button, Tabs, Radio, Space, Row, Col, Table, Popconfirm, Input, Spin } from 'antd'
import { PlusOutlined, SaveOutlined } from '@ant-design/icons'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import EyePreview from '@/components/EyePreview'
import { createFormActions, FormEffectHooks, useFormEffects } from '@formily/antd'
import { GlobalConfig } from '@/global/config'
import { ColumnType } from 'antd/lib/table/interface'
import InitBase from '../components/initBase'
import SettingModal from '../components/settingModal'
import { PublicApi } from '@/services/api'
import { history } from 'umi'
import '../components/index.less'
const payActions = createFormActions()
const { TabPane } = Tabs
const { onFieldValueChange$ } = FormEffectHooks
const PaySetting: React.FC<{}> = () => {
const ref = useRef<any>({})
const [TabList, setTabList] = useState([])
const [mode, setmode] = useState<number>(0)
const [dataInfo, setdataInfo] = useState<any>({})
const [visible, setvisible] = useState<boolean>(false)
const [optionType, setoptionType] = useState(0)
const [isPitchOn, setisPitchOn] = useState<number>(0)
const [payParametersList, setpayParametersList] = useState<any>([])
const [payParametersListResponses, setpayParametersListResponses] = useState<any>([])
const [initialValues, setinitialValues] = useState({})
const [type, settype] = useState<any>(null)
const [hasEdit, sethasEdit] = useState<boolean>(false);
const [loading, setloading] = useState<boolean>(false);
/**
* @description: isSetting
* @param {type} 默认为已从pass平台为此账号配置好了策略
* @return {type}
*/
const [isSetting, setisSetting] = useState(true)
const [showInput, setshowInput] = useState(true) //是否显示授权
const [initParam, setinitParam] = useState({//授权参数
code: '',
value: '',
describe: ''
})
let [tabid, settabid] = useState<any>(null)//选项卡id
const [listID, setlistID] = useState(null)//表格id
let [tabOption, settabOption] = useState({
tab: 1,
type: 1
})
const handleAddMemberBtn = (id: string | number, type: number) => {
// console.log('id', id, 'type', type)
setmode(0)
settype(type)
setvisible(true)
setinitialValues({})
}
const handleEdit = (record: any, type: number | string, index: number) => {
setvisible(true)
setmode(1)//编辑还是新增
settype(type)
setlistID(record.id)
setinitialValues(record)
console.log('类型', type, '下标', index, 'record', record, 'listID:', listID)
}
//删除
const handleDeleteTable = (type: number, id: number, index) => {
let list: any = []
if (type === 1 || type === 3) {
list = [...payParametersListResponses]
list.splice(index, 1)
setpayParametersListResponses(list)
} else if (type === 2) {
list = [...payParametersList]
list.splice(index, 1)
setpayParametersList(list)
}
sethasEdit(true)
}
/**
* @description: 保存 编辑的时候遍历id是否一样 一样就替换
* @param {type} type: 1支付宝 2支付宝银行卡 3微信
* @return {type}
*/
const handleModalOK = (obj: any) => {
// console.log('选项卡:', tabid, '弹窗id:', type)
setvisible(false)
// console.log('选项卡:', tabid, '数据', obj,'mode:',mode)
if (mode === 0) {
if (type == 1 || type == 3) {
let list: any = []
obj.id = `obj-${payParametersListResponses.length}`
list.push(obj)
setpayParametersListResponses([...payParametersListResponses, ...list])
sethasEdit(true)
}
if (type == 2) {
let list: any = []
obj.id = `obj-${payParametersList.length}`
list.push(obj)
setpayParametersList([...payParametersList, ...list])
sethasEdit(true)
}
} else {
if (type == 1 || type == 3) {
let list = [...payParametersListResponses]
if (listID) {
list.forEach((v, i) => {
if (listID == v.id) {
list[i] = obj
}
})
}
setpayParametersListResponses([...list])
sethasEdit(true)
} else if (type == 2) {//支付宝银行卡
let list = [...payParametersList]
if (listID) {
list.forEach((v, i) => {
if (listID == v.id) {
list[i] = obj
}
})
}
setpayParametersList([...list])
sethasEdit(true)
}
}
}
const tableColumns: ColumnType<any>[] = [
{ dataIndex: 'code', title: '参数代码', align: 'center' },
{ dataIndex: 'value', align: 'center', title: '参数值' },
{ dataIndex: 'describe', title: '参数描述', align: 'center' },
{
dataIndex: 'ctl', title: '操作', align: 'center', render: (_, record, index) =>
<>
<Button type='link' onClick={() => handleEdit(record, record.type, index)}>编辑</Button>
<Button type='link' onClick={() => handleDeleteTable(record.type, record.id, index)}>删除</Button>
</>
}
]
//初始化
const initBase = async (id) => {
setloading(true)
await PublicApi.getPayMemberQueryPlatformIsStart({ id: id }).then(res => {
if (res.code === 1000) {
let data = { payParametersListResponses: [], payParametersList: [], isPitchOn: 0, id: '' }
if (JSON.stringify(res.data) !== '{}') {
console.log('加载到')
let { id, isPitchOn, payParametersList, payParametersListResponses } = res.data
setisPitchOn(isPitchOn)
if (id == 6) {
let { id, code, value, describe } = payParametersListResponses[0] || {}
setinitParam({ ...initParam, code, value, describe })
} else {
payParametersList = payParametersList ? payParametersList : []
payParametersListResponses = payParametersListResponses ? payParametersListResponses : []
setpayParametersList(payParametersList)
setpayParametersListResponses(payParametersListResponses)
}
}
setloading(false)
} else {
setisPitchOn(0);
setloading(false)
}
})
}
useEffect(() => {
PublicApi.getPayMemberPayConfig().then(res => {
if (res.code === 1000) {
let ids = res.data.map((v, i) => v.id)
setTabList(res.data)
if (ids.length > 0) {
settabid(ids[0])
initBase(ids[0])
}
} else {
setisSetting(false)
}
})
return () => {
}
}, [])
const useTabEffects = () => {
}
/**
* @description: 提交表单 保存
* @param {type}
* @return {type}
*/
const handleSubmit = () => {
let list: any = []
if (tabid == 1) {
list = [...payParametersList, ...payParametersListResponses]
} else if (tabid == 2) {
list = [...payParametersListResponses]
} else if (tabid == 6) {
list = [{
type: type,
code: initParam.code,
value: initParam.value,
describe: initParam.describe
}]
} else {
list = []
}
let payType = TabList.filter(v => v.id == tabid).map(v => v.payType)
let way: any = TabList.filter(v => v.id == tabid).map(v => v.way)
// if(list.length > 0){
// list.forEach((v:any) => {
// if((v.id).toString().indexOf('obj') !== -1){
// v.id = ''
// }
// });
// }
console.log('list', list)
PublicApi.postPayMemberQueryPlatformUpdate({
id: tabid,
isPitchOn: isPitchOn,
way: way.toString(),
payType: Number(payType),
payParametersAddListRequests: list
}).then(res => {
if (res.code === 1000) {
setTimeout(() => {
history.push('/memberCenter/payandSettle/paySetting/payParamsSetting')
}, 1500)
}
})
}
const changeTab = (tab) => {
settabid(tab)
if (tab == 6) {//授信
settype(tab)
}
if(!!isPitchOn) {
setshowInput(true)
}else {
setshowInput(false)
}
initBase(tab)
}
const changeRadio = (e) => {
setisPitchOn(e.target.value)
if (tabid == 6 && e.target.value) {
setshowInput(true)
} else {
setshowInput(false)
}
}
const options = [{ label: '是', value: 1 }, { label: '否', value: 0 }]
return (
<PageHeaderWrapper
extra={
hasEdit ?
<Popconfirm title="配置已修改,是否保存?" okText="是" cancelText="否" onConfirm={() =>
handleSubmit()
}>
<Button type="primary" icon={<SaveOutlined />} >
保存
</Button>
</Popconfirm>
:
<Button type="primary" onClick={() => handleSubmit()} icon={<SaveOutlined />} >
保存
</Button>
}
>
{
isSetting &&
<Card>
<Tabs onTabClick={(e) => changeTab(e)} type="card">
{
TabList.map((v, i) => {
return <Fragment key={v.id}>
<TabPane tab={`${v.way}`} key={v.id} forceRender>
<Spin spinning={loading}>
<Space size={49}>
<span>是否开启{v.way}</span>
<Radio.Group
className='radio-group-box'
size="small"
value={isPitchOn}
buttonStyle="solid"
options={options}
optionType="button"
onChange={value => changeRadio(value)} />
</Space>
{
(v.id === 1 || v.id === 2) &&
<Row>
<Col ><div style={{ borderLeft: '2px solid #00B37A', margin: '41px 0 8px', padding: '1px 5px' }}>{v.way}参数配置</div></Col>
<Col span={24}>
<Table dataSource={payParametersListResponses} columns={tableColumns} pagination={false} />
{
v.id == 1 ?
<Button style={{ marginBottom: 16, marginTop: 24 }} block icon={<PlusOutlined />} onClick={() => handleAddMemberBtn(`${v.id}`, 1)} type='dashed'>新增参数配置</Button>
:
<Button style={{ marginBottom: 16, marginTop: 24 }} block icon={<PlusOutlined />} onClick={() => handleAddMemberBtn(`${v.id}`, 3)} type='dashed'>新增参数配置</Button>
}
</Col>
</Row>
}
{
v.id === 1 &&
<Row>
<Col ><div style={{ borderLeft: '2px solid #00B37A', margin: '41px 0 8px', padding: '1px 5px' }}>{v.way}转账到银行卡参数配置</div></Col>
<Col span={24}>
<Table dataSource={payParametersList} columns={tableColumns} pagination={false} />
<Button style={{ marginBottom: 16, marginTop: 24 }} block icon={<PlusOutlined />} onClick={() => handleAddMemberBtn(`${v.id}`, 2)} type='dashed'>新增参数配置</Button>
</Col>
</Row>
}
{
(v.id === 6 && showInput) &&
<div style={{ marginTop: 42 }}>
<Space direction="horizontal" size={16}>
初始申请额度不超过
<Input value={initParam.code} addonBefore="¥" onChange={e => setinitParam({ ...initParam, code: e.target.value })} />
允许满<Input value={initParam.value} onChange={e => setinitParam({ ...initParam, value: e.target.value })} />
天后申请上调<Input value={initParam.describe} addonAfter="%" onChange={e => setinitParam({ ...initParam, describe: e.target.value })} />
</Space>
</div>
}
</Spin>
</TabPane>
</Fragment>
})
}
</Tabs>
<SettingModal
mode={mode}
id={listID}
type={type}
dialogVisible={visible}
initialValues={initialValues}
onCancel={() => setvisible(false)}
onOK={(list) => handleModalOK(list)}
/>
</Card>
}
{
isSetting === false &&
<InitBase />
}
</PageHeaderWrapper>
)
}
export default PaySetting
\ No newline at end of file
/*
* @Author: LeeJiancong
* @Date: 2020-08-19 15:25:54
* @LastEditors: LeeJiancong
* @Copyright: 1549414730@qq.com
* @LastEditTime: 2020-08-21 18:19:53
*/
import React, { useEffect, useState, useRef, Fragment } from 'react'
import { Card, Button, Tabs, Radio, Space, Row, Col, Table, Popconfirm, Input, Spin } from 'antd'
import { PlusOutlined, SaveOutlined } from '@ant-design/icons'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import EyePreview from '@/components/EyePreview'
import { createFormActions, FormEffectHooks, useFormEffects } from '@formily/antd'
import { GlobalConfig } from '@/global/config'
import { ColumnType } from 'antd/lib/table/interface'
import InitBase from '../components/initBase'
import SettingModal from '../components/settingModal'
import { PublicApi } from '@/services/api'
import { history } from 'umi'
import '../components/index.less'
const payActions = createFormActions()
const { TabPane } = Tabs
const { onFieldValueChange$ } = FormEffectHooks
const PaySetting: React.FC<{}> = () => {
const ref = useRef<any>({})
const [TabList, setTabList] = useState([])
const [mode, setmode] = useState<number>(0)
const [dataInfo, setdataInfo] = useState<any>({})
const [visible, setvisible] = useState<boolean>(false)
const [optionType, setoptionType] = useState(0)
const [isPitchOn, setisPitchOn] = useState<number>(0)
const [payParametersList, setpayParametersList] = useState<any>([])
const [payParametersListResponses, setpayParametersListResponses] = useState<any>([])
const [initialValues, setinitialValues] = useState({})
const [type, settype] = useState<any>(null)
const [hasEdit, sethasEdit] = useState<boolean>(false);
const [loading, setloading] = useState<boolean>(false);
/**
* @description: isSetting
* @param {type} 默认为已从pass平台为此账号配置好了策略
* @return {type}
*/
const [isSetting, setisSetting] = useState(true)
const [showInput, setshowInput] = useState(true) //是否显示授权
const [initParam, setinitParam] = useState({//授权参数
code: '',
value: '',
describe: ''
})
let [tabid, settabid] = useState<any>(null)//选项卡id
const [listID, setlistID] = useState(null)//表格id
let [tabOption, settabOption] = useState({
tab: 1,
type: 1
})
const handleAddMemberBtn = (id: string | number, type: number) => {
// console.log('id', id, 'type', type)
setmode(0)
settype(type)
setvisible(true)
setinitialValues({})
}
const handleEdit = (record: any, type: number | string, index: number) => {
setvisible(true)
setmode(1)//编辑还是新增
settype(type)
setlistID(record.id)
setinitialValues(record)
console.log('类型', type, '下标', index, 'record', record, 'listID:', listID)
}
//删除
const handleDeleteTable = (type: number, id: number, index) => {
let list: any = []
if (type === 1 || type === 3) {
list = [...payParametersListResponses]
list.splice(index, 1)
setpayParametersListResponses(list)
} else if (type === 2) {
list = [...payParametersList]
list.splice(index, 1)
setpayParametersList(list)
}
sethasEdit(true)
}
/**
* @description: 保存 编辑的时候遍历id是否一样 一样就替换
* @param {type} type: 1支付宝 2支付宝银行卡 3微信
* @return {type}
*/
const handleModalOK = (obj: any) => {
// console.log('选项卡:', tabid, '弹窗id:', type)
setvisible(false)
// console.log('选项卡:', tabid, '数据', obj,'mode:',mode)
if (mode === 0) {
if (type == 1 || type == 3) {
let list: any = []
obj.id = `obj-${payParametersListResponses.length}`
list.push(obj)
setpayParametersListResponses([...payParametersListResponses, ...list])
sethasEdit(true)
}
if (type == 2) {
let list: any = []
obj.id = `obj-${payParametersList.length}`
list.push(obj)
setpayParametersList([...payParametersList, ...list])
sethasEdit(true)
}
} else {
if (type == 1 || type == 3) {
let list = [...payParametersListResponses]
if (listID) {
list.forEach((v, i) => {
if (listID == v.id) {
list[i] = obj
}
})
}
setpayParametersListResponses([...list])
sethasEdit(true)
} else if (type == 2) {//支付宝银行卡
let list = [...payParametersList]
if (listID) {
list.forEach((v, i) => {
if (listID == v.id) {
list[i] = obj
}
})
}
setpayParametersList([...list])
sethasEdit(true)
}
}
}
const tableColumns: ColumnType<any>[] = [
{ dataIndex: 'code', title: '参数代码', align: 'center' },
{ dataIndex: 'value', align: 'center', title: '参数值' },
{ dataIndex: 'describe', title: '参数描述', align: 'center' },
{
dataIndex: 'ctl', title: '操作', align: 'center', render: (_, record, index) =>
<>
<Button type='link' onClick={() => handleEdit(record, record.type, index)}>编辑</Button>
<Button type='link' onClick={() => handleDeleteTable(record.type, record.id, index)}>删除</Button>
</>
}
]
//初始化
const initBase = async (id) => {
setloading(true)
await PublicApi.getPayMemberQueryPlatformIsStart({ id: id }).then(res => {
if (res.code === 1000) {
let data = { payParametersListResponses: [], payParametersList: [], isPitchOn: 0, id: '' }
if (JSON.stringify(res.data) !== '{}') {
console.log('加载到')
let { id, isPitchOn, payParametersList, payParametersListResponses } = res.data
setisPitchOn(isPitchOn)
if (id == 6) {
let { id, code, value, describe } = payParametersListResponses[0] || {}
setinitParam({ ...initParam, code, value, describe })
} else {
payParametersList = payParametersList ? payParametersList : []
payParametersListResponses = payParametersListResponses ? payParametersListResponses : []
setpayParametersList(payParametersList)
setpayParametersListResponses(payParametersListResponses)
}
}
setloading(false)
} else {
setisPitchOn(0);
setloading(false)
}
})
}
useEffect(() => {
PublicApi.getPayMemberPayConfig().then(res => {
if (res.code === 1000) {
let ids = res.data.map((v, i) => v.id)
setTabList(res.data)
if (ids.length > 0) {
settabid(ids[0])
initBase(ids[0])
}
} else {
setisSetting(false)
}
})
return () => {
}
}, [])
const useTabEffects = () => {
}
/**
* @description: 提交表单 保存
* @param {type}
* @return {type}
*/
const handleSubmit = () => {
let list: any = []
if (tabid == 1) {
list = [...payParametersList, ...payParametersListResponses]
} else if (tabid == 2) {
list = [...payParametersListResponses]
} else if (tabid == 6) {
list = [{
type: type,
code: initParam.code,
value: initParam.value,
describe: initParam.describe
}]
} else {
list = []
}
let payType = TabList.filter(v => v.id == tabid).map(v => v.payType)
let way: any = TabList.filter(v => v.id == tabid).map(v => v.way)
// if(list.length > 0){
// list.forEach((v:any) => {
// if((v.id).toString().indexOf('obj') !== -1){
// v.id = ''
// }
// });
// }
console.log('list', list)
PublicApi.postPayMemberQueryPlatformUpdate({
platformPayWays:[
{
id: tabid,
isPitchOn: isPitchOn,
way: way.toString(),
payType: Number(payType),
payParametersAddListRequests: list
}
]
}).then(res => {
if (res.code === 1000) {
setTimeout(() => {
history.push('/memberCenter/payandSettle/paySetting/payParamsSetting')
}, 1500)
}
})
}
const changeTab = (tab) => {
settabid(tab)
if (tab == 6) {//授信
settype(tab)
}
if(!!isPitchOn) {
setshowInput(true)
}else {
setshowInput(false)
}
initBase(tab)
}
const changeRadio = (e) => {
setisPitchOn(e.target.value)
if (tabid == 6 && e.target.value) {
setshowInput(true)
} else {
setshowInput(false)
}
}
const options = [{ label: '是', value: 1 }, { label: '否', value: 0 }]
return (
<PageHeaderWrapper
extra={
hasEdit ?
<Popconfirm title="配置已修改,是否保存?" okText="是" cancelText="否" onConfirm={() =>
handleSubmit()
}>
<Button type="primary" icon={<SaveOutlined />} >
保存
</Button>
</Popconfirm>
:
<Button type="primary" onClick={() => handleSubmit()} icon={<SaveOutlined />} >
保存
</Button>
}
>
{
isSetting &&
<Card>
<Tabs onTabClick={(e) => changeTab(e)} type="card">
{
TabList.map((v, i) => {
return <Fragment key={v.id}>
<TabPane tab={`${v.way}`} key={v.id} forceRender>
<Spin spinning={loading}>
<Space size={49}>
<span>是否开启{v.way}</span>
<Radio.Group
className='radio-group-box'
size="small"
value={isPitchOn}
buttonStyle="solid"
options={options}
optionType="button"
onChange={value => changeRadio(value)} />
</Space>
{
(v.id === 1 || v.id === 2) &&
<Row>
<Col ><div style={{ borderLeft: '2px solid #00B37A', margin: '41px 0 8px', padding: '1px 5px' }}>{v.way}参数配置</div></Col>
<Col span={24}>
<Table dataSource={payParametersListResponses} columns={tableColumns} pagination={false} />
{
v.id == 1 ?
<Button style={{ marginBottom: 16, marginTop: 24 }} block icon={<PlusOutlined />} onClick={() => handleAddMemberBtn(`${v.id}`, 1)} type='dashed'>新增参数配置</Button>
:
<Button style={{ marginBottom: 16, marginTop: 24 }} block icon={<PlusOutlined />} onClick={() => handleAddMemberBtn(`${v.id}`, 3)} type='dashed'>新增参数配置</Button>
}
</Col>
</Row>
}
{
v.id === 1 &&
<Row>
<Col ><div style={{ borderLeft: '2px solid #00B37A', margin: '41px 0 8px', padding: '1px 5px' }}>{v.way}转账到银行卡参数配置</div></Col>
<Col span={24}>
<Table dataSource={payParametersList} columns={tableColumns} pagination={false} />
<Button style={{ marginBottom: 16, marginTop: 24 }} block icon={<PlusOutlined />} onClick={() => handleAddMemberBtn(`${v.id}`, 2)} type='dashed'>新增参数配置</Button>
</Col>
</Row>
}
{
(v.id === 6 && showInput) &&
<div style={{ marginTop: 42 }}>
<Space direction="horizontal" size={16}>
初始申请额度不超过
<Input value={initParam.code} addonBefore="¥" onChange={e => setinitParam({ ...initParam, code: e.target.value })} />
允许满<Input value={initParam.value} onChange={e => setinitParam({ ...initParam, value: e.target.value })} />
天后申请上调<Input value={initParam.describe} addonAfter="%" onChange={e => setinitParam({ ...initParam, describe: e.target.value })} />
</Space>
</div>
}
</Spin>
</TabPane>
</Fragment>
})
}
</Tabs>
<SettingModal
mode={mode}
id={listID}
type={type}
dialogVisible={visible}
initialValues={initialValues}
onCancel={() => setvisible(false)}
onOK={(list) => handleModalOK(list)}
/>
</Card>
}
{
isSetting === false &&
<InitBase />
}
</PageHeaderWrapper>
)
}
export default PaySetting
......@@ -6,8 +6,8 @@ import { PublicApi } from '@/services/api'
/**
* @description: 公用
* @param {type}
* @return {type}
* @param {type}
* @return {type}
*/
export const commonEnquieryOfferSchema: ISchema = {
type:'object',
......@@ -33,7 +33,7 @@ export const commonEnquieryOfferSchema: ISchema = {
},
"x-component-props":{
placeholder:'报价单搜索'
placeholder:'报价单'
}
}
}
......@@ -63,7 +63,7 @@ export const commonEnquieryOfferSchema: ISchema = {
inquiryListNo:{//需求单号
type:'string',
"x-mega-props":{
},
"x-component-props":{
placeholder:'询价单号'
......@@ -95,7 +95,7 @@ export const commonEnquieryOfferSchema: ISchema = {
sumbit:{
"x-component":'Submit',
"x-mega-props":{
span:1
span:1
},
"x-component-props":{
children:'查询'
......@@ -108,8 +108,8 @@ export const commonEnquieryOfferSchema: ISchema = {
/**
* @description: 需求报价-需求单查询
* @param {type}
* @return {type}
* @param {type}
* @return {type}
*/
export const enquierySearchSchema: ISchema = {
type:'object',
......@@ -207,8 +207,8 @@ export const enquierySearchSchema: ISchema = {
/**
* @description: 需求报价-报价查询
* @param {type}
* @return {type}
* @param {type}
* @return {type}
*/
export const enquieryOfferSearchSchema: ISchema = {
type:'object',
......@@ -293,8 +293,8 @@ export const enquieryOfferSearchSchema: ISchema = {
/**
* @description: 报价单新增编辑-需求单查询
* @param {type}
* @return {type}
* @param {type}
* @return {type}
*/
export const dialogEqformSearch: ISchema = {
type:'object',
......@@ -376,7 +376,7 @@ export const dialogEqformSearch: ISchema = {
}
/**
* @description: 报价单查询-搜索
* @param {type}
* @param {type}
* @return {type}
*/
export const quoteFormSearch: ISchema = {
......@@ -485,4 +485,4 @@ export const quoteFormSearch: ISchema = {
}
}
}
}
\ No newline at end of file
}
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