recycle.blade.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. @extends('layouts.app')
  2. @section('title')停用-货主@endsection
  3. @section('content')
  4. <span id="nav2">
  5. @component('maintenance.menu')@endcomponent
  6. @component('maintenance.owner.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 table-hover" 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="(owner,i) in owners" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  23. <td class="text-muted">@{{owner.id}}</td>
  24. <td>@{{owner.code}}</td>
  25. <td>@{{owner.name}}</td>
  26. <td class="text-muted">@{{owner.created_at}}</td>
  27. <td>
  28. @can('货主-删除')
  29. <button class="btn btn-sm btn-outline-danger" @click="restoreSelected(owner)">恢复</button> @endcan
  30. </td>
  31. </tr>
  32. </table>
  33. {{$owners->links()}}
  34. </div>
  35. </div>
  36. </div>
  37. @endsection
  38. @section('lastScript')
  39. <script>
  40. new Vue({
  41. el:"#list",
  42. data:{
  43. owners:[
  44. @foreach( $owners as $owner )
  45. {id:'{{$owner->id}}',code:'{{$owner->code}}',name:'{{$owner->name}}',created_at:'{{$owner->created_at}}'},
  46. @endforeach
  47. ],
  48. selectTr:0
  49. },
  50. methods:{
  51. restoreSelected:function(owner){
  52. let _this=this;
  53. confirm('确定要恢复停用货主“' + owner.name + '”吗?');
  54. let ajaxUrl='{{url("maintenance/owners/restoreSelected")}}';
  55. axios.post(ajaxUrl,{id:owner.id}).then(function(response){
  56. if(response.data.success){
  57. tempTip.setDuration(1000);
  58. tempTip.showSuccess('恢复货主'+owner.name+'成功');
  59. window.location.reload();
  60. }else{
  61. tempTip.setDuration(2500);
  62. tempTip.show('恢复货主失败,错误:'+response.data.fail_info);
  63. }
  64. }).catch(function (e) {
  65. alert('网络连接错误:'+e);
  66. tempTip.setDuration(2500);
  67. tempTip.show('恢复货主失败,网络连接错误:'+e);
  68. })
  69. },
  70. }
  71. });
  72. </script>
  73. @endsection