index.blade.php 8.7 KB

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