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

fix: 对接交易流程规则/采购流程规则

parent 410e36a0
......@@ -8,8 +8,8 @@ import {
import ReutrnEle from '@/components/ReturnEle';
import './index.less'
import { ruleDetailSchema } from './schema'
import { createFormActions, ISchema, FormEffectHooks } from '@formily/antd'
import { findItemAndDelete, omit } from '@/utils'
import { createFormActions } from '@formily/antd'
import { omit } from '@/utils'
import { PublicApi } from '@/services/api'
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import RuleSetting from './components/RuleSetting'
......@@ -28,22 +28,19 @@ const AddRule:React.FC<{}> = (props) => {
// 整体表单提交
const formSubmit = async (values) => {
setIsDisabled(true)
const params = omit(values, ['state']) // 移除不需要的字段
addSchemaAction.getFieldState('processEnumId', state => {
const process = state.dataSource.filter(item => item.id === params.processEnumId)[0]
params.type = process.type
params.processEnum = process.processEnum
params.processEnumId = process.id
})
const params = omit(values, ['status']) // 移除不需要的字段
let res: any = {}
if(pageStatus === PageStatus.EDIT){
res = await PublicApi.postManageRuleUpdate(params)
}else if(pageStatus === PageStatus.ADD){
res = await PublicApi.postManageRuleAdd(params)
if(pageStatus === PageStatus.EDIT) {
res = await PublicApi.postOrderPurchaseProcessUpdate(params)
} else if (pageStatus === PageStatus.ADD){
res = await PublicApi.postOrderPurchaseProcessCreate(params)
}
if(res.code === 1000) {
history.goBack(-1)
}
setIsDisabled(false)
history.goBack(-1)
}
return (
......
import React, {useEffect, useRef, useState} from 'react'
import React, {useEffect, useState} from 'react'
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import EyePreview from '@/components/EyePreview'
import { findItemAndDelete, formatTimeString } from '@/utils'
......@@ -11,7 +11,6 @@ import {
import { Button, message } from 'antd'
import NiceForm from '@/components/NiceForm'
import ModalTable from '@/components/ModalTable'
import { GlobalConfig } from '@/global/config'
import { FORM_FILTER_PATH } from '@/formSchema/const'
import SearchSelect from '@/components/NiceForm/components/SearchSelect'
import Search from '@/components/NiceForm/components/Search'
......@@ -32,7 +31,6 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const [productRowSelection, productRowCtl] = useRowSelectionTable({customKey: 'id'})
const [productsLength, setProductsLength] = useState(0)
const [initValue, setInitialValue] = useState({})
const [idNotInList, setIdNotInList] = useState([])
const {
id,
......@@ -52,14 +50,14 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
// table删除合同
const handleDeleteTable = (id) => {
const value = addSchemaAction.getFieldValue('ruleContracts')
addSchemaAction.setFieldValue('ruleContracts', findItemAndDelete(value, id))
const value = addSchemaAction.getFieldValue('contracts')
addSchemaAction.setFieldValue('contracts', findItemAndDelete(value, id, 'contractId'))
}
const handleAddBtn = () => {
const checkBoxs = addSchemaAction.getFieldValue('ruleContracts')
productRowCtl.setSelectedRowKeys(checkBoxs.map(v => v.id))
productRowCtl.setSelectRow(checkBoxs)
const checkBoxs = addSchemaAction.getFieldValue('contracts')
productRowCtl.setSelectedRowKeys(checkBoxs.map(v => v.contractId))
productRowCtl.setSelectRow(processFields(checkBoxs, true))
setVisibleChannelRroduct(true)
}
......@@ -69,45 +67,45 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const tableColumns = [
{
dataIndex: 'id',
dataIndex: 'contractId',
title: 'ID',
key: 'id',
key: 'contractId',
className: 'commonHide',
},
{
dataIndex: 'contractNo',
title: '合同编号',
key: 'contractNo',
render: (_, record) => <EyePreview url={`/memberCenter/contract/manage/QueryList/QueryListdetails?contractId=${record.id}`}>{_}</EyePreview>
render: (_, record) => <EyePreview url={`/memberCenter/contract/manage/QueryList/QueryListdetails?contractId=${record.contractId}`}>{_}</EyePreview>
},
{
dataIndex: 'contractAbstract',
dataIndex: 'digest',
title: '合同摘要',
key: 'contractAbstract',
key: 'digest',
},
{
dataIndex: 'startTime',
dataIndex: 'effectTime',
title: '合同生效/失效时间',
key: 'startTime',
render: (t, r) => <>
<div>{t}</div>
<div>{r.endTime}</div>
<div>{r.expireTime}</div>
</>
},
{
dataIndex: 'partyBName',
dataIndex: 'partyB',
title: '合同乙方',
key: 'partyBName'
key: 'partyB'
},
{
dataIndex: 'sourceNo',
dataIndex: 'receiptNo',
title: '对应单据',
key: 'sourceNo'
key: 'receiptNo'
},
{
dataIndex: 'sourceType',
dataIndex: 'contractType',
title: '寻源类型',
key: 'sourceType',
key: 'contractType',
render: (text:any, reocrd:any)=>{
if(text===1)
return '采购询价'
......@@ -120,7 +118,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
{
dataIndex: 'ctl',
title: '操作',
render: (_, record) => <Button type='link' disabled={pageStatus === PageStatus.PREVIEW} onClick={() => handleDeleteTable(record.id)}>删除</Button>
render: (_, record) => <Button type='link' disabled={pageStatus === PageStatus.PREVIEW} onClick={() => handleDeleteTable(record.contractId)}>删除</Button>
}
]
......@@ -129,10 +127,34 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
formSubmit && formSubmit(values)
}
const processFields = (contractLists, render) => {
return render ? contractLists.map((item) => ({
id: item['contractId'],
contractNo: item['contractNo'],
contractAbstract: item['digest'],
startTime: item['effectTime'],
endTime: item['expireTime'],
partyBName: item['partyB'],
freeAmount: item['amount'],
sourceType: item['contractType'],
sourceNo: item['receiptNo'],
})) : contractLists.map((item) => ({
contractId: item['id'],
contractNo: item['contractNo'],
digest: item['contractAbstract'],
effectTime: item['startTime'],
expireTime: item['endTime'],
partyB: item['partyBName'],
amount: item['freeAmount'],
contractType: item['sourceType'],
receiptNo: item['sourceNo'],
}))
}
const handleOkAdd = async () => {
setVisibleChannelRroduct(false)
setProductsLength(productRowCtl.selectRow.length);
addSchemaAction.setFieldValue('ruleContracts', productRowCtl.selectRow)
addSchemaAction.setFieldValue('contracts', processFields(productRowCtl.selectRow, false))
clearModalParams()
}
......@@ -160,9 +182,9 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
key: 'contractNo'
},
{
dataIndex: 'contractAbstract',
dataIndex: 'digest',
title: '合同摘要',
key: 'contractAbstract'
key: 'digest'
},
{
dataIndex: 'startTime',
......@@ -260,15 +282,15 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
useEffect(() => {
async function getInitValue() {
const { data } = await PublicApi.getManageRuleDetails({id: id, current: '1', pageSize: '1000', contractAbstract: ''})
if(!data.isApplyContract) {
const res = await getBindingContracts({id: id.toString(), current: '1', pageSize: '1000', contractAbstract: ''})
addSchemaAction.setFieldState('ruleContracts', state => {
state.value = res.data
const { data } = await PublicApi.getOrderPurchaseProcessGet({processId: id})
if(!data.allContracts) {
const res = await getBindingContracts({id: id.toString(), current: '1', pageSize: '1000', digest: ''})
addSchemaAction.setFieldState('contracts', state => {
state.value = processFields(res.data, false)
})
setProductsLength(res.totalCount)
}
addSchemaAction.setFieldValue('isApplyContract', data.isApplyContract === 1 ? 1 : 0)
addSchemaAction.setFieldValue('allContracts', data.allContracts)
setInitialValue(data)
}
if(id != '') {
......@@ -277,15 +299,15 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
}, [id])
// 拿到绑定的合同
const getBindingContracts = async ({id = '1', current = '1', pageSize = '10', contractAbstract = ''}) => {
const res = await PublicApi.getManageRuleContractList({id, current, pageSize, contractAbstract});
const getBindingContracts = async ({id = '1', current = '1', pageSize = '10', digest = ''}) => {
const res = await PublicApi.getOrderPurchaseProcessContractPage({processId: id, current, pageSize, digest});
return res.data
}
const paginationChange = async (page: number, size: number) => {
if(id !== '') {
const result = await getBindingContracts({id, current: page.toString(), pageSize: size.toString()})
addSchemaAction.setFieldValue('ruleContracts', result.data)
addSchemaAction.setFieldValue('contracts', result.data)
}
}
......
......@@ -48,7 +48,8 @@ enum ProcessTagType {
'售后换货流程',
'售后退货流程',
'售后维修流程',
'加工生产流程'
'加工生产流程',
'直发客户自动二次发货'
}
const SelectProcesss = (props: ISchemaFieldComponentProps) => {
......@@ -61,7 +62,7 @@ const SelectProcesss = (props: ISchemaFieldComponentProps) => {
const { value, mutators, editable } = props
useEffect(() => {
PublicApi.getManagePurchaseProcesByMember().then(res => {
PublicApi.getOrderTradeProcessBaseList().then(res => {
setFieldState({
dataSource: res.data,
showMore
......@@ -85,8 +86,8 @@ const SelectProcesss = (props: ISchemaFieldComponentProps) => {
}
const renderProcessType = (v: any) => {
return <Tag color={ProcessTagColor[v.type - 1]}>
{ProcessTagType[v.type - 1]}
return <Tag color={ProcessTagColor[v.processType - 1]}>
{ProcessTagType[v.processType - 1]}
</Tag>
}
......@@ -94,7 +95,7 @@ const SelectProcesss = (props: ISchemaFieldComponentProps) => {
<div style={{ width: '100%' }}>
<SelectStyles>
{
showDataSource.map(v => <div key={v.id} onClick={() => handleCheck(v.id)} className={cx('select_style_border', value === v.id ? 'active' : '')}>
showDataSource.map(v => <div key={v.baseProcessid} onClick={() => handleCheck(v.baseProcessid)} className={cx('select_style_border', value === v.baseProcessid ? 'active' : '')}>
<div>
<Row style={{ color: '#303133' }}>
<Col>{v.name}</Col>
......@@ -104,7 +105,7 @@ const SelectProcesss = (props: ISchemaFieldComponentProps) => {
}
</Col>
</Row>
<div style={{ color: '#909399' }}>{v.explain}</div>
<div style={{ color: '#909399' }}>{v.description}</div>
</div>
</div>)
}
......
......@@ -23,7 +23,7 @@ const PurchaseRules: React.FC<{}> = () => {
const fetchData = (params: any) => {
if(!params?.name) delete params.name
return new Promise((resolve, reject) => {
PublicApi.getManageRuleList(params).then(res => {
PublicApi.getOrderPurchaseProcessPage(params).then(res => {
const { data } = res
resolve(data)
})
......@@ -33,8 +33,8 @@ const PurchaseRules: React.FC<{}> = () => {
const columns: ColumnType<any>[] = [
{
title: '流程规则ID',
dataIndex: 'id',
key: 'id',
dataIndex: 'processId',
key: 'processId',
},
{
title: '流程规则名称',
......@@ -42,21 +42,21 @@ const PurchaseRules: React.FC<{}> = () => {
key: 'name',
className: 'commonPickColor',
render: (text: any, record: any) => <EyePreview
url={`/memberCenter/tranactionAbility/purchaseRules/detail?id=${record.id}&preview=1`}
url={`/memberCenter/tranactionAbility/purchaseRules/detail?id=${record.processId}&preview=1`}
>
{text}
</EyePreview>
},
{
title: '操作时间',
dataIndex: 'updateTime',
key: 'updateTime',
dataIndex: 'createTime',
key: 'createTime',
render: (text: any, record: any) => text && moment(text).format('YYYY-MM-DD HH:mm:ss')
},
{
title: '状态',
dataIndex: 'state',
key: 'state',
dataIndex: 'status',
key: 'status',
render: (text: any, record: any) => {
let component: ReactNode = null
component = (
......@@ -69,7 +69,7 @@ const PurchaseRules: React.FC<{}> = () => {
>
<Button
type="link"
style={record.state ? { color: '#00B37A' } : { color: 'red' }}>{record.state ? <>有效 <PlayCircleOutlined /></> : <>无效 <PauseCircleOutlined /></>}</Button>
style={record.status ? { color: '#00B37A' } : { color: 'red' }}>{record.state ? <>有效 <PlayCircleOutlined /></> : <>无效 <PauseCircleOutlined /></>}</Button>
</Popconfirm>
)
return component
......@@ -82,7 +82,7 @@ const PurchaseRules: React.FC<{}> = () => {
return (
<>
{
(record.state === 0) ? <>
(record.status === 0) ? <>
<Popconfirm
title="确定要执行这个操作?"
onConfirm={() => handelDelete(record)}
......@@ -92,7 +92,7 @@ const PurchaseRules: React.FC<{}> = () => {
>
<Button type='link'>删除</Button>
</Popconfirm>
<Button type='link' onClick={()=>history.push(`/memberCenter/tranactionAbility/purchaseRules/add?id=${record.id}`)}>修改</Button>
<Button type='link' onClick={()=>history.push(`/memberCenter/tranactionAbility/purchaseRules/add?id=${record.processId}`)}>修改</Button>
</> : ''
}
</>
......@@ -102,7 +102,7 @@ const PurchaseRules: React.FC<{}> = () => {
];
const confirm = (record: any) => {
PublicApi.postManageRuleStartOrStop({ id: record.id, state: record.state ? 0 : 1 }).then(res => {
PublicApi.postOrderPurchaseProcessStatusUpdate({ processId: record.processId, status: record.status ? 0 : 1 }).then(res => {
ref.current.reload()
})
}
......@@ -112,7 +112,7 @@ const PurchaseRules: React.FC<{}> = () => {
}
const handelDelete = (record: any) => {
PublicApi.postManageRuleDelete({ id: record.id }).then(res => {
PublicApi.postOrderPurchaseProcessDelete({ processId: record.processId }).then(res => {
if(res.code === 1000)
ref.current.reload()
})
......
......@@ -47,7 +47,7 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
}
]
},
"processEnumId": {
"baseProcessId": {
type: 'string',
title: '流程选择',
"x-component": 'SelectProcesss',
......@@ -90,24 +90,24 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
labelAlign: 'left'
},
properties: {
"isApplyContract": {
"allContracts": {
"type": "radio",
enum: [
{ label: '所有合同(默认)', value: 1 },
{ label: '指定合同', value: 0 },
{ label: '所有合同(默认)', value: true },
{ label: '指定合同', value: false },
],
"title": "适用合同",
default: 1,
default: true,
required: true,
"x-linkages": [
{
type: 'value:visible',
target: 'ruleContracts',
target: 'contracts',
"condition": "{{!$value}}"
}
]
},
"ruleContracts": {
"contracts": {
type: 'array:number',
"x-component": 'MultTable',
"x-component-props": {
......
import React, {useState} from 'react'
import { history } from 'umi'
import { Button, Card } from 'antd'
import { Button, Card, message } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
SaveOutlined,
......@@ -33,33 +33,53 @@ const AddRule:React.FC<{}> = (props) => {
productId: item.id,
commodityId: item.commodityId,
name: item.name,
customerCategoryName: item.customerCategoryName,
category: item.customerCategoryName,
priceType: item.priceType,
brandName: item.brandName
brand: item.brandName
}))
values.isElectronicContract = values.isElectronicContract ? 1 : 0
const params = omit(values, ['state']) // 移除不需要的字段
addSchemaAction.getFieldState('transactionProcesssId', state => {
let dataSource = state.dataSource.filter(item => params.transactionProcesssId === item.id)
params.transactionProcess = dataSource[0].name
params.type = dataSource[0].type
})
const params = omit(values, ['status']) // 移除不需要的字段
if(params?.hasContract) {
params.contract = {
contractId: params.contractId,
}
}
if(params?.time) {
params.time = Number(params.time)
if(params?.expireHours) {
params.expireHours = Number(params.expireHours)
}
if(params?.payments) {
params.payments = params.payments.map(item => ({
...item,
payRate: Number(item['payRate'])
}))
// 百分比校验
if(params.payments.reduce((a, b) => a + b.payRate, 0) !== 100) {
setIsDisabled(false)
return message.error('支付比例之和100')
}
}
addSchemaAction.getFieldState('shopIds', state => {
let dataSource = state.props['x-component-props'].dataSource.filter(item => params.shopIds[0] === item.id)
params.shopType = dataSource[0].type
params.shopId = dataSource[0].id
params.shopEnvironment = dataSource[0].environment
})
const _params = omit(params, ['status', 'shopIds', 'contractId'])
let res: any = {}
if(pageStatus === PageStatus.EDIT){
res = await PublicApi.postOrderTradingRulesUpdata(params)
res = await PublicApi.postOrderTradeProcessUpdate(_params)
}else if(pageStatus === PageStatus.ADD){
res = await PublicApi.postOrderTradingRulesAdd(params)
res = await PublicApi.postOrderTradeProcessCreate(_params)
}
// if(res.code === 1000){
setIsDisabled(false)
if(res.code === 1000){
history.goBack(-1)
// }
}
setIsDisabled(false)
}
return (
......
......@@ -19,6 +19,7 @@ import Search from '@/components/NiceForm/components/Search'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import Submit from '@/components/NiceForm/components/Submit'
import SelectProcesss from './selectProcesss'
import { usePaymentTable } from '../model/usePaymentTable'
export interface RuleSettingProps {
addSchemaAction: ISchemaFormActions,
......@@ -41,6 +42,8 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
pageStatus
} = usePageStatus()
const { paymentColumns, paymentComponents, ...sectionProps } = usePaymentTable(addSchemaAction)
const fetchProductList = async (params) => {
const shopIds = addSchemaAction.getFieldValue('shopIds')
if(shopIds.length){
......@@ -243,25 +246,29 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
useEffect(() => {
async function getInitValue() {
const { data } = await PublicApi.getOrderTradingRulesDetails({id: id})
if(data.isTacitlyApprove === 2) {
const { data }: any = await PublicApi.getOrderTradeProcessGet({processId: id})
if(data.allProducts === false) {
const res = await getBindingProducts({id: id.toString(), current: '1', pageSize: '1000'})
addSchemaAction.setFieldState('products', state => {
state.value = res.data
})
setProductsLength(res.totalCount)
}
addSchemaAction.setFieldValue('isElectronicContract', data.isElectronicContract ? true : false)
addSchemaAction.setFieldValue('transactionProcesssId', data.transactionProcesssId)
addSchemaAction.setFieldValue('isTacitlyApprove', data.isTacitlyApprove)
if(data.type === 1) {
addSchemaAction.setFieldState('time', state => {
addSchemaAction.setFieldValue('hasContract', data.hasContract ? true : false)
addSchemaAction.setFieldValue('baseProcessId', data.baseProcessId)
addSchemaAction.setFieldValue('allProducts', data.allProducts)
if(data.processType === 1) {
addSchemaAction.setFieldState('expireHours', state => {
state.visible = true
})
}
if(pageStatus === PageStatus.PREVIEW) {
data.time = data.time + '小时'
data.expireHours = data.expireHours + '小时'
}
if(data.hasContract) {
data.contractId = data.contract.contractId
}
data.shopIds = [data.shopId]
setInitialValue(data)
}
if(id != '') {
......@@ -271,7 +278,7 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
// 拿到绑定的商品
const getBindingProducts = async ({id = '1', current = '1', pageSize = '10'}) => {
const res = await PublicApi.getOrderTradingRulesProductList({tradingRulesId: id, current, pageSize, name: null});
const res = await PublicApi.getOrderTradeProcessProductPage({processId: id, current, pageSize, name: null});
return res.data
}
......@@ -282,11 +289,11 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
}
}
// // 查询已设置交易规则的列表
// 查询已设置交易规则的列表
const fatchSetedProducts = (id) => {
let transactionProcesssId = addSchemaAction.getFieldValue("transactionProcesssId")
addSchemaAction.getFieldState("transactionProcesssId", state => {
let type = state.dataSource.filter(item => item.id === transactionProcesssId)[0]["type"]
let baseProcessId = addSchemaAction.getFieldValue("baseProcessId")
addSchemaAction.getFieldState("baseProcessId", state => {
let type = state.dataSource.filter(item => item.baseProcessid === baseProcessId)[0]["processType"]
PublicApi.getOrderTradingRulesProductIdList({shopId: id, type}).then(res => {
const { data, code } = res
setIdNotInList(() => data?.productIds || [])
......@@ -309,6 +316,8 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
initialValues={initValue}
expressionScope={{
tableColumns,
paymentColumns,
paymentComponents,
tableAddButton,
paginationChange,
productsLength,
......@@ -317,38 +326,64 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
components={{
SelectProcesss,
}}
effects={($, { setFieldState }) => {
effects={($, { setFieldState, setFieldValue }) => {
FormEffectHooks.onFormInputChange$().subscribe(() => {
onFieldChange()
})
createAddContractTemplateEffect(addSchemaAction)
$('onFieldValueChange', 'isElectronicContract').subscribe(parentState => {
setFieldState('electronicContractId', state => {
$('onFieldValueChange', 'hasContract').subscribe(parentState => {
setFieldState('contractId', state => {
state.visible = parentState.value
})
})
$('onFieldInputChange', 'shopIds').subscribe(parentState => {
setFieldState('isTacitlyApprove', state => {
state.value = 1
setFieldState('allProducts', state => {
state.value = true
})
fatchSetedProducts(parentState.value[0])
})
$('onFieldInputChange', 'transactionProcesssId').subscribe(parentState => {
$('onFieldInputChange', 'baseProcessId').subscribe(parentState => {
const selectedObject = parentState.dataSource.filter(item => item.baseProcessid === parentState.value)[0]
// 不是下单交易类型 隐藏电子合同
if(parentState.dataSource.filter(item => item.id === parentState.value)[0]["type"] !== 1) {
if(selectedObject["processType"] !== 1) {
setFieldState("MEGA_LAYOUT1_1", state => {
state.visible = false
})
setFieldState("time", state => {
setFieldState("expireHours", state => {
state.visible = false
})
} else {
setFieldState("MEGA_LAYOUT1_1", state => {
state.visible = true
})
setFieldState("time", state => {
setFieldState("expireHours", state => {
state.visible = true
})
}
// 不是多次支付 隐藏支付配置
if(selectedObject['payTimes'] > 0) {
setFieldState("MEGA_LAYOUT1_2", state => {
state.visible = true
})
setFieldState("payments", state => {
state.visible = true
})
let initPayments: any[] = [];
for(let i = 1; i <= selectedObject['payTimes']; i++) {
initPayments.push({
batchNo: i,
payNode: null,
payRate: null
})
}
setFieldValue("payments", initPayments)
} else {
setFieldState("MEGA_LAYOUT1_2", state => {
state.visible = false
})
setFieldState("payments", state => {
state.visible = false
})
}
})
}}
......
.customeFormItem {
margin: 0;
position: 'relative';
.ant-form-item-control {
.ant-form-item-explain-error {
position: absolute;
left: 0;
bottom: 0;
}
}
}
import React, { useRef, useContext } from 'react'
import { Form, Input } from 'antd';
import './index.less'
import { validatorByte } from '@/utils/regExp';
export interface PaymentTableCellProps {
title: React.ReactNode;
editable: boolean;
children: React.ReactNode;
dataIndex: string;
record: any;
handleSave: (record: any) => Promise<any>;
forceEdit: boolean,
formItem: string,
formItemProps: any,
}
const EditableContext = React.createContext<any>({});
export const PaymentEditableRow: React.FC<any> = ({...props }) => {
const [form] = Form.useForm();
const ctx = {
form
}
return (
<Form form={form} component={false}>
<EditableContext.Provider value={ctx}>
<tr {...props} />
</EditableContext.Provider>
</Form>
);
};
export const PaymentTableCell:React.FC<PaymentTableCellProps> = ({
title,
editable,
children,
dataIndex,
record,
handleSave,
forceEdit,
formItem,
formItemProps={},
...restProps
}) => {
const formItemRef = useRef<any>();
const { form } = useContext(EditableContext);
const save = async e => {
try {
const values = await form.validateFields();
handleSave({ ...record, ...values });
} catch (errInfo) {
console.log('Save failed:', errInfo);
}
};
const chooseFormItem = (type, dataIndex) => {
switch(type) {
case 'input': {
return <Input
style={{width: 140}}
type={dataIndex === 'payNode' ? 'string' : 'number'}
ref={formItemRef}
onChange={save}
{...formItemProps}
id={dataIndex + record.batchNo}
className="payment_setting_input"
/>
}
}
}
let childNode = children;
if (editable) {
childNode =
<Form.Item
className="customFormItem"
name={dataIndex}
initialValue={record[dataIndex] || ''}
rules={[
{
required: true,
message: `${title}必须填写`,
},
dataIndex === 'payNode' ? {
validator: (r, v, c) => validatorByte(r, v, c, 24)
} : {
pattern: /^\d+(\.\d{1,2})?$/,
message: `支付比例仅限两位小数`,
},
]}
>
{chooseFormItem(formItem, dataIndex)}
</Form.Item>
}
return <td {...restProps}>{childNode}</td>;
}
PaymentTableCell.defaultProps = {}
export default PaymentTableCell
import React, { useState, useRef, useEffect } from 'react'
import React, { useState, useEffect } from 'react'
import styled from 'styled-components'
import { ISchemaFormProps, ISchemaFieldProps, ISchemaFieldComponentProps, createFormActions, useFieldState } from '@formily/antd'
import { Button, Space, Row, Col, Tag } from 'antd'
import { PlusOutlined, DeleteColumnOutlined, EditOutlined, DeleteOutlined, CaretUpOutlined, CaretDownOutlined, EyeOutlined } from '@ant-design/icons'
import { ISchemaFieldComponentProps, useFieldState } from '@formily/antd'
import { Row, Col, Tag } from 'antd'
import { CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons'
import cx from 'classnames'
import { PublicApi } from '@/services/api'
......@@ -48,7 +48,8 @@ enum ProcessTagType {
'售后换货流程',
'售后退货流程',
'售后维修流程',
'加工生产流程'
'加工生产流程',
'直发客户自动二次发货'
}
const SelectProcesss = (props: ISchemaFieldComponentProps) => {
......@@ -61,7 +62,7 @@ const SelectProcesss = (props: ISchemaFieldComponentProps) => {
const { value, mutators, editable } = props
useEffect(() => {
PublicApi.getOrderTradingRulesTransactionProcessList().then(res => {
PublicApi.getOrderTradeProcessBaseList().then(res => {
setFieldState({
dataSource: res.data,
showMore
......@@ -85,8 +86,8 @@ const SelectProcesss = (props: ISchemaFieldComponentProps) => {
}
const renderProcessType = (v: any) => {
return <Tag color={ProcessTagColor[v.type - 1]}>
{ProcessTagType[v.type - 1]}
return <Tag color={ProcessTagColor[v.processType - 1]}>
{ProcessTagType[v.processType - 1]}
</Tag>
}
......@@ -94,17 +95,17 @@ const SelectProcesss = (props: ISchemaFieldComponentProps) => {
<div style={{ width: '100%' }}>
<SelectStyles>
{
showDataSource.map(v => <div key={v.id} onClick={() => handleCheck(v.id)} className={cx('select_style_border', value === v.id ? 'active' : '')}>
showDataSource.map(v => <div key={v.baseProcessid} onClick={() => handleCheck(v.baseProcessid)} className={cx('select_style_border', value === v.baseProcessid ? 'active' : '')}>
<div>
<Row style={{ color: '#303133' }}>
<Col>{v.name}</Col>
<Col>{v.processName}</Col>
<Col style={{ marginLeft: 6 }}>
{
renderProcessType(v)
}
</Col>
</Row>
<div style={{ color: '#909399' }}>{v.explain}</div>
<div style={{ color: '#909399' }}>{v.description}</div>
</div>
</div>)
}
......
......@@ -7,7 +7,7 @@ const { onFieldValueChange$ } = FormEffectHooks
export const createAddContractTemplateEffect = (context: ISchemaFormActions) => {
const fetchListContractTemplateAll = async () => {
const { data } = await PublicApi.getContractSelectListContractTemplate()
context.setFieldState('electronicContractId', state => {
context.setFieldState('contractId', state => {
state.contractTemplateLists = data
})
return data.map(v => ({
......@@ -16,12 +16,5 @@ export const createAddContractTemplateEffect = (context: ISchemaFormActions) =>
}))
}
useAsyncSelect('electronicContractId', fetchListContractTemplateAll)
}
export const useUnitPreview = (initValue, context) => {
useEffect(() => {
context.setFieldValue('isElectronicContract', initValue?.isElectronicContract ? true : false)
context.setFieldValue('isTacitlyApprove', initValue?.isTacitlyApprove)
}, [initValue])
useAsyncSelect('contractId', fetchListContractTemplateAll)
}
import React, { ReactNode, useRef, useEffect } from 'react'
import React, { ReactNode, useRef } from 'react'
import { history } from 'umi'
import { Button, Popconfirm, Card, message, Dropdown, Menu, Space } from 'antd'
import { Button, Popconfirm, Card, Space } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
PlusOutlined,
PlayCircleOutlined,
EyeOutlined,
PauseCircleOutlined,
CaretDownOutlined
} from '@ant-design/icons'
import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
......@@ -23,10 +21,9 @@ const TransactionRules: React.FC<{}> = () => {
const ref = useRef<any>({})
const fetchData = (params: any) => {
console.log(params, 'params')
if(!params?.name) delete params.name
return new Promise((resolve, reject) => {
PublicApi.getOrderTradingRulesList(params).then(res => {
PublicApi.getOrderTradeProcessPage(params).then(res => {
const { data } = res
resolve(data)
})
......@@ -36,8 +33,8 @@ const TransactionRules: React.FC<{}> = () => {
const columns: ColumnType<any>[] = [
{
title: '交易规则ID',
dataIndex: 'id',
key: 'id',
dataIndex: 'processId',
key: 'processId',
},
{
title: '流程规则名称',
......@@ -45,26 +42,26 @@ const TransactionRules: React.FC<{}> = () => {
key: 'name',
className: 'commonPickColor',
render: (text: any, record: any) => <EyePreview
url={`/memberCenter/tranactionAbility/transactionRules/detail?id=${record.id}&preview=1`}
url={`/memberCenter/tranactionAbility/transactionRules/detail?id=${record.processId}&preview=1`}
>
{text}
</EyePreview>
},
{
title: '交易流程名称',
dataIndex: 'transactionProcess',
key: 'transactionProcess',
dataIndex: 'processName',
key: 'processName',
},
{
title: '操作时间',
dataIndex: 'operationTime',
key: 'operationTime',
dataIndex: 'createTime',
key: 'createTime',
render: (text: any, record: any) => text && moment(text).format('YYYY-MM-DD HH:mm:ss')
},
{
title: '状态',
dataIndex: 'state',
key: 'state',
dataIndex: 'status',
key: 'status',
render: (text: any, record: any) => {
let component: ReactNode = null
component = (
......@@ -77,7 +74,7 @@ const TransactionRules: React.FC<{}> = () => {
>
<Button
type="link"
style={record.state ? { color: '#00B37A' } : { color: 'red' }}>{record.state ? <>有效 <PlayCircleOutlined /></> : <>无效 <PauseCircleOutlined /></>}</Button>
style={record.status ? { color: '#00B37A' } : { color: 'red' }}>{record.status ? <>有效 <PlayCircleOutlined /></> : <>无效 <PauseCircleOutlined /></>}</Button>
</Popconfirm>
)
return component
......@@ -90,7 +87,7 @@ const TransactionRules: React.FC<{}> = () => {
return (
<>
{
(record.state === 0) ? <>
(record.status === 0) ? <>
<Popconfirm
title="确定要执行这个操作?"
onConfirm={() => handelDelete(record)}
......@@ -100,7 +97,7 @@ const TransactionRules: React.FC<{}> = () => {
>
<Button type='link'>删除</Button>
</Popconfirm>
<Button type='link' onClick={()=>history.push(`/memberCenter/tranactionAbility/transactionRules/add?id=${record.id}`)}>修改</Button>
<Button type='link' onClick={()=>history.push(`/memberCenter/tranactionAbility/transactionRules/add?id=${record.processId}`)}>修改</Button>
</> : ''
}
</>
......@@ -110,7 +107,7 @@ const TransactionRules: React.FC<{}> = () => {
];
const confirm = (record: any) => {
PublicApi.postOrderTradingRulesUpdateState({ id: record.id, state: record.state ? 0 : 1 }).then(res => {
PublicApi.postOrderTradeProcessStatusUpdate({ processId: record.processId, status: record.status ? 0 : 1 }).then(res => {
ref.current.reload()
})
}
......@@ -120,7 +117,7 @@ const TransactionRules: React.FC<{}> = () => {
}
const handelDelete = (record: any) => {
PublicApi.postOrderTradingRulesDelete({ id: record.id }).then(res => {
PublicApi.postOrderTradeProcessDelete({ processId: record.processId }).then(res => {
if(res.code === 1000)
ref.current.reload()
})
......@@ -140,7 +137,7 @@ const TransactionRules: React.FC<{}> = () => {
<StandardTable
tableProps={{
rowKey: 'id',
rowKey: 'processId',
}}
columns={columns}
currentRef={ref}
......@@ -188,59 +185,6 @@ const TransactionRules: React.FC<{}> = () => {
/>
}
/>
{/* <StandardTable
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchData(params)}
formilyLayouts={{
justify: 'space-between'
}}
formilyProps={{
layouts: {
order: 1,
span: 4,
},
ctx: {
inline: false,
schema: {
type: 'object',
properties: {
megaLayout0: {
type: 'object',
'x-component': 'mega-layout',
"x-component-props": {
grid: true,
columns: 2,
},
properties: {
name: {
type: 'string',
'x-component-props': {
placeholder: '规则名称',
},
'x-component': 'Search'
}
}
}
}
}
}
}}
formilyChilds={{
layouts: {
order: 0
},
children: (
<>
<Button type="primary" icon={<PlusOutlined />} onClick={() => history.push('/memberCenter/tranactionAbility/transactionRules/add')}>
新建
</Button>
</>
)
}}
/> */}
</Card>
</PageHeaderWrapper>
)
......
import React from 'react'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd';
import PaymentTableCell, { PaymentEditableRow } from '../components/paymentTableCell';
import style from '../index.less'
// 支付配置
const paymentColumns = [
{
dataIndex: 'batchNo',
title: '支付次数',
key: 'batchNo'
},
{
dataIndex: 'payNode',
title: '支付环节',
key: 'payNode',
formItem: 'input',
editable: true,
width: 200,
},
{
dataIndex: 'payRate',
title: '支付比例',
key: 'payRate',
formItem: 'input',
editable: true,
width: 80,
formItemProps: {
suffix: '%',
},
},
]
/**
* @param ctx schemaAction
*/
export const usePaymentTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
const paymentComponents = {
body: {
row: PaymentEditableRow,
cell: PaymentTableCell
}
}
const handleSave = row => {
return new Promise((resolve, reject) => {
const newData = [...ctx.getFieldValue('payments')];
const index = newData.findIndex(item => row.batchNo === item.batchNo);
const item = newData[index];
newData.splice(index, 1, {
...item,
...row,
});
ctx.setFieldValue('payments', newData)
console.log(newData, row)
resolve({item, newData})
})
};
const paymentMergeColumns = paymentColumns.map(col => {
if (!col.editable) {
return col;
}
return {
...col,
onCell: record => ({
record,
editable: ctx.getFormState().editable === false ? false : col.editable,
dataIndex: col.dataIndex,
title: col.title,
formItem: col.formItem,
formItemProps: col.formItemProps,
handleSave
}),
};
})
return {
paymentColumns: paymentMergeColumns,
paymentComponents,
}
}
......@@ -48,7 +48,7 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
}
]
},
"transactionProcesssId": {
"baseProcessId": {
type: 'string',
title: '流程选择',
"x-component": 'SelectProcesss',
......@@ -66,15 +66,8 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
message: '请选择流程配置'
}
],
// required: true,
// "x-component": 'SearchSelect',
// "x-component-props": {
// placeholder: '请选择交易流程',
// className: 'fixed-ant-selected-down',
// fetchSearch: PublicApi.getOrderTradingRulesTransactionProcessList,
// },
},
"time": {
"expireHours": {
type: 'string',
title: "{{help('订单取消时间', '单后超过多少小时未支付后自动取消订单')}}",
"x-component-props": {
......@@ -98,15 +91,22 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
wrapperCol: 24,
},
properties: {
"isElectronicContract": {
"hasContract": {
type: 'string',
"x-component-props": {
children: "使用电子合同"
},
"x-component": "checkboxsingle",
default: false
default: false,
"x-linkages": [
{
type: 'value:visible',
target: 'contractId',
"condition": "{{$value}}"
}
]
},
"electronicContractId": {
"contractId": {
type: 'string',
required: true,
enum: [],
......@@ -116,7 +116,30 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
visible: false
}
}
}
},
// 自定义支付配置
// MEGA_LAYOUT1_2: {
// type: 'object',
// 'x-component': 'mega-layout',
// 'x-component-props': {
// label: '支付配置',
// wrapperCol: 24,
// },
// properties: {
"payments": {
type: 'array:number',
title: '支付配置',
"x-component": 'MultTable',
"x-component-props": {
rowKey: 'batchNo',
columns: "{{paymentColumns}}",
components: "{{paymentComponents}}",
pagination: false,
},
visible: false
},
// }
// }
}
}
}
......@@ -165,20 +188,20 @@ export const ruleDetailSchema: ISchema = padRequiredMessage({
labelAlign: 'left'
},
properties: {
"isTacitlyApprove": {
"allProducts": {
"type": "radio",
enum: [
{ label: '所有商品(默认)', value: 1 },
{ label: '指定商品', value: 2 },
{ label: '所有商品(默认)', value: true },
{ label: '指定商品', value: false },
],
"title": "适用商品",
default: 1,
default: true,
required: true,
"x-linkages": [
{
type: 'value:visible',
target: 'products',
"condition": "{{$value === 2}}"
"condition": "{{$value === false}}"
}
]
},
......
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