index.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
  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">{{ trans('admin.ticket.title') }}</h3>
  10. @can('admin.ticket.store')
  11. <div class="panel-actions">
  12. <button class="btn btn-primary btn-animate btn-animate-side" data-toggle="modal" data-target="#add_ticket_modal">
  13. <span>
  14. <i class="icon wb-plus" aria-hidden="true"></i> {{ trans('user.ticket.new') }}
  15. </span>
  16. </button>
  17. </div>
  18. @endcan
  19. </div>
  20. <div class="panel-body">
  21. <form class="form-row">
  22. <div class="form-group col-lg-3 col-sm-6">
  23. <input class="form-control" name="username" type="text" value="{{ Request::query('username') }}"
  24. placeholder="{{ trans('model.user.username') }}" autocomplete="off" />
  25. </div>
  26. <div class="form-group col-lg-2 col-sm-6 btn-group">
  27. <button class="btn btn-primary" type="submit">{{ trans('common.search') }}</button>
  28. <a class="btn btn-danger" href="{{ route('admin.ticket.index') }}">{{ trans('common.reset') }}</a>
  29. </div>
  30. </form>
  31. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  32. <thead class="thead-default">
  33. <tr>
  34. <th> #</th>
  35. <th> {{ trans('model.user.username') }}</th>
  36. <th> {{ trans('validation.attributes.title') }}</th>
  37. <th> {{ trans('common.status.attribute') }}</th>
  38. <th> {{ trans('common.action') }}</th>
  39. </tr>
  40. </thead>
  41. <tbody>
  42. @foreach ($ticketList as $ticket)
  43. <tr>
  44. <td> {{ $ticket->id }} </td>
  45. <td>
  46. @if (!$ticket->user)
  47. 【{{ trans('common.deleted_item', ['attribute' => trans('common.account')]) }}】
  48. @else
  49. @can('admin.user.index')
  50. <a href="{{ route('admin.user.index', ['id' => $ticket->user->id]) }}" target="_blank">{{ $ticket->user->username }}</a>
  51. @else
  52. {{ $ticket->user->username }}
  53. @endcan
  54. @endif
  55. </td>
  56. <td>
  57. {{ $ticket->title }}
  58. </td>
  59. <td>
  60. {!! $ticket->status_label !!}
  61. </td>
  62. <td>
  63. @can('admin.ticket.edit')
  64. <a class="btn btn-animate btn-animate-vertical btn-outline-info" href="{{ route('admin.ticket.edit', $ticket) }}">
  65. <span>
  66. @if ($ticket->status === 2)
  67. <i class="icon wb-eye" aria-hidden="true" style="left: 40%"> </i>{{ trans('common.view') }}
  68. @else
  69. <i class="icon wb-check" aria-hidden="true" style="left: 40%"> </i>{{ trans('common.open') }}
  70. @endif
  71. </span>
  72. </a>
  73. @endcan
  74. </td>
  75. </tr>
  76. @endforeach
  77. </tbody>
  78. </table>
  79. </div>
  80. <div class="panel-footer">
  81. <div class="row">
  82. <div class="col-sm-4">
  83. {!! trans('admin.ticket.counts', ['num' => $ticketList->total()]) !!}
  84. </div>
  85. <div class="col-sm-8">
  86. <nav class="Page navigation float-right">
  87. {{ $ticketList->links() }}
  88. </nav>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. @can('admin.ticket.store')
  95. <div class="modal fade" id="add_ticket_modal" data-focus-on="input:first" data-keyboard="false" tabindex="-1">
  96. <div class="modal-dialog modal-simple modal-center modal-lg">
  97. <div class="modal-content">
  98. <div class="modal-header">
  99. <button class="close" data-dismiss="modal" type="button" aria-label="{{ trans('common.close') }}">
  100. <span aria-hidden="true">×</span>
  101. </button>
  102. <h4 class="modal-title"> {{ trans('user.ticket.new') }} </h4>
  103. </div>
  104. <div class="modal-body">
  105. <div class="form-group row">
  106. <label class="col-2 col-form-label" for="userId">{{ trans('model.user.attribute') }}</label>
  107. <div class="input-group col-10">
  108. <input class="form-control col-md-4" id="uid" name="uid" type="number" placeholder="{{ trans('model.user.id') }}" />
  109. <div class="input-group-prepend">
  110. <span class="input-group-text">{{ trans('common.or') }}</span>
  111. </div>
  112. <input class="form-control col-md-8" id="username" name="username" type="text" placeholder="{{ trans('model.user.username') }}" />
  113. </div>
  114. </div>
  115. <div class="form-group">
  116. <input class="form-control" id="title" name="title" type="text" placeholder="{{ trans('validation.attributes.title') }}">
  117. </div>
  118. <div class="form-group">
  119. <textarea class="form-control" id="content" name="content" type="text" rows="5" placeholder="{{ trans('validation.attributes.content') }}"></textarea>
  120. </div>
  121. </div>
  122. <div class="modal-footer">
  123. <button class="btn btn-danger mr-auto" data-dismiss="modal" type="button"> {{ trans('common.cancel') }} </button>
  124. <button class="btn btn-success" data-dismiss="modal" type="button" onclick="createTicket()"> {{ trans('common.confirm') }} </button>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. @endcan
  130. @endsection
  131. @section('javascript')
  132. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js"></script>
  133. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
  134. <script>
  135. @can('admin.ticket.store')
  136. // 发起工单
  137. function createTicket() {
  138. const uid = $('#uid').val();
  139. const username = $('#username').val();
  140. const title = $('#title').val();
  141. const content = $('#content').val();
  142. if (uid.trim() === '' && username.trim() === '') {
  143. swal.fire({
  144. title: '{{ trans('admin.ticket.send_to') }}',
  145. icon: 'warning'
  146. });
  147. return false;
  148. }
  149. if (title.trim() === '') {
  150. swal.fire({
  151. title: '{{ trans('validation.required', ['attribute' => trans('validation.attributes.title')]) }}',
  152. icon: 'warning',
  153. });
  154. return false;
  155. }
  156. if (content.trim() === '') {
  157. swal.fire({
  158. title: '{{ trans('validation.required', ['attribute' => trans('validation.attributes.content')]) }}',
  159. icon: 'warning',
  160. });
  161. return false;
  162. }
  163. swal.fire({
  164. title: '{{ trans('user.ticket.submit_tips') }}',
  165. icon: 'question',
  166. showCancelButton: true,
  167. cancelButtonText: '{{ trans('common.close') }}',
  168. confirmButtonText: '{{ trans('common.confirm') }}',
  169. }).then((result) => {
  170. if (result.value) {
  171. $.ajax({
  172. method: 'POST',
  173. url: "{{ route('admin.ticket.store') }}",
  174. data: {
  175. _token: '{{ csrf_token() }}',
  176. uid: uid,
  177. username: username,
  178. title: title,
  179. content: content,
  180. },
  181. dataType: 'json',
  182. success: function(ret) {
  183. $('#add_ticket_modal').modal('hide');
  184. if (ret.status === 'success') {
  185. swal.fire({
  186. title: ret.message,
  187. icon: 'success',
  188. timer: 1000,
  189. showConfirmButton: false,
  190. }).then(() => window.location.reload());
  191. } else {
  192. swal.fire({
  193. title: ret.message,
  194. icon: 'error'
  195. }).then(() => window.location.reload());
  196. }
  197. },
  198. error: function(data) {
  199. $('#add_ticket_modal').modal('hide');
  200. let str = '';
  201. const errors = data.responseJSON;
  202. if ($.isEmptyObject(errors) === false) {
  203. $.each(errors.errors, function(index, value) {
  204. str += '<li>' + value + '</li>';
  205. });
  206. swal.fire({
  207. title: '{{ trans('admin.hint') }}',
  208. html: str,
  209. icon: 'error',
  210. confirmButtonText: '{{ trans('common.confirm') }}',
  211. });
  212. }
  213. },
  214. });
  215. }
  216. });
  217. }
  218. @endcan
  219. </script>
  220. @endsection