info.blade.php 4.7 KB

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