permission.blade.php 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. @extends('admin.base')
  2. @section('content')
  3. <style>
  4. .cate-box{margin-bottom: 15px;padding-bottom:10px;border-bottom: 1px solid #f0f0f0}
  5. .cate-box dt{margin-bottom: 10px;}
  6. .cate-box dt .cate-first{padding:10px 20px}
  7. .cate-box dd{padding:0 50px}
  8. .cate-box dd .cate-second{margin-bottom: 10px}
  9. .cate-box dd .cate-third{padding:0 40px;margin-bottom: 10px}
  10. </style>
  11. <div class="layui-card">
  12. <div class="layui-card-header layuiadmin-card-header-auto">
  13. <h2>第三方 【{{$party->name}}】分配直接权限,直接权限与角色拥有的角色权限不冲突</h2>
  14. </div>
  15. <div class="layui-card-body">
  16. <form action="{{route('admin.party.assignPermission',['party'=>$party])}}" method="post" class="layui-form">
  17. {{csrf_field()}}
  18. {{method_field('put')}}
  19. @forelse($permissions as $first)
  20. <dl class="cate-box">
  21. <dt>
  22. <div class="cate-first"><input id="menu{{$first['id']}}" type="checkbox" name="permissions[]" value="{{$first['id']}}" title="{{$first['display_name']}}" lay-skin="primary" {{$first['own']??''}} ></div>
  23. </dt>
  24. @if(isset($first['_child']))
  25. @foreach($first['_child'] as $second)
  26. <dd>
  27. <div class="cate-second"><input id="menu{{$first['id']}}-{{$second['id']}}" type="checkbox" name="permissions[]" value="{{$second['id']}}" title="{{$second['display_name']}}" lay-skin="primary" {{$second['own']??''}}></div>
  28. @if(isset($second['_child']))
  29. <div class="cate-third">
  30. @foreach($second['_child'] as $thild)
  31. <input type="checkbox" id="menu{{$first['id']}}-{{$second['id']}}-{{$thild['id']}}" name="permissions[]" value="{{$thild['id']}}" title="{{$thild['display_name']}}" lay-skin="primary" {{$thild['own']??''}}>
  32. @endforeach
  33. </div>
  34. @endif
  35. </dd>
  36. @endforeach
  37. @endif
  38. </dl>
  39. @empty
  40. <div style="text-align: center;padding:20px 0;">
  41. 无数据
  42. </div>
  43. @endforelse
  44. <div class="layui-form-item">
  45. <button type="submit" class="layui-btn" lay-submit="" >确 认</button>
  46. <a href="{{route('admin.party')}}" class="layui-btn" >返 回</a>
  47. </div>
  48. </form>
  49. </div>
  50. </div>
  51. @endsection
  52. @section('script')
  53. <script type="text/javascript">
  54. form.on('checkbox', function (data) {
  55. var check = data.elem.checked;//是否选中
  56. var checkId = data.elem.id;//当前操作的选项框
  57. if (check) {
  58. //选中
  59. var ids = checkId.split("-");
  60. if (ids.length == 3) {
  61. //第三极菜单
  62. //第三极菜单选中,则他的上级选中
  63. $("#" + (ids[0] + '-' + ids[1])).prop("checked", true);
  64. $("#" + (ids[0])).prop("checked", true);
  65. } else if (ids.length == 2) {
  66. //第二季菜单
  67. $("#" + (ids[0])).prop("checked", true);
  68. $("input[id*=" + ids[0] + '-' + ids[1] + "]").each(function (i, ele) {
  69. $(ele).prop("checked", true);
  70. });
  71. } else {
  72. //第一季菜单不需要做处理
  73. $("input[id*=" + ids[0] + "-]").each(function (i, ele) {
  74. $(ele).prop("checked", true);
  75. });
  76. }
  77. } else {
  78. //取消选中
  79. var ids = checkId.split("-");
  80. if (ids.length == 2) {
  81. //第二极菜单
  82. $("input[id*=" + ids[0] + '-' + ids[1] + "]").each(function (i, ele) {
  83. $(ele).prop("checked", false);
  84. });
  85. } else if (ids.length == 1) {
  86. $("input[id*=" + ids[0] + "-]").each(function (i, ele) {
  87. $(ele).prop("checked", false);
  88. });
  89. }
  90. }
  91. form.render();
  92. });
  93. </script>
  94. @endsection