index.blade.php 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. @extends('layouts.app')
  2. @section('title')承运商@endsection
  3. @section('content')
  4. <span id="nav2">
  5. @component('maintenance.menu')@endcomponent
  6. @component('maintenance.logistic.menu')@endcomponent
  7. </span>
  8. <div class="container-fluid">
  9. <div class="card">
  10. <div class="card-body">
  11. @if(Session::has('successTip'))
  12. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  13. @endif
  14. <table class="table table-striped table-sm" id="list">
  15. <tr>
  16. <th>ID</th>
  17. <th>承运商名称</th>
  18. <th>承运商代码</th>
  19. <th>承运商联系方式</th>
  20. <th>承运商类型</th>
  21. <th>承运商送货费</th>
  22. <th>备注</th>
  23. <th>创建时间</th>
  24. <th>操作</th>
  25. </tr>
  26. <tr v-for="logistic in logistics">
  27. <td class="text-muted">@{{logistic.id}}</td>
  28. <td>@{{logistic.name}}</td>
  29. <td>@{{logistic.code}}</td>
  30. <td>@{{logistic.mobile}}</td>
  31. <td>@{{logistic.type}}</td>
  32. <td>@{{logistic.delivery_fee}}</td>
  33. <td>@{{logistic.remark}}</td>
  34. <td class="text-muted">@{{logistic.created_at}}</td>
  35. <td>
  36. @can('物流公司-编辑')
  37. <button class="btn btn-sm btn-outline-primary" @click="edit(logistic.id)">改</button> @endcan
  38. @can('物流公司-删除')
  39. <button class="btn btn-sm btn-outline-dark" @click="destroy(logistic)">删</button> @endcan
  40. </td>
  41. </tr>
  42. </table>
  43. {{$logistics->links()}}
  44. </div>
  45. </div>
  46. </div>
  47. @endsection
  48. @section('lastScript')
  49. <script>
  50. new Vue({
  51. el:"#list",
  52. data:{
  53. logistics:[
  54. @foreach( $logistics as $logistic )
  55. {id:'{{$logistic->id}}',name:'{{$logistic->name}}',code:'{{$logistic->code}}',
  56. mobile:"{{$logistic->mobile}}",type:"{{$logistic->type}}",delivery_fee:"{{$logistic->delivery_fee}}",
  57. remark:"{{$logistic->remark}}",created_at:'{{$logistic->created_at}}'},
  58. @endforeach
  59. ],
  60. },
  61. methods:{
  62. edit:function(id){
  63. location.href = "{{url('maintenance/logistic')}}/"+id+"/edit";
  64. },
  65. destroy:function(logistic){
  66. if(!confirm('确定要删除物流公司“' + logistic.name + '”吗?')){return};
  67. let data=this;
  68. let url = "{{url('maintenance/logistic')}}/"+logistic.id;
  69. axios.delete(url,{id:logistic.id})
  70. .then(function (response) {
  71. if(response.data.success){
  72. for (let i = 0; i < data.logistics.length; i++) {
  73. if (data.logistics[i].id===logistic.id){
  74. data.logistics.splice(i,1);
  75. break;
  76. }
  77. }
  78. tempTip.setDuration(1000);
  79. tempTip.showSuccess('删除物流公司"'+logistic.name+'"成功!')
  80. }else{
  81. tempTip.setDuration(1000);
  82. tempTip.show('删除物流公司"'+logistic.name+'"失败!')
  83. }
  84. })
  85. .catch(function (err) {
  86. tempTip.setDuration(3000);
  87. tempTip.show('删除物流公司失败!'+'网络错误:' + err)
  88. });
  89. },
  90. }
  91. });
  92. </script>
  93. @endsection