index.blade.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. @extends('layouts.app')
  2. @section('title')查询-承运商@endsection
  3. @section('content')
  4. <div class="container-fluid">
  5. <div class="card">
  6. <div class="card-body">
  7. @if(Session::has('successTip'))
  8. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  9. @endif
  10. <table class="table table-striped table-sm" id="list">
  11. <tr>
  12. <th>ID</th>
  13. <th>承运商名称</th>
  14. <th>承运商英文名称</th>
  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="(logistic,i) in logistics" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  26. <td class="text-muted">@{{logistic.id}}</td>
  27. <td>@{{logistic.name}}&nbsp;<span class="badge badge-success" v-if="logistic.is_bunched=='Y'">子母单</span></td>
  28. <td>@{{logistic.english_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.belong_company}}</td>
  34. <td>@{{logistic.tag}}</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. tag:"{{$logistic->tag}}",
  60. remark:"{{$logistic->remark}}",belong_company:"{{$logistic->belong_company}}",created_at:'{{$logistic->created_at}}',is_bunched:"{{$logistic->is_bunched}}"},
  61. @endforeach
  62. ],
  63. selectTr:0
  64. },
  65. methods:{
  66. edit:function(id){
  67. location.href = "{{url('maintenance/logistic')}}/"+id+"/edit";
  68. },
  69. destroy:function(logistic){
  70. if(!confirm('确定要删除物流公司“' + logistic.name + '”吗?')){return};
  71. let data=this;
  72. let url = "{{url('maintenance/logistic')}}/"+logistic.id;
  73. axios.delete(url,{id:logistic.id})
  74. .then(function (response) {
  75. if(response.data.success){
  76. for (let i = 0; i < data.logistics.length; i++) {
  77. if (data.logistics[i].id===logistic.id){
  78. data.logistics.splice(i,1);
  79. break;
  80. }
  81. }
  82. tempTip.setDuration(1000);
  83. tempTip.showSuccess('删除物流公司"'+logistic.name+'"成功!')
  84. }else{
  85. tempTip.setDuration(1000);
  86. tempTip.show('删除物流公司"'+logistic.name+'"失败!')
  87. }
  88. })
  89. .catch(function (err) {
  90. tempTip.setDuration(3000);
  91. tempTip.show('删除物流公司失败!'+'网络错误:' + err)
  92. });
  93. },
  94. }
  95. });
  96. </script>
  97. @endsection