部门更新和新增modal框
This commit is contained in:
@@ -1,5 +1,20 @@
|
||||
import { message } from 'antd';
|
||||
import { deptTreePage } from '../../services/admin';
|
||||
import { deptTreePage, deptTreeAll, addDeptment, updateDeptment } from '../../services/admin';
|
||||
|
||||
const buildSelectTree = list => {
|
||||
return list.map(item => {
|
||||
let children = [];
|
||||
if (item.children) {
|
||||
children = buildSelectTree(item.children);
|
||||
}
|
||||
return {
|
||||
title: item.name,
|
||||
value: `${item.name}-${item.id}`,
|
||||
key: item.id,
|
||||
children,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
export default {
|
||||
namespace: 'deptmentList',
|
||||
@@ -13,6 +28,27 @@ export default {
|
||||
},
|
||||
|
||||
effects: {
|
||||
*add({ payload }, { call, put }) {
|
||||
const { onSuccess, body } = payload;
|
||||
const response = yield call(addDeptment, body);
|
||||
if (response && response.code === 0) {
|
||||
onSuccess && onSuccess();
|
||||
}
|
||||
},
|
||||
*update({ payload }, { call, put }) {
|
||||
const { onSuccess, body } = payload;
|
||||
const response = yield call(updateDeptment, body);
|
||||
if (response && response.code === 0) {
|
||||
onSuccess && onSuccess();
|
||||
}
|
||||
},
|
||||
*getDeptmentAll({ payload }, { call, put }) {
|
||||
const result = yield call(deptTreeAll, payload);
|
||||
yield put({
|
||||
type: 'treeSuccess',
|
||||
payload: result.data,
|
||||
});
|
||||
},
|
||||
*getDeptmentList({ payload }, { call, put }) {
|
||||
const result = yield call(deptTreePage, payload);
|
||||
let deptmentData = {};
|
||||
|
||||
Reference in New Issue
Block a user