Commit e8ab40bf authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix:交易规则配置

parent 694c827a
...@@ -17,6 +17,8 @@ import RuleSetting from './components/RuleSetting' ...@@ -17,6 +17,8 @@ import RuleSetting from './components/RuleSetting'
const addSchemaAction = createFormActions() const addSchemaAction = createFormActions()
const AddRule:React.FC<{}> = (props) => { const AddRule:React.FC<{}> = (props) => {
const [isDisabled, setIsDisabled] = useState<boolean>(false)
const { const {
id, id,
preview, preview,
...@@ -25,13 +27,19 @@ const AddRule:React.FC<{}> = (props) => { ...@@ -25,13 +27,19 @@ const AddRule:React.FC<{}> = (props) => {
// 整体表单提交 // 整体表单提交
const formSubmit = async (values) => { const formSubmit = async (values) => {
setIsDisabled(true)
const params = omit(values, ['state']) const params = omit(values, ['state'])
console.log(values, params, 'values') let res: any = {}
if(pageStatus === PageStatus.EDIT){
res = await PublicApi.postOrderTradingRulesBackgroundUpdata(params)
}else if(pageStatus === PageStatus.ADD){
res = await PublicApi.postOrderTradingRulesBackgroundAdd(params)
}
await PublicApi.postOrderTradingRulesBackgroundAdd(params) if(res.code === 1000){
setTimeout(() => { setIsDisabled(false)
history.goBack(-1) history.goBack(-1)
}, 1000) }
} }
return ( return (
...@@ -41,7 +49,13 @@ const AddRule:React.FC<{}> = (props) => { ...@@ -41,7 +49,13 @@ const AddRule:React.FC<{}> = (props) => {
title={pageStatus === PageStatus.PREVIEW ? '查看交易规则' : ( pageStatus === PageStatus.EDIT ? '编辑交易规则' : '新增交易规则' )} title={pageStatus === PageStatus.PREVIEW ? '查看交易规则' : ( pageStatus === PageStatus.EDIT ? '编辑交易规则' : '新增交易规则' )}
className="addRule" className="addRule"
extra={[ extra={[
<Button key="1" onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}> <Button
key="1"
onClick={() => addSchemaAction.submit()}
type="primary"
icon={<SaveOutlined />}
disabled={isDisabled}
>
保存 保存
</Button>, </Button>,
]} ]}
......
import React, {useState} from 'react' import React, {useEffect, useState} from 'react'
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus' import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import { useInitValue } from '@/formSchema/effects/useInitValue' import { useInitValue } from '@/formSchema/effects/useInitValue'
import EyePreview from '@/components/EyePreview' import EyePreview from '@/components/EyePreview'
...@@ -35,6 +35,8 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -35,6 +35,8 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const { addSchemaAction, schema, formSubmit, onFieldChange = () => {} } = props const { addSchemaAction, schema, formSubmit, onFieldChange = () => {} } = props
const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false) const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false)
const [memberRowSelection, memberRowCtl] = useRowSelectionTable({customKey: 'memberId'}) const [memberRowSelection, memberRowCtl] = useRowSelectionTable({customKey: 'memberId'})
const [initValue, setInitialValue] = useState({})
const [membersLength, setMembersLength] = useState(0)
const { const {
id, id,
...@@ -42,15 +44,8 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -42,15 +44,8 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
pageStatus pageStatus
} = usePageStatus() } = usePageStatus()
const initValue = useInitValue(PublicApi.getWarehouseFreightSpaceDetails) const fetchMembersList = async (params) => {
useUnitPreview(initValue, addSchemaAction) const res = await PublicApi.getMemberManageAllProviderPage(params)
const fetchProductList = async (params) => {
const tradingRulesId = addSchemaAction.getFieldValue('transactionProcesssId')
const res = await PublicApi.getOrderTradingRulesProductList({
...params,
tradingRulesId,
})
return res.data return res.data
} }
...@@ -61,11 +56,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -61,11 +56,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
} }
const handleAddMemberBtn = () => { const handleAddMemberBtn = () => {
// const transactionProcesss = addSchemaAction.getFieldValue('transactionProcesssId')
// if (!transactionProcesss) {
// message.error('请先选择交易流程')
// return false
// }
const checkBoxs = addSchemaAction.getFieldValue('memberIds') const checkBoxs = addSchemaAction.getFieldValue('memberIds')
memberRowCtl.setSelectedRowKeys(checkBoxs.map(v => v.productId)) memberRowCtl.setSelectedRowKeys(checkBoxs.map(v => v.productId))
memberRowCtl.setSelectRow(checkBoxs) memberRowCtl.setSelectRow(checkBoxs)
...@@ -77,31 +67,31 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -77,31 +67,31 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const tableColumns = [ const tableColumns = [
{ {
dataIndex: 'id', dataIndex: 'memberId',
title: 'ID', title: 'ID',
key: 'id' key: 'memberId'
}, },
{ {
dataIndex: 'name', dataIndex: 'memberName',
title: '会员名称', title: '会员名称',
key: 'name', key: 'memberName',
render: (_, record) => <EyePreview url={`/memberCenter/commodityAbility/commodity/products/viewProducts?id=${record.id}`}>{_}</EyePreview> // render: (_, record) => <EyePreview url={`/memberCenter/commodityAbility/commodity/products/viewProducts?id=${record.id}`}>{_}</EyePreview>
}, },
{ {
dataIndex: 'type', dataIndex: 'memberTypeName',
title: '会员类型', title: '会员类型',
key: 'type' key: 'memberTypeName'
}, },
{ {
dataIndex: 'role', dataIndex: 'roleName',
title: '会员角色', title: '会员角色',
key: 'role' key: 'roleName'
}, },
{ {
dataIndex: 'class', dataIndex: 'levelTag',
title: '会员等级', title: '会员等级',
key: 'class', key: 'levelTag',
render: (text, record) => <LevelBrand level={3} /> render: (text, record) => <LevelBrand level={record.level} />
}, },
{ {
dataIndex: 'ctl', dataIndex: 'ctl',
...@@ -127,9 +117,9 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -127,9 +117,9 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const columnsSetProduct: any[] = [ const columnsSetProduct: any[] = [
{ {
dataIndex: 'id', dataIndex: 'memberId',
title: 'ID', title: 'ID',
key: 'id' key: 'memberId'
}, },
{ {
dataIndex: 'name', dataIndex: 'name',
...@@ -137,20 +127,20 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -137,20 +127,20 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
key: 'name' key: 'name'
}, },
{ {
dataIndex: 'type', dataIndex: 'memberTypeName',
title: '会员类型', title: '会员类型',
key: 'type' key: 'memberTypeName'
}, },
{ {
dataIndex: 'role', dataIndex: 'roleName',
title: '会员角色', title: '会员角色',
key: 'role' key: 'roleName'
}, },
{ {
dataIndex: 'class', dataIndex: 'levelTag',
title: '会员等级', title: '会员等级',
key: 'class', key: 'levelTag',
render: (text, record) => <LevelBrand level={3} /> render: (text, record) => <LevelBrand level={record.level} />
}, },
] ]
...@@ -228,7 +218,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -228,7 +218,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
// 会员弹框筛选select值 // 会员弹框筛选select值
const fetchSelectOptions = async () => { const fetchSelectOptions = async () => {
const res = await PublicApi.getMemberManagePageitems() const res = await PublicApi.getMemberManagePageitems()
if (res.code === 1000) { if (res.code === 1000) {
const { data = {} }: any = res const { data = {} }: any = res
const { const {
...@@ -246,6 +235,38 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -246,6 +235,38 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
return {} return {}
} }
useEffect(() => {
async function getInitValue() {
const { data } = await PublicApi.getOrderTradingRulesBackgroundDetails({id: id});
if(data.isTacitlyApprove === 2) {
const res = await getBindingMembers({id: id.toString(), current: '1', pageSize: '10'})
addSchemaAction.setFieldState('memberIds', (state) => {
state.value = res.data
})
setMembersLength(res.totalCount);
}
console.log(data, 'data')
addSchemaAction.setFieldValue('isTacitlyApprove', data.isTacitlyApprove === 1 ? 1 : 2)
setInitialValue(data)
}
if(id != '') {
getInitValue();
}
}, [id])
// 拿到绑定的会员
const getBindingMembers = async ({id = '1', current = '1', pageSize = '10'}) => {
const res = await PublicApi.getOrderTradingRulesBackgroundMember({id, current, pageSize})
return res.data
}
const paginationChange = async (page: number, size: number) => {
if(id !== '') {
const result = await getBindingMembers({id, current: page.toString(), pageSize: size.toString()})
addSchemaAction.setFieldValue('memberIds', result.data)
}
}
return ( return (
<> <>
<NiceForm <NiceForm
...@@ -255,6 +276,8 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -255,6 +276,8 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
expressionScope={{ expressionScope={{
tableColumns, tableColumns,
tableAddButton, tableAddButton,
paginationChange,
membersLength
}} }}
components={{ components={{
SelectProcesss, SelectProcesss,
...@@ -263,7 +286,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -263,7 +286,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
FormEffectHooks.onFormInputChange$().subscribe(() => { FormEffectHooks.onFormInputChange$().subscribe(() => {
onFieldChange() onFieldChange()
}) })
createAddContractTemplateEffect(addSchemaAction)
}} }}
onSubmit={handleSubmit} onSubmit={handleSubmit}
actions={addSchemaAction} actions={addSchemaAction}
...@@ -278,7 +300,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -278,7 +300,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
visible={visibleChannelRroduct} visible={visibleChannelRroduct}
columns={columnsSetProduct} columns={columnsSetProduct}
rowSelection={memberRowSelection} rowSelection={memberRowSelection}
fetchTableData={params => fetchProductList(params)} fetchTableData={params => fetchMembersList(params)}
formilyProps={ formilyProps={
{ {
ctx: { ctx: {
...@@ -301,13 +323,10 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => { ...@@ -301,13 +323,10 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
} }
tableProps={{ tableProps={{
rowKey: 'memberId', rowKey: 'memberId',
// pagination: { position: ['none', 'topRight'], size: 'small', simple: true, disabled: true}
// pagination: false
}} }}
/> />
</> </>
) )
} }
......
import React, { useState, useRef, useEffect } from 'react' import React, { useState, useRef, useEffect } from 'react'
import styled from 'styled-components' import styled from 'styled-components'
import { ISchemaFormProps, ISchemaFieldProps, ISchemaFieldComponentProps, createFormActions, useFieldState } from '@formily/antd' import { ISchemaFieldComponentProps, createFormActions, useFieldState } from '@formily/antd'
import { Button, Space, Row, Col, Tag } from 'antd' import { Row, Col, Tag } from 'antd'
import { PlusOutlined, DeleteColumnOutlined, EditOutlined, DeleteOutlined, CaretUpOutlined, CaretDownOutlined, EyeOutlined } from '@ant-design/icons' import { CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons'
import cx from 'classnames' import cx from 'classnames'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { findItemAndDelete } from '@/utils' import { findItemAndDelete } from '@/utils'
...@@ -63,7 +63,7 @@ const SelectProcesss = (props: ISchemaFieldComponentProps) => { ...@@ -63,7 +63,7 @@ const SelectProcesss = (props: ISchemaFieldComponentProps) => {
const value: number[] = props.value || [] const value: number[] = props.value || []
useEffect(() => { useEffect(() => {
PublicApi.getOrderTradingRulesTransactionProcessList().then(res => { PublicApi.getOrderProcessRuleConfigList().then(res => {
setFieldState({ setFieldState({
dataSource: res.data, dataSource: res.data,
showMore showMore
......
...@@ -19,10 +19,9 @@ const TransactionRules: React.FC<{}> = () => { ...@@ -19,10 +19,9 @@ const TransactionRules: React.FC<{}> = () => {
const ref = useRef<any>({}) const ref = useRef<any>({})
const fetchData = (params: any) => { const fetchData = (params: any) => {
console.log(params, 'params')
if(!params?.name) delete params.name if(!params?.name) delete params.name
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
PublicApi.getOrderTradingRulesList(params).then(res => { PublicApi.getOrderTradingRulesBackgroundList(params).then(res => {
const { data } = res const { data } = res
resolve(data) resolve(data)
}) })
...@@ -47,11 +46,11 @@ const TransactionRules: React.FC<{}> = () => { ...@@ -47,11 +46,11 @@ const TransactionRules: React.FC<{}> = () => {
{text} {text}
</EyePreview> </EyePreview>
}, },
{ // {
title: '交易流程名称', // title: '交易流程名称',
dataIndex: 'transactionProcess', // dataIndex: 'transactionProcess',
key: 'transactionProcess', // key: 'transactionProcess',
}, // },
{ {
title: '操作时间', title: '操作时间',
dataIndex: 'operationTime', dataIndex: 'operationTime',
...@@ -107,7 +106,7 @@ const TransactionRules: React.FC<{}> = () => { ...@@ -107,7 +106,7 @@ const TransactionRules: React.FC<{}> = () => {
]; ];
const confirm = (record: any) => { const confirm = (record: any) => {
PublicApi.postOrderTradingRulesUpdateState({ id: record.id, state: record.state ? 0 : 1 }).then(res => { PublicApi.postOrderTradingRulesBackgroundUpdateState({ id: record.id, state: record.state ? 0 : 1 }).then(res => {
ref.current.reload() ref.current.reload()
}) })
} }
...@@ -117,7 +116,7 @@ const TransactionRules: React.FC<{}> = () => { ...@@ -117,7 +116,7 @@ const TransactionRules: React.FC<{}> = () => {
} }
const handelDelete = (record: any) => { const handelDelete = (record: any) => {
PublicApi.postOrderTradingRulesDelete({ id: record.id }).then(res => { PublicApi.postOrderTradingRulesBackgroundDelete({ id: record.id }).then(res => {
if(res.code === 1000) if(res.code === 1000)
ref.current.reload() ref.current.reload()
}) })
......
...@@ -2,68 +2,67 @@ import React, {useState, useRef, useEffect} from 'react' ...@@ -2,68 +2,67 @@ import React, {useState, useRef, useEffect} from 'react'
import { history } from 'umi' import { history } from 'umi'
import { Space, Card, Col, Row, Table } from 'antd' import { Space, Card, Col, Row, Table } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout' import { PageHeaderWrapper } from '@ant-design/pro-layout'
import ReutrnEle from '@/components/ReturnEle'; import ReutrnEle from '@/components/ReturnEle'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import EyePreview from '@/components/EyePreview'; import EyePreview from '@/components/EyePreview'
import LevelBrand from '@/pages/member/components/LevelBrand'; import LevelBrand from '@/pages/member/components/LevelBrand'
import { GetOrderTradingRulesBackgroundDetailsResponse, GetOrderTradingRulesBackgroundMemberResponse } from '@/services/OrderApi'
import { StandardTable } from 'god'
const AddRule:React.FC<{}> = (props) => { const AddRule:React.FC<{}> = (props) => {
const [membersList, setMembersList] = useState<GetOrderTradingRulesBackgroundMemberResponse>()
const [ruleDetails, setRuleDetails] = useState<GetOrderTradingRulesBackgroundDetailsResponse>()
const { id } = history.location.query
useEffect(() => {
// 获取规则详情
PublicApi.getOrderTradingRulesBackgroundDetails({id, current: '1', pageSize: '10'}).then(res => {
const { data } = res
setRuleDetails(data)
})
}, [])
const fetchData = (params) => {
return new Promise((resolve, reject) => {
// 获取绑定的会员列表
PublicApi.getOrderTradingRulesBackgroundMember({id, ...params}).then(res => {
const { data } = res
resolve(data)
})
})
}
const tableColumns = [ const tableColumns = [
{ {
dataIndex: 'id', dataIndex: 'memberId',
title: 'ID', title: 'ID',
key: 'id' key: 'memberId'
}, },
{ {
dataIndex: 'name', dataIndex: 'memberName',
title: '会员名称', title: '会员名称',
key: 'name', key: 'memberName',
render: (_, record) => <EyePreview url={`/memberCenter/commodityAbility/commodity/products/viewProducts?id=${record.id}`}>{_}</EyePreview> // render: (_, record) => <EyePreview url={`/memberCenter/commodityAbility/commodity/products/viewProducts?id=${record.id}`}>{_}</EyePreview>
}, },
{ {
dataIndex: 'type', dataIndex: 'memberTypeName',
title: '会员类型', title: '会员类型',
key: 'type' key: 'memberTypeName'
}, },
{ {
dataIndex: 'role', dataIndex: 'roleName',
title: '会员角色', title: '会员角色',
key: 'role' key: 'roleName'
}, },
{ {
dataIndex: 'class', dataIndex: 'levelTag',
title: '会员等级', title: '会员等级',
key: 'class', key: 'levelTag',
render: (text, record) => <LevelBrand level={text} /> render: (text, record) => <LevelBrand level={record.level} />
}, },
] ]
const tableData = [
{
id: 2,
name: '土豪会员',
type: '大众会员',
role: '大众',
class: 2
},
{
id: 3,
name: '高级会员',
type: '一般会员',
role: '群众',
class: 4
},
{
id: 2,
name: '底层会员',
type: '一般会员',
role: '底层',
class: 1
}
]
return ( return (
<PageHeaderWrapper <PageHeaderWrapper
onBack={() => history.goBack()} onBack={() => history.goBack()}
...@@ -74,23 +73,44 @@ const AddRule:React.FC<{}> = (props) => { ...@@ -74,23 +73,44 @@ const AddRule:React.FC<{}> = (props) => {
<Card headStyle={{borderBottom:'none'}} title="基本信息"> <Card headStyle={{borderBottom:'none'}} title="基本信息">
<Row> <Row>
<Col span={3}> <Col span={3}>
<p>交易规则名称:</p> <p>流程规则名称:</p>
</Col> </Col>
<Col span={21}> <Col span={21}>
<p>B2B区府办鉴定报告</p> <p>{ruleDetails?.name}</p>
</Col> </Col>
<Col span={3}> <Col span={3}>
<p>交易流程名称</p> <p>状态</p>
</Col> </Col>
<Col span={21}> <Col span={21}>
<p>通我们的离开过</p> <p>{ruleDetails?.state ? '有效' : '无效'}</p>
</Col>
{/* <Col span={3}>
<p>交易流程名称:</p>
</Col> </Col>
<Col span={21}>
<p>
{
ruleDetails?.transactionProcesss.toString()
}
</p>
</Col> */}
</Row> </Row>
</Card> </Card>
</Space> </Space>
<Space direction="vertical" style={{width:'100%'}}> <Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title="适用会员"> <Card headStyle={{borderBottom:'none'}} title="适用会员">
<Table dataSource={tableData} columns={tableColumns} /> <Row>
<Col span={3}>
<p>是否所有会员共用:</p>
</Col>
<Col span={21}>
<p>{ruleDetails?.isTacitlyApprove === 1 ? '是' : '否'}</p>
</Col>
</Row>
<StandardTable
columns={tableColumns}
fetchTableData={(params: any) => fetchData(params)}
/>
</Card> </Card>
</Space> </Space>
</PageHeaderWrapper> </PageHeaderWrapper>
......
import React from 'react' import React from 'react'
import { ISchema } from '@formily/antd'; import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { GlobalConfig } from '@/global/config';
import { PublicApi } from '@/services/api';
import { SHOP_TYPES } from '@/constants';
import { padRequiredMessage } from '@/utils'; import { padRequiredMessage } from '@/utils';
...@@ -65,78 +61,14 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({ ...@@ -65,78 +61,14 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
"x-rules": [ "x-rules": [
{ {
required: true, required: true,
message: '请选择收货方式' message: '请选择流程配置'
} }
], ],
// required: true,
// "x-component": 'SearchSelect',
// "x-component-props": {
// placeholder: '请选择交易流程',
// className: 'fixed-ant-selected-down',
// fetchSearch: PublicApi.getOrderTradingRulesTransactionProcessList,
// }
}, },
// MEGA_LAYOUT1_1: {
// type: 'object',
// 'x-component': 'mega-layout',
// 'x-component-props': {
// label: '电子合同',
// wrapperCol: 24,
// },
// properties: {
// isElectronicContract: {
// type: 'string',
// "x-component-props": {
// children: "使用电子合同"
// },
// "x-component": "checkboxsingle",
// default: false
// },
// contractTemplateId: {
// type: 'string',
// required: true,
// enum: [],
// "x-component-props": {
// placeholder: '请选择电子合同模板'
// },
// visible: false
// }
// }
// }
} }
} }
} }
}, },
// "tab-2": {
// "type": "object",
// "x-component": "tabpane",
// "x-component-props": {
// "tab": "适用商城"
// },
// "properties": {
// MEGA_LAYOUT2: {
// type: 'object',
// "x-component": 'mega-layout',
// "x-component-props": {
// labelCol: 4,
// labelAlign: 'left'
// },
// properties: {
// "shopIds": {
// "type": "array:number",
// "x-component": 'CardCheckBox',
// "x-component-props": {
// dataSource: GlobalConfig.web.shopInfo
// },
// "title": "适用商城",
// required: true,
// }
// }
// }
// }
// },
"tab-2": { "tab-2": {
type: 'object', type: 'object',
"x-component": 'tabpane', "x-component": 'tabpane',
......
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