assign.blade.php 4.6 KB

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