index.blade.php 4.6 KB

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