articleList.blade.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link rel="stylesheet" href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css">
  4. @endsection
  5. @section('content')
  6. <div class="page-content container-fluid">
  7. <div class="panel">
  8. <div class="panel-heading">
  9. <h3 class="panel-title">文章列表</h3>
  10. <div class="panel-actions">
  11. <button class="btn btn-primary" onclick="addArticle()"><i class="icon wb-plus"></i>添加文章</button>
  12. </div>
  13. </div>
  14. <div class="panel-body">
  15. <table class="text-center" data-toggle="table" data-mobile-responsive="true">
  16. <thead class="thead-default">
  17. <tr>
  18. <th> #</th>
  19. <th> 类型</th>
  20. <th> 标题</th>
  21. <th> 排序</th>
  22. <th> 发布日期</th>
  23. <th> 操作</th>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. @if($list->isEmpty())
  28. <tr>
  29. <td colspan="6">暂无数据</td>
  30. </tr>
  31. @else
  32. @foreach($list as $vo)
  33. <tr>
  34. <td> {{$vo->id}} </td>
  35. @if ($vo->type == '1')
  36. <td> 文章</td>
  37. @elseif ($vo->type == '2')
  38. <td> 公告</td>
  39. @elseif ($vo->type == '3')
  40. <td> 购买说明</td>
  41. @elseif ($vo->type == '4')
  42. <td> 使用教程</td>
  43. @else
  44. <td> 未知</td>
  45. @endif
  46. <td>
  47. <a href="/article?id={{$vo->id}}" target="_blank"> {{str_limit($vo->title, 80)}} </a>
  48. </td>
  49. <td> {{$vo->sort}} </td>
  50. <td> {{$vo->created_at}} </td>
  51. <td>
  52. <div class="btn-group">
  53. <button class="btn btn-outline-primary" onclick="editArticle('{{$vo->id}}')"><i class="icon wb-edit"></i></button>
  54. <button class="btn btn-outline-danger" onclick="delArticle('{{$vo->id}}')"><i class="icon wb-close"></i></button>
  55. </div>
  56. </td>
  57. </tr>
  58. @endforeach
  59. @endif
  60. </tbody>
  61. </table>
  62. </div>
  63. <div class="panel-footer">
  64. <div class="row">
  65. <div class="col-sm-4">
  66. 共 {{$list->total()}} 篇文章
  67. </div>
  68. <div class="col-sm-8">
  69. <div class="Page navigation float-right">
  70. {{ $list->links() }}
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. @endsection
  78. @section('script')
  79. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js"></script>
  80. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
  81. <script type="text/javascript">
  82. // 添加文章
  83. function addArticle() {
  84. window.location.href = '/admin/addArticle';
  85. }
  86. // 编辑文章
  87. function editArticle(id) {
  88. window.location.href = '/admin/editArticle?id=' + id + '&page=' + '{{Request::get('page', 1)}}';
  89. }
  90. // 删除文章
  91. function delArticle(id) {
  92. swal.fire({
  93. title: '确定删除文章?',
  94. type: 'question',
  95. showCancelButton: true,
  96. cancelButtonText: '{{trans('home.ticket_close')}}',
  97. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  98. }).then((result) => {
  99. if (result.value) {
  100. $.post("/admin/delArticle", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  101. if (ret.status === 'success') {
  102. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  103. .then(() => window.location.reload())
  104. } else {
  105. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  106. }
  107. });
  108. }
  109. });
  110. }
  111. </script>
  112. @endsection