replyTicket.blade.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. showConfirm({
  51. title: '{{ trans('common.close_item', ['attribute' => trans('user.ticket.attribute')]) }}',
  52. text: '{{ trans('user.ticket.close_tips') }}',
  53. onConfirm: function() {
  54. ajaxPatch('{{ route('ticket.close', $ticket) }}', {}, {
  55. success: function(ret) {
  56. handleResponse(ret, {
  57. redirectUrl: '{{ route('ticket.index') }}'
  58. })
  59. }
  60. });
  61. }
  62. });
  63. }
  64. // 回复工单
  65. function replyTicket() {
  66. const content = document.getElementById('editor').value;
  67. if (content.trim() === '') {
  68. showMessage({
  69. title: '{{ ucfirst(trans('validation.required', ['attribute' => trans('validation.attributes.content')])) }}!',
  70. icon: 'warning',
  71. showConfirmButton: true
  72. });
  73. return false;
  74. }
  75. showConfirm({
  76. title: '{{ trans('user.ticket.reply_confirm') }}',
  77. onConfirm: function() {
  78. ajaxPut('{{ route('ticket.reply', $ticket) }}', {
  79. content: content
  80. });
  81. }
  82. });
  83. }
  84. </script>
  85. @endsection