优化字典 select 和 text

This commit is contained in:
sin
2019-03-15 22:59:37 +08:00
parent 888151f523
commit 70b5ea48b3
19 changed files with 184 additions and 216 deletions

View File

@@ -0,0 +1,47 @@
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.text = item2.displayName;
dicTreeItem.value = item2.value;
return true;
});
dicTreeMap[dicKey] = dicTreeItem;
return true;
});
yield put({
type: 'treeSuccess',
payload: {
dicTree: dicList,
dicTreeMap,
},
});
},
},
reducers: {
treeSuccess(state, { payload }) {
return {
...state,
...payload,
};
},
},
};