index.blade.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. @extends('layouts.app')
  2. @section('title')项目组@endsection
  3. @section('content')
  4. <div id="nav2">
  5. @component('maintenance.menu')@endcomponent
  6. @component('maintenance.userOwnerGroup.menu')@endcomponent
  7. </div>
  8. <div class="container-fluid card" id="container">
  9. @if(Session::has('successTip'))
  10. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  11. @endif
  12. <table class="table table-hover table-striped text-nowrap card-body mt-2">
  13. <tr>
  14. <th>序号</th>
  15. <th>名称</th>
  16. <th>创建时间</th>
  17. <th>操作</th>
  18. </tr>
  19. <tr v-for="(group,i) in groups">
  20. <td>@{{ i+1 }}</td>
  21. <td>@{{ group.name }}</td>
  22. <td>@{{ group.created_at }}</td>
  23. <td>
  24. @can("项目组-编辑")<a :href="'{{url('maintenance/userOwnerGroup')}}/'+group.id+'/edit'"><button class="btn btn-sm btn-outline-info">改</button></a>@endcan
  25. @can("项目组-删除")<button class="btn btn-sm btn-outline-danger" @click="destroy(group.id,i,group.name)">删</button>@endcan
  26. </td>
  27. </tr>
  28. </table>
  29. </div>
  30. @stop
  31. @section("lastScript")
  32. <script>
  33. new Vue({
  34. el:"#container",
  35. data:{
  36. groups : [
  37. @foreach($groups as $group)
  38. {
  39. id:"{{$group->id}}",
  40. name:"{{$group->name}}",
  41. created_at:"{{$group->created_at}}",
  42. },
  43. @endforeach
  44. ],
  45. },
  46. methods:{
  47. destroy(id,index,name){
  48. window.tempTip.confirm("确定要删除"+name+"吗?",()=>{
  49. window.axios.delete("{{url('maintenance/userOwnerGroup')}}/"+id)
  50. .then(res=>{
  51. if (res.data.success){
  52. this.$delete(this.groups,index);
  53. window.tempTip.setDuration(2000);
  54. window.tempTip.showSuccess("删除"+name+"成功");
  55. return;
  56. }
  57. window.tempTip.setDuration(3000);
  58. window.tempTip.show(res.data.data);
  59. }).catch(err=>{
  60. window.tempTip.setDuration(3000);
  61. window.tempTip.show("网络错误:"+err);
  62. })
  63. })
  64. }
  65. },
  66. });
  67. </script>
  68. @stop