recycle.blade.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 table-hover" id="list">
  11. <tr>
  12. <th>ID</th>
  13. <th>货主编码</th>
  14. <th>货主名</th>
  15. <th>创建时间</th>
  16. <th>操作</th>
  17. </tr>
  18. <tr v-for="(owner,i) in owners" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  19. <td class="text-muted">@{{owner.id}}</td>
  20. <td>@{{owner.code}}</td>
  21. <td>@{{owner.name}}</td>
  22. <td class="text-muted">@{{owner.created_at}}</td>
  23. <td>
  24. @can('货主-删除')
  25. <button class="btn btn-sm btn-outline-danger" @click="restoreSelected(owner)">恢复</button> @endcan
  26. </td>
  27. </tr>
  28. </table>
  29. {{$owners->links()}}
  30. </div>
  31. </div>
  32. </div>
  33. @endsection
  34. @section('lastScript')
  35. <script>
  36. new Vue({
  37. el:"#list",
  38. data:{
  39. owners:[
  40. @foreach( $owners as $owner )
  41. {id:'{{$owner->id}}',code:'{{$owner->code}}',name:'{{$owner->name}}',created_at:'{{$owner->created_at}}'},
  42. @endforeach
  43. ],
  44. selectTr:0
  45. },
  46. methods:{
  47. restoreSelected:function(owner){
  48. let _this=this;
  49. confirm('确定要恢复停用货主“' + owner.name + '”吗?');
  50. let ajaxUrl='{{url("maintenance/owner/restoreSelected")}}';
  51. axios.post(ajaxUrl,{id:owner.id}).then(function(response){
  52. if(response.data.success){
  53. tempTip.setDuration(1000);
  54. tempTip.showSuccess('恢复货主'+owner.name+'成功');
  55. window.location.reload();
  56. }else{
  57. tempTip.setDuration(2500);
  58. tempTip.show('恢复货主失败,错误:'+response.data.fail_info);
  59. }
  60. }).catch(function (e) {
  61. alert('网络连接错误:'+e);
  62. tempTip.setDuration(2500);
  63. tempTip.show('恢复货主失败,网络连接错误:'+e);
  64. })
  65. },
  66. }
  67. });
  68. </script>
  69. @endsection