couponList.blade.php 6.5 KB

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