42d182ba955a14984e138f63987ed1b0.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php /*a:3:{s:63:"D:\phpstudy_pro\WWW\cxy\bts\php\view\admin\auth\admin_rule.html";i:1581911356;s:61:"D:\phpstudy_pro\WWW\cxy\bts\php\view\admin\common\header.html";i:1582014448;s:61:"D:\phpstudy_pro\WWW\cxy\bts\php\view\admin\common\footer.html";i:1581911356;}*/ ?>
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <title><?php echo config('admin.sys_name'); ?>后台管理</title>
  7. <meta name="renderer" content="webkit">
  8. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  9. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  11. <meta name="apple-mobile-web-app-capable" content="yes">
  12. <meta name="format-detection" content="telephone=no">
  13. <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all" />
  14. <!--<link rel="stylesheet" href="/static/plugins/bootstrap-3.3.7/css/bootstrap.css" media="all" />-->
  15. <!--<link rel="stylesheet" href="/static/plugins/bootstrap-3.3.7/css/bootstrap-theme.css" media="all" />-->
  16. <link rel="stylesheet" href="/static/admin/css/main.css?v=<?php echo time(); ?>" media="all">
  17. <link rel="stylesheet" href="/static/plugins/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
  18. <!--<link rel="stylesheet" href="/static/plugins/bootstrap-select/less/bootstrap-select.less">-->
  19. <!--<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/css/bootstrap-select.min.css">-->
  20. <!--[if lt IE 9]>
  21. <!--<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>-->
  22. <!--<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>-->
  23. <!--<![endif]&ndash;&gt;-->
  24. <style id="LM-bg-color">
  25. </style>
  26. </head>
  27. <div class="LM-container">
  28. <div class="LM-main">
  29. <div class="admin-main layui-anim layui-anim-upbit">
  30. <fieldset class="layui-elem-field layui-field-title">
  31. <legend>权限<?php echo lang('list'); ?></legend>
  32. </fieldset>
  33. <blockquote class="layui-elem-quote">
  34. <a href="<?php echo url('ruleAdd'); ?>" class="layui-btn layui-btn-sm LM-add"><?php echo lang('add'); ?>路由</a>
  35. <a class="layui-btn layui-btn-normal layui-btn-sm" onclick="openAll();">展开或折叠全部</a>
  36. </blockquote>
  37. <table class="layui-table" id="treeGrid" lay-filter="treeGrid"></table>
  38. </div>
  39. </div>
  40. </div>
  41. <script type="text/html" id="auth">
  42. <input type="checkbox" name="auth_open" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="auth_open" {{ d.auth_open == 0 ? 'checked' : '' }}>
  43. </script>
  44. <script type="text/html" id="status">
  45. <input type="checkbox" name="menu_status" value="{{d.id}}" lay-skin="switch" lay-text="显示|隐藏" lay-filter="menu_status" {{ d.menu_status == 1 ? 'checked' : '' }}>
  46. </script>
  47. <script type="text/html" id="order">
  48. <input name="{{d.id}}" data-id="{{d.id}}" class="list_order layui-input" value=" {{d.sort}}" size="10"/>
  49. </script>
  50. <script type="text/html" id="icon">
  51. <span class="icon {{d.icon}}"></span>
  52. </script>
  53. <script type="text/html" id="action">
  54. <a href="<?php echo url('ruleEdit'); ?>?id={{d.id}}" class="layui-btn layui-btn-xs"><?php echo lang('edit'); ?></a>
  55. <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="add"><?php echo lang('add'); ?><?php echo lang('child'); ?></a>
  56. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><?php echo lang('del'); ?></a>
  57. </script>
  58. <script type="text/html" id="topBtn">
  59. <a href="<?php echo url('ruleAdd'); ?>" class="layui-btn layui-btn-sm"><?php echo lang('add'); ?>权限</a>
  60. </script>
  61. <script src="/static/plugins/layui/layui.js" charset="utf-8"></script>
  62. <!--<script src="/static/plugins/bootstrap-3.3.7/js/bootstrap.js" charset="utf-8"></script>-->
  63. <script>
  64. var editObj=null,ptable=null,treeGrid=null,tableId='treeGrid',layer=null;
  65. layui.config({
  66. base: '/static/plugins/layui/extend/'
  67. }).extend({
  68. treeGrid: 'treeGrid/treeGrid'
  69. }).use(['jquery','treeGrid','layer','form'], function(){
  70. var $=layui.jquery ,form = layui.form;
  71. treeGrid = layui.treeGrid;
  72. layer=layui.layer;
  73. ptable=treeGrid.render({
  74. id:tableId
  75. ,elem: '#'+tableId
  76. ,idField:'id'
  77. ,url:'<?php echo url("adminRule"); ?>'
  78. ,cellMinWidth: 100
  79. ,treeId:'id'//树形id字段名称
  80. ,treeUpId:'pid'//树形父id字段名称
  81. ,treeShowName:'title'//以树形式显示的字段
  82. ,height:'full-140'
  83. ,isFilter:false
  84. ,iconOpen:true//是否显示图标【默认显示】
  85. ,isOpenDefault:true//节点默认是展开还是折叠【默认展开】
  86. ,cols: [[
  87. {field: 'id', title: '<?php echo lang("id"); ?>', width: 70, fixed: true},
  88. {field: 'icon', align: 'center',title: '<?php echo lang("icon"); ?>', width: 60,templet: '#icon'},
  89. {field: 'title', title: '权限名称', width: 200},
  90. {field: 'href', title: '控制器/方法', width: 200},
  91. {field: 'auth_open',align: 'center', title: '是否验证权限', width: 150,toolbar: '#auth'},
  92. {field: 'menu_status',align: 'center',title: '菜单<?php echo lang("status"); ?>', width: 150,toolbar: '#status'},
  93. {field: 'sort',align: 'center', title: '<?php echo lang("order"); ?>', width: 80, templet: '#order'},
  94. {title:'操作',width:200, toolbar: '#action',align:"center"},
  95. ]]
  96. ,page:false
  97. });
  98. treeGrid.on('tool('+tableId+')',function (obj) {
  99. var data = obj.data;
  100. if(obj.event === 'del'){
  101. layer.confirm('<?php echo lang("Are you sure you want to delete it"); ?>', function(index){
  102. var loading = layer.load(1, {shade: [0.1, '#fff']});
  103. $.post("<?php echo url('ruleDel'); ?>",{id:data.id},function(res){
  104. layer.close(loading);
  105. if(res.code==1){
  106. layer.msg(res.msg,{time:1000,icon:1});
  107. obj.del();
  108. }else{
  109. layer.msg(res.msg,{time:1000,icon:2});
  110. }
  111. });
  112. layer.close(index);
  113. });
  114. }else if(obj.event === 'add'){
  115. var index = layer.open({
  116. type: 2,
  117. content: '<?php echo url("ruleAdd"); ?>'+'?rule_id='+data.id,
  118. area: ['800px', '600px'],
  119. maxmin: true
  120. });
  121. layer.full(index);
  122. }
  123. });
  124. form.on('switch(auth_open)', function(obj){
  125. loading =layer.load(1, {shade: [0.1,'#fff']});
  126. var id = this.value;
  127. var auth_open = obj.elem.checked===true?0:1;
  128. $.post('<?php echo url("ruleOpen"); ?>',{'id':id,'auth_open':auth_open},function (res) {
  129. layer.close(loading);
  130. if (res.code==1) {
  131. treeGrid.render;
  132. }else{
  133. layer.msg(res.msg,{time:1000,icon:2});
  134. treeGrid.render;
  135. return false;
  136. }
  137. })
  138. });
  139. form.on('switch(menu_status)', function(obj){
  140. loading =layer.load(1, {shade: [0.1,'#fff']});
  141. var id = this.value;
  142. var menu_status = obj.elem.checked===true?1:0;
  143. $.post('<?php echo url("ruleState"); ?>',{'id':id,'menu_status':menu_status},function (res) {
  144. layer.close(loading);
  145. if (res.code==1) {
  146. treeGrid.render;
  147. }else{
  148. layer.msg(res.msg,{time:1000,icon:2});
  149. treeGrid.render;
  150. return false;
  151. }
  152. })
  153. });
  154. $('body').on('blur','.list_order',function() {
  155. var id = $(this).attr('data-id');
  156. var sort = $(this).val();
  157. $.post('<?php echo url("ruleSort"); ?>',{id:id,sort:sort},function(res){
  158. if(res.code > 0){
  159. layer.msg(res.msg,{time:1000,icon:1},function(){
  160. location.href = res.url;
  161. });
  162. }else{
  163. layer.msg(res.msg,{time:1000,icon:2});
  164. treeGrid.render;
  165. }
  166. })
  167. })
  168. });
  169. function openAll() {
  170. var treedata=treeGrid.getDataTreeList(tableId);
  171. treeGrid.treeOpenAll(tableId,!treedata[0][treeGrid.config.cols.isOpen]);
  172. }
  173. </script>