index.blade.php 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. @extends('layouts.app')
  2. @section('content')
  3. <span id="nav2">
  4. @component('waybill.menu')@endcomponent
  5. @component('waybill.billingModel.menu')@endcomponent
  6. </span>
  7. <div class="container-fluid mt-3">
  8. <div class="card">
  9. <div class="card-body">
  10. @if(Session::has('successTip'))
  11. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  12. @endif
  13. <table class="table table-striped table-sm" id="list">
  14. <tr>
  15. <th>代码</th>
  16. <th>承运商名称</th>
  17. <th>省份</th>
  18. <th>城市</th>
  19. <th>计重单位</th>
  20. <th>区间</th>
  21. <th>单价(元)</th>
  22. <th>始重</th>
  23. <th>录入时间</th>
  24. </tr>
  25. <tr v-for="billingModel in billingModels">
  26. <td class="text-muted">@{{billingModel.id}}</td>
  27. <td>@{{billingModel.carrier}}</td>
  28. <td>@{{billingModel.province}}</td>
  29. <td>@{{billingModel.city}}</td>
  30. <td>@{{billingModel.unit}}</td>
  31. <td>@{{billingModel.range_min}} -- @{{billingModel.range_max}}</td>
  32. <td>@{{billingModel.unit_price}}</td>
  33. <td>@{{billingModel.initial_weight}}</td>
  34. <td class="text-muted">@{{billingModel.created_at}}</td>
  35. <td>
  36. @can('计费模型-编辑')
  37. <button class="btn btn-sm btn-outline-primary" @click="edit(billingModel.id)">改</button> @endcan
  38. @can('计费模型-删除')
  39. <button class="btn btn-sm btn-outline-dark" @click="destroy(billingModel)">删</button> @endcan
  40. </td>
  41. </tr>
  42. </table>
  43. {{$billingModels->links()}}
  44. </div>
  45. </div>
  46. </div>
  47. @endsection
  48. @section('lastScript')
  49. <script>
  50. new Vue({
  51. el:"#list",
  52. data:{
  53. billingModels:[
  54. @foreach( $billingModels as $billingModel )
  55. {id:'{{$billingModel->id}}',carrier:'{{$billingModel->carrier->name}}',
  56. province:'{{$billingModel->province->name}}',city:'{{$billingModel->city->name}}',
  57. unit:'{{$billingModel->unit->name}}',range_min:'{{$billingModel->range_min}}',range_max:'{{$billingModel->range_max}}',
  58. unit_price:'{{$billingModel->unit_price}}',initial_weight:'{{$billingModel->initial_weight}}',
  59. created_at:'{{$billingModel->created_at}}'},
  60. @endforeach
  61. ],
  62. },
  63. methods:{
  64. edit:function(id){
  65. location.href = "{{url('billingModel')}}/"+id+"/edit";
  66. },
  67. destroy:function(billingModel){
  68. if(!confirm('确定要删除该计费模型吗?')){return};
  69. let data=this;
  70. let url = "{{url('billingModel')}}/"+billingModel.id;
  71. axios.delete(url,{id:billingModel.id})
  72. .then(function (response) {
  73. if(response.data.success){
  74. for (let i = 0; i < data.billingModels.length; i++) {
  75. if (data.billingModels[i].id===billingModel.id){
  76. data.billingModels.splice(i,1);
  77. break;
  78. }
  79. }
  80. tempTip.setDuration(1000);
  81. tempTip.showSuccess('删除计费模型成功!')
  82. }else{
  83. tempTip.setDuration(1000);
  84. tempTip.show('删除计费模型失败!')
  85. }
  86. })
  87. .catch(function (err) {
  88. tempTip.setDuration(3000);
  89. tempTip.show('删除计费模型失败!'+'网络错误:' + err);
  90. });
  91. },
  92. }
  93. });
  94. </script>
  95. @endsection