فهرست منبع

fix: 员工详情请求

outaozhen 3 سال پیش
والد
کامیت
d81c287470

+ 2 - 2
src/pages/Institutions/Company/List/components/CompanyDrawer.tsx

@@ -26,7 +26,6 @@ const CompanyDrawer: React.FC<CompanyModalProps> = ({
   // pTypeList,
   reload
 }) => {
-  console.log(defaultFormData)
   const form = useForm()
   useEffect(() => {
     if (visible && !schema) {
@@ -70,7 +69,8 @@ const CompanyDrawer: React.FC<CompanyModalProps> = ({
 
   const onMount = () => {
     // console.log(defaultFormData)
-    form.setValues({ ...defaultFormData })
+    form.setValues(type === ModalType.ADD ? {} : { ...defaultFormData })
+    // form.setValues({ ...defaultFormData })
     // delay().then(() => {
     //   form.setSchemaByPath('projectTypeID', {
     //     enum: pTypeList.map(item => item.value),

+ 28 - 14
src/pages/Institutions/Staff/components/StaffDetail.tsx

@@ -5,6 +5,7 @@ import consts from '@/utils/consts'
 import {
   addAccount,
   updateAccount,
+  queryAccountDetail,
   queryInstitutionList,
   queryOrganizationalStructureList
 } from '@/services/api/institution'
@@ -25,6 +26,7 @@ type StaffModalProps = ConnectProps & {
   onVisibleChange: (visible: boolean) => void
   institutionDisable: boolean
   type: ModalType
+  dataId: string
   defaultFormData?: {
     ID: string
     name: string
@@ -44,12 +46,38 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
   schema,
   dispatch,
   type,
+  dataId,
   defaultFormData,
   accountTypeList,
   reload
 }) => {
   const form = useForm()
+
+  const { run: tryUpdateAccount } = useRequest(updateAccount, {
+    manual: true,
+    onSuccess: () => {
+      message.success('更新成功')
+    }
+  })
+
+  const { run: tryAddAccount } = useRequest(addAccount, {
+    manual: true,
+    onSuccess: () => {
+      message.success('创建成功')
+    }
+  })
+
+  const { run: tryGetAccountDetail } = useRequest(queryAccountDetail, {
+    manual: true,
+    onSuccess: () => {
+      setState({ ...state, accountDetail: result })
+    }
+  })
+
   useEffect(() => {
+    if (type === ModalType.PREVIEW) {
+      tryGetAccountDetail({ ID: dataId })
+    }
     if (visible) {
       if (!schema) {
         dispatch({
@@ -84,20 +112,6 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
   //   }
   // }, [organizationList?.length])
 
-  const { run: tryUpdateAccount } = useRequest(updateAccount, {
-    manual: true,
-    onSuccess: () => {
-      message.success('更新成功')
-    }
-  })
-
-  const { run: tryAddAccount } = useRequest(addAccount, {
-    manual: true,
-    onSuccess: () => {
-      message.success('创建成功')
-    }
-  })
-
   const queryInstitutionOptions = async params => {
     const { code = -1, data = {} } = await queryInstitutionList({
       ...params,

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

@@ -53,6 +53,7 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
     institutionDisable: false,
     staffDetail: [],
     ID: '',
+    dataId: '',
     currentModalType: ModalType.ADD,
     defaultFormData: null
   })
@@ -81,6 +82,7 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
               ...state,
               visible: true,
               currentModalType: ModalType.PREVIEW,
+              dataId: record.ID,
               defaultFormData: {
                 // ...record,
                 institution: null,
@@ -243,6 +245,7 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
           type={state.currentModalType}
           defaultFormData={state.defaultFormData}
           visible={state.visible}
+          dataId={state.dataId}
           institutionDisable={state.institutionDisable}
           reload={() => tRef.current?.reload()}
           onVisibleChange={(visible: boolean) => setState({ ...state, visible })}

+ 2 - 1
src/utils/enum.ts

@@ -5,5 +5,6 @@ export enum ModalType {
   ADDITEM = 1,
   UPDATE = 2,
   DEL = 3,
-  MOVE = 4
+  MOVE = 4,
+  PREVIEW = 5
 }