1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { dictionaryTree } from '../../services/admin';
export default {
namespace: 'dictionaryContext',
state: {
dicTree: [],
dicTreeMap: {},
},
effects: {
*tree({ payload }, { call, put }) {
const response = yield call(dictionaryTree, payload);
const dicList = response.data;
const dicTreeMap = {};
dicList.map(item => {
const dicKey = item.enumValue;
const dicTreeItem = {};
item.values.map(item2 => {
dicTreeItem[item2.value] = item2.displayName;
return true;
});
dicTreeMap[dicKey] = dicTreeItem;
return true;
});
yield put({
type: 'treeSuccess',
payload: {
dicTree: dicList,
dicTreeMap,
},
});
},
},
reducers: {
treeSuccess(state, { payload }) {
return {
...state,
...payload,
};
},
},
};