feat: added restore ticket function in ticket descriptor menu
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
629531cce4
commit
983c86ffa5
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { computed, ref, toRefs } from 'vue';
|
||||
import { computed, onMounted, ref, toRefs, watch } from 'vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
@ -24,6 +24,16 @@ const props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
console.log('called');
|
||||
restoreTicket();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.ticket,
|
||||
() => restoreTicket
|
||||
);
|
||||
|
||||
const { push, currentRoute } = useRouter();
|
||||
const { dialog, notify } = useQuasar();
|
||||
const { t } = useI18n();
|
||||
|
@ -373,6 +383,54 @@ async function uploadDocuware(force) {
|
|||
|
||||
if (data) notify({ message: t('PDF sent!'), type: 'positive' });
|
||||
}
|
||||
|
||||
const canRestoreTicket = ref(false);
|
||||
|
||||
const restoreTicket = async () => {
|
||||
const filter = {
|
||||
fields: ['id', 'originFk', 'creationDate', 'newInstance'],
|
||||
where: {
|
||||
originFk: ticketId.value,
|
||||
newInstance: { like: '%"isDeleted":true%' },
|
||||
},
|
||||
order: 'creationDate DESC',
|
||||
limit: 1,
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`TicketLogs`, { params });
|
||||
if (data && data.length) {
|
||||
const now = Date.vnNew();
|
||||
const maxDate = new Date(data[0].creationDate);
|
||||
maxDate.setHours(maxDate.getHours() + 1);
|
||||
if (now <= maxDate) {
|
||||
return (canRestoreTicket.value = true);
|
||||
}
|
||||
return (canRestoreTicket.value = false);
|
||||
}
|
||||
return (canRestoreTicket.value = false);
|
||||
};
|
||||
|
||||
async function openRestoreConfirmation(force) {
|
||||
if (!force)
|
||||
return quasar
|
||||
.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('Are you sure you want to restore the ticket?'),
|
||||
message: t('You are going to restore this ticket'),
|
||||
},
|
||||
})
|
||||
.onOk(async () => {
|
||||
ticketToRestore();
|
||||
});
|
||||
}
|
||||
|
||||
async function ticketToRestore() {
|
||||
const { data } = await axios.post(`Tickets/${ticketId.value}/restore`);
|
||||
if (data) {
|
||||
notify({ message: t('Ticket restored'), type: 'positive' });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -560,6 +618,12 @@ async function uploadDocuware(force) {
|
|||
</QItemSection>
|
||||
<QItemSection>{{ t('Show Proforma') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem v-if="canRestoreTicket" @click="openRestoreConfirmation()" v-ripple clickable>
|
||||
<QItemSection avatar>
|
||||
<QIcon name="restore" />
|
||||
</QItemSection>
|
||||
<QItemSection>{{ t('Restore ticket') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-if="isEditable"
|
||||
@click="showChangeTimeDialog = !showChangeTimeDialog"
|
||||
|
@ -746,4 +810,8 @@ es:
|
|||
You are going to delete this ticket: Vas a eliminar este ticket
|
||||
as PDF signed: como PDF firmado
|
||||
Are you sure you want to replace this delivery note?: ¿Seguro que quieres reemplazar este albarán?
|
||||
Restore ticket: Restaurar ticket
|
||||
Are you sure you want to restore the ticket?: ¿Seguro que quieres restaurar el ticket?
|
||||
You are going to restore this ticket: Vas a restaurar este ticket
|
||||
Ticket restored: Ticket restaurado
|
||||
</i18n>
|
||||
|
|
Loading…
Reference in New Issue