info.blade.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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">
  10. {{ isset($user) ? trans('admin.action.edit_item', ['attribute' => trans('model.user_group.attribute')]) : trans('admin.action.add_item', ['attribute' => trans('model.user_group.attribute')]) }}
  11. </h2>
  12. <div class="panel-actions">
  13. <a class="btn btn-danger" href="{{ route('admin.user.group.index') }}">{{ trans('common.back') }}</a>
  14. </div>
  15. </div>
  16. @if (Session::has('successMsg'))
  17. <x-alert type="success" :message="Session::pull('successMsg')" />
  18. @endif
  19. @if ($errors->any())
  20. <x-alert type="danger" :message="$errors->all()" />
  21. @endif
  22. <div class="panel-body">
  23. <form class="form-horizontal"
  24. action="@isset($group){{ route('admin.user.group.update', $group) }}@else{{ route('admin.user.group.store') }}@endisset"
  25. method="POST" enctype="multipart/form-data">
  26. @isset($group)
  27. @method('PUT')
  28. @endisset
  29. @csrf
  30. <div class="form-group row">
  31. <label class="col-md-2 col-sm-3 col-form-label" for="name">{{ trans('model.user_group.name') }}</label>
  32. <div class="col-md-9 col-sm-9">
  33. <input class="form-control" id="name" name="name" type="text" required />
  34. </div>
  35. </div>
  36. <div class="form-group row">
  37. <label class="col-md-2 col-sm-3 col-form-label" for="nodes">{{ trans('model.user_group.nodes') }}</label>
  38. <div class="col-md-9 col-sm-9">
  39. <div class="btn-group mb-20">
  40. <button class="btn btn-primary" id="select-all" type="button">{{ trans('admin.select_all') }}</button>
  41. <button class="btn btn-danger" id="deselect-all" type="button">{{ trans('admin.clear') }}</button>
  42. </div>
  43. <select class="form-control" id="nodes" name="nodes[]" data-plugin="multiSelect" multiple>
  44. @foreach ($nodes as $id => $name)
  45. <option value="{{ $id }}">{{ $id . ' - ' . $name }}</option>
  46. @endforeach
  47. </select>
  48. </div>
  49. </div>
  50. <div class="form-actions text-right">
  51. <button class="btn btn-success" type="submit">{{ trans('common.submit') }}</button>
  52. </div>
  53. </form>
  54. </div>
  55. </div>
  56. </div>
  57. @endsection
  58. @section('javascript')
  59. <script src="/assets/global/vendor/multi-select/jquery.multi-select.min.js"></script>
  60. <script src="/assets/global/js/Plugin/multi-select.js"></script>
  61. <script src="/assets/custom/jquery.quicksearch.min.js"></script>
  62. <script>
  63. @isset($group)
  64. $(document).ready(function() {
  65. $('#name').val('{{ $group->name }}');
  66. $('#nodes').multiSelect('select', @json(array_map('strval', $group->nodes->pluck('id')->toArray())));
  67. });
  68. @endisset
  69. // 权限列表
  70. $('#nodes').multiSelect({
  71. selectableHeader: '<input type=\'text\' class=\'search-input form-control\' autocomplete=\'off\' placeholder=\'{{ trans('admin.unselected_hint') }}\'>',
  72. selectionHeader: '<input type=\'text\' class=\'search-input form-control\' autocomplete=\'off\' placeholder=\'{{ trans('admin.selected_hint') }}\'>',
  73. afterInit: function() {
  74. const that = this,
  75. $selectableSearch = that.$selectableUl.prev(),
  76. $selectionSearch = that.$selectionUl.prev(),
  77. selectableSearchString = '#' + that.$container.attr('id') + ' .ms-elem-selectable:not(.ms-selected)',
  78. selectionSearchString = '#' + that.$container.attr('id') + ' .ms-elem-selection.ms-selected';
  79. that.qs1 = $selectableSearch.quicksearch(selectableSearchString).on('keydown', function(e) {
  80. if (e.which === 40) {
  81. that.$selectableUl.focus();
  82. return false;
  83. }
  84. });
  85. that.qs2 = $selectionSearch.quicksearch(selectionSearchString).on('keydown', function(e) {
  86. if (e.which === 40) {
  87. that.$selectionUl.focus();
  88. return false;
  89. }
  90. });
  91. },
  92. afterSelect: function() {
  93. this.qs1.cache();
  94. this.qs2.cache();
  95. },
  96. afterDeselect: function() {
  97. this.qs1.cache();
  98. this.qs2.cache();
  99. },
  100. });
  101. // 全选
  102. $('#select-all').click(function() {
  103. $('#nodes').multiSelect('select_all');
  104. return false;
  105. });
  106. // 反选
  107. $('#deselect-all').click(function() {
  108. $('#nodes').multiSelect('deselect_all');
  109. return false;
  110. });
  111. </script>
  112. @endsection