index.blade.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. @extends('layouts.app')
  2. @section('content')
  3. <span id="nav2">
  4. @component('maintenance.menu')@endcomponent
  5. @component('maintenance.authority.menu')@endcomponent
  6. </span>
  7. <div class="container-fluid mt-3">
  8. <div class="card">
  9. <div class="card-body">
  10. @if(Session::has('successTip'))
  11. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  12. @endif
  13. <table class="table table-striped table-sm" id="list">
  14. <tr>
  15. <th>ID</th>
  16. <th>权限名</th>
  17. <th>上级</th>
  18. <th>注释</th>
  19. <th>创建时间</th>
  20. <th>操作</th>
  21. </tr>
  22. <tr v-for="authority in authorities">
  23. <td class="text-muted">@{{authority.id}}</td>
  24. <td>@{{authority.name}}</td>
  25. <td></td>
  26. <td>@{{authority.remark}}</td>
  27. <td class="text-muted">@{{authority.created_at}}</td>
  28. <td>
  29. {{-- @can('权限-编辑')--}}
  30. {{-- <button class="btn btn-sm btn-outline-primary" @click="edit(authority.id)">改</button> @endcan--}}
  31. {{-- @can('权限-删除')--}}
  32. {{-- <button class="btn btn-sm btn-outline-dark" @click="destroy(authority)">删</button> @endcan--}}
  33. </td>
  34. </tr>
  35. </table>
  36. {{$authorities->links()}}
  37. </div>
  38. </div>
  39. </div>
  40. @endsection
  41. @section('lastScript')
  42. <script>
  43. new Vue({
  44. el:"#list",
  45. data:{
  46. authorities:[
  47. @foreach( $authorities as $authority )
  48. {id:'{{$authority->id}}',name:'{{$authority->alias_name}}',remark:'{{$authority->remark}}',created_at:'{{$authority->created_at}}'},
  49. @endforeach
  50. ],
  51. },
  52. methods:{
  53. edit:function(id){
  54. location.href = "{{url('maintenance/authority')}}/"+id+"/edit";
  55. },
  56. destroy:function(authority){
  57. if(!confirm('确定要删除权限“' + authority.name + '”吗?')){return};
  58. let data=this;
  59. let url = "{{url('maintenance/authority')}}/"+authority.id;
  60. axios.delete(url,{id:authority.id})
  61. .then(function (response) {
  62. if(response.data.success){
  63. for (let i = 0; i < data.authorities.length; i++) {
  64. if (data.authorities[i].id===authority.id){
  65. data.authorities.splice(i,1);
  66. break;
  67. }
  68. }
  69. tempTip.setDuration(1000);
  70. tempTip.showSuccess('删除权限"'+authority.name+'"成功!')
  71. }else{
  72. tempTip.setDuration(1000);
  73. tempTip.show('删除权限"'+authority.name+'"失败!')
  74. }
  75. })
  76. .catch(function (err) {
  77. tempTip.setDuration(3000);
  78. tempTip.show('删除权限失败!'+'网络错误:' + err)
  79. console.log(err);
  80. });
  81. },
  82. }
  83. });
  84. </script>
  85. @endsection