index.blade.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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,i) in logistics" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  27. <td class="text-muted">@{{logistic.id}}</td>
  28. <td>@{{logistic.name}}&nbsp;<span class="badge badge-success" v-if="logistic.is_bunched=='Y'">子母单</span></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}}',is_bunched:"{{$logistic->is_bunched}}"},
  58. @endforeach
  59. ],
  60. selectTr:0
  61. },
  62. methods:{
  63. edit:function(id){
  64. location.href = "{{url('maintenance/logistic')}}/"+id+"/edit";
  65. },
  66. destroy:function(logistic){
  67. if(!confirm('确定要删除物流公司“' + logistic.name + '”吗?')){return};
  68. let data=this;
  69. let url = "{{url('maintenance/logistic')}}/"+logistic.id;
  70. axios.delete(url,{id:logistic.id})
  71. .then(function (response) {
  72. if(response.data.success){
  73. for (let i = 0; i < data.logistics.length; i++) {
  74. if (data.logistics[i].id===logistic.id){
  75. data.logistics.splice(i,1);
  76. break;
  77. }
  78. }
  79. tempTip.setDuration(1000);
  80. tempTip.showSuccess('删除物流公司"'+logistic.name+'"成功!')
  81. }else{
  82. tempTip.setDuration(1000);
  83. tempTip.show('删除物流公司"'+logistic.name+'"失败!')
  84. }
  85. })
  86. .catch(function (err) {
  87. tempTip.setDuration(3000);
  88. tempTip.show('删除物流公司失败!'+'网络错误:' + err)
  89. });
  90. },
  91. }
  92. });
  93. </script>
  94. @endsection