articleList.blade.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/plugins/datatables/datatables.min.css" rel="stylesheet" type="text/css" />
  4. <link href="/assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css" rel="stylesheet" type="text/css" />
  5. @endsection
  6. @section('title', '控制面板')
  7. @section('content')
  8. <!-- BEGIN CONTENT BODY -->
  9. <div class="page-content">
  10. <!-- BEGIN PAGE BREADCRUMB -->
  11. <ul class="page-breadcrumb breadcrumb">
  12. <li>
  13. <a href="{{url('admin/articleList')}}">文章管理</a>
  14. <i class="fa fa-circle"></i>
  15. </li>
  16. </ul>
  17. <!-- END PAGE BREADCRUMB -->
  18. <!-- BEGIN PAGE BASE CONTENT -->
  19. <div class="row">
  20. <div class="col-md-12">
  21. <!-- BEGIN EXAMPLE TABLE PORTLET-->
  22. <div class="portlet light bordered">
  23. <div class="portlet-title">
  24. <div class="caption font-dark">
  25. <i class="icon-docs font-dark"></i>
  26. <span class="caption-subject bold uppercase"> 文章列表 </span>
  27. </div>
  28. <div class="actions">
  29. <div class="btn-group">
  30. <button class="btn sbold blue" onclick="addArticle()"> 新增
  31. <i class="fa fa-plus"></i>
  32. </button>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="portlet-body">
  37. <div class="table-scrollable">
  38. <table class="table table-striped table-bordered table-hover table-checkable order-column">
  39. <thead>
  40. <tr>
  41. <th> ID </th>
  42. <th> 标题 </th>
  43. <th> 类型 </th>
  44. <th> 排序 </th>
  45. <th> 发布日期 </th>
  46. <th> 操作 </th>
  47. </tr>
  48. </thead>
  49. <tbody>
  50. @if($articleList->isEmpty())
  51. <tr>
  52. <td colspan="6">暂无数据</td>
  53. </tr>
  54. @else
  55. @foreach($articleList as $article)
  56. <tr class="odd gradeX">
  57. <td> {{$article->id}} </td>
  58. <td> <a href="{{url('user/article?id=' . $article->id)}}" target="_blank"> {{$article->title}} </a> </td>
  59. <td> {{$article->type == '1' ? '文章' : '公告'}} </td>
  60. <td> {{$article->sort}} </td>
  61. <td> {{$article->created_at}} </td>
  62. <td>
  63. <button type="button" class="btn btn-sm blue btn-outline" onclick="editArticle('{{$article->id}}')">
  64. <i class="fa fa-pencil"></i>
  65. </button>
  66. <button type="button" class="btn btn-sm red btn-outline" onclick="delArticle('{{$article->id}}')">
  67. <i class="fa fa-trash"></i>
  68. </button>
  69. </td>
  70. </tr>
  71. @endforeach
  72. @endif
  73. </tbody>
  74. </table>
  75. </div>
  76. <div class="row">
  77. <div class="col-md-4 col-sm-4">
  78. <div class="dataTables_info" role="status" aria-live="polite">共 {{$articleList->total()}} 篇文章</div>
  79. </div>
  80. <div class="col-md-8 col-sm-8">
  81. <div class="dataTables_paginate paging_bootstrap_full_number pull-right">
  82. {{ $articleList->links() }}
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. <!-- END EXAMPLE TABLE PORTLET-->
  89. </div>
  90. </div>
  91. <!-- END PAGE BASE CONTENT -->
  92. </div>
  93. <!-- END CONTENT BODY -->
  94. @endsection
  95. @section('script')
  96. <script src="/js/layer/layer.js" type="text/javascript"></script>
  97. <script type="text/javascript">
  98. // 添加文章
  99. function addArticle() {
  100. window.location.href = '{{url('admin/addArticle')}}';
  101. }
  102. // 编辑文章
  103. function editArticle(id) {
  104. window.location.href = '{{url('admin/editArticle?id=')}}' + id + '&page=' + '{{Request::get('page', 1)}}';
  105. }
  106. // 删除文章
  107. function delArticle(id) {
  108. layer.confirm('确定删除文章?', {icon: 2, title:'警告'}, function(index) {
  109. $.post("{{url('admin/delArticle')}}", {id:id, _token:'{{csrf_token()}}'}, function(ret) {
  110. layer.msg(ret.message, {time:1000}, function() {
  111. if (ret.status == 'success') {
  112. window.location.reload();
  113. }
  114. });
  115. });
  116. layer.close(index);
  117. });
  118. }
  119. </script>
  120. @endsection