info.blade.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/multi-select/multi-select.min.css" rel="stylesheet">
  4. <style>
  5. .ms-container {
  6. width: auto;
  7. }
  8. </style>
  9. @endsection
  10. @section('content')
  11. <div class="page-content container">
  12. <x-ui.panel :title="trans(isset($role) ? 'admin.action.edit_item' : 'admin.action.add_item', ['attribute' => trans('model.role.attribute')])">
  13. <x-slot:actions>
  14. <a class="btn btn-danger" href="{{ route('admin.role.index') }}">{{ trans('common.back') }}</a>
  15. </x-slot:actions>
  16. <x-slot:alert>
  17. @if (Session::has('successMsg'))
  18. <x-alert :message="Session::pull('successMsg')" />
  19. @endif
  20. @if ($errors->any())
  21. <x-alert type="danger" :message="$errors->all()" />
  22. @endif
  23. </x-slot:alert>
  24. <x-admin.form.container :route="isset($role) ? route('admin.role.update', $role['id']) : route('admin.role.store')" :method="isset($role) ? 'PUT' : 'POST'">
  25. <x-admin.form.input name="name" :label="trans('model.role.name')" :help="trans('admin.role.name_hint')" required />
  26. <x-admin.form.input name="description" :label="trans('model.common.description')" :help="trans('admin.role.description_hint')" required />
  27. <x-admin.form.skeleton name="nodes" :label="trans('model.role.permissions')" input_grid="col-xl-9 col-sm-8">
  28. <div class="btn-group mb-20">
  29. <button class="btn btn-primary" id="select-all" type="button">{{ trans('admin.select_all') }}</button>
  30. <button class="btn btn-danger" id="deselect-all" type="button">{{ trans('admin.clear') }}</button>
  31. </div>
  32. <select class="form-control mx-auto w-p100" id="permissions" name="permissions[]" data-plugin="multiSelect" multiple>
  33. @foreach ($permissions as $key => $description)
  34. <option value="{{ $key }}">{{ $description . ' - ' . $key }}</option>
  35. @endforeach
  36. </select>
  37. </x-admin.form.skeleton>
  38. <div class="form-actions text-right">
  39. <button class="btn btn-success" type="submit">{{ trans('common.submit') }}</button>
  40. </div>
  41. </x-admin.form.container>
  42. </x-ui.panel>
  43. </div>
  44. @endsection
  45. @section('javascript')
  46. <script src="/assets/global/vendor/multi-select/jquery.multi-select.min.js"></script>
  47. <script src="/assets/global/js/Plugin/multi-select.js"></script>
  48. <script src="/assets/custom/jquery.quicksearch.min.js"></script>
  49. <script>
  50. let roleData = {};
  51. @isset($role)
  52. roleData = @json($role)
  53. @endisset
  54. @if (old())
  55. roleData = @json(old())
  56. @endif
  57. $(document).ready(function() {
  58. autoPopulateForm(roleData); // 填充表单数据
  59. });
  60. // 权限列表
  61. $('#permissions').multiSelect({
  62. selectableHeader: '<input type=\'text\' class=\'search-input form-control\' autocomplete=\'off\' placeholder=\'{{ trans('admin.unselected_hint') }}\'>',
  63. selectionHeader: '<input type=\'text\' class=\'search-input form-control\' autocomplete=\'off\' placeholder=\'{{ trans('admin.selected_hint') }}\'>',
  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).on('keydown', function(e) {
  71. if (e.which === 40) {
  72. that.$selectableUl.focus();
  73. return false;
  74. }
  75. });
  76. that.qs2 = $selectionSearch.quicksearch(selectionSearchString).on('keydown', function(e) {
  77. if (e.which === 40) {
  78. that.$selectionUl.focus();
  79. return false;
  80. }
  81. });
  82. },
  83. afterSelect: function() {
  84. this.qs1.cache();
  85. this.qs2.cache();
  86. },
  87. afterDeselect: function() {
  88. this.qs1.cache();
  89. this.qs2.cache();
  90. },
  91. });
  92. // 全选
  93. $('#select-all').click(function() {
  94. $('#permissions').multiSelect('select_all');
  95. return false;
  96. });
  97. // 反选
  98. $('#deselect-all').click(function() {
  99. $('#permissions').multiSelect('deselect_all');
  100. return false;
  101. });
  102. </script>
  103. @endsection