index.blade.php 5.1 KB

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