replyTicket.blade.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. @if($ticket->status != 2)
  11. <div class="panel-actions">
  12. <a href="/ticket" class="btn btn-default">返 回</a>
  13. <button class="btn btn-danger" onclick="closeTicket()"> {{trans('home.ticket_close')}} </button>
  14. </div>
  15. @endif
  16. </div>
  17. <div class="panel-body">
  18. <div class="chat-box">
  19. <div class="chats">
  20. @component('components.chatUnit',['ticket'=>$ticket])@endcomponent
  21. @foreach ($replyList as $reply)
  22. @component('components.chatUnit',['ticket'=>$reply])@endcomponent
  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. type: "POST",
  63. url: "/ticket/close",
  64. async: true,
  65. data: {_token: '{{csrf_token()}}', id: '{{$ticket->id}}'},
  66. dataType: 'json',
  67. success: function (ret) {
  68. swal.fire({
  69. title: ret.message,
  70. type: 'success',
  71. timer: 1000,
  72. }).then(() => window.location.href = '/ticket')
  73. },
  74. error: function () {
  75. swal.fire("未知错误!请通知客服!")
  76. }
  77. })
  78. }
  79. })
  80. }
  81. // 回复工单
  82. function replyTicket() {
  83. const content = document.getElementById('editor').value;
  84. if (content.trim() === '') {
  85. swal.fire({title: '您未填写工单内容!', type: 'warning', timer: 1500});
  86. return false;
  87. }
  88. swal.fire({
  89. title: '确定回复工单?',
  90. type: 'question',
  91. allowEnterKey: false,
  92. showCancelButton: true,
  93. cancelButtonText: '{{trans('home.ticket_close')}}',
  94. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  95. }).then((result) => {
  96. if (result.value) {
  97. $.post("/ticket/reply", {
  98. _token: '{{csrf_token()}}',
  99. id: '{{$ticket->id}}',
  100. content: content
  101. }, function (ret) {
  102. if (ret.status === 'success') {
  103. swal.fire({
  104. title: ret.message,
  105. type: 'success',
  106. timer: 1000,
  107. showConfirmButton: false
  108. }).then(() => window.location.reload())
  109. } else {
  110. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  111. }
  112. });
  113. }
  114. })
  115. }
  116. </script>
  117. @endsection