index.blade.php 8.9 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.priceModel.waybillPriceModel.menu')@endcomponent
  7. </span>
  8. <div id="list">
  9. <div class="container-fluid">
  10. <div class="card">
  11. <div>
  12. <form method="GET" action="{{url('maintenance/priceModel/waybillPriceModel')}}" 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="logistic_id" v-model="filterData.logistic_id" class="form-control" @change="setCarrier">
  25. <option > </option>
  26. @foreach($logistics as $logistic)
  27. <option value="{{$logistic->id}}">{{$logistic->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,i) in waybillPriceModels" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  60. <td class="text-muted">@{{waybillPriceModel.id}}</td>
  61. <td>@{{waybillPriceModel.logistic}}</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}}',logistic:'{{$waybillPriceModel->logistic ? $waybillPriceModel->logistic->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',logistic_id:'',province_id: ''},
  100. selectTr:0
  101. },
  102. mounted:function(){
  103. this.initInputs();
  104. },
  105. methods:{
  106. edit:function(id){
  107. location.href = "{{url('maintenance/priceModel/waybillPriceModel')}}/"+id+"/edit";
  108. },
  109. destroy:function(waybillPriceModel){
  110. if(!confirm('确定要删除该计费模型吗?')){return};
  111. let data=this;
  112. let url = "{{url('maintenance/priceModel/waybillPriceModel')}}/"+waybillPriceModel.id;
  113. axios.delete(url,{id:waybillPriceModel.id})
  114. .then(function (response) {
  115. if(response.data.success){
  116. for (let i = 0; i < data.waybillPriceModels.length; i++) {
  117. if (data.waybillPriceModels[i].id===waybillPriceModel.id){
  118. data.waybillPriceModels.splice(i,1);
  119. break;
  120. }
  121. }
  122. tempTip.setDuration(1000);
  123. tempTip.showSuccess('删除计费模型成功!')
  124. }else{
  125. tempTip.setDuration(1000);
  126. tempTip.show('删除计费模型失败!')
  127. }
  128. })
  129. .catch(function (err) {
  130. tempTip.setDuration(3000);
  131. tempTip.show('删除计费模型失败!'+'网络错误:' + err);
  132. });
  133. },
  134. initInputs:function(){
  135. let data=this;
  136. let uriParts =decodeURI(location.href).split("?");
  137. if(uriParts.length>1){
  138. let params = uriParts[1].split('&');
  139. params.forEach(function(paramPair){
  140. let pair=paramPair.split('=');
  141. let key = pair[0], val = pair[1];
  142. $('input[name="'+key+'"]').val(val);
  143. $('select[name="'+key+'"]').val(val);
  144. decodeURI(data.filterData[key]=val);
  145. });
  146. }
  147. },
  148. setPaginate:function(e){
  149. this.filterData.paginate=e.target.value;
  150. var form = document.getElementById("optionSubmit");
  151. form.submit();
  152. },
  153. setCarrier:function (e){
  154. this.filterData.logistic_id=e.target.value;
  155. var form = document.getElementById("optionSubmit");
  156. form.submit();
  157. },
  158. setProvince:function (e){
  159. this.filterData.province_id=e.target.value;
  160. var form = document.getElementById("optionSubmit");
  161. form.submit();
  162. },
  163. }
  164. });
  165. </script>
  166. @endsection