access.blade.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. @extends('admin.public.base')
  2. @section('body_class')
  3. style="margin: 0 auto;width: 96%;padding: 30px 0px;"
  4. @endsection
  5. @section('content')
  6. <style>
  7. .checkmod {
  8. border: 1px solid #ccc;
  9. margin-bottom: 20px;
  10. padding: 0;
  11. }
  12. .checkmod dt label {
  13. background-color: #ececec;
  14. border-bottom: 1px solid #ebebeb;
  15. font-weight: bold;
  16. height: 30px;
  17. line-height: 30px;
  18. padding-left: 30px;
  19. }
  20. .checkmod dd label {
  21. line-height: 30px;
  22. padding-left: 20px;
  23. }
  24. </style>
  25. <div class="row">
  26. <div class="col-xs-12">
  27. <div>
  28. <form class="form-horizontal post-form" id="validation-form" method="post" action="">
  29. @if (request('id',0))
  30. <input name="id" type="hidden" value="{{request('id',0)}}" />
  31. @endif
  32. @foreach ($access_menu as $node)
  33. <dl class="checkmod">
  34. <dt class="hd">
  35. <label class="checkbox"><input class="auth_rules rules_all" type="checkbox" name="rules[]" value="{{$node['id']}}">{{$node['title']}}</label>
  36. </dt>
  37. <dd class="bd">
  38. @if (isset($node['child']))
  39. @foreach ($node['child'] as $child)
  40. <div class="rule_check">
  41. <div>
  42. <label class="checkbox" @if ( !empty($child['tip'])) title='{{$child['tip']}}' @endif >
  43. <input class="auth_rules rules_row" type="checkbox" name="rules[]" value="{{$child['id']}}"/>{{$child['title']}}
  44. </label>
  45. @if ( !empty($child['child']))
  46. @foreach ($child['child'] as $op)
  47. <div style="margin-left:30px;">
  48. <label class="checkbox">
  49. <input class="auth_rules" type="checkbox" name="rules[]" value="{{$op['id']}}" /> {{$op['title']}}
  50. </label>
  51. @if ( !empty($op['child']))
  52. <div style="margin-left:50px;">
  53. @foreach ($op['child'] as $k1 => $op1 )
  54. <span class="child_row">
  55. <label class="checkbox" style="display: inline-block;">
  56. <input class="auth_rules" type="checkbox" name="rules[]" value="{{$op1['id']}}" /> {{$op1['title']}}
  57. </label>
  58. </span>
  59. @endforeach
  60. </div>
  61. @endif
  62. </div>
  63. @endforeach
  64. @endif
  65. </div>
  66. </div>
  67. @endforeach
  68. @endif
  69. </dd>
  70. </dl>
  71. @endforeach
  72. <div class="form-group">
  73. <div class="col-sm-12">
  74. @csrf
  75. <input type="submit" value="提交" class="btn btn-primary" />
  76. </div>
  77. </div>
  78. </form>
  79. </div>
  80. </div>
  81. </div>
  82. @endsection
  83. @section('javascript')
  84. <style>
  85. .checkmod {
  86. padding: 0;
  87. border: 1px solid #ccc;
  88. margin-bottom: 20px;
  89. }
  90. .checkmod dt {
  91. background-color: #ececec;
  92. border-bottom: 1px solid #ebebeb;
  93. font-weight: bold;
  94. height: 30px;
  95. line-height: 30px;
  96. padding-left: 10px;
  97. }
  98. .checkmod dd {
  99. line-height: 30px;
  100. padding-left: 20px;
  101. }
  102. </style>
  103. <script>
  104. $(function() {
  105. <?php echo 'var rules = ['.$rules['rules'].'];' ?>
  106. $('.auth_rules').each(function() {
  107. if($.inArray(parseInt(this.value, 10), rules) > -1) {
  108. $(this).prop('checked', true);
  109. }
  110. if(this.value == '') {
  111. $(this).closest('span').remove();
  112. }
  113. });
  114. //全选节点
  115. $('.rules_all').on('change', function() {
  116. $(this).closest('dl').find('dd').find('input').prop('checked', this.checked);
  117. });
  118. $('.rules_row').on('change', function() {
  119. $(this).closest('.rule_check').find('input').prop('checked', this.checked);
  120. });
  121. });
  122. </script>
  123. @endsection