new_resource.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <{include file="admin/permission/header.html"}>
  2. <{include file="admin/permission/nav.html"}>
  3. <link rel="stylesheet" href="<{$web_cfg.cdn}>/public/static/css/zTreeStyle/zTreeStyle.css">
  4. <script src="<{$web_cfg.cdn}>/public/static/js/jquery-1.4.4.min.js"></script>
  5. <script src="<{$web_cfg.cdn}>/public/static/js/jquery.ztree.all-3.5.js"></script>
  6. <style>
  7. .ztree_add_node {
  8. color:blue;margin-right:0px;
  9. }
  10. .ztree li span.button.add {margin-left:2px; margin-right: -1px; background-position:-144px 0; vertical-align:top; *vertical-align:middle}
  11. .ztree li span.button.add,.ztree li span.button.edit,.ztree li span.button.remove{margin-right:5px;}
  12. </style>
  13. <div class="container">
  14. <div class="panel">
  15. <div class="panel-body">
  16. 注:资源被删除后,拥有此资源权限的用户,将不在有权限。
  17. <div style="margin-left:10px;">
  18. <p></p>
  19. <!-- tree -->
  20. <div id='tree' class="ztree"></div>
  21. <div class='block_15'></div>
  22. <div>
  23. <a class='btn btn-primary btn-xs' href="<{$web_cfg.domain}>/?c=permission&a=AddResourceNew&type=dir" title="创建目录" >创建新目录</a>
  24. </div>
  25. <p></p>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <script>
  31. var setting = {
  32. view: {
  33. nameIsHTML: true,
  34. selectedMulti: false,
  35. addHoverDom: addHoverDom,
  36. removeHoverDom: removeHoverDom
  37. },
  38. edit: {
  39. drag: {
  40. isCopy: false,
  41. isMove: false
  42. },
  43. enable: true,
  44. removeTitle: "删除资源",
  45. renameTitle: "编辑资源",
  46. showRemoveBtn: showRemoveBtn,
  47. showRenameBtn: showRenameBtn
  48. },
  49. data: {
  50. simpleData: {
  51. enable: true
  52. }
  53. },
  54. callback: {
  55. beforeRemove: beforeRemove,
  56. beforeEditName: beforeEditName
  57. }
  58. };
  59. var zNodes = <{$resource}>;
  60. $(document).ready(function(){
  61. $.fn.zTree.init($("#tree"), setting, zNodes);
  62. });
  63. //显示添加按钮
  64. function addHoverDom(treeId, treeNode) {
  65. var id = treeNode.id;
  66. var parent_id = treeNode.pId;
  67. var isParent = treeNode.isParent;
  68. var sObj = $("#" + treeNode.tId + "_span");
  69. if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
  70. var addStr = "";
  71. if (isParent) {
  72. var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
  73. + "' title='添加' onfocus='this.blur();'></span>";
  74. } else {
  75. }
  76. sObj.after(addStr);
  77. //跳转到添加页面
  78. var btn = $("#addBtn_"+treeNode.tId);
  79. if (btn) btn.bind("click", function(){
  80. window.open("<{$web_cfg.domain}>/?c=permission&a=AddResourceNew&parent_id="+id);
  81. });
  82. }
  83. //隐藏添加按钮
  84. function removeHoverDom(treeId, treeNode) {
  85. $("#addBtn_"+treeNode.tId).unbind().remove();
  86. };
  87. //显示删除按钮
  88. function showRemoveBtn(treeId, treeNode) {
  89. var isParent = treeNode.isParent;
  90. if (isParent) return false;
  91. return true;
  92. }
  93. //显示编辑按钮
  94. function showRenameBtn(treeId, treeNode) {
  95. return true;
  96. }
  97. //点击编辑,并在进入编辑前触发
  98. function beforeEditName(treeId, treeNode) {
  99. var id = treeNode.id;
  100. //跳转到编辑页面
  101. window.open("<{$web_cfg.domain}>/?c=permission&a=EditResourceNew&id="+id);
  102. return false;
  103. }
  104. //点击删除,并在进入删除前触发
  105. function beforeRemove(treeId, treeNode) {
  106. var id = treeNode.id;
  107. var name = treeNode.name;
  108. if (!confirm('确认要删除“'+name+'”资源吗?')) {
  109. return false;
  110. }
  111. $.get('<{$web_cfg.domain}>?c=permission&a=delResourceNew',
  112. {'id': id},
  113. function (data) {
  114. if (!data.ok) {
  115. alert(data.msg);
  116. return false;
  117. }
  118. },
  119. 'json'
  120. );
  121. }
  122. </script>
  123. <{include file="admin/permission/bottom.html"}>