Browse Source

feat: 1111

lanjianrong 3 years ago
parent
commit
b86d170198

+ 13 - 9
src/pages/Project/Management/components/ProjectModal.tsx

@@ -2,11 +2,12 @@ import { connect, useRequest } from 'umi'
 import { useEffect } from 'react'
 import { Button, Drawer, message } from 'antd'
 import { addProject, updateProject } from '@/services/api/project'
+import { delay } from '@/utils/util'
 import FormRender, { useForm } from 'form-render'
 import { BaseMenuEnum } from '@/pages/Schema/Base'
 import type { SchemaBaseModelState } from '@/pages/Schema/Base/model'
 import type { ConnectProps } from 'umi'
-import { delay } from '@/utils/util'
+import type { ProjectModelState } from '../../model'
 
 export enum ModalType {
   ADD = 0,
@@ -66,12 +67,12 @@ const ProjectModal: React.FC<ProjectModalProps> = ({
   })
 
   const onMount = () => {
-    form.setSchemaByPath('projectTypeID', {
-      enum: pTypeList.map(item => item.value),
-      enumNames: pTypeList.map(item => item.label)
-    })
+    form.setValues({ ...defaultFormData })
     delay(300).then(() => {
-      form.setValues({ ...defaultFormData })
+      form.setSchemaByPath('projectTypeID', {
+        enum: pTypeList.map(item => item.value),
+        enumNames: pTypeList.map(item => item.label)
+      })
     })
 
     // delay(3000).then(_ => {
@@ -149,6 +150,9 @@ const ProjectModal: React.FC<ProjectModalProps> = ({
   )
 }
 
-export default connect(({ schemaBase }: { schemaBase: SchemaBaseModelState }) => ({
-  schema: schemaBase.base[BaseMenuEnum.PROJECT]?.schema
-}))(ProjectModal)
+export default connect(
+  ({ project, schemaBase }: { project: ProjectModelState; schemaBase: SchemaBaseModelState }) => ({
+    pTypeList: project.projectTypeList.map(item => ({ label: item.name, value: item.ID })),
+    schema: schemaBase.base[BaseMenuEnum.PROJECT]?.schema
+  })
+)(ProjectModal)

+ 1 - 1
src/pages/Project/Management/index.tsx

@@ -160,6 +160,6 @@ const List: React.FC<ListProps> = ({ schema, dispatch, pTypeList }) => {
 export default connect(
   ({ project, schemaBase }: { project: ProjectModelState; schemaBase: SchemaBaseModelState }) => ({
     pTypeList: project.projectTypeList.map(item => ({ label: item.name, value: item.ID })),
-    schema: schemaBase.base[BaseMenuEnum.PROJECT]
+    schema: schemaBase.base[BaseMenuEnum.PROJECT]?.schema
   })
 )(List)

+ 1 - 0
src/pages/Schema/Base/index.tsx

@@ -6,6 +6,7 @@ import { Button } from 'antd'
 import { history, connect } from 'umi'
 import type { ConnectProps } from 'umi'
 import type { SchemaBaseModelState } from './model'
+
 export enum BaseMenuEnum {
   PROJECT = '1',
   COMPANY = '2',