index.blade.php 4.5 KB

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