couponList.blade.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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="/coupon/addCoupon" 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::get('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="" @if(Request::get('type') == '') selected hidden @endif>类型</option>
  23. <option value="1" @if(Request::get('type') == '1') selected hidden @endif>现金券</option>
  24. <option value="2" @if(Request::get('type') == '2') selected hidden @endif>折扣券</option>
  25. <option value="3" @if(Request::get('type') == '3') selected hidden @endif>充值券</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="" @if(Request::get('status') == '') selected hidden @endif>状态</option>
  31. <option value="0" @if(Request::get('status') == '0') selected hidden @endif>未使用/生效中</option>
  32. <option value="1" @if(Request::get('status') == '1') selected hidden @endif>已使用</option>
  33. <option value="2" @if(Request::get('status') == '2') selected hidden @endif>已失效</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="/coupon/couponList" 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. @if($couponList->isEmpty())
  58. <tr>
  59. <td colspan="10">暂无数据</td>
  60. </tr>
  61. @else
  62. @foreach($couponList as $coupon)
  63. <tr>
  64. <td> {{$coupon->id}} </td>
  65. <td> {{$coupon->name}} </td>
  66. <td> {{$coupon->sn}} </td>
  67. <td> @if($coupon->logo) <img src="{{$coupon->logo}}" alt="优惠码logo"/> @endif </td>
  68. <td>
  69. @if($coupon->type == '1')
  70. 抵用券
  71. @elseif($coupon->type == '2')
  72. 折扣券
  73. @else
  74. 充值券
  75. @endif
  76. </td>
  77. <td> {{$coupon->usage == '1' ? '一次性' : '重复使用'}} </td>
  78. <td>
  79. @if($coupon->type == 2)
  80. {{$coupon->discount}}折
  81. @else
  82. {{$coupon->amount}}元
  83. @endif
  84. </td>
  85. <td> {{date('Y-m-d', $coupon->available_start)}} ~ {{date('Y-m-d', $coupon->available_end)}} </td>
  86. <td>
  87. @if($coupon->usage == 1)
  88. @if($coupon->status == '1')
  89. <span class="badge badge-lg badge-default"> 已使用 </span>
  90. @elseif ($coupon->status == '2')
  91. <span class="badge badge-lg badge-default"> 已失效 </span>
  92. @else
  93. <span class="badge badge-lg badge-success"> 未使用 </span>
  94. @endif
  95. @elseif ($coupon->usage == 2)
  96. @if ($coupon->status == '2')
  97. <span class="badge badge-lg badge-default"> 已失效 </span>
  98. @else
  99. <span class="badge badge-lg badge-success"> 生效中 </span>
  100. @endif
  101. @endif
  102. </td>
  103. <td>
  104. @if($coupon->status != '1')
  105. <button class="btn btn-danger" onclick="delCoupon('{{$coupon->id}}','{{$coupon->name}}')"><i class="icon wb-close"></i></button>
  106. @endif
  107. </td>
  108. </tr>
  109. @endforeach
  110. @endif
  111. </tbody>
  112. </table>
  113. </div>
  114. <div class="panel-footer">
  115. <div class="row">
  116. <div class="col-sm-4">
  117. 共 <code>{{$couponList->total()}}</code> 张优惠券
  118. </div>
  119. <div class="col-sm-8">
  120. <nav class="Page navigation float-right">
  121. {{$couponList->links()}}
  122. </nav>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. @endsection
  129. @section('script')
  130. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  131. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  132. <script type="text/javascript">
  133. //回车检测
  134. $(document).on("keypress", "input", function (e) {
  135. if (e.which === 13) {
  136. Search();
  137. return false;
  138. }
  139. });
  140. // 搜索
  141. function Search() {
  142. window.location.href = '/coupon/couponList' + '?sn=' + $("#sn").val() + '&type=' + $("#type").val() + '&status=' + $("#status").val();
  143. }
  144. // 批量导出卡券
  145. function exportCoupon() {
  146. swal.fire({
  147. title: '卡券导出',
  148. text: '确定导出所有卡券吗?',
  149. type: 'question',
  150. showCancelButton: true,
  151. cancelButtonText: '{{trans('home.ticket_close')}}',
  152. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  153. }).then((result) => {
  154. if (result.value) {
  155. window.location.href = '/coupon/exportCoupon';
  156. }
  157. });
  158. }
  159. // 删除卡券
  160. function delCoupon(id, name) {
  161. swal.fire({
  162. title: '确定删除卡券 【' + name + '】 吗?',
  163. type: 'question',
  164. allowEnterKey: false,
  165. showCancelButton: true,
  166. cancelButtonText: '{{trans('home.ticket_close')}}',
  167. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  168. }).then((result) => {
  169. if (result.value) {
  170. $.post("/coupon/delCoupon", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  171. if (ret.status === 'success') {
  172. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  173. .then(() => window.location.reload())
  174. } else {
  175. swal.fire({title: ret.message, type: "error"})
  176. }
  177. });
  178. }
  179. })
  180. }
  181. </script>
  182. @endsection