reply.blade.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. @extends('admin.layouts')
  2. @section('content')
  3. <div class="page-content">
  4. <div class="panel panel-bordered">
  5. <div class="panel-heading">
  6. <h1 class="panel-title cyan-600"><i class="icon wb-help-circle"></i> {{$ticket->title}} </h1>
  7. <div class="panel-actions">
  8. <a href="{{route('admin.ticket.index')}}" class="btn btn-default">返 回</a>
  9. @if($ticket->status !== 2)
  10. <button class="btn btn-danger" onclick="closeTicket()"> {{trans('home.ticket_close')}} </button>
  11. @endif
  12. </div>
  13. </div>
  14. <div class="panel-body">
  15. <div class="chat-box">
  16. <div class="chats">
  17. <x-chat-unit :user="Auth::getUser()" :ticket="$ticket"/>
  18. @foreach ($replyList as $reply)
  19. <x-chat-unit :user="Auth::getUser()" :ticket="$reply"/>
  20. @endforeach
  21. </div>
  22. </div>
  23. </div>
  24. @if($ticket->status !== 2)
  25. <div class="panel-footer pb-30">
  26. <form>
  27. <div class="input-group">
  28. <input type="text" class="form-control" id="editor" placeholder="{{trans('home.ticket_reply_placeholder')}}"/>
  29. <span class="input-group-btn">
  30. <button type="button" class="btn btn-primary" onclick="replyTicket()"> {{trans('home.ticket_reply')}}</button>
  31. </span>
  32. </div>
  33. </form>
  34. </div>
  35. @endif
  36. </div>
  37. </div>
  38. @endsection
  39. @section('script')
  40. <script type="text/javascript">
  41. //回车检测
  42. $(document).on('keypress', 'input', function (e) {
  43. if (e.which === 13) {
  44. replyTicket();
  45. return false;
  46. }
  47. });
  48. // 关闭工单
  49. function closeTicket() {
  50. swal.fire({
  51. title: '确定关闭工单?',
  52. icon: 'question',
  53. showCancelButton: true,
  54. cancelButtonText: '{{trans('home.ticket_close')}}',
  55. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  56. }).then((result) => {
  57. if (result.value) {
  58. $.ajax({
  59. method: 'DELETE',
  60. url: '{{route('admin.ticket.destroy', $ticket->id)}}',
  61. async: true,
  62. data: {_token: '{{csrf_token()}}'},
  63. dataType: 'json',
  64. success: function (ret) {
  65. if (ret.status === 'success') {
  66. swal.fire({
  67. title: ret.message,
  68. icon: 'success',
  69. timer: 1000,
  70. showConfirmButton: false
  71. }).then(() => window.location.href = '{{route('admin.ticket.index')}}');
  72. } else {
  73. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  74. }
  75. },
  76. error: function () {
  77. swal.fire({title: '未知错误!请通知客服', icon: 'error'});
  78. },
  79. });
  80. }
  81. });
  82. }
  83. // 回复工单
  84. function replyTicket() {
  85. const content = document.getElementById('editor').value;
  86. if (content.trim() === '') {
  87. swal.fire({title: '您未填写工单内容!', icon: 'warning', timer: 1500});
  88. return false;
  89. }
  90. swal.fire({
  91. title: '确定回复工单?',
  92. icon: 'question',
  93. allowEnterKey: false,
  94. showCancelButton: true,
  95. cancelButtonText: '{{trans('home.ticket_close')}}',
  96. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  97. }).then((result) => {
  98. if (result.value) {
  99. $.ajax({
  100. method: 'PUT',
  101. url: '{{route('admin.ticket.update', $ticket->id)}}',
  102. data: {_token: '{{csrf_token()}}', content: content},
  103. dataType: 'json',
  104. success: function (ret) {
  105. if (ret.status === 'success') {
  106. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  107. } else {
  108. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  109. }
  110. },
  111. error: function () {
  112. swal.fire({title: '未知错误!请查看运行日志', icon: 'error'});
  113. },
  114. });
  115. }
  116. });
  117. }
  118. </script>
  119. @endsection