replyTicket.blade.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. @extends('user.layouts')
  2. @section('css')
  3. <link href="/assets/examples/css/structure/chat.css" type="text/css" rel="stylesheet">
  4. @endsection
  5. @section('content')
  6. <div class="page-content">
  7. <div class="panel panel-bordered">
  8. <div class="panel-heading">
  9. <h1 class="panel-title cyan-600"><i class="icon wb-help-circle"></i>{{$ticket->title}}</h1>
  10. @if($ticket->status != 2)
  11. <div class="panel-actions">
  12. <button class="btn btn-danger" onclick="closeTicket()"> {{trans('home.ticket_close')}} </button>
  13. </div>
  14. @endif
  15. </div>
  16. <div class="panel-body">
  17. <div class="chat-box">
  18. <div class="chats">
  19. <div class="chat">
  20. <div class="chat-avatar">
  21. <p class="avatar" data-toggle="tooltip" data-placement="right" title="{{trans('home.ticket_reply_me')}}">
  22. <img src="/assets/images/astronaut.svg" alt="{{trans('home.ticket_reply_me')}}"/>
  23. </p>
  24. </div>
  25. <div class="chat-body">
  26. <div class="chat-content">
  27. <p>
  28. {!! $ticket->content !!}
  29. </p>
  30. <time class="chat-time">{{$ticket->created_at}}</time>
  31. </div>
  32. </div>
  33. </div>
  34. @foreach ($replyList as $reply)
  35. <div class="chat @if($reply->user->is_admin) chat-left @endif">
  36. <div class="chat-avatar">
  37. @if ($reply->user->is_admin)
  38. <p class="avatar" data-toggle="tooltip" data-placement="left" title="{{trans('home.ticket_reply_master')}}">
  39. <img src="/assets/images/logo64.png" alt="{{trans('home.ticket_reply_master')}}"/>
  40. </p>
  41. @else
  42. <p class="avatar" data-toggle="tooltip" data-placement="left" title="{{trans('home.ticket_reply_me')}}">
  43. <img src="/assets/images/astronaut.svg" alt="{{trans('home.ticket_reply_me')}}"/>
  44. </p>
  45. @endif
  46. </div>
  47. <div class="chat-body">
  48. <div class="chat-content">
  49. <p>
  50. {!! $reply->content!!}
  51. </p>
  52. <time class="chat-time">{{$reply->created_at}}</time>
  53. </div>
  54. </div>
  55. </div>
  56. @endforeach
  57. </div>
  58. </div>
  59. </div>
  60. @if($ticket->status != 2)
  61. <div class="panel-footer pb-30">
  62. <form>
  63. <div class="input-group">
  64. <input type="text" class="form-control" id="editor" placeholder="{{trans('home.ticket_reply_placeholder')}}"/>
  65. <span class="input-group-btn">
  66. <button type="button" class="btn btn-primary" onclick="replyTicket()"> {{trans('home.ticket_reply')}}</button>
  67. </span>
  68. </div>
  69. </form>
  70. </div>
  71. @endif
  72. </div>
  73. </div>
  74. @endsection
  75. @section('script')
  76. <script type="text/javascript">
  77. //回车检测
  78. $(document).on("keypress", "input", function (e) {
  79. if (e.which === 13) {
  80. replyTicket();
  81. return false;
  82. }
  83. });
  84. // 关闭工单
  85. function closeTicket() {
  86. swal.fire({
  87. title: '{{trans('home.ticket_close_title')}}',
  88. text: '{{trans('home.ticket_close_content')}}',
  89. type: 'warning',
  90. showCancelButton: true,
  91. cancelButtonText: '{{trans('home.ticket_close')}}',
  92. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  93. }).then((result) => {
  94. if (result.value) {
  95. $.ajax({
  96. type: "POST",
  97. url: "/closeTicket",
  98. async: true,
  99. data: {_token: '{{csrf_token()}}', id: '{{$ticket->id}}'},
  100. dataType: 'json',
  101. success: function (ret) {
  102. swal.fire({
  103. title: ret.message,
  104. type: 'success',
  105. timer: 1300
  106. }).then(() => window.location.href = '/tickets')
  107. },
  108. error: function () {
  109. swal.fire("未知错误!请通知客服!")
  110. }
  111. });
  112. }
  113. })
  114. }
  115. // 回复工单
  116. function replyTicket() {
  117. const content = document.getElementById('editor').value;
  118. if (content.trim() === '') {
  119. swal.fire({title: '您未填写工单内容!', type: 'warning'});
  120. return false;
  121. }
  122. swal.fire({
  123. title: '确定回复工单?',
  124. type: 'question',
  125. allowEnterKey: false,
  126. showCancelButton: true,
  127. cancelButtonText: '{{trans('home.ticket_close')}}',
  128. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  129. }).then((result) => {
  130. if (result.value) {
  131. $.post("/replyTicket", {
  132. _token: '{{csrf_token()}}',
  133. id: '{{$ticket->id}}',
  134. content: content
  135. }, function (ret) {
  136. if (ret.status === 'success') {
  137. swal.fire({title: ret.message, type: 'success', timer: 800, showConfirmButton: false}).then(() => window.location.reload())
  138. } else {
  139. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  140. }
  141. });
  142. }
  143. })
  144. }
  145. </script>
  146. @endsection