Browse Source

feat: 1111

lanjianrong 3 years ago
parent
commit
b7c3bf2e73

+ 28 - 31
src/pages/Institutions/Staff/components/StaffDrawer.tsx

@@ -24,10 +24,10 @@ type StaffModalProps = ConnectProps & {
     ID: string
     ID: string
     name: string
     name: string
     accountType: string
     accountType: string
-    dataID: string
+    institutionID: string
   }
   }
   accountTypeList: API.AccountType
   accountTypeList: API.AccountType
-  organizationList: API.OrganizationalStructureListItem
+  organizationList: API.OrganizationalStructureListItem[]
   reload: () => void
   reload: () => void
   schema?: Record<string, any> | null
   schema?: Record<string, any> | null
 }
 }
@@ -45,29 +45,24 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
 }) => {
 }) => {
   const form = useForm()
   const form = useForm()
   useEffect(() => {
   useEffect(() => {
-    if (visible) {
-      if (!schema) {
-        dispatch({
-          type: 'schemaBase/querySchema',
-          payload: {
-            columnType: BaseMenuEnum.STAFF
-          }
-        })
-      }
-      if (!organizationList?.length) {
-        dispatch({
-          type: 'institutions/queryOrganizationList',
-          payload: {
-            dataID: defaultFormData?.dataID,
-            structureType: '1'
-          }
-        })
-      }
+    if (!schema) {
+      dispatch({
+        type: 'schemaBase/querySchema',
+        payload: {
+          columnType: BaseMenuEnum.STAFF
+        }
+      })
+    }
+    if (defaultFormData?.institutionID && !organizationList?.length) {
+      dispatch({
+        type: 'institutions/queryOrganizationList',
+        payload: {
+          dataID: defaultFormData?.institutionID,
+          structureType: '1'
+        }
+      })
     }
     }
-  }, [visible])
-  // useEffect(() => {
-  //   defaultFormData && ref.current?.setFieldsValue({ ...defaultFormData })
-  // }, [defaultFormData])
+  }, [visible, defaultFormData?.institutionID])
 
 
   const { run: tryUpdateAccount } = useRequest(updateAccount, {
   const { run: tryUpdateAccount } = useRequest(updateAccount, {
     manual: true,
     manual: true,
@@ -84,7 +79,7 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
   })
   })
 
 
   const onMount = () => {
   const onMount = () => {
-    console.log(defaultFormData)
+    console.log(organizationList)
 
 
     form.setValues({ ...defaultFormData })
     form.setValues({ ...defaultFormData })
     delay(80).then(() => {
     delay(80).then(() => {
@@ -92,15 +87,20 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
         enum: accountTypeList.map(item => item.value),
         enum: accountTypeList.map(item => item.value),
         enumNames: accountTypeList.map(item => item.label)
         enumNames: accountTypeList.map(item => item.label)
       })
       })
-      form.setSchemaByPath('institution', {
+
+      // console.log('organizationList', organizationList)
+    })
+    delay(500).then(() => {
+      form.setSchemaByPath('organizationalStructureID', {
         // enum: organizationList.map(item => item.value),
         // enum: organizationList.map(item => item.value),
         // enumNames: organizationList.map(item => item.label),
         // enumNames: organizationList.map(item => item.label),
         description: '',
         description: '',
         type: 'string',
         type: 'string',
         widget: 'treeSelect',
         widget: 'treeSelect',
         props: {
         props: {
+          // defaultValue: defaultFormData.institutionID,
           treeDefaultExpandAll: true,
           treeDefaultExpandAll: true,
-          treeData: organizationList.map(item => item.label)
+          treeData: organizationList
         }
         }
       })
       })
     })
     })
@@ -187,10 +187,7 @@ export default connect(
       label: item.name,
       label: item.name,
       value: item.value
       value: item.value
     })),
     })),
-    organizationList: institutions.organizationType.map(item => ({
-      label: item
-      // value: item.dataID
-    })),
+    organizationList: institutions.organizationType,
     schema: schemaBase.base[BaseMenuEnum.STAFF]?.schema
     schema: schemaBase.base[BaseMenuEnum.STAFF]?.schema
   })
   })
 )(StaffDrawer)
 )(StaffDrawer)

+ 2 - 3
src/pages/Institutions/Staff/index.tsx

@@ -122,9 +122,8 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
                 defaultFormData: {
                 defaultFormData: {
                   ...record,
                   ...record,
                   institution: null,
                   institution: null,
-                  institutionID: record.ID,
-                  accountType: record.accountType,
-                  dataID: record.institution.ID
+                  institutionID: record.institution.ID,
+                  accountType: record.accountType
                 }
                 }
               })
               })
             }}>
             }}>

+ 1 - 1
src/pages/Schema/Base/detail.tsx

@@ -50,7 +50,7 @@ const Detail: React.FC<DetailProps> = ({ dispatch, base, location }) => {
     }
     }
   }, [columnType])
   }, [columnType])
   return (
   return (
-    <PageContainer title={menuOptions[columnType]?.label + '数据模型'}>
+    <PageContainer title={menuOptions.find(item => item.value === columnType)?.label + '数据模型'}>
       <div className="bg-white shadow-card p-4" style={{ height: 'calc(100vh - 196px)' }}>
       <div className="bg-white shadow-card p-4" style={{ height: 'calc(100vh - 196px)' }}>
         <Generator
         <Generator
           ref={genRef}
           ref={genRef}