CloseTicketDialog.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <q-dialog ref="dialogRef" @hide="onDialogHide">
  3. <div style="width: 100%; max-width: 500px">
  4. <q-card class="overflow-hidden" style="width: 100%">
  5. <DefaultDialogHeader title="Encerrar Ticket" @close="onDialogCancel" />
  6. <q-card-section class="q-pt-sm column q-gutter-y-md">
  7. <DefaultSelect
  8. v-model="resolved"
  9. label="A solicitação foi resolvida?"
  10. :options="resolvedOptions"
  11. emit-value
  12. map-options
  13. />
  14. <p v-if="resolved !== null" class="text-body2 q-mb-none">
  15. <template v-if="resolved">
  16. Sua solicitação foi resolvida com sucesso, hora de finalizar este suporte.
  17. </template>
  18. <template v-else>
  19. Sua solicitação não foi resolvida, finalize o suporte.
  20. </template>
  21. </p>
  22. </q-card-section>
  23. <q-card-actions align="right" class="q-px-md q-pb-md">
  24. <q-btn
  25. outline
  26. color="primary"
  27. label="Cancelar"
  28. @click="onDialogCancel"
  29. />
  30. <q-btn
  31. v-if="resolved !== null && ticket.status === 'in_progress'"
  32. color="primary"
  33. label="Encerrar"
  34. :loading="loading"
  35. @click="onOKClick"
  36. />
  37. </q-card-actions>
  38. </q-card>
  39. </div>
  40. </q-dialog>
  41. </template>
  42. <script setup>
  43. import { ref } from "vue";
  44. import { useDialogPluginComponent } from "quasar";
  45. import DefaultDialogHeader from "src/components/defaults/DefaultDialogHeader.vue";
  46. import DefaultSelect from "src/components/defaults/DefaultSelect.vue";
  47. import { updateSupportTicket } from "src/api/support_ticket";
  48. defineEmits([...useDialogPluginComponent.emits]);
  49. const { ticket } = defineProps({
  50. ticket: {
  51. type: Object,
  52. required: true,
  53. },
  54. });
  55. const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } =
  56. useDialogPluginComponent();
  57. const loading = ref(false);
  58. const resolved = ref(null);
  59. const resolvedOptions = [
  60. { label: "Sim", value: true },
  61. { label: "Não", value: false },
  62. ];
  63. const onOKClick = async () => {
  64. loading.value = true;
  65. try {
  66. const status = resolved.value ? "resolved" : "unresolved";
  67. await updateSupportTicket(ticket.id, { status });
  68. onDialogOK(true);
  69. } finally {
  70. loading.value = false;
  71. }
  72. };
  73. </script>