index.blade.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. @extends('admin.table_layouts')
  2. @section('content')
  3. <div class="page-content container-fluid">
  4. <div class="panel">
  5. <div class="panel-heading">
  6. <h1 class="panel-title">{{ trans('admin.menu.shop.coupon') }}</h1>
  7. @canany(['admin.coupon.export', 'admin.coupon.create'])
  8. <div class="panel-actions btn-group">
  9. @can('admin.coupon.export')
  10. <button class="btn btn-info" onclick="exportCoupon()"><i class="icon wb-code"></i>{{ trans('admin.massive_export') }}</button>
  11. @endcan
  12. @can('admin.coupon.create')
  13. <a class="btn btn-primary" href="{{ route('admin.coupon.create') }}"><i class="icon wb-plus"></i> {{ trans('common.add') }}</a>
  14. @endcan
  15. </div>
  16. @endcanany
  17. </div>
  18. <div class="panel-body">
  19. <form class="form-row">
  20. <div class="form-group col-lg-3 col-sm-4">
  21. <input class="form-control" name="sn" type="text" value="{{ Request::query('sn') }}" placeholder="{{ trans('model.coupon.sn') }}"
  22. autocomplete="off" />
  23. </div>
  24. <div class="form-group col-lg-3 col-sm-4">
  25. <select class="form-control" id="type" name="type" data-plugin="selectpicker" data-style="btn-outline btn-primary"
  26. title="{{ trans('model.common.type') }}">
  27. <option value="1">{{ trans('admin.coupon.type.voucher') }}</option>
  28. <option value="2">{{ trans('admin.coupon.type.discount') }}</option>
  29. <option value="3">{{ trans('admin.coupon.type.charge') }}</option>
  30. </select>
  31. </div>
  32. <div class="form-group col-lg-3 col-sm-4">
  33. <select class="form-control" id="status" name="status" data-plugin="selectpicker" data-style="btn-outline btn-primary"
  34. title="{{ trans('common.status.attribute') }}">
  35. <option value="0">{{ trans('common.status.available') }}</option>
  36. <option value="1">{{ trans('common.status.used') }}</option>
  37. <option value="2">{{ trans('common.status.expire') }}</option>
  38. </select>
  39. </div>
  40. <div class="form-group col-lg-3 col-sm-4 btn-group">
  41. <button class="btn btn-primary" type="submit">{{ trans('common.search') }}</button>
  42. <button class="btn btn-danger" type="button" onclick="resetSearchForm()">{{ trans('common.reset') }}</button>
  43. </div>
  44. </form>
  45. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  46. <thead class="thead-default">
  47. <tr>
  48. <th> #</th>
  49. <th> {{ trans('model.coupon.name') }}</th>
  50. <th> {{ trans('model.coupon.sn') }}</th>
  51. <th> {{ trans('model.coupon.logo') }}</th>
  52. <th> {{ trans('model.common.type') }}</th>
  53. <th> {{ trans('model.coupon.priority') }}</th>
  54. <th> {{ trans('model.coupon.usable_times') }}</th>
  55. <th> {{ trans('admin.coupon.discount') }}</th>
  56. <th> {{ trans('common.available_date') }}</th>
  57. <th> {{ trans('common.status.attribute') }}</th>
  58. <th> {{ trans('common.action') }}</th>
  59. </tr>
  60. </thead>
  61. <tbody>
  62. @foreach ($couponList as $coupon)
  63. <tr>
  64. <td> {{ $coupon->id }} </td>
  65. <td> {{ $coupon->name }} </td>
  66. <td> {{ $coupon->sn }} </td>
  67. <td>
  68. @if ($coupon->logo)
  69. <img class="h-50" src="{{ asset($coupon->logo) }}" alt="{{ trans('model.coupon.logo') }}" />
  70. @endif
  71. </td>
  72. <td>
  73. {{ [trans('common.status.unknown'), trans('admin.coupon.type.voucher'), trans('admin.coupon.type.discount'), trans('admin.coupon.type.charge')][$coupon->type] }}
  74. </td>
  75. <td> {{ $coupon->priority }} </td>
  76. <td> {{ $coupon->type === 3 ? trans('admin.coupon.single_use') : $coupon->usable_times ?? trans('common.unlimited') }} </td>
  77. <td>
  78. {{ trans_choice('admin.coupon.value', $coupon->type, ['num' => $coupon->type === 2 ? $coupon->value : \App\Utils\Helpers::getPriceTag($coupon->value)]) }}
  79. </td>
  80. <td> {{ $coupon->start_time }} ~ {{ $coupon->end_time }} </td>
  81. <td>
  82. <span class="badge badge-lg @if ($coupon->status) badge-default @else badge-success @endif">
  83. {{ [trans('common.status.available'), trans('common.status.used'), trans('common.status.expire')][$coupon->status] }}
  84. </span>
  85. </td>
  86. <td>
  87. <div class="btn-group">
  88. @can('admin.coupon.show')
  89. <a class="btn btn-info" href="{{ route('admin.coupon.show', $coupon) }}" target="_blank">
  90. <i class="icon wb-eye"></i>
  91. </a>
  92. @endcan
  93. @if ($coupon->status !== 1)
  94. @can('admin.coupon.destroy')
  95. <button class="btn btn-danger" onclick="delCoupon('{{ $coupon->id }}','{{ $coupon->name }}')">
  96. <i class="icon wb-close"></i>
  97. </button>
  98. @endcan
  99. @endif
  100. </div>
  101. </td>
  102. </tr>
  103. @endforeach
  104. </tbody>
  105. </table>
  106. </div>
  107. <div class="panel-footer">
  108. <div class="row">
  109. <div class="col-sm-4">
  110. {!! trans('admin.coupon.counts', ['num' => $couponList->total()]) !!}
  111. </div>
  112. <div class="col-sm-8">
  113. <nav class="Page navigation float-right">
  114. {{ $couponList->links() }}
  115. </nav>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. @endsection
  122. @push('javascript')
  123. <script>
  124. $(document).ready(function() {
  125. $("#type").selectpicker("val", @json(Request::query('type')));
  126. $("#status").selectpicker("val", @json(Request::query('status')));
  127. });
  128. @can('admin.coupon.export')
  129. // 批量导出卡券
  130. function exportCoupon() {
  131. swal.fire({
  132. title: '{{ trans('admin.coupon.export_title') }}',
  133. text: '{{ trans('admin.confirm.export') }}?',
  134. icon: "question",
  135. showCancelButton: true,
  136. cancelButtonText: '{{ trans('common.close') }}',
  137. confirmButtonText: '{{ trans('common.confirm') }}'
  138. }).then((result) => {
  139. if (result.value) {
  140. window.location.href = '{{ route('admin.coupon.export') }}';
  141. }
  142. });
  143. }
  144. @endcan
  145. @can('admin.coupon.destroy')
  146. // 删除卡券
  147. function delCoupon(id, name) {
  148. swal.fire({
  149. title: '{{ trans('admin.confirm.delete.0', ['attribute' => trans('model.coupon.attribute')]) }}' + name +
  150. '{{ trans('admin.confirm.delete.1') }}',
  151. icon: "question",
  152. allowEnterKey: false,
  153. showCancelButton: true,
  154. cancelButtonText: '{{ trans('common.close') }}',
  155. confirmButtonText: '{{ trans('common.confirm') }}'
  156. }).then((result) => {
  157. if (result.value) {
  158. $.ajax({
  159. method: "DELETE",
  160. url: '{{ route('admin.coupon.destroy', '') }}/' + id,
  161. data: {
  162. _token: '{{ csrf_token() }}'
  163. },
  164. dataType: "json",
  165. success: function(ret) {
  166. if (ret.status === "success") {
  167. swal.fire({
  168. title: ret.message,
  169. icon: "success",
  170. timer: 1000,
  171. showConfirmButton: false
  172. }).then(() => window.location.reload());
  173. } else {
  174. swal.fire({
  175. title: ret.message,
  176. icon: "error"
  177. }).then(() => window.location.reload());
  178. }
  179. }
  180. });
  181. }
  182. });
  183. }
  184. @endcan
  185. </script>
  186. @endpush