index.blade.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" type="text/css" rel="stylesheet">
  4. @endsection
  5. @section('content')
  6. <div class="page-content container-fluid">
  7. <div class="panel">
  8. <div class="panel-heading">
  9. <h1 class="panel-title">卡券列表</h1>
  10. <div class="panel-actions btn-group">
  11. <button class="btn btn-info" onclick="exportCoupon()"><i class="icon wb-code"></i>批量导出</button>
  12. <a href="{{route('admin.coupon.create')}}" class="btn btn-primary"><i class="icon wb-plus"></i>生成</a>
  13. </div>
  14. </div>
  15. <div class="panel-body">
  16. <div class="form-row">
  17. <div class="form-group col-lg-3 col-sm-4">
  18. <input type="text" class="form-control" name="sn" id="sn" value="{{Request::input('sn')}}" placeholder="券码" autocomplete="off"/>
  19. </div>
  20. <div class="form-group col-lg-3 col-sm-4">
  21. <select class="form-control" name="type" id="type" onChange="Search()">
  22. <option value="" hidden>类型</option>
  23. <option value="1">现金券</option>
  24. <option value="2">折扣券</option>
  25. <option value="3">充值券</option>
  26. </select>
  27. </div>
  28. <div class="form-group col-lg-3 col-sm-4">
  29. <select class="form-control" name="status" id="status" onChange="Search()">
  30. <option value="" hidden>状态</option>
  31. <option value="0">生效中</option>
  32. <option value="1">已使用</option>
  33. <option value="2">已失效</option>
  34. </select>
  35. </div>
  36. <div class="form-group col-lg-3 col-sm-4 btn-group">
  37. <button class="btn btn-primary" onclick="Search()">搜 索</button>
  38. <a href="{{route('admin.coupon.index')}}" class="btn btn-danger">重 置</a>
  39. </div>
  40. </div>
  41. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  42. <thead class="thead-default">
  43. <tr>
  44. <th> #</th>
  45. <th> 名称</th>
  46. <th> 券码</th>
  47. <th> 图片</th>
  48. <th> 类型</th>
  49. <th> 使用次数</th>
  50. <th> 优惠</th>
  51. <th> 有效期</th>
  52. <th> 状态</th>
  53. <th> 操作</th>
  54. </tr>
  55. </thead>
  56. <tbody>
  57. @foreach($couponList as $coupon)
  58. <tr>
  59. <td> {{$coupon->id}} </td>
  60. <td> {{$coupon->name}} </td>
  61. <td> {{$coupon->sn}} </td>
  62. <td> @if($coupon->logo) <img src="{{$coupon->logo}}" alt="优惠码logo"/> @endif </td>
  63. <td>
  64. @if($coupon->type === 1)
  65. 抵用券
  66. @elseif($coupon->type === 2)
  67. 折扣券
  68. @else
  69. 充值券
  70. @endif
  71. </td>
  72. <td> {{$coupon->type === 3 ? '一次性' : ($coupon->usable_times ?? '无限制')}} </td>
  73. <td>
  74. {{$coupon->value}}@if($coupon->type === 2)%@else元@endif
  75. </td>
  76. <td> {{date('Y-m-d', $coupon->start_time)}} ~ {{date('Y-m-d', $coupon->end_time)}} </td>
  77. <td>
  78. @if($coupon->status === 1)
  79. <span class="badge badge-lg badge-default"> 已使用 </span>
  80. @elseif ($coupon->status === 2)
  81. <span class="badge badge-lg badge-default"> 已失效 </span>
  82. @else
  83. <span class="badge badge-lg badge-success"> 生效中 </span>
  84. @endif
  85. </td>
  86. <td>
  87. @if($coupon->status !== 1)
  88. <button class="btn btn-danger" onclick="delCoupon('{{$coupon->id}}','{{$coupon->name}}')">
  89. <i class="icon wb-close"></i>
  90. </button>
  91. @endif
  92. </td>
  93. </tr>
  94. @endforeach
  95. </tbody>
  96. </table>
  97. </div>
  98. <div class="panel-footer">
  99. <div class="row">
  100. <div class="col-sm-4">
  101. 共 <code>{{$couponList->total()}}</code> 张优惠券
  102. </div>
  103. <div class="col-sm-8">
  104. <nav class="Page navigation float-right">
  105. {{$couponList->links()}}
  106. </nav>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. @endsection
  113. @section('script')
  114. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  115. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  116. <script type="text/javascript">
  117. $(document).ready(function() {
  118. $('#sn').val({{Request::input('sn')}});
  119. $('#type').val({{Request::input('type')}});
  120. $('#status').val({{Request::input('status')}});
  121. });
  122. //回车检测
  123. $(document).on('keypress', 'input', function(e) {
  124. if (e.which === 13) {
  125. Search();
  126. return false;
  127. }
  128. });
  129. // 搜索
  130. function Search() {
  131. window.location.href = '{{route('admin.coupon.index')}}?sn=' + $('#sn').val() + '&type=' + $('#type').val() + '&status=' +
  132. $('#status').val();
  133. }
  134. // 批量导出卡券
  135. function exportCoupon() {
  136. swal.fire({
  137. title: '卡券导出',
  138. text: '确定导出所有卡券吗?',
  139. type: 'question',
  140. showCancelButton: true,
  141. cancelButtonText: '{{trans('home.ticket_close')}}',
  142. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  143. }).then((result) => {
  144. if (result.value) {
  145. window.location.href = '{{route('admin.coupon.export')}}';
  146. }
  147. });
  148. }
  149. // 删除卡券
  150. function delCoupon(id, name) {
  151. swal.fire({
  152. title: '确定删除卡券 【' + name + '】 吗?',
  153. type: 'question',
  154. allowEnterKey: false,
  155. showCancelButton: true,
  156. cancelButtonText: '{{trans('home.ticket_close')}}',
  157. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  158. }).then((result) => {
  159. if (result.value) {
  160. $.ajax({
  161. method: 'DELETE',
  162. url: '{{route('admin.coupon.destroy', '')}}/' + id,
  163. data: {_token: '{{csrf_token()}}'},
  164. dataType: 'json',
  165. success: function(ret) {
  166. if (ret.status === 'success') {
  167. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  168. }
  169. else {
  170. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  171. }
  172. },
  173. });
  174. }
  175. });
  176. }
  177. </script>
  178. @endsection