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"></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. <th>操作</th>
  58. </tr>
  59. <tr v-for="waybillPriceModel in waybillPriceModels">
  60. <td class="text-muted">@{{waybillPriceModel.id}}</td>
  61. <td>@{{waybillPriceModel.carrier}}</td>
  62. <td>@{{waybillPriceModel.province}}</td>
  63. <td>@{{waybillPriceModel.city}}</td>
  64. <td>@{{waybillPriceModel.unit}}</td>
  65. <td>@{{waybillPriceModel.range_min}}<a v-if="waybillPriceModel.range_min&&waybillPriceModel.range_max">&nbsp;&nbsp;--&nbsp;&nbsp;</a> @{{waybillPriceModel.range_max}}</td>
  66. <td>@{{waybillPriceModel.unit_price}}</td>
  67. <td>@{{waybillPriceModel.base_fee}}</td>
  68. <td>@{{waybillPriceModel.initial_weight}}</td>
  69. <td class="text-muted">@{{waybillPriceModel.created_at}}</td>
  70. <td>
  71. @can('计费模型-编辑')
  72. <button class="btn btn-sm btn-outline-primary" @click="edit(waybillPriceModel.id)">改</button> @endcan
  73. @can('计费模型-删除')
  74. <button class="btn btn-sm btn-outline-dark" @click="destroy(waybillPriceModel)">删</button> @endcan
  75. </td>
  76. </tr>
  77. </table>
  78. {{$waybillPriceModels->appends($filterData)->links()}}
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. @endsection
  84. @section('lastScript')
  85. <script>
  86. new Vue({
  87. el:"#list",
  88. data:{
  89. waybillPriceModels:[
  90. @foreach( $waybillPriceModels as $waybillPriceModel )
  91. {id:'{{$waybillPriceModel->id}}',carrier:'{{$waybillPriceModel->carrier_name}}',
  92. province:'{{$waybillPriceModel->province_name}}',city:'{{$waybillPriceModel->city_name}}',
  93. unit:'{{$waybillPriceModel->unit_name}}',range_min:'{{$waybillPriceModel->range_min}}',range_max:'{{$waybillPriceModel->range_max}}',
  94. unit_price:'{{$waybillPriceModel->unit_price}}',base_fee:'{{$waybillPriceModel->base_fee}}',initial_weight:'{{$waybillPriceModel->initial_weight}}',
  95. created_at:'{{$waybillPriceModel->created_at}}'},
  96. @endforeach
  97. ],
  98. filterData:
  99. {paginate:'50',carrier_id:'',province_id: ''},
  100. },
  101. mounted:function(){
  102. this.initInputs();
  103. },
  104. methods:{
  105. edit:function(id){
  106. location.href = "{{url('maintenance/waybillPriceModel')}}/"+id+"/edit";
  107. },
  108. destroy:function(waybillPriceModel){
  109. if(!confirm('确定要删除该计费模型吗?')){return};
  110. let data=this;
  111. let url = "{{url('maintenance/waybillPriceModel')}}/"+waybillPriceModel.id;
  112. axios.delete(url,{id:waybillPriceModel.id})
  113. .then(function (response) {
  114. if(response.data.success){
  115. for (let i = 0; i < data.waybillPriceModels.length; i++) {
  116. if (data.waybillPriceModels[i].id===waybillPriceModel.id){
  117. data.waybillPriceModels.splice(i,1);
  118. break;
  119. }
  120. }
  121. tempTip.setDuration(1000);
  122. tempTip.showSuccess('删除计费模型成功!')
  123. }else{
  124. tempTip.setDuration(1000);
  125. tempTip.show('删除计费模型失败!')
  126. }
  127. })
  128. .catch(function (err) {
  129. tempTip.setDuration(3000);
  130. tempTip.show('删除计费模型失败!'+'网络错误:' + 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