set-permission.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. {template 'common/header'}
  2. <ol class="breadcrumb we7-breadcrumb">
  3. <li><a href="javascript:;" onclick="javascript:history.go(-1);"><i class="wi wi-back-circle"></i> 权限设置</a></li>
  4. </ol>
  5. <form class="form-horizontal form we7-form" action="" method="post">
  6. <table class="table we7-table table-hover we7-form account-and-wxapp">
  7. {loop $menus $name $sections}
  8. {if $name == XZAPP_TYPE_SIGN || $name == WEBAPP_TYPE_SIGN}
  9. {php $menu_name = ACCOUNT_TYPE_SIGN}
  10. {elseif $name == ALIAPP_TYPE_SIGN || $name == BAIDUAPP_TYPE_SIGN || $name == TOUTIAOAPP_TYPE_SIGN}
  11. {php $menu_name = WXAPP_TYPE_SIGN}
  12. {else}
  13. {php $menu_name = $name}
  14. {/if}
  15. {if $sections['section'] && $name == $account_type_menu}
  16. <div>{$account['type_name']}<span class="color-default font-sm"></span>
  17. </div>
  18. {loop $sections['section'] $section_id $section}
  19. {if !in_array($section_id, array('platform_module')) && in_array($account['type'], $section['permission_display'])}
  20. <thead>
  21. <tr class="text-left">
  22. <th colspan="4" class="text-left">
  23. <div class="">
  24. <input id="check-{$section_id}" type="checkbox" name="system_{$section_id}" onChange="selectall(this, 'system_{$section_id}')">
  25. <label for="check-{$section_id}" class=" we7-margin-horizontal-none">{$section['title']}</label>
  26. </div>
  27. </th>
  28. </tr>
  29. </thead>
  30. <tbody class="system_{$section_id}">
  31. {php $i=1;}
  32. {loop $section['menu'] $menu_id $menu}
  33. {if is_array($menu['permission_display']) && !in_array($account['type'], $menu['permission_display'])}{php continue;}{/if}
  34. {if $i%4 == 1 || $i == 1}<tr>{/if}
  35. <td class="text-left vertical-middle" style="overflow:inherit;">
  36. <div class="dropdown system-select-dropdown">
  37. <span>
  38. <input id="check-child-{$menu_id}" type="checkbox" we7-check-all="1" value="{$menu['permission_name']}" {if in_array($menu['permission_name'], $user_menu_permissions)}checked{/if} name="menus[]" autocomplete="off" />
  39. <label for="check-child-{$menu_id}" class="we7-margin-horizontal-none" data-toggle="tooltip">{$menu['title']}{if !empty($menu['sub_permission'])}<span class="caret"></span>{/if}</label>
  40. </span>
  41. {if $menu['sub_permission']}
  42. <ul class="dropdown-menu">
  43. {loop $menu['sub_permission'] $sub_permission}
  44. {if is_array($sub_permission['is_display']) && !in_array($account['type'], $sub_permission['is_display'])}{php continue;}{/if}
  45. <li class="text-left">
  46. <input id="check-child-{$sub_permission['permission_name']}" we7-check-all="1" type="checkbox" value="{$sub_permission['permission_name']}" {if in_array($sub_permission['permission_name'], $user_menu_permissions)}checked{/if} name="menus[]">
  47. <label class="we7-margin-horizontal-none" for="check-child-{$sub_permission['permission_name']}">
  48. {$sub_permission['title']}
  49. </label>
  50. </li>
  51. {/loop}
  52. </ul>
  53. {/if}
  54. </div>
  55. </td>
  56. {if $i%4 == 0}</tr><tr>{/if}
  57. {php $i++;}
  58. {/loop}
  59. {if ($i-1)%4 != 0}
  60. <?php
  61. for ($x=0; $x<4-($i-1)%4; $x++) {
  62. echo "<td></td>";
  63. }
  64. ?>
  65. </tr>
  66. {/if}
  67. </tbody>
  68. {/if}
  69. {/loop}
  70. {/if}
  71. {/loop}
  72. </table>
  73. {if !empty($module)}
  74. <table class="table we7-table table-hover vertical-middle we7-form">
  75. <div>应用<span class="color-default font-sm"></span></div>
  76. <thead>
  77. <tr>
  78. <th colspan="4" class="text-left">
  79. <div class="">
  80. <input id="check-module" type="checkbox" name="module_select" we7-check-all="1" onChange="selectall(this, 'module_select')">
  81. <label for="check-module" class=" we7-margin-horizontal-none">应用权限</label>
  82. </div>
  83. </th>
  84. </tr>
  85. </thead>
  86. <tbody class="module_select system-select-box">
  87. {php $i=1;}
  88. {loop $module $k $m}
  89. {if !empty($m['issystem'])}{php continue;}{/if}
  90. {if $i%4 == 1 || $i == 1}<tr>{/if}
  91. <td class="text-left vertical-middle" style="overflow:inherit;width:25%">
  92. <div class="dropdown system-select-dropdown">
  93. <span class="" data-id="{$k}">
  94. <input id="check-module-{$k}" type="checkbox" value="{$k}" name="module[]" we7-check-all="1" {if in_array($k, $module_permission_keys)}checked{/if}>
  95. <label for="check-module-{$k}" >{php echo mb_substr($m['title'], 0, 12, 'utf-8')}<span class="caret"></span></label>
  96. </span>
  97. <ul class="dropdown-menu" role="menu"></ul>
  98. <input type="hidden" name="{$k}_select" value="0"/>
  99. </div>
  100. </td>
  101. {if $i%4 == 0}</tr>{/if}
  102. {php $i++;}
  103. {/loop}
  104. {if ($i-1)%4 != 0}
  105. <?php
  106. for ($x=0; $x<4-($i-1)%4; $x++) {
  107. echo "<td></td>";
  108. }
  109. ?>
  110. </tr>
  111. {/if}
  112. </tbody>
  113. </table>
  114. {/if}
  115. <button type="submit" class="btn btn-primary span3" name="submit" value="提交">提交</button>
  116. <input type="hidden" name="token" value="{$_W['token']}" />
  117. </form>
  118. <script>
  119. $(function(){
  120. var uniacid = "{$_GPC['uniacid']}";
  121. var acid = "{$_GPC['acid']}";
  122. var module_permission_all = "{$module_permission_all}";
  123. if (module_permission_all == 1) {
  124. setTimeout(function () {
  125. module_select = $('#check-module').click();
  126. })
  127. }
  128. //公众号OR小程序下拉框
  129. $('.account-and-wxapp .dropdown span').hover(function(){
  130. $(this).parent().addClass('open').find('.dropdown-menu').show();
  131. $(this).parent().find('.dropdown-menu').hover(
  132. function(){$(this).show();$(this).parent().addClass('open')},
  133. function(){$(this).hide();$(this).parent().removeClass('open');}
  134. );
  135. },function(){
  136. $(this).parent().removeClass('open').find('.dropdown-menu').hide();
  137. });
  138. //模块下拉框
  139. $('.module_select .dropdown span').hover(function(){
  140. var _this = $(this);
  141. var m = $(this).attr('data-id');
  142. var uid = "{$uid}";
  143. var length = $(this).next().find('li').size();
  144. if(!length) {
  145. _this.next().html('<div class="text-center"><i class="fa-spin wi wi-changing-over"></i> 获取子权限 </div>');
  146. $.post("{php echo url('account/post-user/module')}", {'m' : m, 'uid' : uid, 'uniacid' : uniacid, 'acid' : acid}, function(data) {
  147. if(!data.message.errno) {
  148. var li_nums = data.message.message.length;
  149. var li_checked = 0;
  150. var li_contents = '';
  151. var html = '';
  152. $.each(data.message.message, function(k, v){
  153. var check = '';
  154. if (v.checked) {
  155. check = 'checked';
  156. li_checked ++;
  157. }
  158. html += '<li><a href="javascript:;"><input id="check-moduledetail-'+m+'-'+k+'" we7-check-all="1" type="checkbox" name="module_'+m+'[]" value="'+ v.permission +'" '+check+'/><label for="check-moduledetail-'+m+'-'+k+'" class="we7-padding-left we7-margin-horizontal-none checkbox-inline">'+ v.title +'</label></a></li>';
  159. });
  160. if (li_nums == li_checked) {
  161. li_contents = '已全选';
  162. } else {
  163. li_contents = '已选' + li_checked + '项';
  164. }
  165. var _html = '<div><label class="checkbox-inline info">' + li_contents + '</label></div>';
  166. html = _html + '<ul>' + html + '</ul>';
  167. _this.next().html(html);
  168. } else {
  169. _this.next().html('<div class="text-center">无子权限</div>');
  170. }
  171. }, 'json');
  172. }
  173. $(this).parent().addClass('open').find('.dropdown-menu').show();
  174. $(this).parent().find('.dropdown-menu').hover(
  175. function(){$(this).show();$(this).parent().addClass('open')},
  176. function(){$(this).hide();$(this).parent().removeClass('open');}
  177. );
  178. },function(){
  179. $(this).parent().removeClass('open').find('.dropdown-menu').hide();
  180. });
  181. $('.dropdown span :checkbox').click(function(e){
  182. var _parent = $(this).parents('.dropdown');
  183. _parent.find('.dropdown-menu :checkbox').prop('checked', $(this).prop('checked'));
  184. if($(this).prop('checked')) {
  185. _parent.find('label.info').html('已全选');
  186. _parent.find('input[type="hidden"]').val(1);
  187. } else {
  188. _parent.find('input[type="hidden"]').val(0);
  189. _parent.find('label.info').html('已选0项');
  190. }
  191. });
  192. $('.dropdown-menu').on('click', ':checkbox', function(){
  193. if(!$(this).prop('checked')) {
  194. var i = 0;
  195. $.each($(this).parents('li').siblings(), function(){
  196. if($(this).find(':checkbox').prop('checked')) {
  197. i ++;
  198. }
  199. });
  200. $(this).parents('.dropdown').find('input[type="hidden"]').val(0);
  201. $(this).parents('.dropdown').find('label.info').html('已选' + i + '项');
  202. if(!i) {
  203. $(this).parents('.dropdown').find('span :checkbox').prop('checked', false);
  204. }
  205. } else {
  206. var flag = 0;
  207. var i = 1;
  208. $.each($(this).parents('li').siblings(), function(){
  209. if(!$(this).find(':checkbox').prop('checked')) {
  210. flag = 1;
  211. } else {
  212. i ++;
  213. }
  214. });
  215. if(!flag) {
  216. $(this).parents('.dropdown').find('label.info').html('已全选');
  217. $(this).parents('.dropdown').find('input[type="hidden"]').val(1);
  218. } else {
  219. $(this).parents('.dropdown').find('label.info').html('已选' + i + '项');
  220. $(this).parents('.dropdown').find('input[type="hidden"]').val(0);
  221. }
  222. $(this).parents('.dropdown').find('span :checkbox').prop('checked', true);
  223. }
  224. });
  225. });
  226. //处理全选函数
  227. function selectall(obj, a){
  228. $('.'+a+' input:checkbox').each(function() {
  229. $(this)[0].checked = obj.checked ? true : false;
  230. });
  231. }
  232. //当已经全选时,默认全选按钮选中
  233. $(function() {
  234. $('.table>tbody').each(function() {
  235. var a = true;
  236. $(this).find('input:checkbox').each(function() {
  237. if($(this)[0].checked != true) {
  238. a = false;
  239. return false;
  240. }
  241. });
  242. if(a) $('input[name='+$(this).attr('class')+']:checkbox')[0].checked = true;
  243. });
  244. });
  245. </script>
  246. {template 'common/footer'}