index.blade.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" type="text/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">工单列表</h3>
  10. <div class="panel-actions">
  11. <button class="btn btn-primary btn-animate btn-animate-side" data-toggle="modal" data-target="#add_ticket_modal">
  12. <span>
  13. <i class="icon wb-plus" aria-hidden="true"></i> {{trans('home.ticket_table_new_button')}}
  14. </span>
  15. </button>
  16. </div>
  17. </div>
  18. <div class="panel-body">
  19. <div class="form-row">
  20. <div class="form-group col-lg-3 col-sm-6">
  21. <input type="text" class="form-control" name="email" id="email" value="{{Request::input('email')}}" placeholder="用户名" autocomplete="off"/>
  22. </div>
  23. <div class="form-group col-lg-2 col-sm-6 btn-group">
  24. <button class="btn btn-primary" onclick="Search()">搜 索</button>
  25. <a href="{{route('admin.ticket.index')}}" class="btn btn-danger">重 置</a>
  26. </div>
  27. </div>
  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> 用户名</th>
  33. <th> 标题</th>
  34. <th> 状态</th>
  35. <th> 操作</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. 【账号已删除】
  45. @else
  46. <a href="{{route('admin.user.index', ['id'=>$ticket->user->id])}}" target="_blank">{{$ticket->user->email}}</a>
  47. @endif
  48. </td>
  49. <td>
  50. {{$ticket->title}}
  51. </td>
  52. <td>
  53. {!!$ticket->status_label!!}
  54. </td>
  55. <td>
  56. <a href="{{route('admin.ticket.edit',$ticket->id)}}" class="btn btn-animate btn-animate-vertical btn-outline-info">
  57. <span>
  58. @if($ticket->status === 2)
  59. <i class="icon wb-eye" aria-hidden="true" style="left: 40%"> </i>{{trans('home.ticket_table_view')}}
  60. @else
  61. <i class="icon wb-check" aria-hidden="true" style="left: 40%"> </i>{{trans('home.ticket_open')}}
  62. @endif
  63. </span>
  64. </a>
  65. </td>
  66. </tr>
  67. @endforeach
  68. </tbody>
  69. </table>
  70. </div>
  71. <div class="panel-footer">
  72. <div class="row">
  73. <div class="col-sm-4">
  74. 共 <code>{{$ticketList->total()}}</code> 个工单
  75. </div>
  76. <div class="col-sm-8">
  77. <nav class="Page navigation float-right">
  78. {{$ticketList->links()}}
  79. </nav>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. <div id="add_ticket_modal" class="modal fade" tabindex="-1" data-focus-on="input:first" data-keyboard="false">
  86. <div class="modal-dialog modal-simple modal-center modal-lg">
  87. <div class="modal-content">
  88. <div class="modal-header">
  89. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  90. <span aria-hidden="true">×</span>
  91. </button>
  92. <h4 class="modal-title"> {{trans('home.ticket_table_new_button')}} </h4>
  93. </div>
  94. <div class="modal-body">
  95. <div class="form-group row">
  96. <label for="domain" class="col-2 col-form-label">域名</label>
  97. <div class="input-group col-10">
  98. <input type="number" class="form-control col-md-4" name="user_id" id="user_id" placeholder="用户ID"/>
  99. <div class="input-group-prepend">
  100. <span class="input-group-text">或</span>
  101. </div>
  102. <input type="email" class="form-control col-md-8" name="user_email" id="user_email" placeholder="用户邮箱"/>
  103. </div>
  104. </div>
  105. <div class="form-group">
  106. <input type="text" class="form-control" name="title" id="title" placeholder="标题">
  107. </div>
  108. <div class="form-group">
  109. <textarea type="text" class="form-control" rows="5" name="content" id="content" placeholder="内容"></textarea>
  110. </div>
  111. </div>
  112. <div class="modal-footer">
  113. <button type="button" data-dismiss="modal" class="btn btn-danger"> {{trans('home.ticket_cancel')}} </button>
  114. <button type="button" data-dismiss="modal" class="btn btn-success" onclick="createTicket()"> {{trans('home.ticket_confirm')}} </button>
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. @endsection
  120. @section('script')
  121. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  122. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  123. <script type="text/javascript">
  124. //回车检测
  125. $(document).on('keypress', 'input', function(e) {
  126. if (e.which === 13) {
  127. Search();
  128. return false;
  129. }
  130. });
  131. // 搜索
  132. function Search() {
  133. window.location.href = '{{route('admin.ticket.index')}}?email=' + $('#email').val();
  134. }
  135. // 发起工单
  136. function createTicket() {
  137. const id = $('#user_id').val();
  138. const email = $('#user_email').val();
  139. const title = $('#title').val();
  140. const content = $('#content').val();
  141. if (id.trim() === '' && email.trim() === '') {
  142. swal.fire({title: '请填入目标用户信息!', type: 'warning'});
  143. return false;
  144. }
  145. if (title.trim() === '') {
  146. swal.fire({title: '您未填写工单标题!', type: 'warning'});
  147. return false;
  148. }
  149. if (content.trim() === '') {
  150. swal.fire({title: '您未填写工单内容!', type: 'warning'});
  151. return false;
  152. }
  153. swal.fire({
  154. title: '确定提交工单?',
  155. type: 'question',
  156. showCancelButton: true,
  157. cancelButtonText: '{{trans('home.ticket_close')}}',
  158. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  159. }).then((result) => {
  160. if (result.value) {
  161. $.post('{{route('admin.ticket.store')}}', {
  162. _token: '{{csrf_token()}}',
  163. id: id,
  164. email: email,
  165. title: title,
  166. content: content,
  167. }, function(ret) {
  168. if (ret.status === 'success') {
  169. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).
  170. then(() => window.location.reload());
  171. }
  172. else {
  173. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  174. }
  175. });
  176. }
  177. });
  178. }
  179. </script>
  180. @endsection