articleList.blade.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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('content')
  7. <!-- BEGIN CONTENT BODY -->
  8. <div class="page-content" style="padding-top:0;">
  9. <!-- BEGIN PAGE BASE CONTENT -->
  10. <div class="row">
  11. <div class="col-md-12">
  12. <!-- BEGIN EXAMPLE TABLE PORTLET-->
  13. <div class="portlet light bordered">
  14. <div class="portlet-title">
  15. <div class="caption font-dark">
  16. <span class="caption-subject bold uppercase"> 文章列表 </span>
  17. </div>
  18. <div class="actions">
  19. <div class="btn-group">
  20. <button class="btn sbold blue" onclick="addArticle()"> 添加文章 </button>
  21. </div>
  22. </div>
  23. </div>
  24. <div class="portlet-body">
  25. <div class="table-scrollable table-scrollable-borderless">
  26. <table class="table table-hover table-light">
  27. <thead>
  28. <tr>
  29. <th> # </th>
  30. <th> 类型 </th>
  31. <th> 标题 </th>
  32. <th> 排序 </th>
  33. <th> 发布日期 </th>
  34. <th> 操作 </th>
  35. </tr>
  36. </thead>
  37. <tbody>
  38. @if($list->isEmpty())
  39. <tr>
  40. <td colspan="6" style="text-align: center;">暂无数据</td>
  41. </tr>
  42. @else
  43. @foreach($list as $vo)
  44. <tr class="odd gradeX">
  45. <td> {{$vo->id}} </td>
  46. @if ($vo->type == '1')
  47. <td> 文章 </td>
  48. @elseif ($vo->type == '2')
  49. <td> 公告 </td>
  50. @elseif ($vo->type == '3')
  51. <td> 购买说明 </td>
  52. @elseif ($vo->type == '4')
  53. <td> 使用教程 </td>
  54. @else
  55. <td> 未知 </td>
  56. @endif
  57. <td> <a href="{{url('article?id=' . $vo->id)}}" target="_blank"> {{str_limit($vo->title, 80)}} </a> </td>
  58. <td> {{$vo->sort}} </td>
  59. <td> {{$vo->created_at}} </td>
  60. <td>
  61. <button type="button" class="btn btn-sm blue btn-outline" onclick="editArticle('{{$vo->id}}')"> 编辑 </button>
  62. <button type="button" class="btn btn-sm red btn-outline" onclick="delArticle('{{$vo->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">共 {{$list->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. {{ $list->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 type="text/javascript">
  91. // 添加文章
  92. function addArticle() {
  93. window.location.href = '{{url('admin/addArticle')}}';
  94. }
  95. // 编辑文章
  96. function editArticle(id) {
  97. window.location.href = '{{url('admin/editArticle?id=')}}' + id + '&page=' + '{{Request::get('page', 1)}}';
  98. }
  99. // 删除文章
  100. function delArticle(id) {
  101. layer.confirm('确定删除文章?', {icon: 2, title:'警告'}, function(index) {
  102. $.post("{{url('admin/delArticle')}}", {id:id, _token:'{{csrf_token()}}'}, function(ret) {
  103. layer.msg(ret.message, {time:1000}, function() {
  104. if (ret.status == 'success') {
  105. window.location.reload();
  106. }
  107. });
  108. });
  109. layer.close(index);
  110. });
  111. }
  112. </script>
  113. @endsection