index.blade.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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" @click="selectedColor(model.id,$event)">
  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. selectedStyle: '',
  55. },
  56. mounted(){
  57. $("#container").removeClass("d-none");
  58. },
  59. methods:{
  60. openModal(model){
  61. if (model) this.status={id:model.id,name:model.name,description:model.description};
  62. else this.status={id:"",name:"",description:""};
  63. $("#modal").modal("show");
  64. },
  65. submitCustomerLogStatus(){
  66. let url="{{url('customer/customer/customerLogStatus/save')}}";
  67. let msg=this.status.id ? "成功修改状态“"+this.status.name+"”" : "成功新增状态“"+this.status.name+"”";
  68. window.tempTip.postBasicRequest(url,this.status,(res)=>{
  69. if(res && res.errors){
  70. this.errors = res.errors;
  71. return '';
  72. }
  73. if (this.status.id){
  74. this.models.some((model)=> {
  75. if (model.id === this.status.id){
  76. model.name = this.status.name;
  77. model.description = this.status.description;
  78. return true;
  79. }
  80. });
  81. }else this.models.unshift({
  82. id:res.id,
  83. name:res.name,
  84. description:res.description,
  85. createdAt:res.created_at,
  86. updatedAt:res.updated_at,
  87. });
  88. $("#modal").modal("hide");
  89. return msg;
  90. },true);
  91. },
  92. deleteModel(model,index){
  93. let url="{{url('customer/customer/customerLogStatus/destroy')}}";
  94. let params = {id:model.id};
  95. let msg="成功删除状态“"+model.name+"”";
  96. window.tempTip.confirm("您确定要删除“"+model.name+"”吗?",()=>{
  97. window.tempTip.postBasicRequest(url,params,res=>{
  98. this.$delete(this.models,index);
  99. return msg;
  100. });
  101. });
  102. },
  103. selectedColor(id,e){
  104. $('.table-body').removeClass('focusing')
  105. if (id === this.selectedStyle) {
  106. this.selectedStyle = '';
  107. return;
  108. }
  109. this.selectedStyle = id;
  110. $(e.target).parent('tr').addClass('focusing')
  111. }
  112. },
  113. });
  114. </script>
  115. @endsection