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. <option value="5" th:field="*{dataScope}">仅本人数据权限</option>
  32. </select>
  33. <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 特殊情况下,设置为“自定数据权限”</span>
  34. </div>
  35. </div>
  36. <div class="form-group" id="authDataScope" th:style="'display:' + @{(*{dataScope=='2'} ? 'block' : 'none')} + ''">
  37. <label class="col-sm-3 control-label">数据权限</label>
  38. <div class="col-sm-8">
  39. <div id="deptTrees" class="ztree"></div>
  40. </div>
  41. </div>
  42. </form>
  43. </div>
  44. <th:block th:include="include :: footer" />
  45. <th:block th:include="include :: ztree-js" />
  46. <script type="text/javascript">
  47. $(function() {
  48. var url = ctx + "system/dept/roleDeptTreeData?roleId=" + $("#roleId").val();
  49. var options = {
  50. id: "deptTrees",
  51. url: url,
  52. check: { enable: true, nocheckInherit: true, chkboxType: { "Y": "ps", "N": "ps" } },
  53. expandLevel: 2
  54. };
  55. $.tree.init(options);
  56. });
  57. function submitHandler() {
  58. if ($.validate.form()) {
  59. edit();
  60. }
  61. }
  62. function edit() {
  63. var roleId = $("input[name='roleId']").val();
  64. var roleName = $("input[name='roleName']").val();
  65. var roleKey = $("input[name='roleKey']").val();
  66. var dataScope = $("#dataScope").val();
  67. var deptIds = $.tree.getCheckedNodes();
  68. $.ajax({
  69. cache : true,
  70. type : "POST",
  71. url : ctx + "system/role/authDataScope",
  72. data : {
  73. "roleId": roleId,
  74. "roleName": roleName,
  75. "roleKey": roleKey,
  76. "dataScope": dataScope,
  77. "deptIds": deptIds
  78. },
  79. async : false,
  80. error : function(request) {
  81. $.modal.alertError("系统错误");
  82. },
  83. success : function(data) {
  84. $.operate.successCallback(data);
  85. }
  86. });
  87. }
  88. $("#dataScope").change(function(event){
  89. var dataScope = $(event.target).val();
  90. dataScopeVisible(dataScope);
  91. });
  92. function dataScopeVisible(dataScope) {
  93. if (dataScope == 2) {
  94. $("#authDataScope").show();
  95. } else {
  96. $._tree.checkAllNodes(false);
  97. $("#authDataScope").hide();
  98. }
  99. }
  100. </script>
  101. </body>
  102. </html>