index.blade.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. <th>操作</th>
  24. </tr>
  25. <tr v-for="authority in authorities" @click="selectTr===authority.id?selectTr=0:selectTr=authority.id" :class="selectTr==authority.id ? 'focusing' : ''">
  26. <td class="text-muted">@{{authority.id}}</td>
  27. <td>@{{authority.name}}</td>
  28. <td></td>
  29. <td>@{{authority.permission}}</td>
  30. <td>@{{authority.remark}}</td>
  31. <td>@{{authority.type}}</td>
  32. <td class="text-muted">@{{authority.created_at}}</td>
  33. <td>
  34. {{-- @can('权限-编辑')--}}
  35. {{-- <button class="btn btn-sm btn-outline-primary" @click="edit(authority.id)">改</button> @endcan--}}
  36. {{-- @can('权限-删除')--}}
  37. {{-- <button class="btn btn-sm btn-outline-dark" @click="destroy(authority)">删</button> @endcan--}}
  38. </td>
  39. </tr>
  40. </table>
  41. {{$authorities->links()}}
  42. </div>
  43. </div>
  44. </div>
  45. @endsection
  46. @section('lastScript')
  47. <script>
  48. new Vue({
  49. el:"#list",
  50. data:{
  51. authorities:[
  52. @foreach( $authorities as $authority )
  53. {id:'{{$authority->id}}',name:'{{$authority->alias_name}}',type:'{{$authority->type}}',remark:'{{$authority->remark}}',created_at:'{{$authority->created_at}}',
  54. permission:'{{$authority->permission}}'},
  55. @endforeach
  56. ],
  57. selectTr:''
  58. },
  59. methods:{
  60. edit:function(id){
  61. location.href = "{{url('maintenance/authority')}}/"+id+"/edit";
  62. },
  63. destroy:function(authority){
  64. if(!confirm('确定要删除权限“' + authority.name + '”吗?')){return};
  65. let data=this;
  66. let url = "{{url('maintenance/authority')}}/"+authority.id;
  67. axios.delete(url,{id:authority.id})
  68. .then(function (response) {
  69. if(response.data.success){
  70. for (let i = 0; i < data.authorities.length; i++) {
  71. if (data.authorities[i].id===authority.id){
  72. data.authorities.splice(i,1);
  73. break;
  74. }
  75. }
  76. tempTip.setDuration(1000);
  77. tempTip.showSuccess('删除权限"'+authority.name+'"成功!')
  78. }else{
  79. tempTip.setDuration(1000);
  80. tempTip.show('删除权限"'+authority.name+'"失败!')
  81. }
  82. })
  83. .catch(function (err) {
  84. tempTip.setDuration(3000);
  85. tempTip.show('删除权限失败!'+'网络错误:' + err)
  86. });
  87. },
  88. }
  89. });
  90. </script>
  91. @endsection