assign.blade.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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">分配节点</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={{route('rule.group.assign',$ruleGroup->id)}} method="post" enctype="multipart/form-data" class="form-horizontal">
  22. @method('PUT')
  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-auto">
  27. <input class="form-control" id="name" value="{{$ruleGroup->name}}" readonly/>
  28. </div>
  29. </div>
  30. <div class="form-group row">
  31. <label class="col-md-2 col-sm-3 col-form-label" for="nodes">选择节点</label>
  32. <div class="col-md-9 col-sm-9">
  33. <div class="btn-group mb-20">
  34. <button type="button" class="btn btn-primary" id="select-all">全 选</button>
  35. <button type="button" class="btn btn-danger" id="deselect-all">清 空</button>
  36. </div>
  37. <select class="form-control" name="nodes[]" id="nodes" data-plugin="multiSelect" multiple>
  38. @foreach($nodeList as $node)
  39. <option value="{{$node->id}}">{{$node->id . ' - ' . Str::limit($node->name, 30)}}</option>
  40. @endforeach
  41. </select>
  42. </div>
  43. </div>
  44. <div class="form-actions text-right">
  45. <button type="submit" class="btn btn-success">提 交</button>
  46. </div>
  47. </form>
  48. </div>
  49. </div>
  50. </div>
  51. @endsection
  52. @section('script')
  53. <script src="/assets/global/vendor/multi-select/jquery.multi-select.js" type="text/javascript"></script>
  54. <script src="/assets/global/js/Plugin/multi-select.js"></script>
  55. <script src="/assets/global/js/jquery.quicksearch.js" type="text/javascript"></script>
  56. <script type="text/javascript">
  57. $(document).ready(function () {
  58. $('#nodes').multiSelect('select',@json($ruleGroup->nodes));
  59. })
  60. // 权限列表
  61. $('#nodes').multiSelect({
  62. selectableHeader: "<input type='text' class='search-input form-control' autocomplete='off' placeholder='待分配节点,此处可搜索'>",
  63. selectionHeader: "<input type='text' class='search-input form-control' autocomplete='off' placeholder='已分配节点,此处可搜索'>",
  64. afterInit: function () {
  65. const that = this,
  66. $selectableSearch = that.$selectableUl.prev(),
  67. $selectionSearch = that.$selectionUl.prev(),
  68. selectableSearchString = '#' + that.$container.attr('id') + ' .ms-elem-selectable:not(.ms-selected)',
  69. selectionSearchString = '#' + that.$container.attr('id') + ' .ms-elem-selection.ms-selected';
  70. that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
  71. .on('keydown', function (e) {
  72. if (e.which === 40) {
  73. that.$selectableUl.focus();
  74. return false;
  75. }
  76. });
  77. that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
  78. .on('keydown', function (e) {
  79. if (e.which === 40) {
  80. that.$selectionUl.focus();
  81. return false;
  82. }
  83. });
  84. },
  85. afterSelect: function () {
  86. this.qs1.cache();
  87. this.qs2.cache();
  88. },
  89. afterDeselect: function () {
  90. this.qs1.cache();
  91. this.qs2.cache();
  92. }
  93. });
  94. // 全选
  95. $('#select-all').click(function () {
  96. $('#nodes').multiSelect('select_all');
  97. return false;
  98. });
  99. // 反选
  100. $('#deselect-all').click(function () {
  101. $('#nodes').multiSelect('deselect_all');
  102. return false;
  103. });
  104. </script>
  105. @endsection