mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-29 04:14:12 +00:00
users
This commit is contained in:
+24
-25
@@ -55,8 +55,14 @@ export default {
|
||||
const data = yield call(remove, { id: payload })
|
||||
if (data && data.success) {
|
||||
yield put({
|
||||
type: 'deleteSuccess',
|
||||
payload,
|
||||
type: 'querySuccess',
|
||||
payload: {
|
||||
list: data.data,
|
||||
pagination:{
|
||||
total: data.page.total,
|
||||
current: data.page.current,
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -66,8 +72,14 @@ export default {
|
||||
const data = yield call(create, payload)
|
||||
if (data && data.success) {
|
||||
yield put({
|
||||
type: 'createSuccess',
|
||||
payload,
|
||||
type: 'querySuccess',
|
||||
payload: {
|
||||
list: data.data,
|
||||
pagination:{
|
||||
total: data.page.total,
|
||||
current: data.page.current,
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -79,8 +91,14 @@ export default {
|
||||
const data = yield call(update, newUser)
|
||||
if (data && data.success) {
|
||||
yield put({
|
||||
type: 'updateSuccess',
|
||||
payload: newUser,
|
||||
type: 'querySuccess',
|
||||
payload: {
|
||||
list: data.data,
|
||||
pagination:{
|
||||
total: data.page.total,
|
||||
current: data.page.current,
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -90,25 +108,6 @@ export default {
|
||||
showLoading(state) {
|
||||
return { ...state, loading: true }
|
||||
},
|
||||
createSuccess(state, action) {
|
||||
const newUser = action.payload
|
||||
return { ...state, list: [newUser, ...state.list], loading: false }
|
||||
},
|
||||
deleteSuccess(state, action) {
|
||||
const id = action.payload
|
||||
const newList = state.list.filter(user => user.id !== id)
|
||||
return { ...state, list: newList, loading: false }
|
||||
},
|
||||
updateSuccess(state, action) {
|
||||
const updateUser = action.payload
|
||||
const newList = state.list.map(user => {
|
||||
if (user.id === updateUser.id) {
|
||||
return { ...user, ...updateUser }
|
||||
}
|
||||
return user
|
||||
})
|
||||
return { ...state, list: newList, loading: false }
|
||||
},
|
||||
querySuccess(state, action) {
|
||||
return { ...state, ...action.payload, loading: false }
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user