You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.9 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. @extends('admin.layouts.app')
  2. @section('title', '角色权限设置')
  3. @section('content')
  4. <h2 class="sub-header">角色权限设置</h2>[ <a href="<?php echo route('admin_userrole'); ?>">角色列表</a> ]<br><br>
  5. <form method="post" action="<?php echo route('admin_userrole_dopermissions'); ?>" role="form" enctype="multipart/form-data" class="table-responsive"><div class="table-responsive">{{ csrf_field() }}
  6. <input style="display:none;" name="role_id" type="text" id="role_id" value="<?php echo $role_id; ?>">
  7. <ul class="list-group">
  8. <?php if($menus){foreach($menus as $row){ ?>
  9. <li class="list-group-item <?php if($row["deep"]==0){echo 'list-group-item-info';} ?>"><?php echo '<span style="padding-left:'.($row["deep"]*30).'px;"></span>'; ?><input type='checkbox' <?php if($row["is_access"]==1){echo "checked='checked'";} ?> name='menuid[]' value='<?php echo $row["id"]; ?>' level='<?php echo $row["deep"]; ?>' onclick='javascript:checknode(this);'> <?php for($i=0;$i<$row["deep"];$i++){echo "—";}echo $row["name"]; ?></li>
  10. <?php }} ?>
  11. </ul>
  12. <button type="submit" class="btn btn-success" value="Submit">保存(Submit)</button><br><br>
  13. </div><!-- 表格结束 --></form><!-- 表单结束 -->
  14. <script>
  15. function checknode(obj)
  16. {
  17. var chk = $("input[type='checkbox']");
  18. var count = chk.length;
  19. var num = chk.index(obj);
  20. var level_top = level_bottom = chk.eq(num).attr('level');
  21. for (var i = num; i >= 0; i--)
  22. {
  23. var le = chk.eq(i).attr('level');
  24. if (le <level_top)
  25. {
  26. chk.eq(i).prop("checked", true);
  27. var level_top = level_top - 1;
  28. }
  29. }
  30. for (var j = num + 1; j < count; j++)
  31. {
  32. var le = chk.eq(j).attr('level');
  33. if (chk.eq(num).prop("checked"))
  34. {
  35. if (le > level_bottom)
  36. {
  37. chk.eq(j).prop("checked", true);
  38. }
  39. else if (le == level_bottom)
  40. {
  41. break;
  42. }
  43. }
  44. else
  45. {
  46. if (le >level_bottom)
  47. {
  48. chk.eq(j).prop("checked", false);
  49. }else if(le == level_bottom)
  50. {
  51. break;
  52. }
  53. }
  54. }
  55. }
  56. </script>
  57. @endsection