index.blade.php 11 KB

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