| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <!DOCTYPE html>
- <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
- <head>
- <th:block th:include="include :: header('修改角色')" />
- <th:block th:include="include :: ztree-css" />
- </head>
- <body class="white-bg">
- <div class="wrapper wrapper-content animated fadeInRight ibox-content">
- <form class="form-horizontal m" id="form-role-edit" th:object="${user}">
- <input id="userId" name="userId" type="hidden" th:field="*{userId}"/>
- <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>
- <th:block th:include="include :: footer" />
- <th:block th:include="include :: ztree-js" />
- <script type="text/javascript">
- $(function() {
- var url = ctx + "system/author/tree/" + $("#userId").val();
- var options = {
- id: "menuTrees",
- url: url,
- check: { enable: true},
- expandLevel: 0,
- onCheck:function (event,treeId,treeNode) {
- // console.log(treeNode);
- // console.log(treeNode.getParentNode());
- }
- };
- $.tree.init(options);
- });
-
- $("#form-role-edit").validate({
- onkeyup: false,
- rules:{
- roleName:{
- remote: {
- url: ctx + "system/role/checkRoleNameUnique",
- type: "post",
- dataType: "json",
- data: {
- "roleId": function() {
- return $("#roleId").val();
- },
- "roleName": function() {
- return $.common.trim($("#roleName").val());
- }
- },
- dataFilter: function(data, type) {
- return $.validate.unique(data);
- }
- }
- },
- roleKey:{
- remote: {
- url: ctx + "system/role/checkRoleKeyUnique",
- type: "post",
- dataType: "json",
- data: {
- "roleId": function() {
- return $("#roleId").val();
- },
- "roleKey": function() {
- return $.common.trim($("#roleKey").val());
- }
- },
- dataFilter: function(data, type) {
- return $.validate.unique(data);
- }
- }
- },
- roleSort:{
- digits:true
- },
- },
- messages: {
- "roleName": {
- remote: "角色名称已经存在"
- },
- "roleKey": {
- remote: "角色权限已经存在"
- }
- },
- focusCleanup: true
- });
- function edit() {
- var userId = $("input[name='userId']").val();
- // console.log($.tree)
- // console.log($.tree.getNodes()[0].getCheckStatus())
- var authorIds = $.tree.getCheckedNodesRole();
- $.ajax({
- cache : true,
- type : "POST",
- url : ctx + "system/author/tree/edit",
- data : {
- "userId": userId,
- "authorIds": authorIds
- },
- async : false,
- error : function(request) {
- $.modal.alertError("系统错误");
- },
- success : function(data) {
- $.operate.successCallback(data);
- }
- });
- }
-
- function submitHandler() {
- if ($.validate.form()) {
- edit();
- }
- }
- </script>
- </body>
- </html>
|