reply.blade.php 5.1 KB

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