Merge branch 'dev' into 8322-route
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Alex Moreno 2025-01-27 07:17:21 +00:00
commit be3f853b14
1 changed files with 60 additions and 10 deletions

View File

@ -2,7 +2,7 @@
import { onBeforeMount, ref } from 'vue'; import { onBeforeMount, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useQuasar } from 'quasar';
import axios from 'axios'; import axios from 'axios';
import VnLocation from 'src/components/common/VnLocation.vue'; import VnLocation from 'src/components/common/VnLocation.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
@ -13,11 +13,12 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue'; import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import CustomerNewCustomsAgent from 'src/pages/Customer/components/CustomerNewCustomsAgent.vue'; import CustomerNewCustomsAgent from 'src/pages/Customer/components/CustomerNewCustomsAgent.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue'; import VnInputNumber from 'src/components/common/VnInputNumber.vue';
import VnConfirm from 'components/ui/VnConfirm.vue';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const quasar = useQuasar();
const urlUpdate = ref(''); const urlUpdate = ref('');
const agencyModes = ref([]); const agencyModes = ref([]);
const incoterms = ref([]); const incoterms = ref([]);
@ -83,8 +84,26 @@ const deleteNote = (id, index) => {
notes.value.splice(index, 1); notes.value.splice(index, 1);
}; };
const onDataSaved = async () => { const updateAddress = async (data) => {
let payload = { await axios.patch(urlUpdate.value, data);
};
const updateAddressTicket = async () => {
urlUpdate.value += '?updateObservations=true';
};
const updateObservations = async (payload) => {
await axios.post('AddressObservations/crud', payload);
notes.value = [];
deletes.value = [];
toCustomerAddress();
};
async function updateAll({ data, payload }) {
await updateObservations(payload);
await updateAddress(data);
}
function getPayload() {
return {
creates: notes.value.filter((note) => note.$isNew), creates: notes.value.filter((note) => note.$isNew),
deletes: deletes.value, deletes: deletes.value,
updates: notes.value updates: notes.value
@ -101,14 +120,40 @@ const onDataSaved = async () => {
where: { id: note.id }, where: { id: note.id },
})), })),
}; };
}
await axios.post('AddressObservations/crud', payload); async function handleDialog(data) {
notes.value = []; const payload = getPayload();
deletes.value = []; const body = { data, payload };
if (payload.updates.length) {
quasar
.dialog({
component: VnConfirm,
componentProps: {
title: t(
'confirmTicket'
),
message: t('confirmDeletionMessage'),
},
})
.onOk(async () => {
await updateAddressTicket();
await updateAll(body);
toCustomerAddress(); toCustomerAddress();
}; })
.onCancel(async () => {
await updateAll(body);
toCustomerAddress();
});
} else {
updateAll(body);
toCustomerAddress();
}
}
const toCustomerAddress = () => { const toCustomerAddress = () => {
notes.value = [];
deletes.value = [];
router.push({ router.push({
name: 'CustomerAddress', name: 'CustomerAddress',
params: { params: {
@ -143,7 +188,7 @@ function handleLocation(data, location) {
:observe-form-changes="false" :observe-form-changes="false"
:url-update="urlUpdate" :url-update="urlUpdate"
:url="`Addresses/${route.params.addressId}`" :url="`Addresses/${route.params.addressId}`"
@on-data-saved="onDataSaved()" :save-fn="handleDialog"
auto-load auto-load
> >
<template #moreActions> <template #moreActions>
@ -336,4 +381,9 @@ es:
Remove note: Eliminar nota Remove note: Eliminar nota
Longitude: Longitud Longitude: Longitud
Latitude: Latitud Latitude: Latitud
confirmTicket: ¿Desea modificar también los estados de todos los tickets que están a punto de ser servidos?
confirmDeletionMessage: Si le das a aceptar, se modificaran todas las notas de los ticket a futuro
en:
confirmTicket: Do you also want to modify the states of all the tickets that are about to be served?
confirmDeletionMessage: If you click accept, all the notes of the future tickets will be modified
</i18n> </i18n>