index.blade.php 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 mt-3">
  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. </tr>
  22. <tr v-for="logistic in logistics">
  23. <td class="text-muted">@{{logistic.id}}</td>
  24. <td>@{{logistic.name}}</td>
  25. <td>@{{logistic.code}}</td>
  26. <td class="text-muted">@{{logistic.created_at}}</td>
  27. <td>
  28. @can('物流公司-编辑')
  29. <button class="btn btn-sm btn-outline-primary" @click="edit(logistic.id)">改</button> @endcan
  30. @can('物流公司-删除')
  31. <button class="btn btn-sm btn-outline-dark" @click="destroy(logistic)">删</button> @endcan
  32. </td>
  33. </tr>
  34. </table>
  35. {{$logistics->links()}}
  36. </div>
  37. </div>
  38. </div>
  39. @endsection
  40. @section('lastScript')
  41. <script>
  42. new Vue({
  43. el:"#list",
  44. data:{
  45. logistics:[
  46. @foreach( $logistics as $logistic )
  47. {id:'{{$logistic->id}}',name:'{{$logistic->name}}',code:'{{$logistic->code}}',created_at:'{{$logistic->created_at}}'},
  48. @endforeach
  49. ],
  50. },
  51. methods:{
  52. edit:function(id){
  53. location.href = "{{url('maintenance/logistic')}}/"+id+"/edit";
  54. },
  55. destroy:function(logistic){
  56. if(!confirm('确定要删除物流公司“' + logistic.name + '”吗?')){return};
  57. let data=this;
  58. let url = "{{url('maintenance/logistic')}}/"+logistic.id;
  59. axios.delete(url,{id:logistic.id})
  60. .then(function (response) {
  61. if(response.data.success){
  62. for (let i = 0; i < data.logistics.length; i++) {
  63. if (data.logistics[i].id===logistic.id){
  64. data.logistics.splice(i,1);
  65. break;
  66. }
  67. }
  68. tempTip.setDuration(1000);
  69. tempTip.showSuccess('删除物流公司"'+logistic.name+'"成功!')
  70. }else{
  71. tempTip.setDuration(1000);
  72. tempTip.show('删除物流公司"'+logistic.name+'"失败!')
  73. }
  74. })
  75. .catch(function (err) {
  76. tempTip.setDuration(3000);
  77. tempTip.show('删除物流公司失败!'+'网络错误:' + err)
  78. console.log(err);
  79. });
  80. },
  81. }
  82. });
  83. </script>
  84. @endsection