index.blade.php 3.8 KB

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