reply.blade.php 5.2 KB

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