diff --git a/admin-web/mock/admin.js b/admin-web/mock/admin.js
index 5fac79368..d6d031072 100644
--- a/admin-web/mock/admin.js
+++ b/admin-web/mock/admin.js
@@ -6,6 +6,7 @@ import adminMenuAll from './geographic/admin-menu-all.json';
import adminUrls from './geographic/admin-urls';
import resourceTree from './geographic/resource-tree.json';
import roleQuery from './geographic/role-query.json';
+import dictionaryList from './geographic/dictionary-list.json';
function getAdminMenu(req, res) {
return res.json(adminMenu);
@@ -43,6 +44,10 @@ function getDictionaryText(req, res) {
return res.json(resultBody(values));
}
+function getDictionaryList(req, res) {
+ return res.json(dictionaryList);
+}
+
export default {
'GET /admin-api/admins/admin/menu_resource_tree': getAdminMenuAll,
'GET /admin-api/admins/admin/url_resource_list': getAdminUrls,
@@ -51,4 +56,5 @@ export default {
'GET /admin-api/admins/admin/page': getQueryRole,
'GET /admin-api/admins/dictionary/getList': getDictionaryKeys,
'GET /admin-api/admins/dictionary/queryText': getDictionaryText,
+ // 'GET /admin-api/admins/data_dict/list': getDictionaryList,
};
diff --git a/admin-web/mock/geographic/dictionary-list.json b/admin-web/mock/geographic/dictionary-list.json
index ead438f3d..d60bc1f04 100644
--- a/admin-web/mock/geographic/dictionary-list.json
+++ b/admin-web/mock/geographic/dictionary-list.json
@@ -8,7 +8,7 @@
"value": "1",
"displayName": "男",
"sort": 1,
- "memo": ""
+ "memo": "性别 - 男"
},
{
"id": 2,
@@ -16,7 +16,7 @@
"value": "2",
"displayName": "女",
"sort": 2,
- "memo": ""
+ "memo": "性别 - 女"
}
]
}
\ No newline at end of file
diff --git a/admin-web/src/models/admin/dictionaryList.js b/admin-web/src/models/admin/dictionaryList.js
index 6f5f94c1f..ea004ad49 100644
--- a/admin-web/src/models/admin/dictionaryList.js
+++ b/admin-web/src/models/admin/dictionaryList.js
@@ -1,5 +1,5 @@
-import { message } from 'antd';
-import { addResource, updateResource, deleteResource, dictionaryList } from '../../services/admin';
+import {message} from 'antd';
+import {dictionaryAdd, dictionaryDelete, dictionaryList, dictionaryUpdate} from '../../services/admin';
export default {
namespace: 'dictionaryList',
@@ -11,7 +11,7 @@ export default {
effects: {
*add({ payload }, { call, put }) {
const { callback, body } = payload;
- const response = yield call(addResource, body);
+ const response = yield call(dictionaryAdd, body);
if (callback) {
callback(response);
}
@@ -22,7 +22,7 @@ export default {
},
*update({ payload }, { call, put }) {
const { callback, body } = payload;
- const response = yield call(updateResource, body);
+ const response = yield call(dictionaryUpdate, body);
if (callback) {
callback(response);
}
@@ -32,23 +32,53 @@ export default {
});
},
*delete({ payload }, { call, put }) {
- const response = yield call(deleteResource, payload);
+ const response = yield call(dictionaryDelete, payload);
message.info('删除成功!');
+ // yield put({
+ // type: 'treeSuccess',
+ // payload: {
+ // list: response.data,
+ // },
+ // });
yield put({
- type: 'treeSuccess',
- payload: {
- list: response.data,
- },
+ type: 'tree',
+ payload: {},
});
},
*tree({ payload }, { call, put }) {
const { queryParams } = payload;
const response = yield call(dictionaryList, queryParams);
message.info('查询成功!');
+
+ // 将数据格式化成 tree 格式
+ // debugger;
+ let treeNodeMap = new Map(); // key: enumValue value: Node
+ for(let i = 0, len = response.data.length; i < len; i++){
+ let dataDict = response.data[i];
+ let treeNode = treeNodeMap.get(dataDict.enumValue);
+ if (!treeNode) {
+ treeNode = {
+ enumValue: dataDict.enumValue,
+ children: [dataDict]
+ };
+ treeNodeMap.set(dataDict.enumValue, treeNode);
+ treeNode.index = dataDict.enumValue; // 因为 Table 必须要有 rowKey ,所以这里需要处理下。主要是数据字典的结构特殊
+ } else {
+ treeNode.children.push(dataDict);
+ }
+ dataDict.index = dataDict.id; // 因为 Table 必须要有 rowKey ,所以这里需要处理下。主要是数据字典的结构特殊
+ }
+ // 因为不支持 Map.values() 返回的结果,所以这里进行转换。
+ let list = [];
+ treeNodeMap.forEach(function (value, key, map) {
+ list.push(value)
+ });
+ // console.log(list);
+
yield put({
type: 'treeSuccess',
payload: {
- list: response.data,
+ list: list,
},
});
},
diff --git a/admin-web/src/pages/Admin/DictionaryList.js b/admin-web/src/pages/Admin/DictionaryList.js
index a47b525be..720f6fbe7 100644
--- a/admin-web/src/pages/Admin/DictionaryList.js
+++ b/admin-web/src/pages/Admin/DictionaryList.js
@@ -3,7 +3,7 @@
import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import moment from 'moment';
-import { Card, Form, Input, Select, Button, Modal, message, Table, Divider } from 'antd';
+import { Card, Form, Input, InputNumber, Select, Button, Modal, message, Table, Divider } from 'antd';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import styles from './DictionaryList.less';
@@ -32,8 +32,8 @@ const CreateForm = Form.create()(props => {
width: 200,
};
- const title = modalType === 'add' ? '添加一个数据字典' : '更新一个数据字典';
- const okText = modalType === 'add' ? '添加' : '更新';
+ const title = modalType === 'add' ? '新建数据字典' : '编辑数据字典';
+ const okText = '保存';
return (