info.blade.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/multi-select/multi-select.min.css" type="text/css" rel="stylesheet">
  4. @endsection
  5. @section('content')
  6. <div class="page-content container">
  7. <div class="panel">
  8. <div class="panel-heading">
  9. <h2 class="panel-title">@isset($ruleGroup)编辑@else添加@endisset规则分组</h2>
  10. <div class="panel-actions">
  11. <a href="{{route('rule.group.index')}}" class="btn btn-danger">返 回</a>
  12. </div>
  13. </div>
  14. @if (Session::has('successMsg'))
  15. <x-alert type="success" :message="Session::get('successMsg')"/>
  16. @endif
  17. @if($errors->any())
  18. <x-alert type="danger" :message="$errors->first()"/>
  19. @endif
  20. <div class="panel-body">
  21. <form action=@isset($ruleGroup){{route('rule.group.update',$ruleGroup->id)}}@else{{route('rule.group.store')}}@endisset method="post" enctype="multipart/form-data" class="form-horizontal">
  22. @isset($ruleGroup)@method('PUT')@endisset
  23. @csrf
  24. <div class="form-group row">
  25. <label class="col-md-2 col-sm-3 col-form-label" for="name">分组名称</label>
  26. <div class="col-md-9 col-sm-9">
  27. <input type="text" class="form-control" name="name" id="name"/>
  28. </div>
  29. </div>
  30. <div class="form-group row">
  31. <label class="col-md-2 col-sm-3 col-form-label" for="type">审计模式</label>
  32. <div class="col-md-10 col-sm-8">
  33. <ul class="list-unstyled list-inline">
  34. <li class="list-inline-item">
  35. <div class="radio-custom radio-primary">
  36. <input type="radio" name="type" id="block" value="1" checked/>
  37. <label for="block">阻断</label>
  38. </div>
  39. </li>
  40. <li class="list-inline-item">
  41. <div class="radio-custom radio-primary">
  42. <input type="radio" name="type" id="unblock" value="0"/>
  43. <label for="unblock">放行</label>
  44. </div>
  45. </li>
  46. </ul>
  47. </div>
  48. </div>
  49. <div class="form-group row">
  50. <label class="col-md-2 col-sm-3 col-form-label" for="rules">选择规则</label>
  51. <div class="col-md-9 col-sm-9">
  52. <div class="btn-group mb-20">
  53. <button type="button" class="btn btn-primary" id="select-all">全 选</button>
  54. <button type="button" class="btn btn-danger" id="deselect-all">清 空</button>
  55. </div>
  56. <select class="form-control" name="rules[]" id="rules" data-plugin="multiSelect" multiple>
  57. @foreach($ruleList as $rule)
  58. <option value="{{$rule->id}}">{{$rule->id . ' - ' . $rule->name}}</option>
  59. @endforeach
  60. </select>
  61. </div>
  62. </div>
  63. <div class="form-actions text-right">
  64. <button type="submit" class="btn btn-success">提 交</button>
  65. </div>
  66. </form>
  67. </div>
  68. </div>
  69. </div>
  70. @endsection
  71. @section('script')
  72. <script src="/assets/global/vendor/multi-select/jquery.multi-select.js" type="text/javascript"></script>
  73. <script src="/assets/global/js/Plugin/multi-select.js"></script>
  74. <script src="/assets/global/js/jquery.quicksearch.js" type="text/javascript"></script>
  75. <script type="text/javascript">
  76. @isset($ruleGroup)
  77. $(document).ready(function () {
  78. $('#name').val('{{$ruleGroup->name}}');
  79. $("input[name='type'][value='{{$ruleGroup->type}}']").click();
  80. $('#rules').multiSelect('select',@json($ruleGroup->rules));
  81. })
  82. @endisset
  83. // 权限列表
  84. $('#rules').multiSelect({
  85. selectableHeader: "<input type='text' class='search-input form-control' autocomplete='off' placeholder='待分配规则,此处可搜索'>",
  86. selectionHeader: "<input type='text' class='search-input form-control' autocomplete='off' placeholder='已分配规则,此处可搜索'>",
  87. afterInit: function () {
  88. const that = this,
  89. $selectableSearch = that.$selectableUl.prev(),
  90. $selectionSearch = that.$selectionUl.prev(),
  91. selectableSearchString = '#' + that.$container.attr('id') + ' .ms-elem-selectable:not(.ms-selected)',
  92. selectionSearchString = '#' + that.$container.attr('id') + ' .ms-elem-selection.ms-selected';
  93. that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
  94. .on('keydown', function (e) {
  95. if (e.which === 40) {
  96. that.$selectableUl.focus();
  97. return false;
  98. }
  99. });
  100. that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
  101. .on('keydown', function (e) {
  102. if (e.which === 40) {
  103. that.$selectionUl.focus();
  104. return false;
  105. }
  106. });
  107. },
  108. afterSelect: function () {
  109. this.qs1.cache();
  110. this.qs2.cache();
  111. },
  112. afterDeselect: function () {
  113. this.qs1.cache();
  114. this.qs2.cache();
  115. }
  116. });
  117. // 全选
  118. $('#select-all').click(function () {
  119. $('#rules').multiSelect('select_all');
  120. return false;
  121. });
  122. // 反选
  123. $('#deselect-all').click(function () {
  124. $('#rules').multiSelect('deselect_all');
  125. return false;
  126. });
  127. </script>
  128. @endsection