info.blade.php 4.9 KB

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