couponList.blade.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" rel="stylesheet" type="text/css">
  4. @endsection
  5. @section('content')
  6. <div class="page-content container-fluid">
  7. <div class="panel">
  8. <div class="panel-heading">
  9. <h3 class="panel-title">卡券列表</h3>
  10. <div class="panel-actions btn-group">
  11. <button class="btn btn-info" onclick="exportCoupon()"><i class="icon wb-code"></i>批量导出</button>
  12. <button class="btn btn-primary" onclick="addCoupon()"><i class="icon wb-plus"></i>生成</button>
  13. </div>
  14. </div>
  15. <div class="panel-body">
  16. <div class="form-inline mb-20">
  17. <div class="form-group">
  18. <select class="form-control" name="type" id="type" onChange="do_search()">
  19. <option value="" @if(Request::get('type') == '') selected @endif>类型</option>
  20. <option value="1" @if(Request::get('type') == '1') selected @endif>现金券</option>
  21. <option value="2" @if(Request::get('type') == '2') selected @endif>折扣券</option>
  22. <option value="3" @if(Request::get('type') == '3') selected @endif>充值券</option>
  23. </select>
  24. <input type="text" class="form-control" name="sn" value="{{Request::get('sn')}}" id="sn" placeholder="券码" autocomplete="off" onkeydown="if(event.keyCode==13){do_search();}">
  25. </div>
  26. <div class="btn-group">
  27. <button class="btn btn-primary" onclick="doSearch()">搜索</button>
  28. <button class="btn btn-danger" onclick="doReset()">重置</button>
  29. </div>
  30. </div>
  31. <table class="text-center" data-toggle="table" data-mobile-responsive="true">
  32. <thead class="thead-default">
  33. <tr>
  34. <th> #</th>
  35. <th> 名称</th>
  36. <th> 券码</th>
  37. <th> LOGO</th>
  38. <th> 类型</th>
  39. <th> 用途</th>
  40. <th> 优惠</th>
  41. <th> 有效期</th>
  42. <th> 状态</th>
  43. <th> 操作</th>
  44. </tr>
  45. </thead>
  46. <tbody>
  47. @if($couponList->isEmpty())
  48. <tr>
  49. <td colspan="10">暂无数据</td>
  50. </tr>
  51. @else
  52. @foreach($couponList as $coupon)
  53. <tr>
  54. <td> {{$coupon->id}} </td>
  55. <td> {{$coupon->name}} </td>
  56. <td> {{$coupon->sn}} </td>
  57. <td> @if($coupon->logo)<<img src="{{$coupon->logo}}" alt="优惠码logo"/> @endif </td>
  58. <td>
  59. @if($coupon->type == '1')
  60. 抵用券
  61. @elseif($coupon->type == '2')
  62. 折扣券
  63. @else
  64. 充值券
  65. @endif
  66. </td>
  67. <td> {{$coupon->usage == '1' ? '一次性' : '可重复'}} </td>
  68. <td>
  69. @if($coupon->type == '1' || $coupon->type == '3')
  70. {{$coupon->amount}}元
  71. @else
  72. {{$coupon->discount}}折
  73. @endif
  74. </td>
  75. <td> {{date('Y-m-d', $coupon->available_start)}} ~ {{date('Y-m-d', $coupon->available_end)}} </td>
  76. <td>
  77. @if ($coupon->usage == 1)
  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. @endif
  86. </td>
  87. <td>
  88. @if($coupon->status != '1')
  89. <button class="btn btn-danger" onclick="delCoupon('{{$coupon->id}}')"><i class="icon wb-close"></i></button>
  90. @endif
  91. </td>
  92. </tr>
  93. @endforeach
  94. @endif
  95. </tbody>
  96. </table>
  97. </div>
  98. <div class="panel-footer">
  99. <div class="row">
  100. <div class="col-md-4 col-sm-4">
  101. 共 {{$couponList->total()}} 张优惠券
  102. </div>
  103. <div class="col-md-8 col-sm-8">
  104. <div class="Page navigation float-right">
  105. {{ $couponList->links() }}
  106. </div>
  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. // 批量导出卡券
  118. function exportCoupon() {
  119. swal.fire({
  120. title: '卡券导出',
  121. text: '确定导出所有卡券吗?',
  122. type: 'question',
  123. showCancelButton: true,
  124. cancelButtonText: '{{trans('home.ticket_close')}}',
  125. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  126. }).then((result) => {
  127. if (result.value) {
  128. window.location.href = '/coupon/exportCoupon';
  129. }
  130. });
  131. }
  132. // 添加卡券
  133. function addCoupon() {
  134. window.location.href = '/coupon/addCoupon';
  135. }
  136. // 删除卡券
  137. function delCoupon(id) {
  138. swal.fire({
  139. title: '确定删除该卡券吗?',
  140. type: 'question',
  141. allowEnterKey: false,
  142. showCancelButton: true,
  143. cancelButtonText: '{{trans('home.ticket_close')}}',
  144. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  145. }).then((result) => {
  146. if (result.value) {
  147. $.post("/coupon/delCoupon", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  148. if (ret.status === 'success') {
  149. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  150. .then(() => window.location.reload())
  151. } else {
  152. swal.fire({title: ret.message, type: "error"})
  153. }
  154. });
  155. }
  156. })
  157. }
  158. </script>
  159. @endsection