replyTicket.blade.php 4.2 KB

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