Просмотр исходного кода

feat: 人员增加状态列以及新建时设置是否是创建人列

lanjianrong 3 лет назад
Родитель
Сommit
a227867316

+ 1 - 2
src/app.tsx

@@ -155,12 +155,11 @@ export const request: RequestConfig = {
 
       if (res?.code !== consts.RET_CODE.SUCCESS) {
         // 抛出错误到 errorHandler 中处理
-        const error = new Error(errorInfo.errorMessage)
+        const error = new Error(errorInfo.errorMessage?.toString())
         error.name = 'BizError'
         error.data = resData
         error.info = errorInfo
         error.response = res
-        console.log('1111', error)
         throw error
       }
       return response

+ 9 - 3
src/pages/Institutions/Company/Detail/components/Staff.tsx

@@ -102,12 +102,13 @@ const Staff: React.FC<ListProps> = ({
       dataIndex: 'createdTime',
       key: 'createdTime',
       title: '创建时间',
-      renderText: text => dayjs(text * 1000).format('YYYY-MM-DD')
+      renderText: text => dayjs(text).format('YYYY-MM-DD')
     },
     {
       dataIndex: 'created',
       key: 'created',
-      title: '创建人'
+      title: '创建者',
+      renderText: (_, record) => record?.created?.name
     },
     {
       dataIndex: 'accountType',
@@ -150,13 +151,18 @@ const Staff: React.FC<ListProps> = ({
       )
     }
   ]
+
+  const wrapHeight = document.querySelector('.ant-pro-page-container-warp')?.clientHeight || 0
+
   return (
     <div>
       <ProTable<API.AccountListItem>
         rowKey="ID"
         params={state.params}
         actionRef={tRef}
-        scroll={{ y: document.body.clientHeight - 371 }}
+        scroll={{
+          y: document.body.clientHeight - (263 + wrapHeight)
+        }}
         columns={generateColumns(columns, schema)}
         search={false}
         request={async (params, filter, sorter) => {

+ 50 - 37
src/pages/Institutions/Staff/components/StaffDetail.tsx

@@ -113,14 +113,16 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
         structureType: '1'
       })
       if (code === consts.RET_CODE.SUCCESS) {
-        form.setSchemaByPath('organizationalStructureID', {
-          type: 'string',
-          widget: 'treeSelect',
-          props: {
-            treeDefaultExpandAll: true,
-            treeData: list
-          }
-        })
+        setTimeout(() => {
+          form.setSchemaByPath('organizationalStructureID', {
+            type: 'string',
+            widget: 'treeSelect',
+            props: {
+              treeDefaultExpandAll: true,
+              treeData: list
+            }
+          })
+        }, 80)
       }
     }
     if (dataID) {
@@ -137,6 +139,14 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
           account.institutionID = data.institution.name
           account.organizationalStructureID = data.organizationalStructure?.name
         }
+
+        setTimeout(() => {
+          if (type === ModalType.UPDATE && !data.isCreated) {
+            form.setSchemaByPath('isCreated', {
+              hidden: true
+            })
+          }
+        }, 80)
         form.setValues({
           ...account
         })
@@ -148,36 +158,38 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
         form.setValues(values)
       }
     }
-    form.setSchemaByPath('accountType', {
-      type: 'string',
-      widget: 'select',
-      enum: accountTypeList.map(item => item.value),
-      enumNames: accountTypeList.map(item => item.label)
-    })
-    form.setSchemaByPath('institutionID', {
-      type: 'string',
-      widget: 'site',
-      disabled: institutionDisable
-    })
-    if (type === ModalType.UPDATE) {
-      form.setSchemaByPath('account', {
-        disabled: true
+    setTimeout(() => {
+      form.setSchemaByPath('accountType', {
+        type: 'string',
+        widget: 'select',
+        enum: accountTypeList.map(item => item.value),
+        enumNames: accountTypeList.map(item => item.label)
       })
-    }
-
-    form.setSchemaByPath('organizationalStructureID', {
-      disabled: hiddenOrganization,
-      hidden: !institutionID
-    })
-    if (hiddenOrganization && (type === ModalType.UPDATE || type === ModalType.PREVIEW)) {
-      form.setSchemaByPath('password', {
-        hidden: true
+      form.setSchemaByPath('institutionID', {
+        type: 'string',
+        widget: 'site',
+        disabled: institutionDisable
       })
-    } else {
-      form.setSchemaByPath('password', {
-        required: false
+      if (type === ModalType.UPDATE) {
+        form.setSchemaByPath('account', {
+          disabled: true
+        })
+      }
+
+      form.setSchemaByPath('organizationalStructureID', {
+        disabled: hiddenOrganization,
+        hidden: !institutionID
       })
-    }
+      if (hiddenOrganization && (type === ModalType.UPDATE || type === ModalType.PREVIEW)) {
+        form.setSchemaByPath('password', {
+          hidden: true
+        })
+      } else {
+        form.setSchemaByPath('password', {
+          required: false
+        })
+      }
+    }, 80)
   }
 
   const watch = {
@@ -217,7 +229,7 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
     }
   }
   return (
-    <div>
+    <div className="mt-6">
       {schema && (
         <FormRender
           form={form}
@@ -235,7 +247,8 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
             type="primary"
             onClick={() => {
               form.submit()
-            }}>
+            }}
+          >
             提交
           </Button>
         )}

+ 11 - 4
src/pages/Institutions/Staff/index.tsx

@@ -87,9 +87,15 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
       title: '名称'
     },
     {
-      dataIndex: 'password',
-      key: 'password',
-      title: '密码'
+      dataIndex: 'enable',
+      key: 'enable',
+      title: '状态',
+      filters: true,
+      filterMultiple: false,
+      valueEnum: {
+        false: { text: '禁用', status: 'Error' },
+        true: { text: '启用', status: 'Success' }
+      }
     },
     {
       dataIndex: 'gender',
@@ -121,7 +127,8 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
     {
       dataIndex: 'created',
       key: 'created',
-      title: '创建者'
+      title: '创建者',
+      renderText: (_, record) => record?.created?.name
     },
     {
       dataIndex: 'accountType',

+ 4 - 1
src/services/api/typings.d.ts

@@ -117,7 +117,10 @@ declare namespace API {
     }
     key: string
     value: string
-    created: string
+    created?: {
+      id: string
+      name: string
+    }
     createdID: string
     id: string
     dataID: string