permission.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. {template 'common/header'}
  2. {if $do == 'display'}
  3. <div class="clearfix">
  4. <div class="we7-padding-bottom clearfix">
  5. {if empty($module['main_module'])}
  6. <div class="pull-right">
  7. <a href="{php echo url('module/permission/post', array('m' => $module_name))}" class="btn btn-primary we7-padding-horizontal">添加操作员</a>
  8. <a href="{php echo url('user/register', array('type' => USER_TYPE_CLERK, 'm' => $module_name))}" target="_blank" class="btn btn-primary we7-padding-horizontal">注册操作员</a>
  9. </div>
  10. {/if}
  11. </div>
  12. <table class="table we7-table table-hover">
  13. <thead class="navbar-inner">
  14. <tr>
  15. <th class="text-center" style="width:100px;">操作员名称</th>
  16. <th class="text-center" style="width:150px">权限信息</th>
  17. <th class="text-right" style="width:100px;">操作</th>
  18. </tr>
  19. </thead>
  20. <tbody>
  21. {if !empty($user_permissions)}
  22. {loop $user_permissions $item}
  23. <tr>
  24. <td class="text-center" style="width:50px;">{$item['user_info']['username']}</td>
  25. <td class="text-center">
  26. {if !empty($item['permission']) && !array_key_exists('all', $item['permission'])}
  27. {loop $item['permission'] $permission}
  28. <span class="label label-primary">{$permission}</span>
  29. {/loop}
  30. {else}
  31. <span class="label label-primary">所有</span>
  32. {/if}
  33. </td>
  34. <td style="width:100px;">
  35. <div class="link-group" >
  36. {if empty($module['main_module'])}
  37. <a href="{php echo url('module/permission/post', array('uid' => $item['uid'], 'm' => $module_name));}">编辑</a>
  38. <a href="javascript:void(0);" onclick="deleteClerk('{$item["uid"]}', '{$module_name}')" class="del">删除</a>
  39. {else}
  40. <span>---</span>
  41. {/if}
  42. </div>
  43. </td>
  44. </tr>
  45. {/loop}
  46. {else}
  47. <tr ng-if="!wechats">
  48. <td colspan="3" class="text-center">暂无数据</td>
  49. </tr>
  50. {/if}
  51. </tbody>
  52. </table>
  53. <script>
  54. var url = "{php echo url('module/permission/delete');}";
  55. function deleteClerk(uid, module_name) {
  56. url += "&uid=" + uid;
  57. url += "&m=" + module_name;
  58. util.confirm(function () {
  59. window.location.href = url;
  60. }, function () {
  61. return false;
  62. }, '确认删除吗?');
  63. }
  64. </script>
  65. </div>
  66. {/if}
  67. {if $do == 'post'}
  68. <div class="clearfix">
  69. <form action="" method="post" class="form-horizontal form ajaxfrom we7-form" role="form" id="form-user">
  70. <div class="form-group">
  71. <label class="col-sm-2 ontrol-label">用户名</label>
  72. <div class="col-sm-6 input-group">
  73. <input id="" name="username" type="text" class="form-control" value="{$user['username']}" {if !empty($_GPC['uid'])}readonly{/if}/>
  74. <span class="input-group-btn">
  75. <a href="{php echo url('user/register', array('type' => USER_TYPE_CLERK, 'm' => $module_name, 'redirect' => 'post'))}" target="_blank" class="btn btn-default">注册操作员</a>
  76. </span>
  77. </div>
  78. <div class="col-sm-offset-2">
  79. <span class="help-block">请输入用户名,用户名为 3 到 15 个字符组成,包括汉字,大小写字母(不区分大小写)</span>
  80. </div>
  81. </div>
  82. <div class="form-group module-permission">
  83. <label class="col-sm-2 control-label">权限设置</label>
  84. <div class="col-sm-10">
  85. {loop $all_permission $key $module_val}
  86. <div class="col-sm-10 col-lg-10 col-xs-12 plugin-name">{$module_val['info']['title']}</div>
  87. {loop $module_val['permission'] $sub_key $permission}
  88. <div class="col-sm-4 dropdown">
  89. <span class="checkbox">
  90. <input id="check-child-{$key}-{$sub_key}" type="checkbox" value="{$permission['permission']}" name="module_permission[{$module_val['info']['name']}][]" {if !empty($permission['checked'])}checked{/if}>
  91. <label for="check-child-{$key}-{$sub_key}" data-toggle="tooltip">{$permission['title']}{if !empty($menu['sub_permission'])}<span class="caret"></span>{/if}</label>
  92. </span>
  93. {if $permission['sub_permission']}
  94. <ul class="dropdown-menu">
  95. {loop $permission['sub_permission'] $sub_permission}
  96. <li class="text-left">
  97. <input id="check-child-{$sub_permission['permission']}" we7-check-all="1" type="checkbox" value="{$sub_permission['permission']}" {if !empty($sub_permission['checked'])}checked{/if} name="module_permission[{$module_val['info']['name']}][]">
  98. <label for="check-child-{$sub_permission['permission']}">
  99. {$sub_permission['title']}
  100. </label>
  101. </li>
  102. {/loop}
  103. </ul>
  104. {/if}
  105. </div>
  106. {/loop}
  107. {/loop}
  108. </div>
  109. </div>
  110. <div class="form-group">
  111. <div class="col-sm-offset-2 ">
  112. <input type="submit" class="btn btn-primary span3" name="submit" value="提交" />
  113. <input type="hidden" name="token" value="{$_W['token']}" />
  114. </div>
  115. </div>
  116. </form>
  117. </div>
  118. <script>
  119. $('.module-permission .dropdown span').hover(function(){
  120. $(this).parent().addClass('open').find('.dropdown-menu').show();
  121. $(this).parent().find('.dropdown-menu').hover(
  122. function(){$(this).show();$(this).parent().addClass('open')},
  123. function(){$(this).hide();$(this).parent().removeClass('open');}
  124. );
  125. },function(){
  126. $(this).parent().removeClass('open').find('.dropdown-menu').hide();
  127. });
  128. var haveChecked = false;
  129. $('input[type="checkbox"]').each(function(i, n) {
  130. if ($(n).prop('checked')) {
  131. haveChecked = true;
  132. }
  133. });
  134. if (!haveChecked) {
  135. $('input[type="checkbox"]').each(function(i, n) {
  136. $(n).prop('checked', 'checked')
  137. });
  138. }
  139. </script>
  140. {/if}
  141. {template 'common/footer'}