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

feat:销售订单-提交审核

parent ebd0821e
import { createFormActions, FormEffectHooks, FormPath } from '@formily/antd'
import { useLinkageUtils } from '@/utils/formEffectUtils'
const { onFormInit$ } = FormEffectHooks
const { onFormMount$ } = FormEffectHooks
/**
* @description 处理异步请求的下拉选择
......@@ -11,7 +11,7 @@ export const useAsyncSelect = async (name, service: () => Promise<any[]>, format
const { dispatch, setFieldState } = createFormActions()
const linkage = useLinkageUtils()
onFormInit$().subscribe(() => {
onFormMount$().subscribe(() => {
setFieldState(name, state => {
FormPath.setIn(state, 'props.x-props.hasFeedback', true)
})
......
import React, { useContext, useRef } from 'react'
import { Modal, Button } from 'antd'
import { createFormActions, ISchema } from '@formily/antd'
import ModalForm from '@/components/ModalForm'
import { history } from 'umi'
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'
import { PublicApi } from '@/services/api'
import { useHttpRequest } from '@/hooks/useHttpRequest'
import { OrderDetailContext } from '../../_public/order/context'
export interface OrderElectronModalProps {
currentRef: any
}
const schemaActions = createFormActions()
const schema: ISchema = {
type: 'object',
properties: {
NO_SUBMIT: {
type: 'object',
"x-component": "mega-layout",
"x-component-props": {
labelAlign: 'left',
labelCol: 6
},
properties: {
usingElectronicContracts: {
type: 'radio',
title: '是否使用电子合同',
enum: [
{ label: '是', value: 1 },
{ label: '否', value: 2 },
],
default: 1,
"x-linkages": [
{
type: 'value:visible',
target: 'contractTemplateId',
condition: "{{$value === 1}}"
},
{
type: 'value:visible',
target: 'electronicContractName',
condition: "{{$value === 1}}"
}
]
},
contractTemplateId: {
type: 'string',
enum: [],
title: '电子合同模板',
required: true,
"x-component-props": {
placeholder: '请选择电子合同模板',
style: {
minWidth: 140
}
},
"x-props": {
addonAfter: "{{electronBtn}}"
}
},
electronicContractName: {
type: 'string',
"x-component": 'children',
"x-component-props": {
children: ""
},
title: '电子合同',
},
electronicContractUrl: {
type: 'string',
display: false,
},
state: {
type: 'radio',
title: '是否审核通过',
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 CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
const formRef = useRef<any>({})
const { data } = useContext(OrderDetailContext)
const { run, loading } = useHttpRequest(PublicApi.postOrderSignatureSignContractCreate, {ctlType: 'none'})
const { run: submitRun, loading: submitLoading } = useHttpRequest(PublicApi.postOrderSubmittedReviewOrder)
const createElectron = async () => {
const contractTemplateId = schemaActions.getFieldValue('contractTemplateId')
const orderNo = data.orderNo
const signMemberId = data.createMemberId
const params = {
contractTemplateId,
orderNo,
signMemberId
}
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>
})
}
}
const electronBtn = <Button style={{marginLeft: 24}} onClick={createElectron} loading={loading}>生成电子合同</Button>
const handleSubmit = async (value) => {
const params = {
...value,
id: data.id,
}
const { code } = await submitRun(params)
if (code === 1000) {
history.goBack()
}
}
const handleConfirm = () => {
schemaActions.submit()
}
return (
<ModalForm
modalTitle='确认提交审核'
previewPlaceholder=' '
currentRef={props.currentRef}
schema={schema}
actions={schemaActions}
onSubmit={handleSubmit}
confirm={handleConfirm}
modalProps={{
confirmLoading: submitLoading
}}
expressionScope={{
electronBtn
}}
effects={($, actions) => {
useAsyncSelect('contractTemplateId', async () => (await PublicApi.getOrderSelectListContractTemplate()).data, ['name', 'id'])
}}
/>
)
}
CreateOrderElectronModal.defaultProps = {}
export default CreateOrderElectronModal
\ No newline at end of file
......@@ -9,7 +9,7 @@ import { useOrderDetail } from '../../../_public/order/effects/useOrderDetail';
import { history } from 'umi'
import { useHttpRequest } from '@/hooks/useHttpRequest';
import OrderDetailSection from '../../../components/orderDetailSection';
import OrderElectronModal from '@/pages/transaction/components/orderElectronModal';
import CreateOrderElectronModal from '@/pages/transaction/components/createElectronModal';
const ReadyApprovedOrderDetail: React.FC = () => {
const { formContext, id, detailList } = useOrderDetail({type: 'saleOrder'})
......@@ -35,7 +35,7 @@ const ReadyApprovedOrderDetail: React.FC = () => {
</OrderDetailWrapper>
{/* 提交时触发的弹窗集合 */}
<OrderElectronModal
<CreateOrderElectronModal
currentRef={electronRef}
/>
</OrderDetailContext.Provider>
......
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