replyTicket.blade.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. @php
  17. $currentUser = Auth::user();
  18. @endphp
  19. <x-chat-unit :user="$currentUser" :ticket="$ticket" />
  20. @foreach ($replyList as $reply)
  21. <x-chat-unit :user="$currentUser" :ticket="$reply" />
  22. @endforeach
  23. </div>
  24. </div>
  25. </div>
  26. <div class="panel-footer pb-30">
  27. <form>
  28. <div class="input-group">
  29. <input class="form-control" id="editor" type="text" placeholder="{{ trans('user.ticket.reply_placeholder') }}" />
  30. <span class="input-group-btn">
  31. <button class="btn btn-primary" type="button" onclick="replyTicket()"> {{ trans('common.send') }}</button>
  32. </span>
  33. </div>
  34. </form>
  35. </div>
  36. </div>
  37. </div>
  38. @endsection
  39. @section('javascript')
  40. <script>
  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: '{{ trans('user.ticket.close') }}',
  52. text: '{{ trans('user.ticket.close_tips') }}',
  53. icon: 'question',
  54. showCancelButton: true,
  55. cancelButtonText: '{{ trans('common.close') }}',
  56. confirmButtonText: '{{ trans('common.confirm') }}',
  57. }).then((result) => {
  58. if (result.value) {
  59. $.ajax({
  60. method: 'POST',
  61. url: '{{ route('closeTicket') }}',
  62. async: true,
  63. data: {
  64. _token: '{{ csrf_token() }}',
  65. id: '{{ $ticket->id }}'
  66. },
  67. dataType: 'json',
  68. success: function(ret) {
  69. swal.fire({
  70. title: ret.message,
  71. icon: 'success',
  72. timer: 1300,
  73. }).then(() => window.location.href = '{{ route('ticket') }}');
  74. },
  75. error: function() {
  76. swal.fire({
  77. title: '{{ trans('user.ticket.error') }}',
  78. icon: 'error'
  79. });
  80. },
  81. });
  82. }
  83. });
  84. }
  85. // 回复工单
  86. function replyTicket() {
  87. const content = document.getElementById('editor').value;
  88. if (content.trim() === '') {
  89. swal.fire({
  90. title: '{{ ucfirst(trans('validation.required', ['attribute' => trans('validation.attributes.content')])) }}!',
  91. icon: 'warning',
  92. timer: 1500,
  93. });
  94. return false;
  95. }
  96. swal.fire({
  97. title: '{{ trans('user.ticket.reply_confirm') }}',
  98. icon: 'question',
  99. allowEnterKey: false,
  100. showCancelButton: true,
  101. cancelButtonText: '{{ trans('common.close') }}',
  102. confirmButtonText: '{{ trans('common.confirm') }}',
  103. }).then((result) => {
  104. if (result.value) {
  105. $.post('{{ route('replyTicket') }}', {
  106. _token: '{{ csrf_token() }}',
  107. id: '{{ $ticket->id }}',
  108. content: content,
  109. }, function(ret) {
  110. if (ret.status === 'success') {
  111. swal.fire({
  112. title: ret.message,
  113. icon: 'success',
  114. timer: 1000,
  115. showConfirmButton: false,
  116. }).then(() => window.location.reload());
  117. } else {
  118. swal.fire({
  119. title: ret.message,
  120. icon: 'error'
  121. }).then(() => window.location.reload());
  122. }
  123. });
  124. }
  125. });
  126. }
  127. </script>
  128. @endsection