index.blade.php 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. @extends('layouts.app')
  2. @section('title')税率@endsection
  3. @section('content')
  4. <div class="container-fluid" id="container">
  5. <div class="card">
  6. <div class="card-body">
  7. @include("maintenance.taxRate._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-hover table-striped text-nowrap">
  12. <tr>
  13. <th>序号</th>
  14. <th>税率</th>
  15. <th>创建时间</th>
  16. <th>最后操作时间</th>
  17. <th></th>
  18. </tr>
  19. <tr v-for="(taxRate,i) in taxRates" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  20. <td>@{{ i+1 }}</td>
  21. <td>@{{ taxRate.value }}%</td>
  22. <td class="text-muted">@{{ taxRate.created_at }}</td>
  23. <td class="text-muted">@{{ taxRate.updated_at }}</td>
  24. <td>
  25. @can("税率-编辑")<button class="btn btn-sm btn-outline-info" @click="openModal(taxRate)">改</button>@endcan
  26. @can("税率-删除")<button class="btn btn-sm btn-outline-danger" @click="deleteModel(taxRate,i)">删</button>@endcan
  27. </td>
  28. </tr>
  29. </table>
  30. </div>
  31. </div>
  32. </div>
  33. @stop
  34. @section("lastScript")
  35. <script>
  36. new Vue({
  37. el:"#container",
  38. data:{
  39. taxRates:[
  40. @foreach($taxRates as $taxRate)@json($taxRate),@endforeach
  41. ],
  42. taxRate:{},
  43. selectTr:0,
  44. },
  45. methods:{
  46. openModal(model){
  47. if (model) this.taxRate={id:model.id,value:model.value};
  48. else this.taxRate={};
  49. $("#modal").modal("show");
  50. },
  51. submit(){
  52. let url="{{url('maintenance/taxRate/save')}}";
  53. let msg=this.taxRate.id ? "成功修改税率" : "成功新增税率";
  54. window.tempTip.postBasicRequest(url,this.taxRate,(res)=>{
  55. if (this.taxRate.id){
  56. this.taxRates.some((model)=> {
  57. if (model.id === this.taxRate.id){
  58. model.value = this.taxRate.value;
  59. return true;
  60. }
  61. });
  62. }else this.taxRates.unshift({
  63. id:res.id,
  64. value:res.value,
  65. created_at:res.created_at,
  66. updated_at:res.updated_at,
  67. });
  68. $("#modal").modal("hide");
  69. return msg;
  70. },true);
  71. },
  72. deleteModel(model,index){
  73. let url="{{url('maintenance/taxRate/destroy')}}";
  74. let params = {id:model.id};
  75. let msg="成功删除税率“"+model.value+"%”";
  76. window.tempTip.confirm("您确定要删除税率“"+model.value+"%”吗?",()=>{
  77. window.tempTip.postBasicRequest(url,params,res=>{
  78. this.$delete(this.taxRates,index);
  79. return msg;
  80. });
  81. });
  82. },
  83. },
  84. });
  85. </script>
  86. @stop