articleList.blade.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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" id="sample_1">
  39. <thead>
  40. <tr>
  41. <th> ID </th>
  42. <th> 标题 </th>
  43. <th> 排序 </th>
  44. <th> 发布日期 </th>
  45. <th> 操作 </th>
  46. </tr>
  47. </thead>
  48. <tbody>
  49. @if($articleList->isEmpty())
  50. <tr>
  51. <td colspan="5">暂无数据</td>
  52. </tr>
  53. @else
  54. @foreach($articleList as $article)
  55. <tr class="odd gradeX">
  56. <td> {{$article->id}} </td>
  57. <td> <a href="{{url('user/article?id=' . $article->id)}}" target="_blank"> {{$article->title}} </a> </td>
  58. <td> {{$article->sort}} </td>
  59. <td> {{$article->created_at}} </td>
  60. <td>
  61. <button type="button" class="btn btn-sm blue btn-outline" onclick="editArticle('{{$article->id}}')">编辑</button>
  62. <button type="button" class="btn btn-sm red btn-outline" onclick="delArticle('{{$article->id}}')">删除</button>
  63. </td>
  64. </tr>
  65. @endforeach
  66. @endif
  67. </tbody>
  68. </table>
  69. </div>
  70. <div class="row">
  71. <div class="col-md-4 col-sm-4">
  72. <div class="dataTables_info" role="status" aria-live="polite">共 {{$articleList->total()}} 篇文章</div>
  73. </div>
  74. <div class="col-md-8 col-sm-8">
  75. <div class="dataTables_paginate paging_bootstrap_full_number pull-right">
  76. {{ $articleList->links() }}
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <!-- END EXAMPLE TABLE PORTLET-->
  83. </div>
  84. </div>
  85. <!-- END PAGE BASE CONTENT -->
  86. </div>
  87. <!-- END CONTENT BODY -->
  88. @endsection
  89. @section('script')
  90. <script src="/assets/global/plugins/bootbox/bootbox.min.js" type="text/javascript"></script>
  91. <script type="text/javascript">
  92. // 添加文章
  93. function addArticle() {
  94. window.location.href = '{{url('admin/addArticle')}}';
  95. }
  96. // 编辑文章
  97. function editArticle(id) {
  98. window.location.href = '{{url('admin/editArticle?id=')}}' + id + '&page=' + '{{Request::get('page', 1)}}';
  99. }
  100. // 删除文章
  101. function delArticle(id) {
  102. var _token = '{{csrf_token()}}';
  103. bootbox.confirm({
  104. message: "确定删除文章?",
  105. buttons: {
  106. confirm: {
  107. label: '确定',
  108. className: 'btn-success'
  109. },
  110. cancel: {
  111. label: '取消',
  112. className: 'btn-danger'
  113. }
  114. },
  115. callback: function (result) {
  116. if (result) {
  117. $.post("{{url('admin/delArticle')}}", {id:id, _token:_token}, function(ret){
  118. if (ret.status == 'success') {
  119. bootbox.alert(ret.message, function(){
  120. window.location.reload();
  121. });
  122. } else {
  123. bootbox.alert(ret.message);
  124. }
  125. });
  126. }
  127. }
  128. });
  129. }
  130. </script>
  131. @endsection