index.blade.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. @extends('layouts.app')
  2. @section('title')客户@endsection
  3. @section('content')
  4. <div id="nav2">
  5. @component('customer.menu')@endcomponent
  6. @component('customer.customer.menu')@endcomponent
  7. </div>
  8. <div class="d-none container-fluid" id="container">
  9. <div class="card">
  10. <div class="card-body">
  11. @include("customer.customerLogStatus._edit")
  12. <div class="row pull-left ml-1">
  13. @can("客户-客户状态-录入")<button class="btn btn-outline-info mb-1 mr-3" @click="openModal()"><span class="fa fa-plus"></span>&nbsp;新&nbsp;&nbsp;增</button>@endcan
  14. </div>
  15. <table class="table table-striped table-bordered table-hover">
  16. <tr>
  17. <th>序号</th>
  18. <th>名称</th>
  19. <th>说明</th>
  20. <th>创建时间</th>
  21. <th>修改时间</th>
  22. <th>操作</th>
  23. </tr>
  24. <tr v-for="(model,i) in models">
  25. <td>@{{ i+1 }}</td>
  26. <td>@{{ model.name }}</td>
  27. <td>@{{ model.description }}</td>
  28. <td>@{{ model.createdAt }}</td>
  29. <td>@{{ model.updatedAt }}</td>
  30. <td>
  31. @can("客户-客户状态-编辑")<button class="btn btn-sm btn-outline-info" @click="openModal(model)">改</button>@endcan
  32. @can("客户-客户状态-删除")<button class="btn btn-sm btn-outline-danger" @click="deleteModel(model,i)">删</button>@endcan
  33. </td>
  34. </tr>
  35. </table>
  36. </div>
  37. </div>
  38. </div>
  39. @stop
  40. @section("lastScript")
  41. <script>
  42. new Vue({
  43. el:"#container",
  44. data:{
  45. status:{},
  46. models:[
  47. @foreach($customerLogStatuses as $customerLogStatus)
  48. {id:"{{$customerLogStatus->id}}",'name':"{{$customerLogStatus->name}}", 'description':"{{$customerLogStatus->description}}"
  49. , 'createdAt':"{{$customerLogStatus->created_at}}"
  50. , 'updatedAt':"{{$customerLogStatus->updated_at}}"},
  51. @endforeach
  52. ],
  53. errors:[],
  54. },
  55. mounted(){
  56. $("#container").removeClass("d-none");
  57. },
  58. methods:{
  59. openModal(model){
  60. if (model) this.status={id:model.id,name:model.name,description:model.description};
  61. else this.status={id:"",name:"",description:""};
  62. $("#modal").modal("show");
  63. },
  64. submitCustomerLogStatus(){
  65. let url="{{url('customer/customer/customerLogStatus/save')}}";
  66. let msg=this.status.id ? "成功修改状态“"+this.status.name+"”" : "成功新增状态“"+this.status.name+"”";
  67. window.tempTip.postBasicRequest(url,this.status,(res)=>{
  68. if(res && res.errors){
  69. this.errors = res.errors;
  70. return '';
  71. }
  72. if (this.status.id){
  73. this.models.some((model)=> {
  74. if (model.id === this.status.id){
  75. model.name = this.status.name;
  76. model.description = this.status.description;
  77. return true;
  78. }
  79. });
  80. }else this.models.unshift({
  81. id:res.id,
  82. name:res.name,
  83. description:res.description,
  84. createdAt:res.created_at,
  85. updatedAt:res.updated_at,
  86. });
  87. $("#modal").modal("hide");
  88. return msg;
  89. },true);
  90. },
  91. deleteModel(model,index){
  92. let url="{{url('customer/customer/customerLogStatus/destroy')}}";
  93. let params = {id:model.id};
  94. let msg="成功删除状态“"+model.name+"”";
  95. window.tempTip.confirm("您确定要删除“"+model.name+"”吗?",()=>{
  96. window.tempTip.postBasicRequest(url,params,res=>{
  97. this.$delete(this.models,index);
  98. return msg;
  99. });
  100. });
  101. },
  102. },
  103. });
  104. </script>
  105. @endsection