perm.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="renderer" content="webkit|ie-comp|ie-stand">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  8. <meta http-equiv="Cache-Control" content="no-siteapp" />
  9. <!--[if lt IE 9]>
  10. <script type="text/javascript" src="${ctx}/assets/lib/html5.js"></script>
  11. <script type="text/javascript" src="${ctx}/assets/lib/respond.min.js"></script>
  12. <script type="text/javascript" src="${ctx}/assets/lib/PIE_IE678.js"></script>
  13. <![endif]-->
  14. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui/css/H-ui.min.css" />
  15. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/H-ui.admin.css" />
  16. <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/Hui-iconfont/1.0.7/iconfont.css" />
  17. <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/icheck/icheck.css" />
  18. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/skin/default/skin.css" id="skin" />
  19. <link rel="stylesheet" type="text/css" href="${ctx}/assets/static/h-ui.admin/css/style.css" />
  20. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" >
  21. <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/easyui/themes/gray/easyui.css" />
  22. <link rel="stylesheet" type="text/css" href="${ctx}/assets/lib/easyui/themes/icon.css" />
  23. <script type="text/ecmascript" src="${ctx}/assets/lib/jquery/1.9.1/jquery.js"></script>
  24. <script type="text/javascript" src="${ctx}/assets/static/h-ui/js/H-ui.js"></script>
  25. <script type="text/javascript" src="${ctx}/assets/lib/layer/3.0.3/layer.js"></script>
  26. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqueryui/jquery-ui.css" />
  27. <link rel="stylesheet" type="text/css" media="screen" href="${ctx}/assets/lib/jqgrid/css/ui.jqgrid.css" />
  28. <script type="text/ecmascript" src="${ctx}/assets/lib/jqueryui/jquery-ui.js"></script>
  29. <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/i18n/grid.locale-cn.js"></script>
  30. <script type="text/ecmascript" src="${ctx}/assets/lib/jqgrid/js/jquery.jqGrid.min.js"></script>
  31. <script type="text/ecmascript" src="${ctx}/assets/lib/easyui/jquery.easyui.min.js"></script>
  32. <script type="text/ecmascript" src="${ctx}/assets/lib/easyui/locale/easyui-lang-zh_CN.js"></script>
  33. <script type="text/javascript" src="${ctx}/assets/js/base.js"></script>
  34. <script type="text/javascript" src="${ctx}/assets/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
  35. <!--[if IE 6]>
  36. <script type="text/javascript" src="${ctx}/assets/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
  37. <script>DD_belatedPNG.fix('*');</script>
  38. <![endif]-->
  39. <title>角色管理</title>
  40. </head>
  41. <body>
  42. <div id="table" class="easyui-tabs" style="width: 100%; height: 400px;">
  43. <div title="菜单权限" style="padding:5px;display:none;">
  44. <ul id="tree_menu" class="ztree"></ul>
  45. </div>
  46. <div title="站点权限" style="padding:5px;display:none;">
  47. <ul id="tree_site" class="ztree"></ul>
  48. </div>
  49. <div title="栏目权限" style="padding:5px;display:none;">
  50. 选择站点:<select id="permSite"><option>请选择站点</option></select>
  51. <ul id="tree_column" class="ztree"></ul>
  52. </div>
  53. <div title="机构权限" style="padding:5px;display:none;">
  54. <ul id="tree_org" class="ztree"></ul>
  55. </div>
  56. </div>
  57. </body>
  58. </html>
  59. <script type="text/javascript">
  60. //菜单权限
  61. $(function(){
  62. function zTreeMenu(event, treeId, treeNode) {
  63. $.post("${ctx}/myconsole/perm/saveMenuPerm",{"roleid":"${RoleID}","permid":treeNode.id,"checked":treeNode.checked},function(data){
  64. //alert(data);
  65. layer.msg(data);
  66. })
  67. };
  68. var zNodes = [],menuPerm = [];
  69. var menuTree = JSON.parse('${Menu}');
  70. var perms=eval(menuTree.Perm);
  71. perms.forEach(function(item,index){
  72. menuPerm.push(item.permid);
  73. });
  74. var menus=eval(menuTree.Menu);
  75. //console.log(menus);
  76. menus.forEach(function(item,index)
  77. {
  78. zNodes.push({id:item.keyid,pId:item.parentid,name:item.menuname,open:true,checked:menuPerm.includes(item.keyid)});
  79. })
  80. var setting_menu = {
  81. check: {
  82. enable: true,
  83. chkboxType: { "Y" : "p", "N" : "s" },//勾选时关联父,取消勾选时关联子
  84. autoCheckTrigger: true
  85. },
  86. data: {
  87. simpleData: {
  88. idKey:"id",
  89. pIdKey:"pId",
  90. enable:true,
  91. rootPId:"0"
  92. }
  93. },
  94. callback: {
  95. onCheck: zTreeMenu
  96. }
  97. };
  98. $.fn.zTree.init($("#tree_menu"), setting_menu, zNodes);
  99. })
  100. </script>
  101. <script type="text/javascript">
  102. //站点权限
  103. $(function(){
  104. function zTreeSite(event, treeId, treeNode) {
  105. $.post("${ctx}/myconsole/perm/saveSitePerm",{"roleid":"${RoleID}","permid":treeNode.id,"checked":treeNode.checked},function(data){
  106. //alert(data);
  107. layer.msg(data);
  108. })
  109. };
  110. var zNodesite = [],sitePerm = [];
  111. var siteTree = JSON.parse('${Site}');
  112. var perms=eval(siteTree.Perm);
  113. perms.forEach(function(item,index){
  114. sitePerm.push(item.permid);
  115. });
  116. var sites=eval(siteTree.Site);
  117. //myconsole.log(sites);
  118. sites.forEach(function(item,index)
  119. {
  120. zNodesite.push({id:item.siteid,pId:item.parentid,name:item.sitename,open:true,checked:sitePerm.includes(item.siteid)});
  121. })
  122. var setting_site = {
  123. check: {
  124. enable: true,
  125. chkboxType: { "Y" : "", "N" : "" },
  126. autoCheckTrigger: true
  127. },
  128. data: {
  129. simpleData: {
  130. idKey:"id",
  131. pIdKey:"pId",
  132. enable:true,
  133. rootPId:"0"
  134. }
  135. },
  136. callback: {
  137. onCheck: zTreeSite
  138. }
  139. };
  140. $.fn.zTree.init($("#tree_site"), setting_site, zNodesite);
  141. })
  142. </script>
  143. <script type="text/javascript">
  144. //栏目权限
  145. $(function(){
  146. $('#table').tabs({
  147. onSelect: function(title){
  148. if(title=="栏目权限"){
  149. $.post("${ctx}/myconsole/perm/getPermSite",{"roleid":"${RoleID}"},function(data){
  150. //console.log(data);
  151. var siteData = JSON.parse(data);
  152. var sites=siteData.Site;
  153. sites.forEach(function(item,index){
  154. $("#permSite").append("<option value='"+item.siteid+"'>"+item.sitename+"</option>");
  155. })
  156. })
  157. }
  158. }
  159. });
  160. function zTreecolumn(event, treeId, treeNode) {
  161. $.post("${ctx}/myconsole/perm/saveColumnPerm",{"roleid":"${RoleID}","permid":treeNode.id,"siteid":treeNode.siteid,"checked":treeNode.checked},function(data){
  162. //alert(data);
  163. layer.msg(data);
  164. })
  165. };
  166. $("#permSite").change(function(){
  167. $.post("${ctx}/myconsole/perm/getPermColumn",{"roleid":"${RoleID}","siteID":$(this).val()},function(data){
  168. //console.log(data);
  169. var zNodecolumn = [],columnPerm = [];
  170. var columnTree = JSON.parse(data);
  171. var perms=eval(columnTree.Perm);
  172. perms.forEach(function(item,index){
  173. columnPerm.push(item.siteid+":"+item.permid);
  174. });
  175. //console.log(columnPerm);
  176. var columns=eval(columnTree.Column);
  177. //myconsole.log(sites);
  178. columns.forEach(function(item,index){
  179. if(item.parentid==0){
  180. zNodecolumn.push({id:item.columnid,pId:item.siteid,name:item.columnname,open:true,checked:columnPerm.includes(item.siteid+":"+item.columnid),chkDisabled:false,siteid:item.siteid});
  181. }else{
  182. zNodecolumn.push({id:item.columnid,pId:item.parentid,name:item.columnname,open:true,checked:columnPerm.includes(item.siteid+":"+item.columnid),chkDisabled:false,siteid:item.siteid});
  183. }
  184. })
  185. var setting_column = {
  186. check: {
  187. enable: true,
  188. chkboxType: { "Y" : "ps", "N" : "ps" },
  189. autoCheckTrigger: true
  190. },
  191. data: {
  192. simpleData: {
  193. idKey:"id",
  194. pIdKey:"pId",
  195. enable:true,
  196. rootPId:"0"
  197. }
  198. },
  199. callback: {
  200. onCheck: zTreecolumn
  201. }
  202. };
  203. $.fn.zTree.init($("#tree_column"), setting_column, zNodecolumn);
  204. })
  205. })
  206. })
  207. </script>
  208. <script type="text/javascript">
  209. //机构权限
  210. $(function(){
  211. function zTreeOrg(event, treeId, treeNode) {
  212. $.post("${ctx}/myconsole/perm/saveOrgPerm",{"roleid":"${RoleID}","permid":treeNode.id,"checked":treeNode.checked},function(data){
  213. //alert(data);
  214. layer.msg(data);
  215. })
  216. };
  217. var zNodesorg = [],orgPerm = [];
  218. var orgTree = JSON.parse('${Org}');
  219. var perms=eval(orgTree.Perm);
  220. perms.forEach(function(item,index){
  221. orgPerm.push(item.permid);
  222. });
  223. var orgs=eval(orgTree.Org);
  224. //myconsole.log(orgs);
  225. orgs.forEach(function(item,index)
  226. {
  227. zNodesorg.push({id:item.orgid,pId:item.parentid,name:item.orgname,open:true,checked:orgPerm.includes(item.orgid)});
  228. })
  229. var setting_org = {
  230. check: {
  231. chkboxType: { "Y" : "", "N" : "" },
  232. enable: true,
  233. autoCheckTrigger: true
  234. },
  235. data: {
  236. simpleData: {
  237. idKey:"id",
  238. pIdKey:"pId",
  239. enable:true,
  240. rootPId:"0"
  241. }
  242. },
  243. callback: {
  244. onCheck: zTreeOrg
  245. }
  246. };
  247. $.fn.zTree.init($("#tree_org"), setting_org, zNodesorg);
  248. })
  249. </script>