feat: refs #6951 clone ticket
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
79b242f3a6
commit
5803b8392b
|
@ -3,7 +3,7 @@ import axios from 'axios';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter, useRoute } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { usePrintService } from 'composables/usePrintService';
|
import { usePrintService } from 'composables/usePrintService';
|
||||||
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
|
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
|
@ -17,13 +17,14 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
const { push, currentRoute } = useRouter();
|
||||||
const route = useRoute();
|
const { dialog, notify } = useQuasar();
|
||||||
const quasar = useQuasar();
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { openReport, sendEmail } = usePrintService();
|
const { openReport, sendEmail } = usePrintService();
|
||||||
|
|
||||||
const ticket = ref(props.ticket);
|
const ticket = ref(props.ticket);
|
||||||
|
const ticketId = currentRoute.value.params.id;
|
||||||
|
const actions = { remove: remove, clone: clone };
|
||||||
|
|
||||||
function openDeliveryNote(type = 'deliveryNote', documentType = 'pdf') {
|
function openDeliveryNote(type = 'deliveryNote', documentType = 'pdf') {
|
||||||
const path = `Tickets/${ticket.value.id}/delivery-note-${documentType}`;
|
const path = `Tickets/${ticket.value.id}/delivery-note-${documentType}`;
|
||||||
|
@ -35,7 +36,7 @@ function openDeliveryNote(type = 'deliveryNote', documentType = 'pdf') {
|
||||||
|
|
||||||
function sendDeliveryNoteConfirmation(type = 'deliveryNote', documentType = 'pdf') {
|
function sendDeliveryNoteConfirmation(type = 'deliveryNote', documentType = 'pdf') {
|
||||||
const customer = ticket.value.client;
|
const customer = ticket.value.client;
|
||||||
quasar.dialog({
|
dialog({
|
||||||
component: SendEmailDialog,
|
component: SendEmailDialog,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
data: {
|
data: {
|
||||||
|
@ -67,7 +68,7 @@ function showSmsDialog(template, customData) {
|
||||||
const address = ticket.value.address;
|
const address = ticket.value.address;
|
||||||
const client = ticket.value.client;
|
const client = ticket.value.client;
|
||||||
const phone =
|
const phone =
|
||||||
route.params.phone ||
|
currentRoute.value.params.phone ||
|
||||||
address.mobile ||
|
address.mobile ||
|
||||||
address.phone ||
|
address.phone ||
|
||||||
client.mobile ||
|
client.mobile ||
|
||||||
|
@ -82,7 +83,7 @@ function showSmsDialog(template, customData) {
|
||||||
Object.assign(data, customData);
|
Object.assign(data, customData);
|
||||||
}
|
}
|
||||||
|
|
||||||
quasar.dialog({
|
dialog({
|
||||||
component: VnSmsDialog,
|
component: VnSmsDialog,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
phone: phone,
|
phone: phone,
|
||||||
|
@ -95,43 +96,63 @@ function showSmsDialog(template, customData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function showSmsDialogWithChanges() {
|
async function showSmsDialogWithChanges() {
|
||||||
const query = `TicketLogs/${route.params.id}/getChanges`;
|
const query = `TicketLogs/${ticketId}/getChanges`;
|
||||||
const response = await axios.get(query);
|
const response = await axios.get(query);
|
||||||
|
|
||||||
showSmsDialog('orderChanges', { changes: response.data });
|
showSmsDialog('orderChanges', { changes: response.data });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendSms(body) {
|
async function sendSms(body) {
|
||||||
await axios.post(`Tickets/${route.params.id}/sendSms`, body);
|
await axios.post(`Tickets/${ticketId}/sendSms`, body);
|
||||||
quasar.notify({
|
notify({
|
||||||
message: 'Notification sent',
|
message: 'Notification sent',
|
||||||
type: 'positive',
|
type: 'positive',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirmDelete() {
|
function openConfirmDialog(callback) {
|
||||||
quasar
|
dialog({
|
||||||
.dialog({
|
component: VnConfirm,
|
||||||
component: VnConfirm,
|
componentProps: {
|
||||||
componentProps: {
|
promise: actions[callback],
|
||||||
promise: remove,
|
},
|
||||||
},
|
});
|
||||||
})
|
}
|
||||||
.onOk(async () => await router.push({ name: 'TicketList' }));
|
|
||||||
|
async function clone() {
|
||||||
|
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 } });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function remove() {
|
async function remove() {
|
||||||
const id = route.params.id;
|
try {
|
||||||
await axios.post(`Tickets/${id}/setDeleted`);
|
await axios.post(`Tickets/${ticketId}/setDeleted`);
|
||||||
|
|
||||||
quasar.notify({
|
notify({ message: t('Ticket deleted'), type: 'positive' });
|
||||||
message: t('Ticket deleted'),
|
notify({
|
||||||
type: 'positive',
|
message: t('You can undo this action within the first hour'),
|
||||||
});
|
icon: 'info',
|
||||||
quasar.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' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
@ -227,9 +248,15 @@ async function remove() {
|
||||||
</QList>
|
</QList>
|
||||||
</QMenu>
|
</QMenu>
|
||||||
</QItem>
|
</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">
|
<template v-if="!ticket.isDeleted">
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
<QItem @click="confirmDelete()" v-ripple clickable>
|
<QItem @click="openConfirmDialog('remove')" v-ripple clickable>
|
||||||
<QItemSection avatar>
|
<QItemSection avatar>
|
||||||
<QIcon name="delete" />
|
<QIcon name="delete" />
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
|
@ -253,4 +280,7 @@ es:
|
||||||
Order changes: Cambios del pedido
|
Order changes: Cambios del pedido
|
||||||
Ticket deleted: Ticket eliminado
|
Ticket deleted: Ticket eliminado
|
||||||
You can undo this action within the first hour: Puedes deshacer esta acción dentro de la primera hora
|
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>
|
</i18n>
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/// <reference types="cypress" />
|
||||||
|
describe('Ticket descriptor', () => {
|
||||||
|
const toCloneOpt = '.q-list > :nth-child(5)';
|
||||||
|
const warehouseValue = '.summaryBody > :nth-child(2) > :nth-child(6) > .value > span';
|
||||||
|
const summaryHeader = '.summaryHeader > div';
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
const ticketId = 1;
|
||||||
|
|
||||||
|
cy.login('developer');
|
||||||
|
cy.visit(`/#/ticket/${ticketId}/summary`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should clone the ticket without warehouse', () => {
|
||||||
|
cy.openLeftMenu();
|
||||||
|
cy.openActionsDescriptor();
|
||||||
|
cy.get(toCloneOpt).click();
|
||||||
|
cy.clickConfirm();
|
||||||
|
cy.get(warehouseValue).contains('-');
|
||||||
|
cy.get(summaryHeader)
|
||||||
|
.invoke('text')
|
||||||
|
.then((text) => {
|
||||||
|
const [, owner] = text.split('-');
|
||||||
|
cy.wrap(owner.trim()).should('eq', 'Bruce Wayne (1101)');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue