|  | @@ -1,18 +1,20 @@
 | 
												
													
														
															|  | -import { useRequest } from 'umi'
 |  | 
 | 
												
													
														
															|  | -import { useRef, useEffect } from 'react'
 |  | 
 | 
												
													
														
															|  | -import { Drawer, message } from 'antd'
 |  | 
 | 
												
													
														
															|  | -import type { FormInstance } from 'antd'
 |  | 
 | 
												
													
														
															|  | 
 |  | +import { connect, useRequest } from 'umi'
 | 
												
													
														
															|  | 
 |  | +import { useEffect } from 'react'
 | 
												
													
														
															|  | 
 |  | +import FormRender, { useForm } from 'form-render'
 | 
												
													
														
															|  | 
 |  | +import { Drawer, message, Button } from 'antd'
 | 
												
													
														
															|  |  import { addInstitution, updateInstitution } from '@/services/api/institution'
 |  |  import { addInstitution, updateInstitution } from '@/services/api/institution'
 | 
												
													
														
															|  |  import { BaseMenuEnum } from '@/pages/Schema/Base'
 |  |  import { BaseMenuEnum } from '@/pages/Schema/Base'
 | 
												
													
														
															|  | -import type { SchemaBaseModelState } from '@/pages/Schema/Base/model'
 |  | 
 | 
												
													
														
															|  |  import { ModalType } from '@/utils/enum'
 |  |  import { ModalType } from '@/utils/enum'
 | 
												
													
														
															|  | 
 |  | +import type { SchemaBaseModelState } from '@/pages/Schema/Base/model'
 | 
												
													
														
															|  | 
 |  | +import type { ConnectProps } from 'umi'
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -type CompanyModalProps = {
 |  | 
 | 
												
													
														
															|  | 
 |  | +type CompanyModalProps = ConnectProps & {
 | 
												
													
														
															|  |    visible: boolean
 |  |    visible: boolean
 | 
												
													
														
															|  |    setVisible: (visible: boolean) => void
 |  |    setVisible: (visible: boolean) => void
 | 
												
													
														
															|  |    type: ModalType
 |  |    type: ModalType
 | 
												
													
														
															|  |    defaultFormData?: API.InstitutionListItem
 |  |    defaultFormData?: API.InstitutionListItem
 | 
												
													
														
															|  |    reload: () => void
 |  |    reload: () => void
 | 
												
													
														
															|  | 
 |  | +  schema?: Record<string, any> | null
 | 
												
													
														
															|  |  }
 |  |  }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |  const CompanyDrawer: React.FC<CompanyModalProps> = ({
 |  |  const CompanyDrawer: React.FC<CompanyModalProps> = ({
 | 
												
											
												
													
														
															|  | @@ -20,9 +22,21 @@ const CompanyDrawer: React.FC<CompanyModalProps> = ({
 | 
												
													
														
															|  |    setVisible,
 |  |    setVisible,
 | 
												
													
														
															|  |    type,
 |  |    type,
 | 
												
													
														
															|  |    defaultFormData,
 |  |    defaultFormData,
 | 
												
													
														
															|  | 
 |  | +  schema,
 | 
												
													
														
															|  |    // pTypeList,
 |  |    // pTypeList,
 | 
												
													
														
															|  |    reload
 |  |    reload
 | 
												
													
														
															|  |  }) => {
 |  |  }) => {
 | 
												
													
														
															|  | 
 |  | +  const form = useForm()
 | 
												
													
														
															|  | 
 |  | +  useEffect(() => {
 | 
												
													
														
															|  | 
 |  | +    if (visible && !schema) {
 | 
												
													
														
															|  | 
 |  | +      dispatch({
 | 
												
													
														
															|  | 
 |  | +        type: 'schemaBase/querySchema',
 | 
												
													
														
															|  | 
 |  | +        payload: {
 | 
												
													
														
															|  | 
 |  | +          columnType: BaseMenuEnum.COMPANY
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +      })
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +  }, [visible])
 | 
												
													
														
															|  |    const { run: tryUpdateInstitution } = useRequest(updateInstitution, {
 |  |    const { run: tryUpdateInstitution } = useRequest(updateInstitution, {
 | 
												
													
														
															|  |      manual: true,
 |  |      manual: true,
 | 
												
													
														
															|  |      onSuccess: () => {
 |  |      onSuccess: () => {
 | 
												
											
												
													
														
															|  | @@ -36,14 +50,13 @@ const CompanyDrawer: React.FC<CompanyModalProps> = ({
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |    })
 |  |    })
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -  const onFinish = async (formData, errors) => {
 |  | 
 | 
												
													
														
															|  | -    console.log('formData:', formData, 'errors', errors)
 |  | 
 | 
												
													
														
															|  | 
 |  | +  const onFinish = async formData => {
 | 
												
													
														
															|  |      try {
 |  |      try {
 | 
												
													
														
															|  |        // 执行表单提交
 |  |        // 执行表单提交
 | 
												
													
														
															|  |        if (type === ModalType.ADD) {
 |  |        if (type === ModalType.ADD) {
 | 
												
													
														
															|  | -        await tryAddInstitution(values)
 |  | 
 | 
												
													
														
															|  | 
 |  | +        await tryAddInstitution(formData)
 | 
												
													
														
															|  |        } else {
 |  |        } else {
 | 
												
													
														
															|  | -        await tryUpdateInstitution(values)
 |  | 
 | 
												
													
														
															|  | 
 |  | +        await tryUpdateInstitution(formData)
 | 
												
													
														
															|  |        }
 |  |        }
 | 
												
													
														
															|  |        setVisible(false)
 |  |        setVisible(false)
 | 
												
													
														
															|  |        reload()
 |  |        reload()
 | 
												
											
												
													
														
															|  | @@ -52,6 +65,18 @@ const CompanyDrawer: React.FC<CompanyModalProps> = ({
 | 
												
													
														
															|  |        message.error(error)
 |  |        message.error(error)
 | 
												
													
														
															|  |      }
 |  |      }
 | 
												
													
														
															|  |    }
 |  |    }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +  const onMount = () => {
 | 
												
													
														
															|  | 
 |  | +    console.log(defaultFormData)
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    form.setValues({ ...defaultFormData })
 | 
												
													
														
															|  | 
 |  | +    // delay().then(() => {
 | 
												
													
														
															|  | 
 |  | +    //   form.setSchemaByPath('projectTypeID', {
 | 
												
													
														
															|  | 
 |  | +    //     enum: pTypeList.map(item => item.value),
 | 
												
													
														
															|  | 
 |  | +    //     enumNames: pTypeList.map(item => item.label)
 | 
												
													
														
															|  | 
 |  | +    //   })
 | 
												
													
														
															|  | 
 |  | +    // })
 | 
												
													
														
															|  | 
 |  | +  }
 | 
												
													
														
															|  |    return (
 |  |    return (
 | 
												
													
														
															|  |      <Drawer
 |  |      <Drawer
 | 
												
													
														
															|  |        width="50vw"
 |  |        width="50vw"
 |