index.blade.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. @extends('layouts.app')
  2. @section('title')料箱型号@endsection
  3. @section('content')
  4. <div class="container-fluid card" id="container">
  5. @include("maintenance.materialBoxModel._modal")
  6. <div class="card-body">
  7. <button class="btn btn-outline-info mb-1 mr-3" @click="openModal()"><span class="fa fa-plus"></span>&nbsp;新&nbsp;&nbsp;增</button>
  8. <table class="table table-bordered table-striped">
  9. <tr>
  10. <th>编码</th>
  11. <th>说明</th>
  12. <th>最大商品种类</th>
  13. <th>操作</th>
  14. </tr>
  15. <tr v-for="model in models">
  16. <td>@{{ model.code }}</td>
  17. <td>@{{ model.description }}</td>
  18. <td>@{{ model.maximum_kind }}</td>
  19. <td>
  20. <button class="btn btn-sm btn-outline-primary" @click="edit(city.id)">改</button>
  21. <button class="btn btn-sm btn-outline-dark" @click="destroy(city)">删</button>
  22. </td>
  23. </tr>
  24. </table>
  25. </div>
  26. </div>
  27. @endsection
  28. @section('lastScript')
  29. <script>
  30. new Vue({
  31. el:"#container",
  32. data:{
  33. models:[@foreach($models as $model)@json($model),@endforeach],
  34. model:{},
  35. errors:{},
  36. },
  37. methods:{
  38. openModal(model= {maximum_kind:1}){
  39. this.model = model;
  40. $("#modal").modal("show");
  41. },
  42. submitModel(){
  43. window.tempTip.postBasicRequest("{{url('maintenance/materialBoxModel/save')}}",this.model,res=>{
  44. if (!this.model.id){
  45. this.models.unshift(res);
  46. return "新增成功";
  47. }
  48. this.models.some((model,index)=>{
  49. if (model.id===res.id){
  50. this.$set(this.models,index,res);
  51. return true;
  52. }
  53. });
  54. return "修改成功";
  55. });
  56. },
  57. }
  58. });
  59. </script>
  60. @endsection