Commit c61353f9 authored by 前端-许佳敏's avatar 前端-许佳敏

订单流程

parent 1dc5e5c1
......@@ -582,7 +582,7 @@ export enum PurchaseOrderInsideWorkState {
TWO_LEVEL_AUDIT_ORDER_NOT_ALLOWED,
/**
* 确认电子合同
* 待支付订单
*/
CONFIRM_ELECTRONIC,
......@@ -777,7 +777,7 @@ export const PurchaseOrderInsideWorkStateTexts = {
5: '待确认电子合同',
6: '提交一级审核订单不通过',
7: '提交二级审核订单不通过',
8: '确认电子合同',
8: '待支付订单',
10: '支付成功',
11: '支付失败',
12: '确认收货',
......
import React from 'react'
import React, { useEffect, useState, useContext } from 'react'
import { Modal } from 'antd'
import NiceForm from '@/components/NiceForm'
import { createFormActions, ISchema } from '@formily/antd'
import ModalForm from '@/components/ModalForm'
import { OrderDetailContext } from '../../context'
import { PublicApi } from '@/services/api'
import { history } from 'umi'
export interface OrderElectronModalProps {
currentRef: any
currentRef: any,
}
const schemaActions = createFormActions()
const schema: ISchema = {
type: 'object',
properties: {
NO_SUBMIT: {
type: 'object',
"x-component": "mega-layout",
"x-component-props": {
labelAlign: 'left'
},
properties: {
usingElectronicContracts: {
type: 'radio',
title: '是否使用电子合同',
enum: [
{ label: '是', value: 1 },
{ label: '否', value: 2 },
],
"x-linkages": [
{
type: 'value:visible',
target: 'contractTemplateId',
condition: "{{$value === 1}}"
},
{
type: 'value:visible',
target: 'electronicContractName',
condition: "{{$value === 1}}"
}
]
},
contractTemplateId: {
type: 'string',
enum: [],
title: '电子合同模板'
},
electronicContractName: {
type: 'string',
editable: false,
title: '电子合同',
},
state: {
type: 'radio',
enum: [
{ label: '审核通过', value: 1 },
{ label: '审核不通过', value: 0 },
],
default: 1,
"x-linkages": [
{
type: 'value:visible',
target: 'cause',
condition: "{{$value === 0}}"
}
]
},
cause: {
type: 'textarea',
"x-component-props": {
rows: 4,
placeholder: '在此输入你的原因, 最多60个汉字'
},
title: '审核不通过原因',
"x-rules": [
{
required: true,
message: '请输入审核不通过原因'
},
{
limitByte: true,
maxByte: 30
}
]
}
}
}
}
}
//@todo 尚未完成
const OrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
const { currentRef } = props
const { data } = useContext(OrderDetailContext)
const [visible, setVisible] = useState(false)
useEffect(() => {
currentRef.current = {
visible,
setVisible
}
}, [])
const handleSubmit = async () => {
console.log('签署')
const params = {
id: parseInt(data.id),
}
const { code } = await PublicApi.postOrderElectronicContractsAffirm(params)
if (code === 1000) {
setVisible(false)
history.goBack()
}
}
return (
<ModalForm
currentRef={props.currentRef}
schema={schema}
/>
<Modal
width={1000}
style={{minHeight: 600}}
title='签署电子合同'
okText='签署合同并提交'
cancelText='不签署'
visible={visible}
onOk={handleSubmit}
onCancel={() => setVisible(false)}
>
<div style={{height: 600, position: 'relative'}}>
<iframe src={data.electronicContractUrl} style={{position: 'absolute', left: 0, top: 0, width: '100%', height: '100%', display: 'block'}}/>
</div>
</Modal>
)
}
......
import React, { useState, useEffect, useContext, useRef, useCallback } from 'react'
import OrderDetailHeader from '../../components/OrderDetailHeader'
import { Button, Row, Col } from 'antd'
import { Button, Row, Col, message } from 'antd'
import { Link, history } from 'umi'
import { orderTypeLabel, SALE_ORDER_STATUS, PURCHASE_ORDER_STATUS } from './constant'
import { formatTimeString } from '@/utils'
......@@ -101,11 +101,7 @@ const CommonOrderDetail: React.FC<CommonOrderDetailProps> = (props) => {
case PURCHASE_ORDER_STATUS.READY_CONFIRM_ELECTRON_ORDER: {
console.log('确认')
// const params = {
// id: parseInt(id),
// state: 1
// }
// result = await PublicApi.postOrderElectronicContractsAffirm(params)
break;
}
......@@ -162,7 +158,11 @@ const CommonOrderDetail: React.FC<CommonOrderDetailProps> = (props) => {
// 确认电子合同
if (page_type === PURCHASE_ORDER_STATUS.READY_CONFIRM_ELECTRON_ORDER) {
handleSubmit({})
if (!formData.electronicContractUrl) {
message.error('没有生成电子合同,请联系工作人员')
return ;
}
electronRef.current.setVisible(true)
}
if (page_type === PURCHASE_ORDER_STATUS.READY_RETURN_DOCUMENT) {
......@@ -181,6 +181,10 @@ const CommonOrderDetail: React.FC<CommonOrderDetailProps> = (props) => {
text = '确认电子合同'
break;
}
case PURCHASE_ORDER_STATUS.READY_PAY_ORDER: {
text = '去支付'
break;
}
default: {
text = '提交审核'
break;
......
......@@ -24,6 +24,7 @@ export const useSelfTable = () => {
const popConfirm = () => {
console.log('前往签约')
history.push(`/memberCenter/tranactionAbility/electronicContracts/apply`)
}
useEffect(() => {
......
import React, { useContext } from 'react'
import React, { useContext, useRef } from 'react'
import { Modal, Button } from 'antd'
import NiceForm from '@/components/NiceForm'
import { createFormActions, ISchema } from '@formily/antd'
import ModalForm from '@/components/ModalForm'
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect'
import { history } from 'umi'
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'
import { PublicApi } from '@/services/api'
import { useHttpRequest } from '@/hooks/useHttpRequest'
import { getAuth } from '@/utils/auth'
import { OrderDetailContext } from '../../context'
export interface OrderElectronModalProps {
......@@ -52,6 +51,7 @@ const schema: ISchema = {
type: 'string',
enum: [],
title: '电子合同模板',
required: true,
"x-component-props": {
placeholder: '请选择电子合同模板',
style: {
......@@ -64,9 +64,17 @@ const schema: ISchema = {
},
electronicContractName: {
type: 'string',
editable: false,
"x-component": 'children',
"x-component-props": {
children: ""
},
title: '电子合同',
},
electronicContractUrl: {
type: 'string',
display: false,
},
state: {
type: 'radio',
title: '是否审核通过',
......@@ -107,8 +115,9 @@ const schema: ISchema = {
}
//@todo 尚未完成
const OrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
const formRef = useRef<any>({})
const { data } = useContext(OrderDetailContext)
const { run, loading } = useHttpRequest(PublicApi.postOrderSignatureSignContractCreate)
const { run, loading } = useHttpRequest(PublicApi.postOrderSignatureSignContractCreate, {ctlType: 'none'})
const createElectron = async () => {
const contractTemplateId = schemaActions.getFieldValue('contractTemplateId')
const orderNo = data.orderNo
......@@ -120,14 +129,32 @@ const OrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
signMemberId
}
const { code, data: resData } = await PublicApi.postOrderSignatureSignContractCreate(params)
const { code, data: resData } = await run(params)
if (code === 1000) {
schemaActions.setFieldValue('electronicContractName', resData.contractName)
schemaActions.setFieldValue('electronicContractUrl', resData.contractUrl)
schemaActions.setFieldState('electronicContractName', state => {
state.props["x-component-props"].children = <a href={resData.contractUrl} download={resData.contractName} target='_blank'>{resData.contractName}</a>
})
}
console.log(resData)
console.log(params)
}
const electronBtn = <Button style={{marginLeft: 24}} onClick={createElectron} loading={loading}>生成电子合同</Button>
const handleSubmit = async (value) => {
const params = {
...value,
id: data.id,
}
const { code } = await PublicApi.postOrderSubmittedReviewOrder(params)
if (code === 1000) {
history.goBack()
}
}
const handleConfirm = () => {
schemaActions.submit()
}
return (
<ModalForm
modalTitle='确认提交审核'
......@@ -135,6 +162,8 @@ const OrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
currentRef={props.currentRef}
schema={schema}
actions={schemaActions}
onSubmit={handleSubmit}
confirm={handleConfirm}
expressionScope={{
electronBtn
}}
......
......@@ -21,10 +21,16 @@ import StatusColors from '@/pages/transaction/components/StatusColors'
import OrderPayResultModal from './components/orderPayResultModal'
import OrderDeleveRecord from './components/orderDeleveRecord'
import OrderElectronModal from './components/orderElectronModal'
import ModalForm from '@/components/ModalForm'
import { createFormActions } from '@formily/antd'
export interface CommonOrderDetailProps {}
const approvedActions = createFormActions()
const CommonOrderDetail:React.FC<CommonOrderDetailProps> = (props) => {
const approvedRef = useRef<any>({})
const [btnLoading, setBtnLoading] = useState<boolean>(false)
const [formData, setFormData] = useState<any>(null)
let { id, pageStatus, page_type = SALE_ORDER_STATUS.READY_APPROVED_ORDER, orderDeliveryDetailsId } = usePageStatus()
......@@ -42,6 +48,10 @@ const CommonOrderDetail:React.FC<CommonOrderDetailProps> = (props) => {
}
}, [])
const handleConfirmApproved = () => {
approvedActions.submit()
}
const formContext = {
data: formData,
payResultType,
......@@ -151,6 +161,12 @@ const CommonOrderDetail:React.FC<CommonOrderDetailProps> = (props) => {
electronRef.current.setVisible(true)
return
}
// 一级审核, 二级审核, 确认订单 都需要通过弹窗确认后再提交
if (page_type === SALE_ORDER_STATUS.ONE_LEVEL_APPROVED_ORDER || page_type === SALE_ORDER_STATUS.TWO_LEVEL_APPROVED_ORDER || page_type === SALE_ORDER_STATUS.CONFIRM_ORDER) {
approvedRef.current.setVisible(true)
return ;
}
handleSubmit()
}
......@@ -227,6 +243,62 @@ const CommonOrderDetail:React.FC<CommonOrderDetailProps> = (props) => {
currentRef={electronRef}
/>
<OrderPayResultModal currentRef={payResultVisible} type={payResultType}/>
{/* 提交时触发的弹窗集合 */}
<ModalForm
modalTitle='提示'
currentRef={approvedRef}
confirm={handleConfirmApproved}
actions={approvedActions}
schema={{
type: 'object',
properties: {
NO_SUBMIT: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
labelAlign: 'top',
},
properties: {
state: {
type: 'radio',
enum: [
{ label: '审核通过', value: 1 },
{ label: '审核不通过', value: 0 },
],
default: 1,
"x-linkages": [
{
type: 'value:visible',
target: 'cause',
condition: "{{$value === 0}}"
}
]
},
cause: {
type: 'textarea',
"x-component-props": {
rows: 4,
placeholder: '在此输入你的原因, 最多60个汉字'
},
title: '审核不通过原因',
"x-rules": [
{
required: true,
message: '请输入审核不通过原因'
},
{
limitByte: true,
maxByte: 30
}
]
}
}
}
}
}}
onSubmit={handleSubmit}
/>
</OrderDetailContext.Provider>
</div>
) : null
......
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