Browse Source

feat: dva staff add allStaffList state

lanjianrong 4 năm trước cách đây
mục cha
commit
cc7af94354
3 tập tin đã thay đổi với 23 bổ sung2 xóa
  1. 1 0
      package.json
  2. 17 2
      src/pages/Hr/model.js
  3. 5 0
      src/services/hr.js

+ 1 - 0
package.json

@@ -65,6 +65,7 @@
     "omit.js": "^2.0.2",
     "qs": "^6.9.4",
     "rc-util": "^5.16.1",
+    "rc-virtual-list": "^3.4.8",
     "react": "17.0.2",
     "react-copy-to-clipboard": "^5.0.4",
     "react-dom": "17.0.2",

+ 17 - 2
src/pages/Hr/model.js

@@ -3,13 +3,15 @@
  */
 
 import consts from '@/consts'
-import { getDepartMentList } from '@/services/hr'
+import { getDepartMentList, queryStaffContacts } from '@/services/hr'
+import { isUnDef } from '@/utils/is'
 
 const StaffModel = {
   namespace: 'staff',
   state: {
     departments: [],
-    departmentsMap: {}
+    departmentsMap: {}, // TODO: 组织架构枚举,似乎是为了table下拉筛选?
+    allStaffList: [] // 全公司员工列表
   },
   effects: {
     *fetchDepartments({ payload }, { call, put }) {
@@ -32,11 +34,24 @@ const StaffModel = {
           }
         })
       }
+    },
+    *fetchStaffList({}, { call, put }) {
+      const response = yield call(queryStaffContacts)
+      if (response?.code === consts.RET_CODE.SUCCESS) {
+        yield put({
+          type: 'changState',
+          payload: {
+            key: 'allStaffList',
+            value: response.data?.list || []
+          }
+        })
+      }
     }
   },
   reducers: {
     // 通用的reducer
     changState(state, action) {
+      if (!action?.payload?.key) return
       return {
         ...state,
         [action.payload.key]: action.payload.value

+ 5 - 0
src/services/hr.js

@@ -27,3 +27,8 @@ export async function delDepartment(id) {
 export async function queryDepartmentStaffList() {
   return request('/department/staff')
 }
+
+/** 获取通讯录人员列表 */
+export async function queryStaffContacts() {
+  return request('/staff/contacts')
+}