index.blade.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. @extends('layouts.app')
  2. @section('content')
  3. <span id="nav2">
  4. @component('waybill.menu')@endcomponent
  5. @component('waybill.waybillPriceModel.menu')@endcomponent
  6. </span>
  7. <div id="list">
  8. <div class="container-fluid">
  9. <div class="card">
  10. <div>
  11. <form method="GET" action="{{url('waybill/waybillPriceModel')}}" id="optionSubmit">
  12. <table class="table table-sm table-bordered table-hover text-nowrap ">
  13. <tr>
  14. <td > <label style="margin-left: 2%" class="form-inline">页显示条数:
  15. <select name="paginate" v-model="filterData.paginate" class="form-control" @change="setPaginate">
  16. <option value="50">50行</option>
  17. <option value="100">100行</option>
  18. <option value="200">200行</option>
  19. <option value="500">500行</option>
  20. <option value="1000">1000行</option>
  21. </select></label></td>
  22. <td > <label class="form-inline" style="margin-left: 2%">承运商:
  23. <select name="logistic_id" v-model="filterData.logistic_id" class="form-control" @change="setCarrier">
  24. <option > </option>
  25. @foreach($logistics as $logistic)
  26. <option value="{{$logistic->id}}">{{$logistic->name}}</option>
  27. @endforeach
  28. </select></label></td>
  29. <td><label class="form-inline" style="margin-left: 2%">省份:
  30. <select name="province_id" v-model="filterData.province_id" class="form-control" @change="setProvince">
  31. <option> </option>
  32. @foreach($provinces as $province)
  33. <option value="{{$province->id}}">{{$province->name}}</option>
  34. @endforeach
  35. </select><input hidden type="submit" ></label></td>
  36. </tr>
  37. </table>
  38. </form>
  39. </div>
  40. <div class="card-body">
  41. @if(Session::has('successTip'))
  42. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  43. @endif
  44. <table class="table table-striped table-sm">
  45. <tr>
  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. <th>录入时间</th>
  56. </tr>
  57. <tr v-for="waybillPriceModel in waybillPriceModels">
  58. <td class="text-muted">@{{waybillPriceModel.id}}</td>
  59. <td>@{{waybillPriceModel.carrier}}</td>
  60. <td>@{{waybillPriceModel.province}}</td>
  61. <td>@{{waybillPriceModel.city}}</td>
  62. <td>@{{waybillPriceModel.unit}}</td>
  63. <td>@{{waybillPriceModel.range_min}}<a v-if="waybillPriceModel.range_min&&waybillPriceModel.range_max">&nbsp;&nbsp;--&nbsp;&nbsp;</a> @{{waybillPriceModel.range_max}}</td>
  64. <td>@{{waybillPriceModel.unit_price}}</td>
  65. <td>@{{waybillPriceModel.base_fee}}</td>
  66. <td>@{{waybillPriceModel.initial_weight}}</td>
  67. <td class="text-muted">@{{waybillPriceModel.created_at}}</td>
  68. <td>
  69. @can('计费模型-编辑')
  70. <button class="btn btn-sm btn-outline-primary" @click="edit(waybillPriceModel.id)">改</button> @endcan
  71. @can('计费模型-删除')
  72. <button class="btn btn-sm btn-outline-dark" @click="destroy(waybillPriceModel)">删</button> @endcan
  73. </td>
  74. </tr>
  75. </table>
  76. {{$waybillPriceModels->appends($filterData)->links()}}
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. @endsection
  82. @section('lastScript')
  83. <script>
  84. new Vue({
  85. el:"#list",
  86. data:{
  87. waybillPriceModels:[
  88. @foreach( $waybillPriceModels as $waybillPriceModel )
  89. {id:'{{$waybillPriceModel->id}}',carrier:'{{$waybillPriceModel->carrier_name}}',
  90. province:'{{$waybillPriceModel->province_name}}',city:'{{$waybillPriceModel->city_name}}',
  91. unit:'{{$waybillPriceModel->unit_name}}',range_min:'{{$waybillPriceModel->range_min}}',range_max:'{{$waybillPriceModel->range_max}}',
  92. unit_price:'{{$waybillPriceModel->unit_price}}',base_fee:'{{$waybillPriceModel->base_fee}}',initial_weight:'{{$waybillPriceModel->initial_weight}}',
  93. created_at:'{{$waybillPriceModel->created_at}}'},
  94. @endforeach
  95. ],
  96. filterData:
  97. {paginate:'50',logistic_id:'',province_id: ''},
  98. },
  99. mounted:function(){
  100. this.initInputs();
  101. },
  102. methods:{
  103. edit:function(id){
  104. location.href = "{{url('waybill/waybillPriceModel')}}/"+id+"/edit";
  105. },
  106. destroy:function(waybillPriceModel){
  107. if(!confirm('确定要删除该计费模型吗?')){return};
  108. let data=this;
  109. let url = "{{url('waybill/waybillPriceModel')}}/"+waybillPriceModel.id;
  110. axios.delete(url,{id:waybillPriceModel.id})
  111. .then(function (response) {
  112. if(response.data.success){
  113. for (let i = 0; i < data.waybillPriceModels.length; i++) {
  114. if (data.waybillPriceModels[i].id===waybillPriceModel.id){
  115. data.waybillPriceModels.splice(i,1);
  116. break;
  117. }
  118. }
  119. tempTip.setDuration(1000);
  120. tempTip.showSuccess('删除计费模型成功!')
  121. }else{
  122. tempTip.setDuration(1000);
  123. tempTip.show('删除计费模型失败!')
  124. }
  125. })
  126. .catch(function (err) {
  127. tempTip.setDuration(3000);
  128. tempTip.show('删除计费模型失败!'+'网络错误:' + err);
  129. });
  130. },
  131. initInputs:function(){
  132. let data=this;
  133. let uriParts =decodeURI(location.href).split("?");
  134. if(uriParts.length>1){
  135. let params = uriParts[1].split('&');
  136. params.forEach(function(paramPair){
  137. let pair=paramPair.split('=');
  138. let key = pair[0], val = pair[1];
  139. $('input[name="'+key+'"]').val(val);
  140. $('select[name="'+key+'"]').val(val);
  141. decodeURI(data.filterData[key]=val);
  142. });
  143. }
  144. },
  145. setPaginate:function(e){
  146. this.filterData.paginate=e.target.value;
  147. var form = document.getElementById("optionSubmit");
  148. form.submit();
  149. },
  150. setCarrier:function (e){
  151. this.filterData.logistic_id=e.target.value;
  152. var form = document.getElementById("optionSubmit");
  153. form.submit();
  154. },
  155. setProvince:function (e){
  156. this.filterData.province_id=e.target.value;
  157. var form = document.getElementById("optionSubmit");
  158. form.submit();
  159. },
  160. }
  161. });
  162. </script>
  163. @endsection