index.blade.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <div class="ibox float-e-margins">
  2. <div class="ibox-content">
  3. <a href="{{ route('admin.bai.jia.article.create') }}" class="btn btn-primary margin-bottom" no-pjax>添加文章</a>
  4. <div>
  5. <div class="box-body table-responsive">
  6. <table class="table table-hover table-bordered">
  7. <tbody>
  8. <tr>
  9. <th>标题</th>
  10. <th>副标题</th>
  11. <th>文章分类</th>
  12. <th>是否推荐</th>
  13. <th>状态</th>
  14. <th>操作</th>
  15. </tr>
  16. @foreach($articles as $article)
  17. <tr>
  18. <td><img src="{{ $article->img }}" width="100"> {{$article->title}}</td>
  19. <td>{{$article->sub_title}}</td>
  20. <td>{{$article->type_text}}</td>
  21. <td>@if($article->is_recommend==1) 是 @else 否 @endif</td>
  22. <td>@if($article->status==1) 发布 @else 下架 @endif</td>
  23. <td>
  24. <a class="btn btn-xs btn-primary" href="{{route('admin.bai.jia.article.edit',['id'=>$article->id])}}">
  25. <i data-toggle="tooltip" data-placement="top" class="fa fa-pencil-square-o" title="" data-original-title="编辑"></i></a>
  26. <a class="btn btn-xs btn-danger article-delete" data-url="{{ route('admin.bai.jia.article.delete', ['id'=>$article->id]) }}">
  27. <i data-toggle="tooltip" data-placement="top" class="fa fa-trash" title="删除"></i></a>
  28. <a>
  29. <i class="fa switch @if($article->status) fa-toggle-on @else fa-toggle-off @endif" title="切换状态" value= {{$article->status}} ><input type="hidden" value={{$article->id}}></i>
  30. </a>
  31. </td>
  32. </tr>
  33. @endforeach
  34. </tbody>
  35. </table>
  36. <div id="comment_modal" class="modal inmodal fade"></div>
  37. </div>
  38. <div class="clearfix"></div>
  39. <div class="box-footer clearfix">
  40. {!! $articles->render() !!}
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <script>
  46. $('.article-delete').on('click', function () {
  47. var thisPoint = $(this);
  48. var url = thisPoint.data('url');
  49. swal({
  50. title: "确认删除此项?",
  51. imageUrl: "/assets/backend/activity/backgroundImage/delete-xxl.png",
  52. showCancelButton: true,
  53. confirmButtonColor: "#DD6B55",
  54. confirmButtonText: "确认",
  55. cancelButtonText: "取消",
  56. closeOnConfirm: false,
  57. closeOnCancel: true
  58. },
  59. function (isConfirm) {
  60. if (isConfirm) {
  61. $.ajax({
  62. type: "GET",
  63. url: url,
  64. success: function (data) {
  65. if (data.status) {
  66. swal({
  67. title: "删除成功",
  68. text: "",
  69. type: "success"
  70. },
  71. function () {
  72. location.reload();
  73. });
  74. }
  75. }
  76. });
  77. } else {
  78. }
  79. });
  80. });
  81. $('.switch').on('click', function () {
  82. var value = $(this).attr('value');
  83. var modelId = $(this).children('input').attr('value');
  84. value = parseInt(value);
  85. modelId = parseInt(modelId);
  86. if (value == 1) {
  87. value = 0;
  88. } else {
  89. value = 1;
  90. }
  91. var that = $(this);
  92. $.post("{{route('admin.bai.jia.article.status')}}",
  93. {
  94. status: value,
  95. modelId: modelId
  96. },
  97. function (data, status) {
  98. if (status) {
  99. if (1 == value) {
  100. that.removeClass('fa-toggle-off');
  101. that.addClass('fa-toggle-on');
  102. that.parent('a').parent('td').prev('td').html('发布');
  103. } else {
  104. that.removeClass('fa-toggle-on');
  105. that.addClass('fa-toggle-off');
  106. that.parent('a').parent('td').prev('td').html('下架');
  107. }
  108. that.attr('value', value);
  109. }
  110. });
  111. })
  112. </script>