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>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { computed, ref, toRefs } from 'vue';
|
import { computed, onMounted, ref, toRefs, watch } from 'vue';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
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 { push, currentRoute } = useRouter();
|
||||||
const { dialog, notify } = useQuasar();
|
const { dialog, notify } = useQuasar();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -373,6 +383,54 @@ async function uploadDocuware(force) {
|
||||||
|
|
||||||
if (data) notify({ message: t('PDF sent!'), type: 'positive' });
|
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>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -560,6 +618,12 @@ async function uploadDocuware(force) {
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection>{{ t('Show Proforma') }}</QItemSection>
|
<QItemSection>{{ t('Show Proforma') }}</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
<QItem v-if="canRestoreTicket" @click="openRestoreConfirmation()" v-ripple clickable>
|
||||||
|
<QItemSection avatar>
|
||||||
|
<QIcon name="restore" />
|
||||||
|
</QItemSection>
|
||||||
|
<QItemSection>{{ t('Restore ticket') }}</QItemSection>
|
||||||
|
</QItem>
|
||||||
<QItem
|
<QItem
|
||||||
v-if="isEditable"
|
v-if="isEditable"
|
||||||
@click="showChangeTimeDialog = !showChangeTimeDialog"
|
@click="showChangeTimeDialog = !showChangeTimeDialog"
|
||||||
|
@ -746,4 +810,8 @@ es:
|
||||||
You are going to delete this ticket: Vas a eliminar este ticket
|
You are going to delete this ticket: Vas a eliminar este ticket
|
||||||
as PDF signed: como PDF firmado
|
as PDF signed: como PDF firmado
|
||||||
Are you sure you want to replace this delivery note?: ¿Seguro que quieres reemplazar este albarán?
|
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>
|
</i18n>
|
||||||
|
|
Loading…
Reference in New Issue