set-permission.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. {template 'common/header'}
  2. <ol class="breadcrumb we7-breadcrumb">
  3. <a href="javascript:history.go(-1);"><i class="wi wi-back-circle"></i> </a>
  4. <li>权限设置</li>
  5. </ol>
  6. <form class="form-horizontal form we7-form" action="" method="post">
  7. <div class="alert alert-info">
  8. <i class="fa fa-exclamation-circle"></i> 默认未勾选任何菜单时,用户拥有全部权限。
  9. </div>
  10. <table class="table we7-table table-hover we7-form account-and-wxapp">
  11. {loop $menus $name $sections}
  12. {if $sections['section'] && $name == 'account' && in_array($account['type'], array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH))}
  13. <div class="we7-page-title">{$sections['title']}</div>
  14. {loop $sections['section'] $section_id $section}
  15. {if !in_array($section_id, array('platform_module'))}
  16. <thead>
  17. <tr class="text-left">
  18. <th colspan="4" class="text-left">
  19. <div class="">
  20. <!-- <input id="check-{$section_id}" type="checkbox" we7-check-all="1" name="system_{$section_id}" onChange="selectall(this, 'system_{$section_id}')"> -->
  21. <label for="check-{$section_id}" class=" we7-margin-horizontal-none">{$section['title']}</label>
  22. </div>
  23. </th>
  24. </tr>
  25. </thead>
  26. <tbody class="system_{$section_id}">
  27. {php $i=1;}
  28. {loop $section['menu'] $menu_id $menu}
  29. {if $i%4 == 1 || $i == 1}<tr>{/if}
  30. <td class="text-left vertical-middle" style="overflow:inherit;">
  31. <div class="dropdown system-select-dropdown">
  32. <span>
  33. <input id="check-child-{$menu_id}" type="checkbox" we7-check-all="1" value="{$menu['permission_name']}" {if in_array($menu['permission_name'], $user_menu_permission_account)}checked{/if} name="system[]" autocomplete="off" />
  34. <label for="check-child-{$menu_id}" class="we7-margin-horizontal-none" data-toggle="tooltip">{$menu['title']}</label>
  35. </span>
  36. {if $menu['sub_permission']}
  37. <ul class="dropdown-menu">
  38. {loop $menu['sub_permission'] $sub_permission}
  39. <li class="text-left">
  40. <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_permission_account)}checked{/if} name="system[]">
  41. <label class="we7-margin-horizontal-none" for="check-child-{$sub_permission['permission_name']}">
  42. {$sub_permission['title']}
  43. </label>
  44. </li>
  45. {/loop}
  46. </ul>
  47. {/if}
  48. </div>
  49. </td>
  50. {if $i%4 == 0}</tr><tr>{/if}
  51. {php $i++;}
  52. {/loop}
  53. {if ($i-1)%4 != 0}
  54. <?php
  55. for ($x=0; $x<4-($i-1)%4; $x++) {
  56. echo "<td></td>";
  57. }
  58. ?>
  59. </tr>
  60. {/if}
  61. </tbody>
  62. {/if}
  63. {/loop}
  64. {/if}
  65. {if $sections['section'] && $name == 'wxapp' && $account['type'] == ACCOUNT_TYPE_APP_NORMAL}
  66. <div class="we7-page-title">{$sections['title']}</div>
  67. {loop $sections['section'] $section_id $section}
  68. {if !in_array($section_id, array('wxapp_module'))}
  69. <thead>
  70. <tr class="text-left">
  71. <th colspan="4" class="text-left">
  72. <div class="">
  73. <!-- <input id="check-{$section_id}" type="checkbox" we7-check-all="1" name="system_{$section_id}" onChange="selectall(this, 'system_{$section_id}')"> -->
  74. <label for="check-{$section_id}" class=" we7-margin-horizontal-none">{$section['title']}</label>
  75. </div>
  76. </th>
  77. </tr>
  78. </thead>
  79. <tbody class="system_{$section_id}">
  80. {php $i=1;}
  81. {loop $section['menu'] $menu_id $menu}
  82. {if $menu_id == 'front_download'}{php continue;}{/if}
  83. {if $i%4 == 1 || $i == 1}<tr>{/if}
  84. <td class="text-left vertical-middle" style="overflow:inherit;">
  85. <div class="dropdown system-select-dropdown">
  86. <span>
  87. <input id="check-child-{$menu_id}" type="checkbox" we7-check-all="1" value="{$menu['permission_name']}" {if in_array($menu['permission_name'], $user_menu_permission_wxapp)}checked{/if} name="wxapp[]" autocomplete="off" />
  88. <label for="check-child-{$menu_id}" class="we7-margin-horizontal-none" data-toggle="tooltip">{$menu['title']}</label>
  89. </span>
  90. {if $menu['sub_permission']}
  91. <ul class="dropdown-menu">
  92. {loop $menu['sub_permission'] $sub_permission}
  93. <li class="text-left">
  94. <input id="check-child-{$sub_permission['permission_name']}" we7-check-all="1" type="checkbox" value="{$sub_permission['permission_name']}" {if in_array($menu['permission_name'], $user_menu_permission_wxapp)}checked{/if} name="wxapp[]">
  95. <label class="we7-margin-horizontal-none" for="check-child-{$sub_permission['permission_name']}">
  96. {$sub_permission['title']}
  97. </label>
  98. </li>
  99. {/loop}
  100. </ul>
  101. {/if}
  102. </div>
  103. </td>
  104. {if $i%4 == 0}</tr><tr>{/if}
  105. {php $i++;}
  106. {/loop}
  107. {if ($i-1)%4 != 0}
  108. <?php
  109. for ($x=0; $x<4-($i-1)%4; $x++) {
  110. echo "<td></td>";
  111. }
  112. ?>
  113. </tr>
  114. {/if}
  115. </tbody>
  116. {/if}
  117. {/loop}
  118. {/if}
  119. {/loop}
  120. </table>
  121. {if !empty($module)}
  122. <table class="table we7-table table-hover vertical-middle we7-form">
  123. <div class="we7-page-title">应用</div>
  124. <thead>
  125. <tr>
  126. <th colspan="4" class="text-left">
  127. <div class="">
  128. <!-- <input type="checkbox" we7-check-all="1" name="module[]" onChange="selectall(this, 'module_select')"> -->
  129. <label class=" we7-margin-horizontal-none">应用权限</label>
  130. </div>
  131. </th>
  132. </tr>
  133. </thead>
  134. <tbody class="module_select" >
  135. {php $i=1;}
  136. {loop $module $k $m}
  137. {if empty($m['issystem'])}
  138. {if $i%4 == 1 || $i == 1}<tr>{/if}
  139. <td class="text-left vertical-middle" style="overflow:inherit;width:25%">
  140. <div class="dropdown system-select-dropdown">
  141. <span class="" data-id="{$k}">
  142. <input id="check-module-{$k}" type="checkbox" value="{$k}" name="module[]" we7-check-all="1" {if in_array($k, $module_permission_keys)}checked{/if}>
  143. <label for="check-module-{$k}" title="{$m['title']}">{php echo mb_substr($m['title'], 0, 12, 'utf-8')}</label>
  144. </span>
  145. <ul class="dropdown-menu" role="menu">
  146. </ul>
  147. <input type="hidden" name="{$k}_select" value="0"/>
  148. </div>
  149. </td>
  150. {if $i%4 == 0}</tr>{/if}
  151. {php $i++;}
  152. {/if}
  153. {/loop}
  154. {if ($i-1)%4 != 0}
  155. <?php
  156. for ($x=0; $x<4-($i-1)%4; $x++) {
  157. echo "<td></td>";
  158. }
  159. ?>
  160. </tr>
  161. {/if}
  162. </tbody>
  163. </table>
  164. {/if}
  165. <button type="submit" class="btn btn-primary span3" name="submit" value="提交" onclick="if ($('input:checkbox:checked').size() == 0) {return confirm('您未勾选任何菜单权限,意味着允许用户使用所有功能。确定吗?')}">提交</button>
  166. <input type="hidden" name="token" value="{$_W['token']}" />
  167. </form>
  168. <script>
  169. $(function(){
  170. var uniacid = "{$_GPC['uniacid']}";
  171. var acid = "{$_GPC['acid']}";
  172. //公众号OR小程序下拉框
  173. $('.account-and-wxapp .dropdown span').hover(function(){
  174. $(this).parent().addClass('open').find('.dropdown-menu').show();
  175. $(this).parent().find('.dropdown-menu').hover(
  176. function(){$(this).show();$(this).parent().addClass('open')},
  177. function(){$(this).hide();$(this).parent().removeClass('open');}
  178. );
  179. },function(){
  180. $(this).parent().removeClass('open').find('.dropdown-menu').hide();
  181. });
  182. //模块下拉框
  183. $('.module_select .dropdown span').hover(function(){
  184. var _this = $(this);
  185. var m = $(this).attr('data-id');
  186. var uid = "{$uid}";
  187. var length = $(this).next().find('li').size();
  188. if(!length) {
  189. $.post("{php echo url('account/post-user/module')}", {'m' : m, 'uid' : uid, 'uniacid' : uniacid, 'acid' : acid}, function(data) {
  190. console.log(data);
  191. if(!data.message.errno) {
  192. var li_nums = data.message.message.length;
  193. var li_checked = 0;
  194. var li_contents = '';
  195. var html = '';
  196. $.each(data.message.message, function(k, v){
  197. var check = '';
  198. if (v.checked) {
  199. check = 'checked';
  200. li_checked ++;
  201. }
  202. 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>';
  203. });
  204. if (li_nums == li_checked) {
  205. li_contents = '已全选';
  206. } else {
  207. li_contents = '已选' + li_checked + '项';
  208. }
  209. var _html = '<li><label class="checkbox-inline info">' + li_contents + '</label></li>';
  210. html = _html + html;
  211. }
  212. _this.next().html(html);
  213. }, 'json');
  214. }
  215. $(this).parent().addClass('open').find('.dropdown-menu').show();
  216. $(this).parent().find('.dropdown-menu').hover(
  217. function(){$(this).show();$(this).parent().addClass('open')},
  218. function(){$(this).hide();$(this).parent().removeClass('open');}
  219. );
  220. },function(){
  221. $(this).parent().removeClass('open').find('.dropdown-menu').hide();
  222. });
  223. $('.dropdown span :checkbox').click(function(e){
  224. var _parent = $(this).parents('.dropdown');
  225. _parent.find('.dropdown-menu :checkbox').prop('checked', $(this).prop('checked'));
  226. if($(this).prop('checked')) {
  227. _parent.find('label.info').html('已全选');
  228. _parent.find('input[type="hidden"]').val(1);
  229. } else {
  230. _parent.find('input[type="hidden"]').val(0);
  231. _parent.find('label.info').html('已选0项');
  232. }
  233. });
  234. $('.dropdown-menu').on('click', ':checkbox', function(){
  235. if(!$(this).prop('checked')) {
  236. var i = 0;
  237. $.each($(this).parents('li').siblings(), function(){
  238. if($(this).find(':checkbox').prop('checked')) {
  239. i ++;
  240. }
  241. });
  242. $(this).parents('.dropdown').find('input[type="hidden"]').val(0);
  243. $(this).parents('.dropdown').find('label.info').html('已选' + i + '项');
  244. if(!i) {
  245. $(this).parents('.dropdown').find('span :checkbox').prop('checked', false);
  246. }
  247. } else {
  248. var flag = 0;
  249. var i = 1;
  250. $.each($(this).parents('li').siblings(), function(){
  251. if(!$(this).find(':checkbox').prop('checked')) {
  252. flag = 1;
  253. } else {
  254. i ++;
  255. }
  256. });
  257. if(!flag) {
  258. $(this).parents('.dropdown').find('label.info').html('已全选');
  259. $(this).parents('.dropdown').find('input[type="hidden"]').val(1);
  260. } else {
  261. $(this).parents('.dropdown').find('label.info').html('已选' + i + '项');
  262. $(this).parents('.dropdown').find('input[type="hidden"]').val(0);
  263. }
  264. $(this).parents('.dropdown').find('span :checkbox').prop('checked', true);
  265. }
  266. });
  267. });
  268. //当已经全选时,默认全选按钮选中
  269. $(function() {
  270. $('.table>tbody').each(function() {
  271. var a = true;
  272. $(this).find('input:checkbox').each(function() {
  273. if($(this)[0].checked != true) {
  274. a = false;
  275. return false;
  276. }
  277. });
  278. if(a) $('input[name='+$(this).attr('class')+']:checkbox')[0].checked = true;
  279. });
  280. });
  281. </script>
  282. {template 'common/footer'}