|
|
@@ -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
|