index.blade.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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" id="list">
  10. <div id="form_div"></div>
  11. <div class="card-body">
  12. @if(Session::has('successTip'))
  13. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  14. @endif
  15. <span class="mb-1 btn btn-sm btn-outline-secondary tooltipTarget" @click="syncOwners">同步货主</span>
  16. <table class="table table-striped table-sm table-hover">
  17. <tr>
  18. <th>ID</th>
  19. <th>货主编码</th>
  20. <th>货主名</th>
  21. <th>创建时间</th>
  22. <th>操作</th>
  23. </tr>
  24. <tr v-for="(owner,i) in owners" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  25. <td class="text-muted">@{{owner.id}}</td>
  26. <td>@{{owner.code}}</td>
  27. <td>@{{owner.name}}</td>
  28. <td class="text-muted">@{{owner.created_at}}</td>
  29. <td>
  30. @can('货主-编辑')
  31. <button class="btn btn-sm btn-outline-primary" @click="edit(owner.id)">改</button> @endcan
  32. @can('货主-删除')
  33. <button class="btn btn-sm btn-outline-danger" @click="destroy(owner)">停用</button> @endcan
  34. </td>
  35. </tr>
  36. </table>
  37. {{$owners->withQueryString()->links()}}
  38. </div>
  39. </div>
  40. </div>
  41. @endsection
  42. @section('lastScript')
  43. <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
  44. <script>
  45. new Vue({
  46. el:"#list",
  47. data:{
  48. owners:[
  49. @foreach( $owners as $owner )
  50. {id:'{{$owner->id}}',code:'{{$owner->code}}',name:'{{$owner->name}}',created_at:'{{$owner->created_at}}'},
  51. @endforeach
  52. ],
  53. selectTr:0
  54. },
  55. mounted:function(){
  56. let data = [
  57. [{name: 'code', type: 'input',tip:'可支持多货主编码,模糊搜索可在两侧添加百分号(%)进行',placeholder:'货主编码'},
  58. {name: 'name', type: 'input',tip:'可支持多货主名称,模糊搜索可在两侧添加百分号(%)进行',placeholder:'货主名称'}]
  59. ];
  60. this.from =new query({
  61. el: '#form_div',
  62. condition: data,
  63. });
  64. this.from.init();
  65. },
  66. methods:{
  67. edit:function(id){
  68. location.href = "{{url('maintenance/owner')}}/"+id+"/edit";
  69. },
  70. destroy:function(owner){
  71. confirm('确定要停用货主“' + owner.name + '”吗?');
  72. let data=this;
  73. let url = "{{url('maintenance/owner')}}/"+owner.id;
  74. axios.delete(url,{id:owner.id})
  75. .then(function (response) {
  76. if(response.data.success){
  77. for (let i = 0; i < data.owners.length; i++) {
  78. if (data.owners[i].id===owner.id){
  79. data.owners.splice(i,1);
  80. break;
  81. }
  82. }
  83. tempTip.setDuration(1000);
  84. tempTip.showSuccess('停用货主"'+owner.name+'"成功!')
  85. }else{
  86. tempTip.setDuration(1000);
  87. tempTip.show('停用货主"'+owner.name+'"失败!')
  88. }
  89. })
  90. .catch(function (err) {
  91. tempTip.setDuration(3000);
  92. tempTip.show('停用货主失败!'+'网络错误:' + err);
  93. });
  94. },
  95. syncOwners(){
  96. let url = '{{url('inventory/syncOwners')}}';
  97. axios.get(url).then(function (response) {
  98. if(!response.data.success){
  99. tempTip.setDuration(3000);
  100. tempTip.show(response.data.data);
  101. }else {
  102. tempTip.setDuration(2000);
  103. tempTip.showSuccess('同步货主成功!');
  104. location.reload();
  105. }
  106. }).catch(function (err) {
  107. tempTip.setDuration(3000);
  108. tempTip.show('同步货主失败,网络链接错误!'+err);
  109. })
  110. },
  111. }
  112. });
  113. </script>
  114. @endsection