Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
b29844f0
提交
b29844f0
authored
3月 21, 2019
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
前端:管理员模块添加功能重构
前端:管理员模块修改功能重构
上级
e3a14c2a
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
140 行增加
和
106 行删除
+140
-106
DictionaryText.js
admin-web/src/components/Dictionary/DictionaryText.js
+1
-1
adminList.js
admin-web/src/models/admin/adminList.js
+44
-20
AdminList.js
admin-web/src/pages/Admin/AdminList.js
+81
-84
AdminAddDTO.java
.../main/java/cn/iocoder/mall/admin/api/dto/AdminAddDTO.java
+7
-0
AdminUpdateDTO.java
...in/java/cn/iocoder/mall/admin/api/dto/AdminUpdateDTO.java
+7
-1
没有找到文件。
admin-web/src/components/Dictionary/DictionaryText.js
浏览文件 @
b29844f0
...
@@ -5,7 +5,7 @@ export default class DictionaryText extends PureComponent {
...
@@ -5,7 +5,7 @@ export default class DictionaryText extends PureComponent {
componentDidMount
()
{}
componentDidMount
()
{}
render
()
{
render
()
{
debugger
;
//
debugger;
const
{
dicKey
,
dicValue
}
=
this
.
props
;
const
{
dicKey
,
dicValue
}
=
this
.
props
;
return
(
return
(
<
DictionaryContext
.
Consumer
>
<
DictionaryContext
.
Consumer
>
...
...
admin-web/src/models/admin/adminList.js
浏览文件 @
b29844f0
...
@@ -20,10 +20,17 @@ export default {
...
@@ -20,10 +20,17 @@ export default {
namespace
:
'adminList'
,
namespace
:
'adminList'
,
state
:
{
state
:
{
// 分页列表相关
list
:
[],
list
:
[],
searchParams
:
SEARCH_PARAMS_DEFAULT
,
searchParams
:
SEARCH_PARAMS_DEFAULT
,
pagination
:
PaginationHelper
.
defaultPaginationConfig
,
pagination
:
PaginationHelper
.
defaultPaginationConfig
,
// 添加 or 修改表单相关
modalVisible
:
false
,
modalType
:
undefined
,
// 'add' or 'update' 表单
formVals
:
{},
// 当前表单值
// 分配角色表单相关
roleList
:
[],
roleList
:
[],
roleCheckedKeys
:
[],
roleCheckedKeys
:
[],
roleAssignLoading
:
false
,
roleAssignLoading
:
false
,
...
@@ -44,31 +51,37 @@ export default {
...
@@ -44,31 +51,37 @@ export default {
},
},
});
});
},
},
*
add
({
payload
},
{
call
,
put
})
{
*
add
({
payload
},
{
call
,
put
})
{
const
{
callback
,
body
,
queryParams
}
=
payload
;
const
{
callback
,
body
}
=
payload
;
const
response
=
yield
call
(
addAdmin
,
body
);
const
response
=
yield
call
(
addAdmin
,
body
);
if
(
callback
)
{
if
(
response
.
code
===
0
)
{
callback
(
response
);
if
(
callback
)
{
callback
(
response
);
}
// 刷新列表
yield
put
({
type
:
'query'
,
payload
:
{
...
PaginationHelper
.
defaultPayload
},
});
}
}
yield
put
({
type
:
'query'
,
payload
:
{
...
queryParams
,
},
});
},
},
*
update
({
payload
},
{
call
,
put
})
{
*
update
({
payload
},
{
call
,
put
})
{
const
{
callback
,
body
,
queryParams
}
=
payload
;
const
{
callback
,
body
}
=
payload
;
const
response
=
yield
call
(
updateAdmin
,
body
);
const
response
=
yield
call
(
updateAdmin
,
body
);
if
(
callback
)
{
if
(
response
.
code
===
0
)
{
callback
(
response
);
if
(
callback
)
{
callback
(
response
);
}
// 刷新列表
yield
put
({
type
:
'query'
,
payload
:
{
...
PaginationHelper
.
defaultPayload
},
});
}
}
yield
put
({
type
:
'query'
,
payload
:
{
...
queryParams
,
},
});
},
},
*
updateStatus
({
payload
},
{
call
,
put
})
{
*
updateStatus
({
payload
},
{
call
,
put
})
{
const
{
body
,
queryParams
}
=
payload
;
const
{
body
,
queryParams
}
=
payload
;
...
@@ -148,5 +161,16 @@ export default {
...
@@ -148,5 +161,16 @@ export default {
roleAssignLoading
:
payload
,
roleAssignLoading
:
payload
,
};
};
},
},
setAll
(
state
,
{
payload
})
{
console
.
log
(
'setAll'
);
console
.
log
({
...
state
,
...
payload
,
});
return
{
...
state
,
...
payload
,
};
}
},
},
};
};
admin-web/src/pages/Admin/AdminList.js
浏览文件 @
b29844f0
...
@@ -15,7 +15,7 @@ const { TreeNode } = Tree;
...
@@ -15,7 +15,7 @@ const { TreeNode } = Tree;
const
status
=
[
'未知'
,
'正常'
,
'禁用'
];
const
status
=
[
'未知'
,
'正常'
,
'禁用'
];
// 列表
// 列表
function
List
({
dataSource
,
pagination
,
searchParams
,
dispatch
})
{
function
List
({
dataSource
,
pagination
,
searchParams
,
dispatch
,
handleModalVisible
})
{
const
columns
=
[
const
columns
=
[
{
{
title
:
'用户名'
,
title
:
'用户名'
,
...
@@ -44,7 +44,7 @@ function List ({ dataSource, pagination, searchParams, dispatch }) {
...
@@ -44,7 +44,7 @@ function List ({ dataSource, pagination, searchParams, dispatch }) {
const
statusText
=
record
.
status
===
1
?
'禁用'
:
'禁用'
;
const
statusText
=
record
.
status
===
1
?
'禁用'
:
'禁用'
;
return
(
return
(
<
Fragment
>
<
Fragment
>
<
a
onClick
=
{()
=>
this
.
handleModalVisible
(
true
,
'update'
,
record
)}
>
编辑
<
/a
>
<
a
onClick
=
{()
=>
handleModalVisible
(
true
,
'update'
,
record
)}
>
编辑
<
/a
>
<
Divider
type
=
"vertical"
/>
<
Divider
type
=
"vertical"
/>
<
a
onClick
=
{()
=>
this
.
handleRoleAssign
(
record
)}
>
角色分配
<
/a
>
<
a
onClick
=
{()
=>
this
.
handleRoleAssign
(
record
)}
>
角色分配
<
/a
>
<
Divider
type
=
"vertical"
/>
<
Divider
type
=
"vertical"
/>
...
@@ -147,19 +147,51 @@ const SearchForm = Form.create()(props => {
...
@@ -147,19 +147,51 @@ const SearchForm = Form.create()(props => {
);
);
});
});
// 添加
f
orm 表单
// 添加
or 修改 F
orm 表单
const
AddOrUpdateForm
=
Form
.
create
()(
props
=>
{
const
AddOrUpdateForm
=
Form
.
create
()(
props
=>
{
const
{
modalVisible
,
form
,
handleAdd
,
handleModalVisible
,
modalType
,
initValue
s
}
=
props
;
const
{
dispatch
,
modalVisible
,
form
,
handleModalVisible
,
modalType
,
formVal
s
}
=
props
;
const
okHandle
=
()
=>
{
const
okHandle
=
()
=>
{
form
.
validateFields
((
err
,
fields
Value
)
=>
{
form
.
validateFields
((
err
,
fields
)
=>
{
if
(
err
)
return
;
if
(
err
)
return
;
form
.
resetFields
();
// 添加表单
handleAdd
({
if
(
modalType
===
'add'
)
{
fields
:
fieldsValue
,
dispatch
({
modalType
,
type
:
'adminList/add'
,
initValues
,
payload
:
{
});
body
:
{
...
fields
,
},
callback
:
()
=>
{
// 清空表单
form
.
resetFields
();
// 提示
message
.
success
(
'添加成功'
);
// 关闭弹窗
handleModalVisible
();
},
},
});
// 修改表单
}
else
{
dispatch
({
type
:
'adminList/update'
,
payload
:
{
body
:
{
...
formVals
,
...
fields
,
},
callback
:
()
=>
{
// 清空表单
form
.
resetFields
();
// 提示
message
.
success
(
'更新成功'
);
// 关闭弹窗
handleModalVisible
();
},
},
});
}
});
});
};
};
...
@@ -176,24 +208,24 @@ const AddOrUpdateForm = Form.create()(props => {
...
@@ -176,24 +208,24 @@ const AddOrUpdateForm = Form.create()(props => {
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"用户名"
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"用户名"
>
{
form
.
getFieldDecorator
(
'username'
,
{
{
form
.
getFieldDecorator
(
'username'
,
{
rules
:
[{
required
:
true
,
message
:
'请输入用户名!'
},
rules
:
[{
required
:
true
,
message
:
'请输入用户名!'
},
{
max
:
16
,
min
:
6
,
message
:
'长度为
6-16
位'
},
{
max
:
16
,
min
:
6
,
message
:
'长度为
6-16
位'
},
{
validator
:
(
rule
,
value
,
callback
)
=>
checkTypeWithEnglishAndNumbers
(
rule
,
value
,
callback
,
'数字以及字母'
)}
{
validator
:
(
rule
,
value
,
callback
)
=>
checkTypeWithEnglishAndNumbers
(
rule
,
value
,
callback
,
'数字以及字母'
)}
],
],
initialValue
:
initValue
s
.
username
,
initialValue
:
formVal
s
.
username
,
})(
<
Input
placeholder
=
"请输入"
/>
)}
})(
<
Input
placeholder
=
"请输入"
/>
)}
<
/FormItem
>
<
/FormItem
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"昵称"
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"昵称"
>
{
form
.
getFieldDecorator
(
'nickname'
,
{
{
form
.
getFieldDecorator
(
'nickname'
,
{
rules
:
[{
required
:
true
,
message
:
'请输入昵称!'
},
rules
:
[{
required
:
true
,
message
:
'请输入昵称!'
},
{
max
:
10
,
message
:
'姓名最大长度为10'
}],
{
max
:
10
,
message
:
'姓名最大长度为
10'
}],
initialValue
:
initValue
s
.
nickname
,
initialValue
:
formVal
s
.
nickname
,
})(
<
Input
placeholder
=
"请输入"
/>
)}
})(
<
Input
placeholder
=
"请输入"
/>
)}
<
/FormItem
>
<
/FormItem
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"密码"
>
<
FormItem
labelCol
=
{{
span
:
5
}}
wrapperCol
=
{{
span
:
15
}}
label
=
"密码"
>
{
form
.
getFieldDecorator
(
'password'
,
{
{
form
.
getFieldDecorator
(
'password'
,
{
rules
:
[{
required
:
modalType
===
'add'
,
message
:
'请填写密码'
},
// 添加时,必须输入密码
rules
:
[{
required
:
modalType
===
'add'
,
message
:
'请填写密码'
},
// 添加时,必须输入密码
{
max
:
16
,
min
:
6
,
message
:
'长度为
6-18
位'
}],
{
max
:
16
,
min
:
6
,
message
:
'长度为
6-18
位'
}],
initialValue
:
initValue
s
.
password
,
initialValue
:
formVal
s
.
password
,
})(
<
Input
placeholder
=
"请输入"
type
=
"password"
/>
)}
})(
<
Input
placeholder
=
"请输入"
type
=
"password"
/>
)}
<
/FormItem
>
<
/FormItem
>
<
/Modal
>
<
/Modal
>
...
@@ -281,13 +313,8 @@ const RoleAssignModal = Form.create()(props => {
...
@@ -281,13 +313,8 @@ const RoleAssignModal = Form.create()(props => {
}))
}))
@
Form
.
create
()
@
Form
.
create
()
class
Resource
List
extends
PureComponent
{
class
Admin
List
extends
PureComponent
{
state
=
{
state
=
{
// 添加 or 修改弹窗
modalVisible
:
false
,
modalType
:
undefined
,
// 'add' or 'update'
initValues
:
{},
// 分配角色弹窗
// 分配角色弹窗
modalRoleVisible
:
false
,
modalRoleVisible
:
false
,
...
@@ -304,52 +331,19 @@ class ResourceList extends PureComponent {
...
@@ -304,52 +331,19 @@ class ResourceList extends PureComponent {
});
});
}
}
handleModalVisible
=
(
flag
,
modalType
,
initValues
)
=>
{
handleModalVisible
=
(
modalVisible
,
modalType
,
formVals
)
=>
{
this
.
setState
({
// debugger;
modalVisible
:
!!
flag
,
const
{
dispatch
}
=
this
.
props
;
initValues
:
initValues
||
{},
dispatch
({
modalType
:
modalType
||
'add'
,
type
:
'adminList/setAll'
,
payload
:
{
modalVisible
,
modalType
,
formVals
:
formVals
||
{}
},
});
});
};
};
handleAdd
=
({
fields
,
modalType
,
initValues
})
=>
{
const
{
dispatch
,
data
}
=
this
.
props
;
const
queryParams
=
{
pageNo
:
data
.
pageNo
,
pageSize
:
data
.
pageSize
,
};
if
(
modalType
===
'add'
)
{
dispatch
({
type
:
'adminList/add'
,
payload
:
{
body
:
{
...
fields
,
},
queryParams
,
callback
:
()
=>
{
message
.
success
(
'添加成功'
);
this
.
handleModalVisible
();
},
},
});
}
else
{
dispatch
({
type
:
'adminList/update'
,
payload
:
{
body
:
{
...
initValues
,
...
fields
,
},
queryParams
,
callback
:
()
=>
{
message
.
success
(
'更新成功'
);
this
.
handleModalVisible
();
},
},
});
}
};
handleStatus
(
row
)
{
handleStatus
(
row
)
{
const
{
dispatch
,
data
}
=
this
.
props
;
const
{
dispatch
,
data
}
=
this
.
props
;
const
queryParams
=
{
const
queryParams
=
{
...
@@ -450,29 +444,25 @@ class ResourceList extends PureComponent {
...
@@ -450,29 +444,25 @@ class ResourceList extends PureComponent {
};
};
render
()
{
render
()
{
let
that
=
this
;
//
let that = this;
const
{
dispatch
,
list
,
searchParams
,
pagination
,
data
}
=
this
.
props
;
const
{
dispatch
,
list
,
searchParams
,
pagination
,
modalVisible
,
data
,
modalType
,
formVals
}
=
this
.
props
;
const
{
roleList
,
roleCheckedKeys
,
roleAssignLoading
}
=
data
;
const
{
roleList
,
roleCheckedKeys
,
roleAssignLoading
}
=
data
;
const
{
// const {
modalVisible
,
// // modalVisible,
modalType
,
// // modalType,
initValues
,
// formVals,
modalRoleVisible
,
// modalRoleVisible,
}
=
this
.
state
;
// } = this.state;
const
modalRoleVisible
=
false
;
const
parentMethods
=
{
handleAdd
:
this
.
handleAdd
,
handleModalVisible
:
this
.
handleModalVisible
,
modalType
,
initValues
,
};
// 列表属性
// 列表属性
const
listProps
=
{
const
listProps
=
{
dataSource
:
list
,
dataSource
:
list
,
pagination
,
pagination
,
searchParams
,
searchParams
,
dispatch
dispatch
,
handleModalVisible
:
this
.
handleModalVisible
,
// Function
};
};
// 搜索表单属性
// 搜索表单属性
...
@@ -481,6 +471,13 @@ class ResourceList extends PureComponent {
...
@@ -481,6 +471,13 @@ class ResourceList extends PureComponent {
};
};
// 添加
// 添加
const
addFormProps
=
{
modalVisible
,
modalType
:
modalType
,
formVals
:
formVals
,
dispatch
,
handleModalVisible
:
this
.
handleModalVisible
,
// Function
};
return
(
return
(
<
PageHeaderWrapper
>
<
PageHeaderWrapper
>
...
@@ -502,7 +499,7 @@ class ResourceList extends PureComponent {
...
@@ -502,7 +499,7 @@ class ResourceList extends PureComponent {
<
List
{...
listProps
}
/
>
<
List
{...
listProps
}
/
>
<
/Card
>
<
/Card
>
<
AddOrUpdateForm
{...
parentMethods
}
modalVisible
=
{
modalVisible
}
/
>
<
AddOrUpdateForm
{...
addFormProps
}
/
>
<
RoleAssignModal
<
RoleAssignModal
loading
=
{
roleAssignLoading
}
loading
=
{
roleAssignLoading
}
...
@@ -518,4 +515,4 @@ class ResourceList extends PureComponent {
...
@@ -518,4 +515,4 @@ class ResourceList extends PureComponent {
}
}
}
}
export
default
Resource
List
;
export
default
Admin
List
;
admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/AdminAddDTO.java
浏览文件 @
b29844f0
package
cn
.
iocoder
.
mall
.
admin
.
api
.
dto
;
package
cn
.
iocoder
.
mall
.
admin
.
api
.
dto
;
import
org.hibernate.validator.constraints.Length
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.Pattern
;
/**
/**
* 管理员添加 DTO
* 管理员添加 DTO
...
@@ -11,16 +14,20 @@ public class AdminAddDTO {
...
@@ -11,16 +14,20 @@ public class AdminAddDTO {
* 登陆账号
* 登陆账号
*/
*/
@NotEmpty
(
message
=
"登陆账号不能为空"
)
@NotEmpty
(
message
=
"登陆账号不能为空"
)
@Length
(
min
=
6
,
max
=
16
,
message
=
"账号长度为 6-16 位"
)
@Pattern
(
regexp
=
"^[A-Za-z0-9]+$"
,
message
=
"账号格式为数字以及字母"
)
private
String
username
;
private
String
username
;
/**
/**
* 昵称
* 昵称
*/
*/
@NotEmpty
(
message
=
"昵称不能为空"
)
@NotEmpty
(
message
=
"昵称不能为空"
)
@Length
(
max
=
10
,
message
=
"昵称长度最大为 10 位"
)
private
String
nickname
;
private
String
nickname
;
/**
/**
* 密码
* 密码
*/
*/
@NotEmpty
(
message
=
"密码不能为空"
)
@NotEmpty
(
message
=
"密码不能为空"
)
@Length
(
min
=
6
,
max
=
16
,
message
=
"密码长度为 6-16 位"
)
private
String
password
;
private
String
password
;
public
String
getUsername
()
{
public
String
getUsername
()
{
...
...
admin/admin-service-api/src/main/java/cn/iocoder/mall/admin/api/dto/AdminUpdateDTO.java
浏览文件 @
b29844f0
package
cn
.
iocoder
.
mall
.
admin
.
api
.
dto
;
package
cn
.
iocoder
.
mall
.
admin
.
api
.
dto
;
import
org.hibernate.validator.constraints.Length
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Pattern
;
/**
/**
* 管理员更新 DTO
* 管理员更新 DTO
...
@@ -17,16 +20,19 @@ public class AdminUpdateDTO {
...
@@ -17,16 +20,19 @@ public class AdminUpdateDTO {
* 登陆账号
* 登陆账号
*/
*/
@NotEmpty
(
message
=
"登陆账号不能为空"
)
@NotEmpty
(
message
=
"登陆账号不能为空"
)
@Length
(
min
=
6
,
max
=
16
,
message
=
"账号长度为 6-16 位"
)
@Pattern
(
regexp
=
"^[A-Za-z0-9]+$"
,
message
=
"账号格式为数字以及字母"
)
private
String
username
;
private
String
username
;
/**
/**
* 昵称
* 昵称
*/
*/
@NotEmpty
(
message
=
"昵称不能为空"
)
@NotEmpty
(
message
=
"昵称不能为空"
)
@Length
(
max
=
10
,
message
=
"昵称长度最大为 10 位"
)
private
String
nickname
;
private
String
nickname
;
/**
/**
* 密码
* 密码
*/
*/
@
NotEmpty
(
message
=
"密码不能为空
"
)
@
Length
(
min
=
6
,
max
=
16
,
message
=
"密码长度为 6-16 位
"
)
private
String
password
;
private
String
password
;
public
String
getUsername
()
{
public
String
getUsername
()
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论