Kaynağa Gözat

feat: 通讯录请求更新

outaozhen 4 yıl önce
ebeveyn
işleme
cdd1bca797
1 değiştirilmiş dosya ile 27 ekleme ve 13 silme
  1. 27 13
      src/pages/Hr/AddressBook/index.jsx

+ 27 - 13
src/pages/Hr/AddressBook/index.jsx

@@ -1,14 +1,25 @@
 import BasicTable from '@/components/Table'
 import consts from '@/consts'
-import { queryStaff } from '@/services/staff'
 import { PageContainer } from '@ant-design/pro-layout'
-import React, { useState } from 'react'
+import React, { useEffect, useState } from 'react'
+import { connect } from 'umi'
 import Organization from './components/Organization'
 
-const AddressBook = () => {
+const AddressBook = props => {
+  const { dispatch, allStaffList = [] } = props
   const [state, setState] = useState({
     params: { id: '0' }
   })
+  const initData = () => {
+    dispatch({
+      type: 'staff/fetchStaffList'
+    })
+  }
+  useEffect(() => {
+    if (!allStaffList.length) {
+      initData()
+    }
+  }, [])
   const onSelect = id => {
     setState({ ...state, params: { id } })
   }
@@ -75,15 +86,16 @@ const AddressBook = () => {
                 params={{ departmentId: state.params.id }}
                 rowKey={record => record.id}
                 columns={columns}
-                request={async params => {
-                  const { code = -1, data: { list = [], total = 0 } = { list: [], total: 0 } } =
-                    await queryStaff({ ...params })
-                  return {
-                    data: list,
-                    success: code === consts.RET_CODE.SUCCESS,
-                    total
-                  }
-                }}
+                dataSource={allStaffList}
+                // request={async params => {
+                //   const { code = -1, data: { list = [], total = 0 } = { list: [], total: 0 } } =
+                //     await queryStaff({ ...params })
+                //   return {
+                //     data: list,
+                //     success: code === consts.RET_CODE.SUCCESS,
+                //     total
+                //   }
+                // }}
                 search={false}
               />
             )}
@@ -94,4 +106,6 @@ const AddressBook = () => {
   )
 }
 
-export default AddressBook
+export default connect(({ staff }) => ({
+  allStaffList: staff.allStaffList
+}))(AddressBook)