new_usergroupCpt.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <{include file="./admin/header.html"}>
  2. <{include file="./admin/left.html"}>
  3. <{include file="./admin/nav.html"}>
  4. <link rel="stylesheet" href="<{$web_cfg.cdn}>/public/static/css/zTreeStyle/zTreeStyle.css">
  5. <script src="<{$web_cfg.cdn}>/public/static/js/jquery-1.4.4.min.js"></script>
  6. <script src="<{$web_cfg.cdn}>/public/static/js/jquery.ztree.all-3.5.js"></script>
  7. <div class="panel">
  8. <div class="panel-body">
  9. <div style="margin-left:10px;">
  10. <p></p>
  11. <!-- 容器 -->
  12. <div id='tree' class="ztree"></div>
  13. <input id='groupid' type='hidden' value='<{$groupid}>' />
  14. </div>
  15. <div style="text-align:center;"><input id="submit" class="btn" type='submit' value='权限修改提交' /></div>
  16. </div>
  17. </div>
  18. <script>
  19. var setting = {
  20. view: {
  21. nameIsHTML: true
  22. },
  23. check: {
  24. enable: true,
  25. chkboxType: { "Y" : "", "N" : "" }
  26. },
  27. data: {
  28. simpleData: {
  29. enable: true
  30. }
  31. },
  32. callback: {}
  33. };
  34. var zNodes = <{$resource}>;
  35. $(document).ready(function(){
  36. var objTree = $.fn.zTree.init($("#tree"), setting, zNodes);
  37. //勾选用户组已有权限
  38. checkedUsergroupCpt();
  39. //禁用登陆用户没有的权限
  40. disableCpt();
  41. //提交权限
  42. $("#submit").click(function () {
  43. var checkNodes = objTree.getCheckedNodes(true);
  44. var resourceids = [];
  45. for (var i=0; i < checkNodes.length; i++) {
  46. resourceids.push(checkNodes[i].id);
  47. }
  48. var groupid = $('#groupid').val();
  49. if (groupid == '') {
  50. alert('无效用户组id');
  51. return false;
  52. }
  53. console.log(resourceids);
  54. $.post("<{$web_cfg.domain}>?c=permission&a=editUsergroupCpt"
  55. , {resourceids: resourceids, groupid: groupid}
  56. , function (data) {
  57. if (data.ok) {
  58. alert('编辑权限成功');
  59. location.reload();
  60. } else {
  61. alert(data.msg);
  62. return false;
  63. }
  64. },
  65. 'json'
  66. );
  67. return false;
  68. });
  69. //勾选用户组已有权限
  70. function checkedUsergroupCpt() {
  71. var usergroupCpt = <{$usergroupCpt}>;
  72. for (var i=0; i<usergroupCpt.length; i++) {
  73. var node = objTree.getNodeByParam("id", usergroupCpt[i].resourceid, null);
  74. try {
  75. objTree.checkNode(node, true, true, 1);
  76. } catch(e) {}
  77. }
  78. }
  79. //禁用登陆用户没有没有的权限
  80. function disableCpt() {
  81. var disableTreeIds = <{$disableTreeIds}>;
  82. var zTree = $.fn.zTree.getZTreeObj("tree");
  83. for (var i=0; i<disableTreeIds.length; i++) {
  84. var treeId = disableTreeIds[i];
  85. var node = zTree.getNodeByParam("id", treeId, null);
  86. zTree.setChkDisabled(node, true, true, false);
  87. }
  88. }
  89. });
  90. </script>
  91. <{include file="./admin/bottom.html"}>