index.blade.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. @extends('admin.table_layouts')
  2. @section('content')
  3. <div class="page-content container-fluid">
  4. <div class="panel">
  5. <div class="panel-heading">
  6. <h3 class="panel-title">{{ trans('admin.article.title') }}</h3>
  7. @can('admin.article.create')
  8. <div class="panel-actions">
  9. <a class="btn btn-primary" href="{{ route('admin.article.create') }}">
  10. <i class="icon wb-plus" aria-hidden="true"></i> {{ trans('common.add') }}
  11. </a>
  12. </div>
  13. @endcan
  14. </div>
  15. <div class="panel-body">
  16. <form class="form-row">
  17. <div class="form-group col-xxl-1 col-lg-1 col-md-1 col-sm-4">
  18. <input class="form-control" type="number" value="{{ Request::query('id') }}" placeholder="ID" />
  19. </div>
  20. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4">
  21. <select class="form-control" id="type" name="type" data-plugin="selectpicker" data-style="btn-outline btn-primary"
  22. title="{{ trans('model.common.type') }}">
  23. <option value="1">{{ trans('admin.article.type.knowledge') }}</option>
  24. <option value="2">{{ trans('admin.article.type.announcement') }}</option>
  25. </select>
  26. </div>
  27. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4">
  28. <select class="form-control" id="category" name="category" data-plugin="selectpicker" data-style="btn-outline btn-primary"
  29. title="{{ trans('model.article.category') }}">
  30. @foreach ($categories as $category)
  31. <option value="{{ $category->category }}">{{ $category->category }}</option>
  32. @endforeach
  33. </select>
  34. </div>
  35. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4">
  36. <select class="form-control" id="language" name="language" data-plugin="selectpicker" data-style="btn-outline btn-primary"
  37. title="{{ trans('model.article.language') }}">
  38. @foreach (config('common.language') as $key => $value)
  39. <option value="{{ $key }}">
  40. <i class="fi fi-{{ $value[1] }}" aria-hidden="true"></i>
  41. <span style="padding: inherit;">{{ $value[0] }}</span>
  42. </option>
  43. @endforeach
  44. </select>
  45. </div>
  46. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4 btn-group">
  47. <button class="btn btn-primary" type="submit">{{ trans('common.search') }}</button>
  48. <a class="btn btn-danger" href="{{ route('admin.article.index') }}">{{ trans('common.reset') }}</a>
  49. </div>
  50. </form>
  51. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  52. <thead class="thead-default">
  53. <tr>
  54. <th> #</th>
  55. <th> {{ trans('model.common.type') }}</th>
  56. <th> {{ trans('model.article.category') }}</th>
  57. <th> {{ trans('validation.attributes.title') }}</th>
  58. <th> {{ trans('model.article.language') }}</th>
  59. <th> {{ trans('model.common.sort') }}</th>
  60. <th> {{ trans('model.article.created_at') }}</th>
  61. <th> {{ trans('common.action') }}</th>
  62. </tr>
  63. </thead>
  64. <tbody>
  65. @foreach ($articles as $article)
  66. <tr>
  67. <td> {{ $article->id }} </td>
  68. @if ($article->type === 1)
  69. <td> {{ trans('admin.article.type.knowledge') }}</td>
  70. @elseif ($article->type === 2)
  71. <td> {{ trans('admin.article.type.announcement') }}</td>
  72. @else
  73. <td> {{ trans('common.status.unknown') }}</td>
  74. @endif
  75. <td class="text-left">
  76. {{ Str::limit($article->category, 30) }}
  77. </td>
  78. <td class="text-left">
  79. @if (! empty($article->logo))
  80. <img class="mr-5" src="{{ asset($article->logo) }}" alt="logo" style="height: 32px" loading="lazy" />
  81. @endif
  82. {{ Str::limit($article->title, 50) }}
  83. </td>
  84. <td>
  85. @if (isset(config('common.language')[$article->language]))
  86. <i class="fi fi-{{ config('common.language')[$article->language][1] }}" aria-hidden="true"></i>
  87. <span style="padding: inherit;">{{ config('common.language')[$article->language][0] }}</span>
  88. @else
  89. {{ __('common.status.unknown') }}
  90. @endif
  91. <td> {{ $article->sort }} </td>
  92. <td> {{ $article->created_at }} </td>
  93. <td>
  94. @canany(['admin.article.show', 'admin.article.edit', 'admin.article.destroy'])
  95. <div class="btn-group">
  96. @can('admin.article.show')
  97. <a class="btn btn-outline-success" href="{{ route('admin.article.show', $article) }}">
  98. <i class="icon wb-eye" aria-hidden="true"></i></a>
  99. @endcan
  100. @can('admin.article.edit')
  101. <a class="btn btn-outline-primary"
  102. href="{{ route('admin.article.edit', ['article' => $article->id, 'page' => Request::query('page')]) }}">
  103. <i class="icon wb-edit" aria-hidden="true"></i></a>
  104. @endcan
  105. @can('admin.article.destroy')
  106. <a class="btn btn-outline-danger"
  107. href="javascript:delArticle('{{ route('admin.article.destroy', $article->id) }}', '{{ $article->id }}')">
  108. <i class="icon wb-close" aria-hidden="true"></i></a>
  109. @endcan
  110. </div>
  111. @endcanany
  112. </td>
  113. </tr>
  114. @endforeach
  115. </tbody>
  116. </table>
  117. </div>
  118. <div class="panel-footer">
  119. <div class="row">
  120. <div class="col-sm-4">
  121. {!! trans('admin.article.counts', ['num' => $articles->total()]) !!}
  122. </div>
  123. <div class="col-sm-8">
  124. <nav class="Page navigation float-right">
  125. {{ $articles->links() }}
  126. </nav>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. @endsection
  133. @push('javascript')
  134. @can('admin.article.destroy')
  135. <script>
  136. $(document).ready(function() {
  137. $('#type').selectpicker('val', @json(Request::query('type')))
  138. $('#category').selectpicker('val', @json(Request::query('category')))
  139. $('#language').selectpicker('val', @json(Request::query('language')))
  140. })
  141. // 删除文章
  142. function delArticle(url, id) {
  143. swal.fire({
  144. title: '{{ trans('admin.confirm.delete.0', ['attribute' => trans('model.article.attribute')]) }}' +
  145. id +
  146. '{{ trans('admin.confirm.delete.1') }}',
  147. icon: 'question',
  148. showCancelButton: true,
  149. cancelButtonText: '{{ trans('common.close') }}',
  150. confirmButtonText: '{{ trans('common.confirm') }}',
  151. }).then((result) => {
  152. if (result.value) {
  153. $.ajax({
  154. method: 'DELETE',
  155. url: url,
  156. data: {
  157. _token: '{{ csrf_token() }}',
  158. },
  159. dataType: 'json',
  160. success: function(ret) {
  161. if (ret.status === 'success') {
  162. swal.fire({
  163. title: ret.message,
  164. icon: 'success',
  165. timer: 1000,
  166. showConfirmButton: false,
  167. }).then(() => window.location.reload())
  168. } else {
  169. swal.fire({
  170. title: ret.message,
  171. icon: 'error',
  172. }).then(() => window.location.reload())
  173. }
  174. },
  175. })
  176. }
  177. })
  178. }
  179. </script>
  180. @endcan
  181. @endpush