人人商城

set-permission.tpl.php 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 0) ? (include $this->template('common/header', TEMPLATE_INCLUDEPATH)) : (include template('common/header', TEMPLATE_INCLUDEPATH));?>
  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. <table class="table we7-table table-hover we7-form account-and-wxapp">
  8. <?php if(is_array($menus)) { foreach($menus as $name => $sections) { ?>
  9. <?php if($sections['section'] && $name == 'account' && in_array($account['type'], array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH))) { ?>
  10. <div class="we7-page-title"><?php echo $sections['title'];?><span class="color-default font-sm">(<i class="fa fa-exclamation-circle"></i> 默认未勾选任何菜单时,用户拥有全部权限)</span>
  11. </div>
  12. <?php if(is_array($sections['section'])) { foreach($sections['section'] as $section_id => $section) { ?>
  13. <?php if(!in_array($section_id, array('platform_module'))) { ?>
  14. <thead>
  15. <tr class="text-left">
  16. <th colspan="4" class="text-left">
  17. <div class="">
  18. <input id="check-<?php echo $section_id;?>" type="checkbox" name="system_<?php echo $section_id;?>" onChange="selectall(this, 'system_<?php echo $section_id;?>')">
  19. <label for="check-<?php echo $section_id;?>" class=" we7-margin-horizontal-none"><?php echo $section['title'];?></label>
  20. </div>
  21. </th>
  22. </tr>
  23. </thead>
  24. <tbody class="system_<?php echo $section_id;?>">
  25. <?php $i=1;?>
  26. <?php if(is_array($section['menu'])) { foreach($section['menu'] as $menu_id => $menu) { ?>
  27. <?php if(is_array($menu['permission_display']) && !in_array($account['type'], $menu['permission_display'])) { ?><?php continue;?><?php } ?>
  28. <?php if($i%4 == 1 || $i == 1) { ?><tr><?php } ?>
  29. <td class="text-left vertical-middle" style="overflow:inherit;">
  30. <div class="dropdown system-select-dropdown">
  31. <span>
  32. <input id="check-child-<?php echo $menu_id;?>" type="checkbox" we7-check-all="1" value="<?php echo $menu['permission_name'];?>" <?php if(in_array($menu['permission_name'], $user_menu_permission_account)) { ?>checked<?php } ?> name="system[]" autocomplete="off" />
  33. <label for="check-child-<?php echo $menu_id;?>" class="we7-margin-horizontal-none" data-toggle="tooltip"><?php echo $menu['title'];?><?php if(!empty($menu['sub_permission'])) { ?><span class="caret"></span><?php } ?></label>
  34. </span>
  35. <?php if($menu['sub_permission']) { ?>
  36. <ul class="dropdown-menu">
  37. <?php if(is_array($menu['sub_permission'])) { foreach($menu['sub_permission'] as $sub_permission) { ?>
  38. <li class="text-left">
  39. <input id="check-child-<?php echo $sub_permission['permission_name'];?>" we7-check-all="1" type="checkbox" value="<?php echo $sub_permission['permission_name'];?>" <?php if(in_array($sub_permission['permission_name'], $user_menu_permission_account)) { ?>checked<?php } ?> name="system[]">
  40. <label class="we7-margin-horizontal-none" for="check-child-<?php echo $sub_permission['permission_name'];?>">
  41. <?php echo $sub_permission['title'];?>
  42. </label>
  43. </li>
  44. <?php } } ?>
  45. </ul>
  46. <?php } ?>
  47. </div>
  48. </td>
  49. <?php if($i%4 == 0) { ?></tr><tr><?php } ?>
  50. <?php $i++;?>
  51. <?php } } ?>
  52. <?php if(($i-1)%4 != 0) { ?>
  53. <?php
  54. for ($x=0; $x<4-($i-1)%4; $x++) {
  55. echo "<td></td>";
  56. }
  57. ?>
  58. </tr>
  59. <?php } ?>
  60. </tbody>
  61. <?php } ?>
  62. <?php } } ?>
  63. <?php } ?>
  64. <?php if($sections['section'] && $name == 'wxapp' && $account['type'] == ACCOUNT_TYPE_APP_NORMAL) { ?>
  65. <div class="we7-page-title"><?php echo $sections['title'];?></div>
  66. <?php if(is_array($sections['section'])) { foreach($sections['section'] as $section_id => $section) { ?>
  67. <?php if(!in_array($section_id, array('platform_module'))) { ?>
  68. <thead>
  69. <tr class="text-left">
  70. <th colspan="4" class="text-left">
  71. <div class="">
  72. <input id="check-<?php echo $section_id;?>" type="checkbox" name="system_<?php echo $section_id;?>" we7-check-all="1" onChange="selectall(this, 'system_<?php echo $section_id;?>')">
  73. <label for="check-<?php echo $section_id;?>" class=" we7-margin-horizontal-none"><?php echo $section['title'];?><span class="caret"></span></label>
  74. </div>
  75. </th>
  76. </tr>
  77. </thead>
  78. <tbody class="system_<?php echo $section_id;?>">
  79. <?php $i=1;?>
  80. <?php if(is_array($section['menu'])) { foreach($section['menu'] as $menu_id => $menu) { ?>
  81. <?php if($menu_id == 'front_download') { ?><?php continue;?><?php } ?>
  82. <?php if($i%4 == 1 || $i == 1) { ?><tr><?php } ?>
  83. <td class="text-left vertical-middle" style="overflow:inherit;">
  84. <div class="dropdown system-select-dropdown">
  85. <span>
  86. <input id="check-child-<?php echo $menu_id;?>" type="checkbox" we7-check-all="1" value="<?php echo $menu['permission_name'];?>" <?php if(in_array($menu['permission_name'], $user_menu_permission_wxapp)) { ?>checked<?php } ?> name="wxapp[]" autocomplete="off" />
  87. <label for="check-child-<?php echo $menu_id;?>" class="we7-margin-horizontal-none" data-toggle="tooltip"><?php echo $menu['title'];?><?php if(!empty($menu['sub_permission'])) { ?><span class="caret"></span><?php } ?></label>
  88. </span>
  89. <?php if($menu['sub_permission']) { ?>
  90. <ul class="dropdown-menu">
  91. <?php if(is_array($menu['sub_permission'])) { foreach($menu['sub_permission'] as $sub_permission) { ?>
  92. <li class="text-left">
  93. <input id="check-child-<?php echo $sub_permission['permission_name'];?>" we7-check-all="1" type="checkbox" value="<?php echo $sub_permission['permission_name'];?>" <?php if(in_array($sub_permission['permission_name'], $user_menu_permission_wxapp)) { ?>checked<?php } ?> name="wxapp[]">
  94. <label class="we7-margin-horizontal-none" for="check-child-<?php echo $sub_permission['permission_name'];?>">
  95. <?php echo $sub_permission['title'];?>
  96. </label>
  97. </li>
  98. <?php } } ?>
  99. </ul>
  100. <?php } ?>
  101. </div>
  102. </td>
  103. <?php if($i%4 == 0) { ?></tr><tr><?php } ?>
  104. <?php $i++;?>
  105. <?php } } ?>
  106. <?php if(($i-1)%4 != 0) { ?>
  107. <?php
  108. for ($x=0; $x<4-($i-1)%4; $x++) {
  109. echo "<td></td>";
  110. }
  111. ?>
  112. </tr>
  113. <?php } ?>
  114. </tbody>
  115. <?php } ?>
  116. <?php } } ?>
  117. <?php } ?>
  118. <?php } } ?>
  119. </table>
  120. <?php if(!empty($module)) { ?>
  121. <table class="table we7-table table-hover vertical-middle we7-form">
  122. <div class="we7-page-title">应用<span class="color-default font-sm">(<i class="fa fa-exclamation-circle"></i> 默认未勾选任何菜单时,用户拥有全部权限)</span></div>
  123. <thead>
  124. <tr>
  125. <th colspan="4" class="text-left">
  126. <div class="">
  127. <input id="check-module" type="checkbox" name="module_select" we7-check-all="1" onChange="selectall(this, 'module_select')">
  128. <label for="check-module" class=" we7-margin-horizontal-none">应用权限</label>
  129. </div>
  130. </th>
  131. </tr>
  132. </thead>
  133. <tbody class="module_select system-select-box">
  134. <?php $i=1;?>
  135. <?php if(is_array($module)) { foreach($module as $k => $m) { ?>
  136. <?php if(empty($m['issystem'])) { ?>
  137. <?php if($i%4 == 1 || $i == 1) { ?><tr><?php } ?>
  138. <td class="text-left vertical-middle" style="overflow:inherit;width:25%">
  139. <div class="dropdown system-select-dropdown">
  140. <span class="" data-id="<?php echo $k;?>">
  141. <input id="check-module-<?php echo $k;?>" type="checkbox" value="<?php echo $k;?>" name="module[]" we7-check-all="1" <?php if(in_array($k, $module_permission_keys)) { ?>checked<?php } ?>>
  142. <label for="check-module-<?php echo $k;?>" ><?php echo mb_substr($m['title'], 0, 12, 'utf-8')?><span class="caret"></span></label>
  143. </span>
  144. <ul class="dropdown-menu" role="menu"></ul>
  145. <input type="hidden" name="<?php echo $k;?>_select" value="0"/>
  146. </div>
  147. </td>
  148. <?php if($i%4 == 0) { ?></tr><?php } ?>
  149. <?php $i++;?>
  150. <?php } ?>
  151. <?php } } ?>
  152. <?php if(($i-1)%4 != 0) { ?>
  153. <?php
  154. for ($x=0; $x<4-($i-1)%4; $x++) {
  155. echo "<td></td>";
  156. }
  157. ?>
  158. </tr>
  159. <?php } ?>
  160. </tbody>
  161. </table>
  162. <?php } ?>
  163. <button type="submit" class="btn btn-primary span3" name="submit" value="提交" onclick="if ($('input:checkbox:checked').size() == 0) {return confirm('您未勾选任何菜单权限,意味着允许用户使用所有功能。确定吗?')}">提交</button>
  164. <input type="hidden" name="token" value="<?php echo $_W['token'];?>" />
  165. </form>
  166. <script>
  167. $(function(){
  168. var uniacid = "<?php echo $_GPC['uniacid'];?>";
  169. var acid = "<?php echo $_GPC['acid'];?>";
  170. //公众号OR小程序下拉框
  171. $('.account-and-wxapp .dropdown span').hover(function(){
  172. $(this).parent().addClass('open').find('.dropdown-menu').show();
  173. $(this).parent().find('.dropdown-menu').hover(
  174. function(){$(this).show();$(this).parent().addClass('open')},
  175. function(){$(this).hide();$(this).parent().removeClass('open');}
  176. );
  177. },function(){
  178. $(this).parent().removeClass('open').find('.dropdown-menu').hide();
  179. });
  180. //模块下拉框
  181. $('.module_select .dropdown span').hover(function(){
  182. var _this = $(this);
  183. var m = $(this).attr('data-id');
  184. var uid = "<?php echo $uid;?>";
  185. var length = $(this).next().find('li').size();
  186. if(!length) {
  187. _this.next().html('<div class="text-center"><i class="fa-spin wi wi-changing-over"></i> 获取子权限 </div>');
  188. $.post("<?php echo url('account/post-user/module')?>", {'m' : m, 'uid' : uid, 'uniacid' : uniacid, 'acid' : acid}, function(data) {
  189. if(!data.message.errno) {
  190. var li_nums = data.message.message.length;
  191. var li_checked = 0;
  192. var li_contents = '';
  193. var html = '';
  194. $.each(data.message.message, function(k, v){
  195. var check = '';
  196. if (v.checked) {
  197. check = 'checked';
  198. li_checked ++;
  199. }
  200. 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>';
  201. });
  202. if (li_nums == li_checked) {
  203. li_contents = '已全选';
  204. } else {
  205. li_contents = '已选' + li_checked + '项';
  206. }
  207. var _html = '<div><label class="checkbox-inline info">' + li_contents + '</label></div>';
  208. html = _html + '<ul>' + html + '</ul>';
  209. _this.next().html(html);
  210. } else {
  211. _this.next().html('<div class="text-center">无子权限</div>');
  212. }
  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 selectall(obj, a){
  270. $('.'+a+' input:checkbox').each(function() {
  271. $(this)[0].checked = obj.checked ? true : false;
  272. });
  273. }
  274. //当已经全选时,默认全选按钮选中
  275. $(function() {
  276. $('.table>tbody').each(function() {
  277. var a = true;
  278. $(this).find('input:checkbox').each(function() {
  279. if($(this)[0].checked != true) {
  280. a = false;
  281. return false;
  282. }
  283. });
  284. if(a) $('input[name='+$(this).attr('class')+']:checkbox')[0].checked = true;
  285. });
  286. });
  287. </script>
  288. <?php (!empty($this) && $this instanceof WeModuleSite || 0) ? (include $this->template('common/footer', TEMPLATE_INCLUDEPATH)) : (include template('common/footer', TEMPLATE_INCLUDEPATH));?>