Procházet zdrojové kódy

fix: 人员管理添加、编辑、表格内定字段相关内容

outaozhen před 3 roky
rodič
revize
f644dd13ee

+ 1 - 0
src/pages/Institutions/Company/Detail/components/Organization.tsx

@@ -190,6 +190,7 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
         toolbar={{
           actions: [
             <Button
+              type="primary"
               onClick={() =>
                 setState({
                   ...state,

+ 44 - 7
src/pages/Institutions/Company/Detail/components/Staff.tsx

@@ -4,12 +4,14 @@ import { Button } from 'antd'
 import consts from '@/utils/consts'
 // import { history } from 'umi'
 import { connect } from 'umi'
+import dayjs from 'dayjs'
 import { queryAcountList } from '@/services/api/institution'
 import StaffDrawer, { ModalType } from '@/pages/Institutions/Staff/components/StaffDrawer'
 import type { SchemaBaseModelState } from '@/pages/Schema/Base/model'
 import { BaseMenuEnum } from '@/pages/Schema/Base'
 import type { InstitutionsModelState } from '@/pages/Institutions/model'
 import { generateColumns } from '@/utils/util'
+import { genderEum } from '@/pages/Institutions/Staff'
 
 type ListProps = ConnectProps & {
   accountType: API.AccountType[]
@@ -34,7 +36,8 @@ const Staff: React.FC<ListProps> = ({ schema, dataID, dispatch, accountTypeList
   const [state, setState] = useState({
     params: {
       search: null,
-      accountType: '1'
+      accountType: '1',
+      dataID: dataID
     },
     visible: false,
     currentModalType: ModalType.ADD,
@@ -50,23 +53,55 @@ const Staff: React.FC<ListProps> = ({ schema, dataID, dispatch, accountTypeList
       title: '姓名'
     },
     {
+      dataIndex: 'password',
+      key: 'password',
+      title: '密码'
+    },
+    {
+      dataIndex: 'gender',
+      key: 'gender',
+      title: '性别',
+      render: (_, { gender }) => {
+        return <span>{genderEum[gender]}</span>
+      }
+    },
+    {
       dataIndex: 'institution',
-      title: '组织架构',
-      render: (_, record) => record.institution.name
+      key: 'institution',
+      title: '所属企事业单位',
+      renderText: (_, record) => record.institution.name
     },
     {
       dataIndex: 'phone',
+      key: 'phone',
       title: '手机'
     },
     {
       dataIndex: 'createdTime',
-      title: '创建时间'
+      key: 'createdTime',
+      title: '创建时间',
+      renderText: text => dayjs(text * 1000).format('YYYY-MM-DD')
     },
     {
       dataIndex: 'created',
+      key: 'created',
       title: '创建人'
     },
     {
+      dataIndex: 'accountType',
+      key: 'accountType',
+      title: '账号类型',
+      filters: true,
+      filterMultiple: false,
+      valueEnum: accountTypeList.reduce((prev, curr) => {
+        const items = { ...prev }
+        items[curr.value] = {
+          text: curr.label
+        }
+        return items
+      }, {})
+    },
+    {
       title: '操作',
       dataIndex: 'operation',
       render: (_, record) => (
@@ -79,11 +114,12 @@ const Staff: React.FC<ListProps> = ({ schema, dataID, dispatch, accountTypeList
                 visible: true,
                 currentModalType: ModalType.UPDATE,
                 defaultFormData: {
-                  ...record,
                   institution: null,
-                  institutionID: record.ID,
+                  ID: record.ID,
+                  name: record.name,
+                  institutionID: record.institution.ID,
                   accountType: record.accountType,
-                  dataID: record.institution.ID
+                  dataID: record.institutionID
                 }
               })
             }}>
@@ -119,6 +155,7 @@ const Staff: React.FC<ListProps> = ({ schema, dataID, dispatch, accountTypeList
           },
           actions: [
             <Button
+              type="primary"
               onClick={() => {
                 setState({ ...state, visible: true, currentModalType: ModalType.ADD })
               }}>

+ 4 - 4
src/pages/Institutions/Company/Detail/index.tsx

@@ -27,8 +27,8 @@ const CompanyDetail: React.FC<CompanyDetailProps> = ({ location }) => {
 
   const menuMap: Record<string, React.ReactNode> = {
     [TabEnum.STAFF]: '人员管理',
-    [TabEnum.ORGANIZATION]: '组织架构',
-    [TabEnum.ROLE]: '角色权限'
+    [TabEnum.ORGANIZATION]: '组织架构'
+    // [TabEnum.ROLE]: '角色权限'
   }
   const [initConfig, setInitConfig] = useState<CompanyNameState>({
     mode: 'inline',
@@ -72,8 +72,8 @@ const CompanyDetail: React.FC<CompanyDetailProps> = ({ location }) => {
         return <Staff dataID={dataID} />
       case TabEnum.ORGANIZATION:
         return <Organization dataID={dataID} structureType={structureType} />
-      case TabEnum.ROLE:
-        return <Role />
+      // case TabEnum.ROLE:
+      //   return <Role />
       default:
         return null
     }

+ 4 - 33
src/pages/Institutions/Staff/components/StaffDrawer.tsx

@@ -78,25 +78,6 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
       })
     }
   }, [organizationList?.length])
-  // useEffect(() => {
-  //   if (!schema) {
-  //     dispatch({
-  //       type: 'schemaBase/querySchema',
-  //       payload: {
-  //         columnType: BaseMenuEnum.STAFF
-  //       }
-  //     })
-  //   }
-  //   if (defaultFormData?.dataID && !organizationList?.length) {
-  //     dispatch({
-  //       type: 'institutions/queryOrganizationList',
-  //       payload: {
-  //         dataID: defaultFormData?.dataID,
-  //         structureType: '1'
-  //       }
-  //     })
-  //   }
-  // }, [visible, defaultFormData?.dataID])
 
   const { run: tryUpdateAccount } = useRequest(updateAccount, {
     manual: true,
@@ -148,7 +129,7 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
         // enum: accountTypeList.map(item => item.value),
         // enumNames: accountTypeList.map(item => item.label)
       })
-      form.setSchemaByPath('institution', {
+      form.setSchemaByPath('institutionID', {
         type: 'string',
         widget: 'site'
       })
@@ -187,18 +168,6 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
       message.error(error)
     }
   }
-  // const queryInstitutionOptions = async search => {
-  //   const { code = -1, data = {} } = await queryInstitutionList({
-  //     search,
-  //     current: 1,
-  //     pageSize: 100
-  //   })
-  //   if (code === consts.RET_CODE.SUCCESS) {
-  //     return data.items.map(item => ({ label: item.name, value: item.ID }))
-  //   }
-  //   return []
-  // }
-  // const { institution } = defaultFormData || {}
   return (
     <Drawer
       width="50vw"
@@ -218,7 +187,9 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
         />
       )}
       <div>
-        <Button onClick={form.submit}>提交</Button>
+        <Button type="primary" onClick={form.submit}>
+          提交
+        </Button>
       </div>
     </Drawer>
   )

+ 33 - 7
src/pages/Institutions/Staff/index.tsx

@@ -20,6 +20,11 @@ type ListProps = ConnectProps & {
   schema?: Record<string, any> | null
 }
 
+export const genderEum = {
+  0: '男',
+  1: '女'
+}
+
 const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList }) => {
   // console.log(accountTypeList)
 
@@ -63,6 +68,7 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
   const columns: ProColumnType<API.AccountListItem>[] = [
     {
       dataIndex: 'account',
+      key: 'account',
       title: '账号',
       render: (name, record) => (
         <div
@@ -76,25 +82,43 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
     },
     {
       dataIndex: 'name',
+      key: 'name',
       title: '名称'
     },
-    // {
-    //   dataIndex: 'institution',
-    //   title: '所属企事业单位',
-    //   renderText: (_, record) => record.institution.name
-    //   // valueEnum:
-    // },
+    {
+      dataIndex: 'password',
+      key: 'password',
+      title: '密码'
+    },
+    {
+      dataIndex: 'gender',
+      key: 'gender',
+      title: '性别',
+      render: (_, { gender }) => {
+        return <span>{genderEum[gender]}</span>
+      }
+    },
+    {
+      dataIndex: 'institution',
+      key: 'institution',
+      title: '所属企事业单位',
+      renderText: (_, record) => record.institution.name
+      // valueEnum:
+    },
     {
       dataIndex: 'createdTime',
+      key: 'createdTime',
       title: '创建时间',
       renderText: text => dayjs(text * 1000).format('YYYY-MM-DD')
     },
     {
       dataIndex: 'created',
+      key: 'created',
       title: '创建者'
     },
     {
       dataIndex: 'accountType',
+      key: 'accountType',
       title: '账号类型',
       filters: true,
       filterMultiple: false,
@@ -122,7 +146,8 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
                 defaultFormData: {
                   // ...record,
                   institution: null,
-
+                  ID: record.ID,
+                  name: record.name,
                   institutionID: record.institution.ID,
                   accountType: record.accountType
                 }
@@ -170,6 +195,7 @@ const CompanyList: React.FC<ListProps> = ({ schema, dispatch, accountTypeList })
           },
           actions: [
             <Button
+              type="primary"
               onClick={() =>
                 setState({ ...state, visible: true, currentModalType: ModalType.ADD })
               }>

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

@@ -102,6 +102,7 @@ declare namespace API {
     createdID: string
     id: string
     dataID: string
+    gender: string
   }
 
   type AccountListParams = BasicPageParams & {