fix(VnTable): autoload when has url parameters
This commit is contained in:
parent
1c006a278e
commit
5833b4d856
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, computed, watch } from 'vue';
|
import { ref, onBeforeMount, onMounted, computed, watch } 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 { useQuasar } from 'quasar';
|
||||||
|
@ -96,6 +96,7 @@ const DEFAULT_MODE = 'card';
|
||||||
const TABLE_MODE = 'table';
|
const TABLE_MODE = 'table';
|
||||||
const mode = ref(DEFAULT_MODE);
|
const mode = ref(DEFAULT_MODE);
|
||||||
const selected = ref([]);
|
const selected = ref([]);
|
||||||
|
const hasParams = ref(false);
|
||||||
const routeQuery = JSON.parse(route?.query[$props.searchUrl] ?? '{}');
|
const routeQuery = JSON.parse(route?.query[$props.searchUrl] ?? '{}');
|
||||||
const params = ref({ ...routeQuery, ...routeQuery.filter?.where });
|
const params = ref({ ...routeQuery, ...routeQuery.filter?.where });
|
||||||
const orders = ref(parseOrder(routeQuery.filter?.order));
|
const orders = ref(parseOrder(routeQuery.filter?.order));
|
||||||
|
@ -117,11 +118,14 @@ const tableModes = [
|
||||||
disable: $props.disableOption?.card,
|
disable: $props.disableOption?.card,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
onBeforeMount(() => {
|
||||||
|
setUserParams(route.query[$props.searchUrl]);
|
||||||
|
hasParams.value = Object.keys(params.value).length !== 0;
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
mode.value = quasar.platform.is.mobile ? DEFAULT_MODE : $props.defaultMode;
|
mode.value = quasar.platform.is.mobile ? DEFAULT_MODE : $props.defaultMode;
|
||||||
stateStore.rightDrawer = true;
|
stateStore.rightDrawer = true;
|
||||||
setUserParams(route.query[$props.searchUrl]);
|
|
||||||
columnsVisibilitySkiped.value = [
|
columnsVisibilitySkiped.value = [
|
||||||
...splittedColumns.value.columns
|
...splittedColumns.value.columns
|
||||||
.filter((c) => c.visible == false)
|
.filter((c) => c.visible == false)
|
||||||
|
@ -295,6 +299,7 @@ defineExpose({
|
||||||
:disable-infinite-scroll="isTableMode"
|
:disable-infinite-scroll="isTableMode"
|
||||||
@save-changes="reload"
|
@save-changes="reload"
|
||||||
:has-sub-toolbar="$attrs['hasSubToolbar'] ?? isEditable"
|
:has-sub-toolbar="$attrs['hasSubToolbar'] ?? isEditable"
|
||||||
|
:auto-load="hasParams || $attrs['auto-load']"
|
||||||
>
|
>
|
||||||
<template
|
<template
|
||||||
v-for="(_, slotName) in $slots"
|
v-for="(_, slotName) in $slots"
|
||||||
|
|
Loading…
Reference in New Issue