|
@@ -25,16 +25,12 @@
|
|
|
class="col-12"
|
|
class="col-12"
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
- <DefaultInputDatePicker
|
|
|
|
|
- v-model:untreated-date="form.date"
|
|
|
|
|
- label="Data do Registro"
|
|
|
|
|
- class="col-6"
|
|
|
|
|
- />
|
|
|
|
|
-
|
|
|
|
|
<DefaultSelect
|
|
<DefaultSelect
|
|
|
- v-model="form.priority"
|
|
|
|
|
|
|
+ v-model="form.severity"
|
|
|
label="Prioridade"
|
|
label="Prioridade"
|
|
|
:options="priorityOptions"
|
|
:options="priorityOptions"
|
|
|
|
|
+ emit-value
|
|
|
|
|
+ map-options
|
|
|
class="col-6"
|
|
class="col-6"
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
@@ -46,7 +42,7 @@
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
<DefaultSelect
|
|
<DefaultSelect
|
|
|
- v-model="form.unit_target"
|
|
|
|
|
|
|
+ v-model="form.scope"
|
|
|
label="Destino"
|
|
label="Destino"
|
|
|
:options="unitTargetOptions"
|
|
:options="unitTargetOptions"
|
|
|
emit-value
|
|
emit-value
|
|
@@ -61,8 +57,8 @@
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
<UnitSelect
|
|
<UnitSelect
|
|
|
- v-if="form.unit_target === 'specific'"
|
|
|
|
|
- v-model="form.unit"
|
|
|
|
|
|
|
+ v-if="form.scope === 'specific'"
|
|
|
|
|
+ v-model="selectedUnit"
|
|
|
class="col-6"
|
|
class="col-6"
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
@@ -128,11 +124,11 @@ import { useDialogPluginComponent } from "quasar";
|
|
|
import CustomTabComponent from "src/components/shared/CustomTabComponent.vue";
|
|
import CustomTabComponent from "src/components/shared/CustomTabComponent.vue";
|
|
|
import DefaultDialogHeader from "src/components/defaults/DefaultDialogHeader.vue";
|
|
import DefaultDialogHeader from "src/components/defaults/DefaultDialogHeader.vue";
|
|
|
import DefaultInput from "src/components/defaults/DefaultInput.vue";
|
|
import DefaultInput from "src/components/defaults/DefaultInput.vue";
|
|
|
-import DefaultInputDatePicker from "src/components/defaults/DefaultInputDatePicker.vue";
|
|
|
|
|
import DefaultSelect from "src/components/defaults/DefaultSelect.vue";
|
|
import DefaultSelect from "src/components/defaults/DefaultSelect.vue";
|
|
|
import UnitSelect from "src/components/selects/UnitSelect.vue";
|
|
import UnitSelect from "src/components/selects/UnitSelect.vue";
|
|
|
import TicketCommentCard from "./TicketCommentCard.vue";
|
|
import TicketCommentCard from "./TicketCommentCard.vue";
|
|
|
import { userStore } from "src/stores/user";
|
|
import { userStore } from "src/stores/user";
|
|
|
|
|
+import { createSupportTicket, updateSupportTicket } from "src/api/support_ticket";
|
|
|
|
|
|
|
|
defineEmits([...useDialogPluginComponent.emits]);
|
|
defineEmits([...useDialogPluginComponent.emits]);
|
|
|
|
|
|
|
@@ -151,6 +147,7 @@ const { user } = userStore();
|
|
|
const formRef = ref(null);
|
|
const formRef = ref(null);
|
|
|
const loading = ref(false);
|
|
const loading = ref(false);
|
|
|
const currentTab = ref("ticket");
|
|
const currentTab = ref("ticket");
|
|
|
|
|
+const selectedUnit = ref(ticket?.unit_id ? { value: ticket.unit_id } : null);
|
|
|
|
|
|
|
|
const tabs = computed(() => {
|
|
const tabs = computed(() => {
|
|
|
const base = [{ name: "ticket", label: "Ticket" }];
|
|
const base = [{ name: "ticket", label: "Ticket" }];
|
|
@@ -197,19 +194,23 @@ const unitTargetOptions = [
|
|
|
{ label: "Unidade Específica", value: "specific" },
|
|
{ label: "Unidade Específica", value: "specific" },
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
-const today = new Date();
|
|
|
|
|
-const todayUntreated = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, "0")}-${String(today.getDate()).padStart(2, "0")}`;
|
|
|
|
|
-
|
|
|
|
|
const form = ref({
|
|
const form = ref({
|
|
|
- title: ticket?.title ?? null,
|
|
|
|
|
- date: ticket?.date ?? todayUntreated,
|
|
|
|
|
- priority: ticket?.priority ?? null,
|
|
|
|
|
- unit_target: ticket?.unit_target ?? null,
|
|
|
|
|
- unit: ticket?.unit ?? null,
|
|
|
|
|
- sector: ticket?.sector ?? null,
|
|
|
|
|
|
|
+ title: ticket?.title ?? null,
|
|
|
|
|
+ severity: ticket?.severity ?? null,
|
|
|
|
|
+ scope: ticket?.scope ?? null,
|
|
|
|
|
+ sector: ticket?.sector ?? null,
|
|
|
description: ticket?.description ?? null,
|
|
description: ticket?.description ?? null,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+const buildPayload = () => ({
|
|
|
|
|
+ title: form.value.title,
|
|
|
|
|
+ severity: form.value.severity,
|
|
|
|
|
+ scope: form.value.scope,
|
|
|
|
|
+ sector: form.value.sector || null,
|
|
|
|
|
+ description: form.value.description || null,
|
|
|
|
|
+ unit_id: form.value.scope === "specific" ? (selectedUnit.value?.value ?? null) : null,
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
const onAddComment = () => {
|
|
const onAddComment = () => {
|
|
|
// TODO: implement add comment
|
|
// TODO: implement add comment
|
|
|
};
|
|
};
|
|
@@ -217,8 +218,13 @@ const onAddComment = () => {
|
|
|
const onOKClick = async () => {
|
|
const onOKClick = async () => {
|
|
|
loading.value = true;
|
|
loading.value = true;
|
|
|
try {
|
|
try {
|
|
|
- // TODO: implement save
|
|
|
|
|
- onDialogOK(form.value);
|
|
|
|
|
|
|
+ const payload = buildPayload();
|
|
|
|
|
+ if (ticket?.id) {
|
|
|
|
|
+ await updateSupportTicket(ticket.id, payload);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ await createSupportTicket(payload);
|
|
|
|
|
+ }
|
|
|
|
|
+ onDialogOK(true);
|
|
|
} finally {
|
|
} finally {
|
|
|
loading.value = false;
|
|
loading.value = false;
|
|
|
}
|
|
}
|