fix: refs #6900 fine tunning #661
|
@ -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));
|
||||
|
||||
</script>
|
||||
jsegarra marked this conversation as resolved
Outdated
jsegarra
commented
Porque :key="$router.path" no sirve? Porque :key="$router.path" no sirve?
jorgep
commented
No, no detecta el cambio. No, no detecta el cambio.
|
||||
<template>
|
||||
<VnCard
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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);
|
||||
jorgep
commented
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: [
|
||||
|
|
Loading…
Reference in New Issue
En caso de cambiar de factura, se consulta si es rectificativa, si no lo es, se oculta del menu lateral.