fix(VnSection): refs #8197 check route
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
a1ef002a24
commit
7bca8a4194
|
@ -2,9 +2,9 @@
|
||||||
import RightMenu from './RightMenu.vue';
|
import RightMenu from './RightMenu.vue';
|
||||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||||
import VnTableFilter from '../VnTable/VnTableFilter.vue';
|
import VnTableFilter from '../VnTable/VnTableFilter.vue';
|
||||||
import { onBeforeMount, computed, ref } from 'vue';
|
import { onBeforeMount, onMounted, onUnmounted, computed, ref } from 'vue';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { useHasContent } from 'src/composables/useHasContent';
|
import { useHasContent } from 'src/composables/useHasContent';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -47,16 +47,12 @@ const $props = defineProps({
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
let arrayData;
|
let arrayData;
|
||||||
const sectionValue = computed(() => $props.section ?? $props.dataKey);
|
const sectionValue = computed(() => $props.section ?? $props.dataKey);
|
||||||
const isMainSection = computed(() => {
|
const isMainSection = ref();
|
||||||
const isSame = sectionValue.value == route.name;
|
|
||||||
if (!isSame && arrayData) {
|
|
||||||
arrayData.reset(['userParams', 'filter']);
|
|
||||||
arrayData.setCurrentFilter();
|
|
||||||
}
|
|
||||||
return isSame;
|
|
||||||
});
|
|
||||||
const searchbarId = 'section-searchbar';
|
const searchbarId = 'section-searchbar';
|
||||||
const hasContent = useHasContent(`#${searchbarId}`);
|
const hasContent = useHasContent(`#${searchbarId}`);
|
||||||
|
|
||||||
|
@ -68,7 +64,23 @@ onBeforeMount(() => {
|
||||||
...$props.arrayDataProps,
|
...$props.arrayDataProps,
|
||||||
navigate: $props.redirect,
|
navigate: $props.redirect,
|
||||||
});
|
});
|
||||||
|
checkIsMain();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const unsubscribe = router.afterEach(() => {
|
||||||
|
checkIsMain();
|
||||||
|
});
|
||||||
|
onUnmounted(() => unsubscribe());
|
||||||
|
});
|
||||||
|
|
||||||
|
function checkIsMain() {
|
||||||
|
isMainSection.value = sectionValue.value == route.name;
|
||||||
|
if (!isMainSection.value && arrayData) {
|
||||||
|
arrayData.reset(['userParams', 'filter']);
|
||||||
|
arrayData.setCurrentFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<slot name="searchbar">
|
<slot name="searchbar">
|
||||||
|
|
Loading…
Reference in New Issue