Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
e7fae73a
Commit
e7fae73a
authored
Nov 16, 2018
by
fengshuonan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改角色
parent
6ab43fac
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
165 deletions
+95
-165
src/main/java/cn/stylefeng/guns/modular/system/controller/RoleController.java
+14
-4
src/main/webapp/_static/modular/system/role/role.js
+1
-1
src/main/webapp/assets/modular/system/role/role.js
+1
-1
src/main/webapp/assets/modular/system/role/role_edit.js
+79
-159
No files found.
src/main/java/cn/stylefeng/guns/modular/system/controller/RoleController.java
View file @
e7fae73a
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
*/
*/
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
controller
;
package
cn
.
stylefeng
.
guns
.
modular
.
system
.
controller
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.stylefeng.guns.core.common.annotion.BussinessLog
;
import
cn.stylefeng.guns.core.common.annotion.BussinessLog
;
import
cn.stylefeng.guns.core.common.annotion.Permission
;
import
cn.stylefeng.guns.core.common.annotion.Permission
;
import
cn.stylefeng.guns.core.common.constant.Const
;
import
cn.stylefeng.guns.core.common.constant.Const
;
...
@@ -85,8 +86,8 @@ public class RoleController extends BaseController {
...
@@ -85,8 +86,8 @@ public class RoleController extends BaseController {
* 跳转到修改角色
* 跳转到修改角色
*/
*/
@Permission
@Permission
@RequestMapping
(
value
=
"/role_edit
/{roleId}
"
)
@RequestMapping
(
value
=
"/role_edit"
)
public
String
roleEdit
(
@
PathVariable
Integer
roleId
,
Model
model
)
{
public
String
roleEdit
(
@
RequestParam
Integer
roleId
,
Model
model
)
{
if
(
ToolUtil
.
isEmpty
(
roleId
))
{
if
(
ToolUtil
.
isEmpty
(
roleId
))
{
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -193,8 +194,17 @@ public class RoleController extends BaseController {
...
@@ -193,8 +194,17 @@ public class RoleController extends BaseController {
if
(
ToolUtil
.
isEmpty
(
roleId
))
{
if
(
ToolUtil
.
isEmpty
(
roleId
))
{
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
ServiceException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
this
.
roleService
.
selectById
(
roleId
);
Role
role
=
this
.
roleService
.
selectById
(
roleId
);
return
SUCCESS_TIP
;
Map
<
String
,
Object
>
roleMap
=
BeanUtil
.
beanToMap
(
role
);
Integer
pid
=
role
.
getPid
();
String
pName
=
ConstantFactory
.
me
().
getSingleRoleName
(
pid
);
roleMap
.
put
(
"pName"
,
pName
);
String
deptName
=
ConstantFactory
.
me
().
getDeptName
(
role
.
getDeptid
());
roleMap
.
put
(
"deptName"
,
deptName
);
return
ResponseData
.
success
(
roleMap
);
}
}
/**
/**
...
...
src/main/webapp/_static/modular/system/role/role.js
View file @
e7fae73a
...
@@ -63,7 +63,7 @@ Role.openChangeRole = function () {
...
@@ -63,7 +63,7 @@ Role.openChangeRole = function () {
area
:
[
'800px'
,
'450px'
],
//宽高
area
:
[
'800px'
,
'450px'
],
//宽高
fix
:
false
,
//不固定
fix
:
false
,
//不固定
maxmin
:
true
,
maxmin
:
true
,
content
:
Feng
.
ctxPath
+
'/role/role_edit
/
'
+
this
.
seItem
.
id
content
:
Feng
.
ctxPath
+
'/role/role_edit
?roleId=
'
+
this
.
seItem
.
id
});
});
this
.
layerIndex
=
index
;
this
.
layerIndex
=
index
;
}
}
...
...
src/main/webapp/assets/modular/system/role/role.js
View file @
e7fae73a
...
@@ -64,7 +64,7 @@ Role.openChangeRole = function () {
...
@@ -64,7 +64,7 @@ Role.openChangeRole = function () {
area
:
[
'800px'
,
'400px'
],
//宽高
area
:
[
'800px'
,
'400px'
],
//宽高
fix
:
false
,
//不固定
fix
:
false
,
//不固定
maxmin
:
true
,
maxmin
:
true
,
content
:
Feng
.
ctxPath
+
'/role/role_edit
/
'
+
this
.
seItem
.
id
content
:
Feng
.
ctxPath
+
'/role/role_edit
?roleId=
'
+
this
.
seItem
.
id
});
});
}
}
};
};
...
...
src/main/webapp/assets/modular/system/role/role_edit.js
View file @
e7fae73a
/**
/**
* 角色详情对话框(可用于添加和修改对话框)
* 角色详情对话框(可用于添加和修改对话框)
*/
*/
var
RolInfoDlg
=
{
var
RoleEditDlg
=
{
roleInfoData
:
{},
data
:
{
deptZtree
:
null
,
id
:
""
,
pNameZtree
:
null
,
name
:
""
,
validateFields
:
{
pName
:
""
,
name
:
{
pid
:
""
,
validators
:
{
tips
:
""
,
notEmpty
:
{
deptName
:
""
,
message
:
'用户名不能为空'
deptid
:
""
,
}
num
:
""
}
},
tips
:
{
validators
:
{
notEmpty
:
{
message
:
'别名不能为空'
}
}
},
pName
:
{
validators
:
{
notEmpty
:
{
message
:
'父级名称不能为空'
}
}
}
}
}
};
};
/**
/**
* 清除数据
*/
RolInfoDlg
.
clearData
=
function
()
{
this
.
roleInfoData
=
{};
};
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
RolInfoDlg
.
set
=
function
(
key
,
value
)
{
this
.
roleInfoData
[
key
]
=
(
typeof
value
==
"undefined"
)
?
$
(
"#"
+
key
).
val
()
:
value
;
return
this
;
};
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
RolInfoDlg
.
get
=
function
(
key
)
{
return
$
(
"#"
+
key
).
val
();
};
/**
* 关闭此对话框
* 关闭此对话框
*/
*/
Rol
Info
Dlg
.
close
=
function
()
{
Rol
eEdit
Dlg
.
close
=
function
()
{
parent
.
layer
.
close
(
window
.
parent
.
Role
.
layerIndex
);
parent
.
layer
.
close
(
window
.
parent
.
Role
.
layerIndex
);
};
};
/**
/**
* 点击部门input框时
* 验证表单
*
* @param e
* @param treeId
* @param treeNode
* @returns
*/
*/
RolInfoDlg
.
onClickDept
=
function
(
e
,
treeId
,
treeNode
)
{
RoleEditDlg
.
validateForm
=
function
()
{
$
(
"#deptName"
).
attr
(
"value"
,
RolInfoDlg
.
deptZtree
.
getSelectedVal
());
$
(
"#deptid"
).
attr
(
"value"
,
treeNode
.
id
);
};
RolInfoDlg
.
onDblClickDept
=
function
(
e
,
treeId
,
treeNode
)
{
$
(
"#deptName"
).
attr
(
"value"
,
RolInfoDlg
.
deptZtree
.
getSelectedVal
());
$
(
"#deptid"
).
attr
(
"value"
,
treeNode
.
id
);
$
(
"#deptContent"
).
fadeOut
(
"fast"
);
};
/**
var
data
=
RoleEditDlg
.
data
;
* 点击父级菜单input框时
*
* @param e
* @param treeId
* @param treeNode
* @returns
*/
RolInfoDlg
.
onClickPName
=
function
(
e
,
treeId
,
treeNode
)
{
$
(
"#pName"
).
attr
(
"value"
,
RolInfoDlg
.
pNameZtree
.
getSelectedVal
());
$
(
"#pid"
).
attr
(
"value"
,
treeNode
.
id
);
};
/**
if
(
!
data
.
name
)
{
* 显示部门选择的树
return
"请输入角色名称"
;
*
}
* @returns
if
(
!
(
data
.
pName
))
{
*/
return
"请输入上级名称"
;
RolInfoDlg
.
showDeptSelectTree
=
function
()
{
}
Feng
.
showInputTree
(
"deptName"
,
"deptContent"
);
if
(
!
data
.
deptName
)
{
};
return
"请输入部门名称"
;
}
/**
if
(
!
data
.
tips
)
{
* 显示父级菜单的树
return
"请输入备注"
;
*
* @returns
*/
RolInfoDlg
.
showPNameSelectTree
=
function
()
{
Feng
.
showInputTree
(
"pName"
,
"pNameContent"
);
};
/**
* 收集数据
*/
RolInfoDlg
.
collectData
=
function
()
{
this
.
set
(
'id'
).
set
(
'name'
).
set
(
'pid'
).
set
(
'deptid'
).
set
(
'tips'
).
set
(
'num'
);
};
/**
* 验证数据是否为空
*/
RolInfoDlg
.
validate
=
function
()
{
$
(
'#roleInfoForm'
).
data
(
"bootstrapValidator"
).
resetForm
();
$
(
'#roleInfoForm'
).
bootstrapValidator
(
'validate'
);
return
$
(
"#roleInfoForm"
).
data
(
'bootstrapValidator'
).
isValid
();
};
/**
* 提交添加用户
*/
RolInfoDlg
.
addSubmit
=
function
()
{
this
.
clearData
();
this
.
collectData
();
if
(
!
this
.
validate
())
{
return
;
}
}
//提交信息
return
true
;
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/role/add"
,
function
(
data
)
{
Feng
.
success
(
"添加成功!"
);
window
.
parent
.
Role
.
table
.
refresh
();
RolInfoDlg
.
close
();
},
function
(
data
)
{
Feng
.
error
(
"添加失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
ajax
.
set
(
this
.
roleInfoData
);
ajax
.
start
();
};
};
/**
/**
* 提交
修改
* 提交
添加角色
*/
*/
RolInfoDlg
.
editSubmit
=
function
()
{
RoleEditDlg
.
editSubmit
=
function
()
{
this
.
clearData
();
this
.
collectData
();
if
(
!
this
.
validate
())
{
return
;
}
//提交信息
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/role/edit"
,
function
(
data
)
{
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/role/edit"
,
function
(
data
)
{
Feng
.
success
(
"修改成功!"
);
Feng
.
success
(
"修改成功!"
);
window
.
parent
.
Role
.
table
.
refresh
();
window
.
parent
.
Role
.
table
.
refresh
();
Rol
Info
Dlg
.
close
();
Rol
eEdit
Dlg
.
close
();
},
function
(
data
)
{
},
function
(
data
)
{
Feng
.
error
(
"修改失败!"
+
data
.
responseJSON
.
message
+
"!"
);
Feng
.
error
(
"修改失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
});
ajax
.
set
(
this
.
roleInfoD
ata
);
ajax
.
set
(
this
.
d
ata
);
ajax
.
start
();
ajax
.
start
();
};
};
$
(
function
()
{
$
(
function
()
{
Feng
.
initValidator
(
"roleInfoForm"
,
RolInfoDlg
.
validateFields
);
var
deptTree
=
new
$ZTree
(
"deptTree"
,
"/dept/tree"
);
//初始化角色的详情数据
deptTree
.
bindOnClick
(
RolInfoDlg
.
onClickDept
);
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/role/view/"
+
Feng
.
getUrlParam
(
"roleId"
));
deptTree
.
bindOnDblClick
(
RolInfoDlg
.
onDblClickDept
)
var
result
=
ajax
.
start
();
deptTree
.
init
();
RoleEditDlg
.
data
=
result
.
data
;
RolInfoDlg
.
deptZtree
=
deptTree
;
RoleEditDlg
.
app
=
new
Vue
({
el
:
'#roleForm'
,
data
:
RoleEditDlg
.
data
,
methods
:
{
submitForm
:
function
(
e
)
{
e
.
preventDefault
();
},
showDeptSelectTree
:
function
()
{
var
formName
=
encodeURIComponent
(
"parent.RoleEditDlg.app.deptName"
);
var
formId
=
encodeURIComponent
(
"parent.RoleEditDlg.app.deptid"
);
var
treeUrl
=
encodeURIComponent
(
Feng
.
ctxPath
+
"/dept/tree"
);
layer
.
open
({
type
:
2
,
title
:
'部门选择'
,
area
:
[
'300px'
,
'400px'
],
content
:
Feng
.
ctxPath
+
'/system/commonTree?formName='
+
formName
+
"&formId="
+
formId
+
"&treeUrl="
+
treeUrl
});
},
showParentSelectTree
:
function
()
{
var
formName
=
encodeURIComponent
(
"parent.RoleEditDlg.app.pName"
);
var
formId
=
encodeURIComponent
(
"parent.RoleEditDlg.app.pid"
);
var
treeUrl
=
encodeURIComponent
(
Feng
.
ctxPath
+
"/role/roleTreeList"
);
layer
.
open
({
type
:
2
,
title
:
'部门选择'
,
area
:
[
'300px'
,
'400px'
],
content
:
Feng
.
ctxPath
+
'/system/commonTree?formName='
+
formName
+
"&formId="
+
formId
+
"&treeUrl="
+
treeUrl
});
},
ensure
:
function
()
{
var
result
=
RoleEditDlg
.
validateForm
();
if
(
result
===
true
)
{
RoleEditDlg
.
editSubmit
();
}
else
{
Feng
.
alert
(
result
);
}
},
close
:
function
()
{
RoleEditDlg
.
close
();
}
}
});
var
pNameTree
=
new
$ZTree
(
"pNameTree"
,
"/role/roleTreeList"
);
pNameTree
.
bindOnClick
(
RolInfoDlg
.
onClickPName
);
pNameTree
.
init
();
RolInfoDlg
.
pNameZtree
=
pNameTree
;
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment