couponList.blade.php 8.3 KB

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