|
|
|
@ -3,7 +3,7 @@ import axios from 'axios';
|
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
import { useQuasar } from 'quasar';
|
|
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
|
import { useRouter, useRoute } from 'vue-router';
|
|
|
|
|
import { useRouter } from 'vue-router';
|
|
|
|
|
import { usePrintService } from 'composables/usePrintService';
|
|
|
|
|
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
|
|
|
|
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
|
|
|
@ -17,13 +17,49 @@ const props = defineProps({
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
const quasar = useQuasar();
|
|
|
|
|
const { push, currentRoute } = useRouter();
|
|
|
|
|
const { dialog, notify } = useQuasar();
|
|
|
|
|
const { t } = useI18n();
|
|
|
|
|
const { openReport, sendEmail } = usePrintService();
|
|
|
|
|
|
|
|
|
|
const ticket = ref(props.ticket);
|
|
|
|
|
const ticketId = currentRoute.value.params.id;
|
|
|
|
|
const actions = {
|
|
|
|
|
clone: async () => {
|
|
|
|
|
const opts = { message: t('Ticket cloned'), type: 'positive' };
|
|
|
|
|
let clonedTicketId;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const { data } = await axios.post(`Tickets/${ticketId}/clone`, {
|
|
|
|
|
shipped: ticket.value.shipped,
|
|
|
|
|
});
|
|
|
|
|
clonedTicketId = data;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
opts.message = t('It was not able to clone the ticket');
|
|
|
|
|
opts.type = 'negative';
|
|
|
|
|
} finally {
|
|
|
|
|
notify(opts);
|
|
|
|
|
|
|
|
|
|
if (clonedTicketId)
|
|
|
|
|
push({ name: 'TicketSummary', params: { id: clonedTicketId } });
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
remove: async () => {
|
|
|
|
|
try {
|
|
|
|
|
await axios.post(`Tickets/${ticketId}/setDeleted`);
|
|
|
|
|
|
|
|
|
|
notify({ message: t('Ticket deleted'), type: 'positive' });
|
|
|
|
|
notify({
|
|
|
|
|
message: t('You can undo this action within the first hour'),
|
|
|
|
|
icon: 'info',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
push({ name: 'TicketList' });
|
|
|
|
|
} catch (e) {
|
|
|
|
|
notify({ message: e.message, type: 'negative' });
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function openDeliveryNote(type = 'deliveryNote', documentType = 'pdf') {
|
|
|
|
|
const path = `Tickets/${ticket.value.id}/delivery-note-${documentType}`;
|
|
|
|
@ -35,7 +71,7 @@ function openDeliveryNote(type = 'deliveryNote', documentType = 'pdf') {
|
|
|
|
|
|
|
|
|
|
function sendDeliveryNoteConfirmation(type = 'deliveryNote', documentType = 'pdf') {
|
|
|
|
|
const customer = ticket.value.client;
|
|
|
|
|
quasar.dialog({
|
|
|
|
|
dialog({
|
|
|
|
|
component: SendEmailDialog,
|
|
|
|
|
componentProps: {
|
|
|
|
|
data: {
|
|
|
|
@ -67,7 +103,7 @@ function showSmsDialog(template, customData) {
|
|
|
|
|
const address = ticket.value.address;
|
|
|
|
|
const client = ticket.value.client;
|
|
|
|
|
const phone =
|
|
|
|
|
route.params.phone ||
|
|
|
|
|
currentRoute.value.params.phone ||
|
|
|
|
|
address.mobile ||
|
|
|
|
|
address.phone ||
|
|
|
|
|
client.mobile ||
|
|
|
|
@ -82,7 +118,7 @@ function showSmsDialog(template, customData) {
|
|
|
|
|
Object.assign(data, customData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quasar.dialog({
|
|
|
|
|
dialog({
|
|
|
|
|
component: VnSmsDialog,
|
|
|
|
|
componentProps: {
|
|
|
|
|
phone: phone,
|
|
|
|
@ -95,42 +131,26 @@ function showSmsDialog(template, customData) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function showSmsDialogWithChanges() {
|
|
|
|
|
const query = `TicketLogs/${route.params.id}/getChanges`;
|
|
|
|
|
const query = `TicketLogs/${ticketId}/getChanges`;
|
|
|
|
|
const response = await axios.get(query);
|
|
|
|
|
|
|
|
|
|
showSmsDialog('orderChanges', { changes: response.data });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function sendSms(body) {
|
|
|
|
|
await axios.post(`Tickets/${route.params.id}/sendSms`, body);
|
|
|
|
|
quasar.notify({
|
|
|
|
|
await axios.post(`Tickets/${ticketId}/sendSms`, body);
|
|
|
|
|
notify({
|
|
|
|
|
message: 'Notification sent',
|
|
|
|
|
type: 'positive',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function confirmDelete() {
|
|
|
|
|
quasar
|
|
|
|
|
.dialog({
|
|
|
|
|
component: VnConfirm,
|
|
|
|
|
componentProps: {
|
|
|
|
|
promise: remove,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.onOk(async () => await router.push({ name: 'TicketList' }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function remove() {
|
|
|
|
|
const id = route.params.id;
|
|
|
|
|
await axios.post(`Tickets/${id}/setDeleted`);
|
|
|
|
|
|
|
|
|
|
quasar.notify({
|
|
|
|
|
message: t('Ticket deleted'),
|
|
|
|
|
type: 'positive',
|
|
|
|
|
});
|
|
|
|
|
quasar.notify({
|
|
|
|
|
message: t('You can undo this action within the first hour'),
|
|
|
|
|
icon: 'info',
|
|
|
|
|
function openConfirmDialog(callback) {
|
|
|
|
|
dialog({
|
|
|
|
|
component: VnConfirm,
|
|
|
|
|
componentProps: {
|
|
|
|
|
promise: actions[callback],
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
@ -227,9 +247,15 @@ async function remove() {
|
|
|
|
|
</QList>
|
|
|
|
|
</QMenu>
|
|
|
|
|
</QItem>
|
|
|
|
|
<QItem @click="openConfirmDialog('clone')" v-ripple clickable>
|
|
|
|
|
<QItemSection avatar>
|
|
|
|
|
<QIcon name="content_copy" />
|
|
|
|
|
</QItemSection>
|
|
|
|
|
<QItemSection>{{ t('To clone ticket') }}</QItemSection>
|
|
|
|
|
</QItem>
|
|
|
|
|
<template v-if="!ticket.isDeleted">
|
|
|
|
|
<QSeparator />
|
|
|
|
|
<QItem @click="confirmDelete()" v-ripple clickable>
|
|
|
|
|
<QItem @click="openConfirmDialog('remove')" v-ripple clickable>
|
|
|
|
|
<QItemSection avatar>
|
|
|
|
|
<QIcon name="delete" />
|
|
|
|
|
</QItemSection>
|
|
|
|
@ -253,4 +279,7 @@ es:
|
|
|
|
|
Order changes: Cambios del pedido
|
|
|
|
|
Ticket deleted: Ticket eliminado
|
|
|
|
|
You can undo this action within the first hour: Puedes deshacer esta acción dentro de la primera hora
|
|
|
|
|
To clone ticket: Clonar ticket
|
|
|
|
|
Ticket cloned: Ticked clonado
|
|
|
|
|
It was not able to clone the ticket: No se pudo clonar el ticket
|
|
|
|
|
</i18n>
|
|
|
|
|