index.blade.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. @extends('layouts.app')
  2. @section('title')查询-仓库@endsection
  3. @section('content')
  4. <span id="nav2">
  5. @component('maintenance.menu')@endcomponent
  6. @component('maintenance.warehouse.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>SKU减产系数</th>
  21. <th>联系人</th>
  22. <th>联系电话</th>
  23. <th>地址</th>
  24. <th>创建时间</th>
  25. <th>操作</th>
  26. </tr>
  27. <tr v-for="(warehouse,i) in warehouses" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  28. <td class="text-muted">@{{warehouse.id}}</td>
  29. <td>@{{warehouse.name}}</td>
  30. <td>@{{warehouse.code}}</td>
  31. <td>@{{warehouse.production_capacity}}</td>
  32. <td>@{{warehouse.reduced_production_capacity_coefficient}}%</td>
  33. <td>@{{warehouse.principal}}</td>
  34. <td>@{{warehouse.phone}}</td>
  35. <td>@{{warehouse.address}}</td>
  36. <td class="text-muted">@{{warehouse.created_at}}</td>
  37. <td>
  38. @can('仓库-编辑')
  39. <button class="btn btn-sm btn-outline-primary" @click="edit(warehouse.id)">改</button> @endcan
  40. @can('仓库-删除')
  41. <button class="btn btn-sm btn-outline-dark" @click="destroy(warehouse)">删</button> @endcan
  42. </td>
  43. </tr>
  44. </table>
  45. {{$warehouses->links()}}
  46. </div>
  47. </div>
  48. </div>
  49. @endsection
  50. @section('lastScript')
  51. <script>
  52. new Vue({
  53. el:"#list",
  54. data:{
  55. warehouses:[
  56. @foreach( $warehouses as $warehouse )
  57. {id:'{{$warehouse->id}}',name:'{{$warehouse->name}}',
  58. production_capacity:"{{$warehouse->production_capacity}}",
  59. principal:"{{$warehouse->principal}}",
  60. phone:"{{$warehouse->phone}}",
  61. address:"{{$warehouse->address}}",
  62. reduced_production_capacity_coefficient:"{{$warehouse->reduced_production_capacity_coefficient}}",
  63. code:'{{$warehouse->code}}',created_at:'{{$warehouse->created_at}}'},
  64. @endforeach
  65. ],
  66. selectTr:0,
  67. },
  68. methods:{
  69. edit:function(id){
  70. location.href = "{{url('maintenance/warehouse')}}/"+id+"/edit";
  71. },
  72. destroy:function(warehouse){
  73. if(!confirm('确定要删除仓库“' + warehouse.name + '”吗?')){return};
  74. let data=this;
  75. let url = "{{url('maintenance/warehouse')}}/"+warehouse.id;
  76. axios.delete(url,{id:warehouse.id})
  77. .then(function (response) {
  78. if(response.data.success){
  79. for (let i = 0; i < data.warehouses.length; i++) {
  80. if (data.warehouses[i].id===warehouse.id){
  81. data.warehouses.splice(i,1);
  82. break;
  83. }
  84. }
  85. tempTip.setDuration(1000);
  86. tempTip.showSuccess('删除仓库"'+warehouse.name+'"成功!')
  87. }else{
  88. tempTip.setDuration(1000);
  89. tempTip.show('删除仓库"'+warehouse.name+'"失败!')
  90. }
  91. })
  92. .catch(function (err) {
  93. tempTip.setDuration(3000);
  94. tempTip.show('删除仓库失败!'+'网络错误:' + err)
  95. });
  96. },
  97. }
  98. });
  99. </script>
  100. @endsection