Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
f47e5647
提交
f47e5647
authored
3月 15, 2019
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
前端-数据字典的增删改查
上级
b1e10dc5
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
113 行增加
和
62 行删除
+113
-62
admin.js
admin-web/mock/admin.js
+6
-0
dictionary-list.json
admin-web/mock/geographic/dictionary-list.json
+3
-2
dictionaryList.js
admin-web/src/models/admin/dictionaryList.js
+40
-10
DictionaryList.js
admin-web/src/pages/Admin/DictionaryList.js
+43
-50
admin.js
admin-web/src/services/admin.js
+21
-0
没有找到文件。
admin-web/mock/admin.js
浏览文件 @
f47e5647
...
@@ -6,6 +6,7 @@ import adminMenuAll from './geographic/admin-menu-all.json';
...
@@ -6,6 +6,7 @@ import adminMenuAll from './geographic/admin-menu-all.json';
import
adminUrls
from
'./geographic/admin-urls'
;
import
adminUrls
from
'./geographic/admin-urls'
;
import
resourceTree
from
'./geographic/resource-tree.json'
;
import
resourceTree
from
'./geographic/resource-tree.json'
;
import
roleQuery
from
'./geographic/role-query.json'
;
import
roleQuery
from
'./geographic/role-query.json'
;
import
dictionaryList
from
'./geographic/dictionary-list.json'
;
function
getAdminMenu
(
req
,
res
)
{
function
getAdminMenu
(
req
,
res
)
{
return
res
.
json
(
adminMenu
);
return
res
.
json
(
adminMenu
);
...
@@ -43,6 +44,10 @@ function getDictionaryText(req, res) {
...
@@ -43,6 +44,10 @@ function getDictionaryText(req, res) {
return
res
.
json
(
resultBody
(
values
));
return
res
.
json
(
resultBody
(
values
));
}
}
function
getDictionaryList
(
req
,
res
)
{
return
res
.
json
(
dictionaryList
);
}
export
default
{
export
default
{
'GET /admin-api/admins/admin/menu_resource_tree'
:
getAdminMenuAll
,
'GET /admin-api/admins/admin/menu_resource_tree'
:
getAdminMenuAll
,
'GET /admin-api/admins/admin/url_resource_list'
:
getAdminUrls
,
'GET /admin-api/admins/admin/url_resource_list'
:
getAdminUrls
,
...
@@ -51,4 +56,5 @@ export default {
...
@@ -51,4 +56,5 @@ export default {
'GET /admin-api/admins/admin/page'
:
getQueryRole
,
'GET /admin-api/admins/admin/page'
:
getQueryRole
,
'GET /admin-api/admins/dictionary/getList'
:
getDictionaryKeys
,
'GET /admin-api/admins/dictionary/getList'
:
getDictionaryKeys
,
'GET /admin-api/admins/dictionary/queryText'
:
getDictionaryText
,
'GET /admin-api/admins/dictionary/queryText'
:
getDictionaryText
,
// 'GET /admin-api/admins/data_dict/list': getDictionaryList,
};
};
admin-web/mock/geographic/dictionary-list.json
浏览文件 @
f47e5647
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
"value"
:
"1"
,
"value"
:
"1"
,
"displayName"
:
"男"
,
"displayName"
:
"男"
,
"sort"
:
1
,
"sort"
:
1
,
"memo"
:
""
"memo"
:
"
性别 - 男
"
},
},
{
{
"id"
:
2
,
"id"
:
2
,
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
"value"
:
"2"
,
"value"
:
"2"
,
"displayName"
:
"女"
,
"displayName"
:
"女"
,
"sort"
:
2
,
"sort"
:
2
,
"memo"
:
""
"memo"
:
"
性别 - 女
"
}
}
]
]
}
}
\ No newline at end of file
admin-web/src/models/admin/dictionaryList.js
浏览文件 @
f47e5647
import
{
message
}
from
'antd'
;
import
{
message
}
from
'antd'
;
import
{
addResource
,
updateResource
,
deleteResource
,
dictionaryList
}
from
'../../services/admin'
;
import
{
dictionaryAdd
,
dictionaryDelete
,
dictionaryList
,
dictionaryUpdate
}
from
'../../services/admin'
;
export
default
{
export
default
{
namespace
:
'dictionaryList'
,
namespace
:
'dictionaryList'
,
...
@@ -11,7 +11,7 @@ export default {
...
@@ -11,7 +11,7 @@ export default {
effects
:
{
effects
:
{
*
add
({
payload
},
{
call
,
put
})
{
*
add
({
payload
},
{
call
,
put
})
{
const
{
callback
,
body
}
=
payload
;
const
{
callback
,
body
}
=
payload
;
const
response
=
yield
call
(
addResource
,
body
);
const
response
=
yield
call
(
dictionaryAdd
,
body
);
if
(
callback
)
{
if
(
callback
)
{
callback
(
response
);
callback
(
response
);
}
}
...
@@ -22,7 +22,7 @@ export default {
...
@@ -22,7 +22,7 @@ export default {
},
},
*
update
({
payload
},
{
call
,
put
})
{
*
update
({
payload
},
{
call
,
put
})
{
const
{
callback
,
body
}
=
payload
;
const
{
callback
,
body
}
=
payload
;
const
response
=
yield
call
(
updateResourc
e
,
body
);
const
response
=
yield
call
(
dictionaryUpdat
e
,
body
);
if
(
callback
)
{
if
(
callback
)
{
callback
(
response
);
callback
(
response
);
}
}
...
@@ -32,23 +32,53 @@ export default {
...
@@ -32,23 +32,53 @@ export default {
});
});
},
},
*
delete
({
payload
},
{
call
,
put
})
{
*
delete
({
payload
},
{
call
,
put
})
{
const
response
=
yield
call
(
d
eleteResourc
e
,
payload
);
const
response
=
yield
call
(
d
ictionaryDelet
e
,
payload
);
message
.
info
(
'删除成功!'
);
message
.
info
(
'删除成功!'
);
// yield put({
// type: 'treeSuccess',
// payload: {
// list: response.data,
// },
// });
yield
put
({
yield
put
({
type
:
'treeSuccess'
,
type
:
'tree'
,
payload
:
{
payload
:
{},
list
:
response
.
data
,
},
});
});
},
},
*
tree
({
payload
},
{
call
,
put
})
{
*
tree
({
payload
},
{
call
,
put
})
{
const
{
queryParams
}
=
payload
;
const
{
queryParams
}
=
payload
;
const
response
=
yield
call
(
dictionaryList
,
queryParams
);
const
response
=
yield
call
(
dictionaryList
,
queryParams
);
message
.
info
(
'查询成功!'
);
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
({
yield
put
({
type
:
'treeSuccess'
,
type
:
'treeSuccess'
,
payload
:
{
payload
:
{
list
:
response
.
data
,
list
:
list
,
},
},
});
});
},
},
...
...
admin-web/src/pages/Admin/DictionaryList.js
浏览文件 @
f47e5647
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import
React
,
{
PureComponent
,
Fragment
}
from
'react'
;
import
React
,
{
PureComponent
,
Fragment
}
from
'react'
;
import
{
connect
}
from
'dva'
;
import
{
connect
}
from
'dva'
;
import
moment
from
'moment'
;
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
PageHeaderWrapper
from
'@/components/PageHeaderWrapper'
;
import
styles
from
'./DictionaryList.less'
;
import
styles
from
'./DictionaryList.less'
;
...
@@ -32,8 +32,8 @@ const CreateForm = Form.create()(props => {
...
@@ -32,8 +32,8 @@ const CreateForm = Form.create()(props => {
width
:
200
,
width
:
200
,
};
};
const
title
=
modalType
===
'add'
?
'
添加一个数据字典'
:
'更新一个
数据字典'
;
const
title
=
modalType
===
'add'
?
'
新建数据字典'
:
'编辑
数据字典'
;
const
okText
=
modalType
===
'add'
?
'添加'
:
'更新
'
;
const
okText
=
'保存
'
;
return
(
return
(
<
Modal
<
Modal
destroyOnClose
destroyOnClose
...
@@ -43,46 +43,35 @@ const CreateForm = Form.create()(props => {
...
@@ -43,46 +43,35 @@ const CreateForm = Form.create()(props => {
okText
=
{
okText
}
okText
=
{
okText
}
onCancel
=
{()
=>
handleModalVisible
()}
onCancel
=
{()
=>
handleModalVisible
()}
>
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"
菜单展示名
"
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"
大类枚举值
"
>
{
form
.
getFieldDecorator
(
'
displayNam
e'
,
{
{
form
.
getFieldDecorator
(
'
enumValu
e'
,
{
rules
:
[{
required
:
true
,
message
:
'请输入
菜单展示名字
!'
,
min
:
2
}],
rules
:
[{
required
:
true
,
message
:
'请输入
大类枚举值
!'
,
min
:
2
}],
initialValue
:
initValues
.
displayNam
e
,
initialValue
:
initValues
.
enumValu
e
,
})(
<
Input
placeholder
=
"请输入"
/>
)}
})(
<
Input
placeholder
=
"请输入"
/>
)}
<
/FormItem
>
<
/FormItem
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"操作"
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"小类数值"
>
{
form
.
getFieldDecorator
(
'handler'
,
{
{
form
.
getFieldDecorator
(
'value'
,
{
initialValue
:
initValues
.
handler
,
rules
:
[{
required
:
true
,
message
:
'请输入小类数值!'
}],
initialValue
:
initValues
.
value
,
})(
<
Input
placeholder
=
"请输入"
/>
)}
})(
<
Input
placeholder
=
"请输入"
/>
)}
<
/FormItem
>
<
/FormItem
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"资源名字"
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"展示名"
>
{
form
.
getFieldDecorator
(
'name'
,
{
{
form
.
getFieldDecorator
(
'displayName'
,
{
rules
:
[{
required
:
true
,
message
:
'请输入资源名字!'
}],
rules
:
[{
required
:
true
,
message
:
'请输入展示名!'
}],
initialValue
:
initValues
.
name
,
initialValue
:
initValues
.
displayName
,
})(
<
Input
placeholder
=
"请输入"
/>
)}
<
/FormItem
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"父级资源编号"
>
{
form
.
getFieldDecorator
(
'pid'
,
{
rules
:
[{
required
:
true
,
message
:
'请输入父级编号!'
}],
initialValue
:
initValues
.
pid
,
})(
<
Input
placeholder
=
"请输入"
/>
)}
})(
<
Input
placeholder
=
"请输入"
/>
)}
<
span
>
根节点为
0
<
/span
>
<
/FormItem
>
<
/FormItem
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"排序"
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"排序
值
"
>
{
form
.
getFieldDecorator
(
'sort'
,
{
{
form
.
getFieldDecorator
(
'sort'
,
{
rules
:
[{
required
:
true
,
message
:
'请输入
菜单排序
!'
}],
rules
:
[{
required
:
true
,
message
:
'请输入
排序值
!'
}],
initialValue
:
initValues
.
sort
,
initialValue
:
initValues
.
sort
,
})(
<
Input
placeholder
=
"请输入"
/>
)}
})(
<
Input
Number
placeholder
=
"请输入"
/>
)}
<
/FormItem
>
<
/FormItem
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"资源类型"
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"备注"
>
{
form
.
getFieldDecorator
(
'type'
,
{
{
form
.
getFieldDecorator
(
'memo'
,
{
rules
:
[{
required
:
true
,
message
:
'请选择资源类型!'
}],
rules
:
[{
required
:
true
,
message
:
'请输入备注!'
}],
initialValue
:
1
,
initialValue
:
initValues
.
memo
,
})(
})(
<
Input
.
TextArea
placeholder
=
"请输入"
/>
)}
<
Select
showSearch
style
=
{
selectStyle
}
placeholder
=
"请选择"
>
<
Option
value
=
{
1
}
>
菜单
<
/Option
>
<
Option
value
=
{
2
}
>
Url
<
/Option
>
<
/Select
>
)}
<
/FormItem
>
<
/FormItem
>
<
/Modal
>
<
/Modal
>
);
);
...
@@ -176,16 +165,17 @@ class DictionaryList extends PureComponent {
...
@@ -176,16 +165,17 @@ class DictionaryList extends PureComponent {
modalType
,
modalType
,
initValues
,
initValues
,
};
};
let
that
=
this
;
const
columns
=
[
const
columns
=
[
{
{
title
:
'枚举值'
,
title
:
'
大类
枚举值'
,
dataIndex
:
'enumValue'
dataIndex
:
'enumValue'
},
},
{
//
{
title
:
'编号'
,
//
title: '编号',
dataIndex
:
'id'
,
//
dataIndex: 'id',
},
//
},
{
{
title
:
'小类数值'
,
title
:
'小类数值'
,
dataIndex
:
'value'
dataIndex
:
'value'
...
@@ -210,15 +200,18 @@ class DictionaryList extends PureComponent {
...
@@ -210,15 +200,18 @@ class DictionaryList extends PureComponent {
},
},
{
{
title
:
'操作'
,
title
:
'操作'
,
render
:
(
text
,
record
)
=>
(
render
:
function
(
text
,
record
)
{
<
Fragment
>
if
(
!
record
.
id
)
{
<
a
onClick
=
{()
=>
this
.
handleModalVisible
(
true
,
'update'
,
record
)}
>
更新
<
/a
>
return
''
;
<
Divider
type
=
"vertical"
/>
}
<
a
className
=
{
styles
.
tableDelete
}
onClick
=
{()
=>
this
.
handleDelete
(
record
)}
>
return
<
Fragment
>
删除
<
a
onClick
=
{()
=>
that
.
handleModalVisible
(
true
,
'update'
,
record
)}
>
编辑
<
/a
>
<
/a
>
<
Divider
type
=
"vertical"
/>
<
/Fragment
>
<
a
className
=
{
styles
.
tableDelete
}
onClick
=
{()
=>
that
.
handleDelete
(
record
)}
>
),
删除
<
/a
>
<
/Fragment
>
}
},
},
];
];
...
@@ -232,11 +225,11 @@ class DictionaryList extends PureComponent {
...
@@ -232,11 +225,11 @@ class DictionaryList extends PureComponent {
type
=
"primary"
type
=
"primary"
onClick
=
{()
=>
this
.
handleModalVisible
(
true
,
'add'
,
{})}
onClick
=
{()
=>
this
.
handleModalVisible
(
true
,
'add'
,
{})}
>
>
新建
新建
数据字典
<
/Button
>
<
/Button
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
Table
defaultExpandAllRows
=
{
true
}
columns
=
{
columns
}
dataSource
=
{
list
}
rowKey
=
"
enumValue
"
/>
<
Table
defaultExpandAllRows
=
{
true
}
columns
=
{
columns
}
dataSource
=
{
list
}
rowKey
=
"
index
"
/>
<
/Card
>
<
/Card
>
<
CreateForm
{...
parentMethods
}
modalVisible
=
{
modalVisible
}
/
>
<
CreateForm
{...
parentMethods
}
modalVisible
=
{
modalVisible
}
/
>
<
/PageHeaderWrapper
>
<
/PageHeaderWrapper
>
...
...
admin-web/src/services/admin.js
浏览文件 @
f47e5647
...
@@ -129,4 +129,24 @@ export async function dictionaryList(params) {
...
@@ -129,4 +129,24 @@ export async function dictionaryList(params) {
return
request
(
`/admin-api/admins/data_dict/list?
${
stringify
(
params
)}
`
,
{
return
request
(
`/admin-api/admins/data_dict/list?
${
stringify
(
params
)}
`
,
{
method
:
'GET'
,
method
:
'GET'
,
});
});
}
export
async
function
dictionaryAdd
(
params
)
{
return
request
(
`/admin-api/admins/data_dict/add?
${
stringify
(
params
)}
`
,
{
method
:
'POST'
,
body
:
{},
});
}
export
async
function
dictionaryUpdate
(
params
)
{
return
request
(
`/admin-api/admins/data_dict/update?
${
stringify
(
params
)}
`
,
{
method
:
'POST'
,
body
:
{},
});
}
export
async
function
dictionaryDelete
(
params
)
{
return
request
(
`/admin-api/admins/data_dict/delete?
${
stringify
(
params
)}
`
,
{
method
:
'POST'
,
});
}
}
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论