replyTicket.blade.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. @extends('user.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. @if($ticket->status !== 2)
  8. <div class="panel-actions">
  9. <button class="btn btn-danger" onclick="closeTicket()"> {{trans('common.close')}} </button>
  10. </div>
  11. @endif
  12. </div>
  13. <div class="panel-body">
  14. <div class="chat-box">
  15. <div class="chats">
  16. <x-chat-unit :user="Auth::getUser()" :ticket="$ticket"/>
  17. @foreach ($replyList as $reply)
  18. <x-chat-unit :user="Auth::getUser()" :ticket="$reply"/>
  19. @endforeach
  20. </div>
  21. </div>
  22. </div>
  23. <div class="panel-footer pb-30">
  24. <form>
  25. <div class="input-group">
  26. <input type="text" class="form-control" id="editor" placeholder="{{trans('user.ticket.reply_placeholder')}}"/>
  27. <span class="input-group-btn">
  28. <button type="button" class="btn btn-primary" onclick="replyTicket()"> {{trans('common.send')}}</button>
  29. </span>
  30. </div>
  31. </form>
  32. </div>
  33. </div>
  34. </div>
  35. @endsection
  36. @section('javascript')
  37. <script>
  38. //回车检测
  39. $(document).on('keypress', 'input', function(e) {
  40. if (e.which === 13) {
  41. replyTicket();
  42. return false;
  43. }
  44. });
  45. // 关闭工单
  46. function closeTicket() {
  47. swal.fire({
  48. title: '{{trans('user.ticket.close')}}',
  49. text: '{{trans('user.ticket.close_tips')}}',
  50. icon: 'question',
  51. showCancelButton: true,
  52. cancelButtonText: '{{trans('common.close')}}',
  53. confirmButtonText: '{{trans('common.confirm')}}',
  54. }).then((result) => {
  55. if (result.value) {
  56. $.ajax({
  57. method: 'POST',
  58. url: '{{route('closeTicket')}}',
  59. async: true,
  60. data: {_token: '{{csrf_token()}}', id: '{{$ticket->id}}'},
  61. dataType: 'json',
  62. success: function(ret) {
  63. swal.fire({
  64. title: ret.message,
  65. icon: 'success',
  66. timer: 1300,
  67. }).then(() => window.location.href = '{{route('ticket')}}');
  68. },
  69. error: function() {
  70. swal.fire({title: '{{trans('user.ticket.error')}}', icon: 'error'});
  71. },
  72. });
  73. }
  74. });
  75. }
  76. // 回复工单
  77. function replyTicket() {
  78. const content = document.getElementById('editor').value;
  79. if (content.trim() === '') {
  80. swal.fire({title: '{{trans('validation.required', ['attribute' => trans('validation.attributes.content')])}}!', icon: 'warning', timer: 1500});
  81. return false;
  82. }
  83. swal.fire({
  84. title: '{{trans('user.ticket.reply_confirm')}}',
  85. icon: 'question',
  86. allowEnterKey: false,
  87. showCancelButton: true,
  88. cancelButtonText: '{{trans('common.close')}}',
  89. confirmButtonText: '{{trans('common.confirm')}}',
  90. }).then((result) => {
  91. if (result.value) {
  92. $.post('{{route('replyTicket')}}', {
  93. _token: '{{csrf_token()}}',
  94. id: '{{$ticket->id}}',
  95. content: content,
  96. }, function(ret) {
  97. if (ret.status === 'success') {
  98. swal.fire({
  99. title: ret.message,
  100. icon: 'success',
  101. timer: 1000,
  102. showConfirmButton: false,
  103. }).then(() => window.location.reload());
  104. } else {
  105. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  106. }
  107. });
  108. }
  109. });
  110. }
  111. </script>
  112. @endsection