couponList.blade.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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="{{url('/coupon/add')}}" 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="" 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="{{url('/coupon')}}" 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->usage_count}} </td>
  73. <td>
  74. @if($coupon->type == 2)
  75. {{$coupon->discount}}折
  76. @else
  77. {{$coupon->amount}}元
  78. @endif
  79. </td>
  80. <td> {{date('Y-m-d', $coupon->available_start)}} ~ {{date('Y-m-d', $coupon->available_end)}} </td>
  81. <td>
  82. @if($coupon->status == '1')
  83. <span class="badge badge-lg badge-default"> 已使用 </span>
  84. @elseif ($coupon->status == '2')
  85. <span class="badge badge-lg badge-default"> 已失效 </span>
  86. @else
  87. <span class="badge badge-lg badge-success"> 生效中 </span>
  88. @endif
  89. </td>
  90. <td>
  91. @if($coupon->status != '1')
  92. <button class="btn btn-danger" onclick="delCoupon('{{$coupon->id}}','{{$coupon->name}}')">
  93. <i class="icon wb-close"></i>
  94. </button>
  95. @endif
  96. </td>
  97. </tr>
  98. @endforeach
  99. </tbody>
  100. </table>
  101. </div>
  102. <div class="panel-footer">
  103. <div class="row">
  104. <div class="col-sm-4">
  105. 共 <code>{{$couponList->total()}}</code> 张优惠券
  106. </div>
  107. <div class="col-sm-8">
  108. <nav class="Page navigation float-right">
  109. {{$couponList->links()}}
  110. </nav>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. @endsection
  117. @section('script')
  118. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  119. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  120. <script type="text/javascript">
  121. $(document).ready(function () {
  122. $('#type').val({{Request::get('type')}});
  123. $('#status').val({{Request::get('status')}});
  124. });
  125. //回车检测
  126. $(document).on("keypress", "input", function (e) {
  127. if (e.which === 13) {
  128. Search();
  129. return false;
  130. }
  131. });
  132. // 搜索
  133. function Search() {
  134. window.location.href = '/coupon' + '?sn=' + $("#sn").val() + '&type=' + $("#type").val() + '&status=' + $("#status").val();
  135. }
  136. // 批量导出卡券
  137. function exportCoupon() {
  138. swal.fire({
  139. title: '卡券导出',
  140. text: '确定导出所有卡券吗?',
  141. type: 'question',
  142. showCancelButton: true,
  143. cancelButtonText: '{{trans('home.ticket_close')}}',
  144. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  145. }).then((result) => {
  146. if (result.value) {
  147. window.location.href = '/coupon/export';
  148. }
  149. });
  150. }
  151. // 删除卡券
  152. function delCoupon(id, name) {
  153. swal.fire({
  154. title: '确定删除卡券 【' + name + '】 吗?',
  155. type: 'question',
  156. allowEnterKey: false,
  157. showCancelButton: true,
  158. cancelButtonText: '{{trans('home.ticket_close')}}',
  159. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  160. }).then((result) => {
  161. if (result.value) {
  162. $.post("/coupon/delete", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  163. if (ret.status === 'success') {
  164. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  165. .then(() => window.location.reload())
  166. } else {
  167. swal.fire({title: ret.message, type: "error"})
  168. }
  169. });
  170. }
  171. })
  172. }
  173. </script>
  174. @endsection