人人商城

menu.html 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. {template 'common/header-gw'}
  2. <style>
  3. .table>thead>tr>th{border-bottom:0;}
  4. .table>thead>tr>th .checkbox label{font-weight:bold;}
  5. .table>tbody>tr>td{border-top:0;}
  6. .table .checkbox{padding-top:4px;}
  7. .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{overflow:inherit;}
  8. .dropdown>span{display:inline-block; padding:3px 10px; border:1px solid transparent; border-bottom:0; cursor:pointer; position:relative;}
  9. .open>span{color:#d9534f; border-color:rgba(0,0,0,0.15); border-bottom:0; background:#fff; border-top-left-radius:4px; border-top-right-radius:4px; z-index:1001;}
  10. .dropdown-menu{margin:0; border-top-left-radius:0; top:98%;}
  11. .dropdown-menu ul li{float:left;width:230px}
  12. </style>
  13. <ol class="breadcrumb">
  14. <li><a href="./?refresh"><i class="fa fa-home"></i></a></li>
  15. <li><a href="{url 'system/welcome'}">系统</a></li>
  16. <li><a href="{url 'account/display'}">公众号列表</a></li>
  17. <li><a href="{url 'account/permission' array('uniacid' => $uniacid)}">账号操作员列表</a></li>
  18. <li class="active">操作人员权限</li>
  19. </ol>
  20. <form class="form-horizontal form" action="" method="post">
  21. <div class="alert alert-info">
  22. <i class="fa fa-exclamation-circle"></i> 默认未勾选任何菜单时,用户拥有全部权限。
  23. </div>
  24. <div class="panel panel-default">
  25. <div class="panel-body table-responsive" style="overflow:visible">
  26. <table class="table">
  27. {loop $menus $name $sections}
  28. <thead>
  29. <tr class="info">
  30. <th colspan="6">
  31. <div class="checkbox">
  32. <label><input type="checkbox" name="system_{$sections['name']}" onChange="selectall(this, 'system_{$sections["name"]}')">{$sections['title']}</label>
  33. </div>
  34. </th>
  35. </tr>
  36. </thead>
  37. {if $sections['childs']}
  38. <tbody class="system_{$sections['name']}">
  39. {php $i=1;}
  40. {loop $sections['childs'] $item}
  41. {if $i%6 == 1 || $i == 1}<tr>{/if}
  42. <td>
  43. <div class="checkbox">
  44. <label><input type="checkbox" value="{$item['permission_name']}" {if in_array($item['permission_name'], $system_permission['permission'])}checked{/if} name="system[]">{$item['title']}</label>
  45. </div>
  46. </td>
  47. {if $i%6 == 0}</tr>{/if}
  48. {php $i++;}
  49. {/loop}
  50. </tbody>
  51. {/if}
  52. {/loop}
  53. <thead>
  54. <tr class="info">
  55. <th colspan="6">
  56. <div class="checkbox">
  57. <label><input type="checkbox" name="" onChange="selectall(this, 'module_select')">模块权限</label>
  58. </div>
  59. </th>
  60. </tr>
  61. </thead>
  62. {if !empty($module)}
  63. <tbody class="module_select">
  64. {php $i=1;}
  65. {loop $module $k $m}
  66. {if empty($m['issystem']) || $k == 'we7_coupon'}
  67. {if $i%6 == 1 || $i == 1}<tr>{/if}
  68. <td style="overflow:inherit;">
  69. <div class="dropdown">
  70. <span class="" data-id="{$k}">
  71. <label class="checkbox-inline"><input type="checkbox" value="{$k}" name="module[]" {if in_array($k, $mod_keys)}checked{/if}>{$m['title']}</label>
  72. </span>
  73. <ul class="dropdown-menu" role="menu"></ul>
  74. <label class="checkbox-inline info"></label>
  75. <input type="hidden" name="{$k}_select" value="0"/>
  76. </div>
  77. </td>
  78. {if $i%6 == 0}</tr>{/if}
  79. {php $i++;}
  80. {/if}
  81. {/loop}
  82. </tbody>
  83. {/if}
  84. </table>
  85. </div>
  86. </div>
  87. <button type="submit" class="btn btn-primary span3" name="submit" value="提交" onclick="if ($('input:checkbox:checked').size() == 0) {return confirm('您未勾选任何菜单权限,意味着允许用户使用所有功能。确定吗?')}">提交</button>
  88. <input type="hidden" name="token" value="{$_W['token']}" />
  89. </form>
  90. <script>
  91. $(function(){
  92. var aid = "{$_GPC['uniacid']}";
  93. //模块下拉框
  94. $('.dropdown span').hover(function(){
  95. var _this = $(this);
  96. var m = $(this).attr('data-id');
  97. var uid = "{$uid}";
  98. var length = $(this).next().find('li').size();
  99. if(!length) {
  100. $.post("{php echo url('user/permission/module')}", {'m' : m, 'uid' : uid, 'uniacid' : aid}, function(data) {
  101. var data = $.parseJSON(data);
  102. var html = '';
  103. if(!data.errno) {
  104. $.each(data.errmsg, function(k, v){
  105. var check = v.checked ? 'checked' : '';
  106. html += '<li><a href="javascript:;"><label class="checkbox-inline"><input type="checkbox" name="module_'+m+'[]" value="'+ v.permission +'" '+check+'/>'+ v.title +'</label></a></li>';
  107. });
  108. }
  109. _this.next().html(html);
  110. });
  111. }
  112. $(this).parent().addClass('open').find('.dropdown-menu').show();
  113. $(this).parent().find('.dropdown-menu').hover(
  114. function(){$(this).show();$(this).parent().addClass('open')},
  115. function(){$(this).hide();$(this).parent().removeClass('open');}
  116. );
  117. },function(){
  118. $(this).parent().removeClass('open').find('.dropdown-menu').hide();
  119. });
  120. $('.dropdown span :checkbox').click(function(e){
  121. var _parent = $(this).parents('.dropdown');
  122. _parent.find('.dropdown-menu :checkbox').prop('checked', $(this).prop('checked'));
  123. if($(this).prop('checked')) {
  124. $(this).parents('.dropdown').find('label.info').html('已全选');
  125. $(this).parents('.dropdown').find('input[type="hidden"]').val(1);
  126. } else {
  127. $(this).parents('.dropdown').find('input[type="hidden"]').val(0);
  128. $(this).parents('.dropdown').find('label.info').html('已选0项');
  129. }
  130. });
  131. $('.dropdown-menu').on('click', ':checkbox', function(){
  132. if(!$(this).prop('checked')) {
  133. var i = 0;
  134. $.each($(this).parents('li').siblings(), function(){
  135. if($(this).find(':checkbox').prop('checked')) {
  136. i ++;
  137. }
  138. });
  139. $(this).parents('.dropdown').find('input[type="hidden"]').val(0);
  140. $(this).parents('.dropdown').find('label.info').html('已选' + i + '项');
  141. if(!i) {
  142. $(this).parents('.dropdown').find('span :checkbox').prop('checked', false);
  143. }
  144. } else {
  145. var flag = 0;
  146. var i = 1;
  147. $.each($(this).parents('li').siblings(), function(){
  148. if(!$(this).find(':checkbox').prop('checked')) {
  149. flag = 1;
  150. } else {
  151. i ++;
  152. }
  153. });
  154. if(!flag) {
  155. $(this).parents('.dropdown').find('label.info').html('已全选');
  156. $(this).parents('.dropdown').find('input[type="hidden"]').val(1);
  157. } else {
  158. $(this).parents('.dropdown').find('label.info').html('已选' + i + '项');
  159. $(this).parents('.dropdown').find('input[type="hidden"]').val(0);
  160. }
  161. $(this).parents('.dropdown').find('span :checkbox').prop('checked', true);
  162. }
  163. });
  164. });
  165. //处理全选函数
  166. function selectall(obj, a){
  167. $('.'+a+' input:checkbox').each(function() {
  168. $(this)[0].checked = obj.checked ? true : false;
  169. });
  170. }
  171. //当已经全选时,默认全选按钮选中
  172. $(function() {
  173. $('.table>tbody').each(function() {
  174. var a = true;
  175. $(this).find('input:checkbox').each(function() {
  176. if($(this)[0].checked != true) {
  177. a = false;
  178. return false;
  179. }
  180. });
  181. if(a) $('input[name='+$(this).attr('class')+']:checkbox')[0].checked = true;
  182. });
  183. });
  184. </script>
  185. {template 'common/footer-gw'}