Files
RuoYi/ruoyi-admin/src/main/resources/templates/system/role/edit.html

161 lines
5.1 KiB
HTML
Raw Normal View History

2018-07-09 08:44:52 +08:00
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
2018-09-03 08:45:08 +08:00
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>
2018-07-09 08:44:52 +08:00
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-role-edit" th:object="${role}">
<input id="roleId" name="roleId" type="hidden" th:field="*{roleId}"/>
<div class="form-group">
<label class="col-sm-3 control-label ">角色名称:</label>
<div class="col-sm-8">
2019-02-25 13:19:06 +08:00
<input class="form-control" type="text" name="roleName" id="roleName" th:field="*{roleName}" required>
2018-07-09 08:44:52 +08:00
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">权限字符:</label>
<div class="col-sm-8">
2019-02-25 13:19:06 +08:00
<input class="form-control" type="text" name="roleKey" id="roleKey" th:field="*{roleKey}" required>
2018-07-09 08:44:52 +08:00
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">显示顺序:</label>
<div class="col-sm-8">
2019-02-25 13:19:06 +08:00
<input class="form-control" type="text" name="roleSort" id="roleSort" th:field="*{roleSort}" required>
2018-07-09 08:44:52 +08:00
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
<div class="onoffswitch">
<input type="checkbox" th:checked="${role.status == '0' ? true : false}" class="onoffswitch-checkbox" id="status" name="status">
<label class="onoffswitch-label" for="status">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">备注:</label>
<div class="col-sm-8">
<input id="remark" name="remark" class="form-control" type="text" th:field="*{remark}">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">菜单权限</label>
<div class="col-sm-8">
<div id="menuTrees" class="ztree"></div>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script type="text/javascript">
2018-09-03 08:45:08 +08:00
$(function() {
var url = ctx + "system/menu/roleMenuTreeData?roleId=" + $("#roleId").val();
var options = {
id: "menuTrees",
url: url,
2019-03-01 15:26:04 +08:00
check: { enable: true },
2018-09-03 08:45:08 +08:00
expandLevel: 0
};
$.tree.init(options);
});
2018-07-29 17:04:32 +08:00
2018-07-09 08:44:52 +08:00
$("#form-role-edit").validate({
onkeyup: false,
2018-07-09 08:44:52 +08:00
rules:{
roleName:{
remote: {
url: ctx + "system/role/checkRoleNameUnique",
type: "post",
dataType: "json",
data: {
"roleId": function() {
2018-08-23 17:06:31 +08:00
return $("#roleId").val();
2018-07-09 08:44:52 +08:00
},
"roleName": function() {
2018-08-23 17:06:31 +08:00
return $.common.trim($("#roleName").val());
2018-07-09 08:44:52 +08:00
}
},
dataFilter: function(data, type) {
2018-08-23 17:06:31 +08:00
return $.validate.unique(data);
2018-07-09 08:44:52 +08:00
}
}
},
roleKey:{
2018-08-01 13:17:11 +08:00
remote: {
url: ctx + "system/role/checkRoleKeyUnique",
type: "post",
dataType: "json",
data: {
"roleId": function() {
2018-08-23 17:06:31 +08:00
return $("#roleId").val();
2018-08-01 13:17:11 +08:00
},
"roleKey": function() {
2018-08-23 17:06:31 +08:00
return $.common.trim($("#roleKey").val());
2018-08-01 13:17:11 +08:00
}
},
dataFilter: function(data, type) {
2018-08-23 17:06:31 +08:00
return $.validate.unique(data);
2018-08-01 13:17:11 +08:00
}
}
2018-07-09 08:44:52 +08:00
},
roleSort:{
digits:true
},
},
messages: {
"roleName": {
2018-08-01 13:17:11 +08:00
remote: "角色名称已经存在"
},
"roleKey": {
remote: "角色权限已经存在"
2018-07-09 08:44:52 +08:00
}
2019-02-25 13:19:06 +08:00
},
focusCleanup: true
2018-07-09 08:44:52 +08:00
});
2018-09-03 08:45:08 +08:00
2018-07-09 08:44:52 +08:00
function edit() {
var roleId = $("input[name='roleId']").val();
var roleName = $("input[name='roleName']").val();
var roleKey = $("input[name='roleKey']").val();
var roleSort = $("input[name='roleSort']").val();
var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
var remark = $("input[name='remark']").val();
2018-09-03 08:45:08 +08:00
var menuIds = $.tree.getCheckedNodes();
2018-07-09 08:44:52 +08:00
$.ajax({
cache : true,
type : "POST",
2018-07-22 23:05:50 +08:00
url : ctx + "system/role/edit",
2018-07-09 08:44:52 +08:00
data : {
"roleId": roleId,
"roleName": roleName,
"roleKey": roleKey,
"roleSort": roleSort,
"status": status,
"remark": remark,
2018-07-29 17:04:32 +08:00
"menuIds": menuIds
2018-07-09 08:44:52 +08:00
},
async : false,
error : function(request) {
$.modal.alertError("系统错误");
},
success : function(data) {
2018-11-25 17:27:57 +08:00
$.operate.successCallback(data);
2018-07-09 08:44:52 +08:00
}
});
}
2018-10-03 21:44:14 +08:00
function submitHandler() {
2018-10-03 23:11:09 +08:00
if ($.validate.form()) {
2018-10-03 21:44:14 +08:00
edit();
}
}
2018-07-09 08:44:52 +08:00
</script>
</body>
</html>