Commit 56c23826 authored by 卢均锐's avatar 卢均锐

chore: 采购能力中的弹出审核框增加loading效果,修复原因输入框不受控制显示

parent 2430c80c
import React, { useEffect } from 'react'; import React, { useEffect, useState } from 'react';
import { Modal } from 'antd'; import { Modal } from 'antd';
import { import {
SchemaForm, SchemaMarkupField as Field, SchemaForm, SchemaMarkupField as Field,
createAsyncFormActions , createAsyncFormActions,
FormEffectHooks, FormEffectHooks,
} from '@formily/antd' } from '@formily/antd'
import { Input, Radio, DatePicker, Checkbox } from '@formily/antd-components' import { Input, Radio, DatePicker, Checkbox } from '@formily/antd-components'
...@@ -11,7 +11,7 @@ import moment from 'moment'; ...@@ -11,7 +11,7 @@ import moment from 'moment';
import styles from './index.less'; import styles from './index.less';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
const actions = createAsyncFormActions () const actions = createAsyncFormActions()
const { onFieldChange$ } = FormEffectHooks; const { onFieldChange$ } = FormEffectHooks;
export interface IProps { export interface IProps {
...@@ -39,11 +39,12 @@ const ModalOperate: React.FC<IProps> = (props: any) => { ...@@ -39,11 +39,12 @@ const ModalOperate: React.FC<IProps> = (props: any) => {
maxNumber, maxNumber,
} = props; } = props;
const [confirmLoading, setConfirmLoading] = useState<boolean>(false);
const useFormEffects = () => { const useFormEffects = () => {
const { setFieldState } = createAsyncFormActions ()
if (modalType === 'audit') { if (modalType === 'audit') {
onFieldChange$('state').subscribe(({ value }) => { onFieldChange$('state').subscribe(({ value }) => {
setFieldState('auditOpinion', state => { actions.setFieldState('auditOpinion', state => {
if (value == 1) { if (value == 1) {
state.visible = false state.visible = false
} else { } else {
...@@ -54,7 +55,7 @@ const ModalOperate: React.FC<IProps> = (props: any) => { ...@@ -54,7 +55,7 @@ const ModalOperate: React.FC<IProps> = (props: any) => {
} }
if (modalType === 'planAudit') { if (modalType === 'planAudit') {
onFieldChange$('status').subscribe(({ value }) => { onFieldChange$('status').subscribe(({ value }) => {
setFieldState('cause', state => { actions.setFieldState('cause', state => {
if (value == 1) { if (value == 1) {
state.visible = false state.visible = false
} else { } else {
...@@ -206,6 +207,10 @@ const ModalOperate: React.FC<IProps> = (props: any) => { ...@@ -206,6 +207,10 @@ const ModalOperate: React.FC<IProps> = (props: any) => {
}, [visible]) }, [visible])
const handleSubmit = (val: any) => { const handleSubmit = (val: any) => {
if(confirmLoading){
return;
}
setConfirmLoading(true);
let value = { ...val } let value = { ...val }
let params: any = {} let params: any = {}
if (modalType === 'audit') { if (modalType === 'audit') {
...@@ -235,6 +240,8 @@ const ModalOperate: React.FC<IProps> = (props: any) => { ...@@ -235,6 +240,8 @@ const ModalOperate: React.FC<IProps> = (props: any) => {
if (res.code === 1000) { if (res.code === 1000) {
onOk && onOk() onOk && onOk()
} }
}).finally(() => {
setConfirmLoading(false);
}) })
} }
...@@ -262,6 +269,7 @@ const ModalOperate: React.FC<IProps> = (props: any) => { ...@@ -262,6 +269,7 @@ const ModalOperate: React.FC<IProps> = (props: any) => {
onCancel={handleClose} onCancel={handleClose}
onOk={() => actions.submit()} onOk={() => actions.submit()}
afterClose={() => actions.reset()} afterClose={() => actions.reset()}
confirmLoading={confirmLoading}
> >
<SchemaForm <SchemaForm
className={styles.revise_style} className={styles.revise_style}
......
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