replyTicket.blade.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. @extends('user.layouts')
  2. @section('css')
  3. <link rel="stylesheet" href="/assets/examples/css/structure/chat.css">
  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 onkeydown="if (event.keyCode === 13){replyTicket()}">
  63. <div class="input-group">
  64. <input id="editor" type="text/plain" class="form-control" 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. function closeTicket() {
  79. swal.fire({
  80. title: '{{trans('home.ticket_close_title')}}',
  81. text: '{{trans('home.ticket_close_content')}}',
  82. type: 'warning',
  83. showCancelButton: true,
  84. cancelButtonText: '{{trans('home.ticket_close')}}',
  85. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  86. }).then((result) => {
  87. if (result.value) {
  88. $.ajax({
  89. type: "POST",
  90. url: "/closeTicket",
  91. async: true,
  92. data: {_token: '{{csrf_token()}}', id: '{{$ticket->id}}'},
  93. dataType: 'json',
  94. success: function (ret) {
  95. swal.fire({
  96. title: ret.message,
  97. type: 'success',
  98. timer: 1300
  99. }).then(() => window.location.href = '/tickets')
  100. },
  101. error: function () {
  102. swal.fire("未知错误!请通知客服!")
  103. }
  104. });
  105. }
  106. })
  107. }
  108. // 回复工单
  109. function replyTicket() {
  110. const content = document.getElementById('editor').value;
  111. if (content.trim() === '') {
  112. swal.fire({title: '您未填写工单内容!', type: 'warning'});
  113. return false;
  114. }
  115. swal.fire({
  116. title: '确定回复工单?',
  117. type: 'question',
  118. allowEnterKey: false,
  119. showCancelButton: true,
  120. cancelButtonText: '{{trans('home.ticket_close')}}',
  121. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  122. }).then((result) => {
  123. if (result.value) {
  124. $.post("/replyTicket", {
  125. _token: '{{csrf_token()}}',
  126. id: '{{$ticket->id}}',
  127. content: content
  128. }, function (ret) {
  129. if (ret.status === 'success') {
  130. swal.fire({title: ret.message, type: 'success', timer: 1000})
  131. .then(() => window.location.reload())
  132. } else {
  133. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  134. }
  135. });
  136. }
  137. })
  138. }
  139. </script>
  140. @endsection