dataScope.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('角色数据权限')" />
  5. <th:block th:include="include :: ztree-css" />
  6. </head>
  7. <body class="white-bg">
  8. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  9. <form class="form-horizontal m" id="form-role-edit" th:object="${role}">
  10. <input id="roleId" name="roleId" type="hidden" th:field="*{roleId}"/>
  11. <div class="form-group">
  12. <label class="col-sm-3 control-label ">角色名称:</label>
  13. <div class="col-sm-8">
  14. <input class="form-control" type="text" name="roleName" id="roleName" th:field="*{roleName}" readonly="true"/>
  15. </div>
  16. </div>
  17. <div class="form-group">
  18. <label class="col-sm-3 control-label">权限字符:</label>
  19. <div class="col-sm-8">
  20. <input class="form-control" type="text" name="roleKey" id="roleKey" th:field="*{roleKey}" readonly="true">
  21. </div>
  22. </div>
  23. <div class="form-group">
  24. <label class="col-sm-3 control-label">数据范围:</label>
  25. <div class="col-sm-8">
  26. <select id="dataScope" name="dataScope" class="form-control m-b">
  27. <option value="1" th:field="*{dataScope}">全部数据权限</option>
  28. <option value="2" th:field="*{dataScope}">自定数据权限</option>
  29. <option value="3" th:field="*{dataScope}">本部门数据权限</option>
  30. <option value="4" th:field="*{dataScope}">本部门及以下数据权限</option>
  31. </select>
  32. <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 特殊情况下,设置为“自定数据权限”</span>
  33. </div>
  34. </div>
  35. <div class="form-group" id="authDataScope" th:style="'display:' + @{(*{dataScope=='2'} ? 'block' : 'none')} + ''">
  36. <label class="col-sm-3 control-label">数据权限</label>
  37. <div class="col-sm-8">
  38. <div id="deptTrees" class="ztree"></div>
  39. </div>
  40. </div>
  41. </form>
  42. </div>
  43. <th:block th:include="include :: footer" />
  44. <th:block th:include="include :: ztree-js" />
  45. <script type="text/javascript">
  46. $(function() {
  47. var url = ctx + "system/dept/roleDeptTreeData?roleId=" + $("#roleId").val();
  48. var options = {
  49. id: "deptTrees",
  50. url: url,
  51. check: { enable: true, nocheckInherit: true, chkboxType: { "Y": "ps", "N": "ps" } },
  52. expandLevel: 2
  53. };
  54. $.tree.init(options);
  55. });
  56. function submitHandler() {
  57. if ($.validate.form()) {
  58. edit();
  59. }
  60. }
  61. function edit() {
  62. var roleId = $("input[name='roleId']").val();
  63. var roleName = $("input[name='roleName']").val();
  64. var roleKey = $("input[name='roleKey']").val();
  65. var dataScope = $("#dataScope").val();
  66. var deptIds = $.tree.getCheckedNodes();
  67. $.ajax({
  68. cache : true,
  69. type : "POST",
  70. url : ctx + "system/role/authDataScope",
  71. data : {
  72. "roleId": roleId,
  73. "roleName": roleName,
  74. "roleKey": roleKey,
  75. "dataScope": dataScope,
  76. "deptIds": deptIds
  77. },
  78. async : false,
  79. error : function(request) {
  80. $.modal.alertError("系统错误");
  81. },
  82. success : function(data) {
  83. $.operate.successCallback(data);
  84. }
  85. });
  86. }
  87. $("#dataScope").change(function(event){
  88. var dataScope = $(event.target).val();
  89. dataScopeVisible(dataScope);
  90. });
  91. function dataScopeVisible(dataScope) {
  92. if (dataScope == 2) {
  93. $("#authDataScope").show();
  94. } else {
  95. $._tree.checkAllNodes(false);
  96. $("#authDataScope").hide();
  97. }
  98. }
  99. </script>
  100. </body>
  101. </html>