fix: refs #6900 fine tunning #661

Merged
jorgep merged 13 commits from 6900-hotfix-fineTunning into master 2024-09-04 13:58:59 +00:00
3 changed files with 18 additions and 29 deletions
Showing only changes of commit 763cf2e345 - Show all commits

View File

@ -3,8 +3,8 @@ import VnCard from 'components/common/VnCard.vue';
import InvoiceInDescriptor from './InvoiceInDescriptor.vue';
import InvoiceInFilter from '../InvoiceInFilter.vue';
import InvoiceInSearchbar from '../InvoiceInSearchbar.vue';
import axios from 'axios';
import { onBeforeRouteUpdate } from 'vue-router';
import { setRectificative } from '../composables/setRectificative';
const filter = {
include: [
@ -23,19 +23,7 @@ const filter = {
],
};
onBeforeRouteUpdate(async (to) => {
const card = to.matched.find((route) => route.name === 'InvoiceInCard');
const corrective = card.children.find(
(route) => route.name === 'InvoiceInCorrective'
);
const isRectificative = !!(
await axios.get('InvoiceInCorrections', {
params: { filter: { where: { correctingFk: to.params.id } } },
})
).data.length;
corrective.meta.hidden = !isRectificative;
});
onBeforeRouteUpdate(async (to) => await setRectificative(to));

En caso de cambiar de factura, se consulta si es rectificativa, si no lo es, se oculta del menu lateral.

En caso de cambiar de factura, se consulta si es rectificativa, si no lo es, se oculta del menu lateral.
</script>
jsegarra marked this conversation as resolved Outdated

Porque :key="$router.path" no sirve?

Porque :key="$router.path" no sirve?

No, no detecta el cambio.

No, no detecta el cambio.
<template>
<VnCard

View File

@ -0,0 +1,14 @@
import axios from 'axios';
export async function setRectificative(route) {
const card = route.matched.find((route) => route.name === 'InvoiceInCard');
const corrective = card.children.find(
(route) => route.name === 'InvoiceInCorrective'
);
corrective.meta.hidden = !(
await axios.get('InvoiceInCorrections', {
params: { filter: { where: { correctingFk: route.params.id } } },
})
).data.length;
}

View File

@ -1,6 +1,5 @@
import { RouterView } from 'vue-router';
import axios from 'axios';
import { setRectificative } from 'src/pages/InvoiceIn/composables/setRectificative';
export default {
path: '/invoice-in',
name: 'InvoiceIn',
@ -65,19 +64,7 @@ export default {
component: () => import('src/pages/InvoiceIn/Card/InvoiceInCard.vue'),
redirect: { name: 'InvoiceInSummary' },
beforeEnter: async (to, from, next) => {
const isRectificative = !!(
await axios.get('InvoiceInCorrections', {
params: { filter: { where: { correctingFk: to.params.id } } },
})
).data.length;
const card = to.matched.find((route) => route.name === 'InvoiceInCard');
const corrective = card.children.find(
(route) => route.name === 'InvoiceInCorrective'
);
corrective.meta.hidden = !isRectificative;
await setRectificative(to);

Al entrar se comprueba si es rectificativa. Lamentablemente, la opción de onBeforeRouteLeave, solo está disponible dentro de un componente.

Al entrar se comprueba si es rectificativa. Lamentablemente, la opción de onBeforeRouteLeave, solo está disponible dentro de un componente.
next();
},
children: [