fix: refs #6900 fine tunning #661
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { onMounted, ref, reactive } from 'vue';
|
import { onMounted, watch, ref, reactive } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { QSeparator, useQuasar } from 'quasar';
|
import { QSeparator, useQuasar } from 'quasar';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
@ -29,6 +29,15 @@ onMounted(async () => {
|
||||||
getRoutes();
|
getRoutes();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
|||||||
|
() => route.matched,
|
||||||
|
() => {
|
||||||
|
items.value = [];
|
||||||
|
getRoutes();
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
);
|
||||||
|
|
||||||
function findMatches(search, item) {
|
function findMatches(search, item) {
|
||||||
const matches = [];
|
const matches = [];
|
||||||
function findRoute(search, item) {
|
function findRoute(search, item) {
|
||||||
|
@ -52,7 +61,7 @@ function addChildren(module, route, parent) {
|
||||||
const matches = findMatches(mainMenus, route);
|
const matches = findMatches(mainMenus, route);
|
||||||
|
|
||||||
for (const child of matches) {
|
for (const child of matches) {
|
||||||
navigation.addMenuItem(module, child, parent);
|
if (!child.meta.hidden) navigation.addMenuItem(module, child, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ if (props.baseUrl) {
|
||||||
<QPage>
|
<QPage>
|
||||||
<VnSubToolbar />
|
<VnSubToolbar />
|
||||||
<div :class="[useCardSize(), $attrs.class]">
|
<div :class="[useCardSize(), $attrs.class]">
|
||||||
<RouterView />
|
<RouterView :key="$route.path" />
|
||||||
</div>
|
</div>
|
||||||
</QPage>
|
</QPage>
|
||||||
</QPageContainer>
|
</QPageContainer>
|
||||||
|
|
|
@ -3,6 +3,8 @@ import VnCard from 'components/common/VnCard.vue';
|
||||||
import InvoiceInDescriptor from './InvoiceInDescriptor.vue';
|
import InvoiceInDescriptor from './InvoiceInDescriptor.vue';
|
||||||
import InvoiceInFilter from '../InvoiceInFilter.vue';
|
import InvoiceInFilter from '../InvoiceInFilter.vue';
|
||||||
import InvoiceInSearchbar from '../InvoiceInSearchbar.vue';
|
import InvoiceInSearchbar from '../InvoiceInSearchbar.vue';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { onBeforeRouteUpdate } from 'vue-router';
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
include: [
|
include: [
|
||||||
|
@ -20,6 +22,20 @@ const filter = {
|
||||||
{ relation: 'currency' },
|
{ relation: 'currency' },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onBeforeRouteUpdate(async (to) => {
|
||||||
jorgep
commented
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.
|
|||||||
|
const card = to.matched.find((route) => route.name === 'InvoiceInCard');
|
||||||
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.
|
|||||||
|
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;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnCard
|
<VnCard
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { RouterView } from 'vue-router';
|
import { RouterView } from 'vue-router';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
path: '/invoice-in',
|
path: '/invoice-in',
|
||||||
|
@ -63,6 +64,22 @@ export default {
|
||||||
path: ':id',
|
path: ':id',
|
||||||
component: () => import('src/pages/InvoiceIn/Card/InvoiceInCard.vue'),
|
component: () => import('src/pages/InvoiceIn/Card/InvoiceInCard.vue'),
|
||||||
redirect: { name: 'InvoiceInSummary' },
|
redirect: { name: 'InvoiceInSummary' },
|
||||||
|
beforeEnter: async (to, from, next) => {
|
||||||
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.
|
|||||||
|
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;
|
||||||
|
|
||||||
|
next();
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: 'InvoiceInSummary',
|
name: 'InvoiceInSummary',
|
||||||
|
|
|
@ -56,6 +56,7 @@ export const useNavigationStore = defineStore('navigationStore', () => {
|
||||||
function addMenuItem(module, route, parent) {
|
function addMenuItem(module, route, parent) {
|
||||||
const { meta } = route;
|
const { meta } = route;
|
||||||
let { menuChildren = null } = meta;
|
let { menuChildren = null } = meta;
|
||||||
|
if (meta.hidden) return;
|
||||||
jorgep
commented
No lo añade. No lo añade.
|
|||||||
if (menuChildren)
|
if (menuChildren)
|
||||||
menuChildren = menuChildren.map(({ name, title, icon }) => ({
|
menuChildren = menuChildren.map(({ name, title, icon }) => ({
|
||||||
name,
|
name,
|
||||||
|
|
Loading…
Reference in New Issue
Si se realiza algún cambio en el router, se vuelven a crear los items. Esto lo hago para que si enuna ruta se modifica meta.hidden , se oculte o se muestre.