0
0
Fork 0

refs #6772 feat: fix approach

This commit is contained in:
Javier Segarra 2024-02-16 12:59:00 +01:00
parent f38b5845ff
commit 2e86cdfe52
1 changed files with 24 additions and 1 deletions

View File

@ -1,7 +1,9 @@
<script setup>
import { onMounted, ref, watch } from 'vue';
import { onMounted, ref, watch, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useArrayData } from 'composables/useArrayData';
import { useRoute } from 'vue-router';
const route = useRoute();
const { t } = useI18n();
@ -86,7 +88,28 @@ watch(
store.data = props.data;
}
);
watch(
() => route.params.id,
() => {
if (route.path === props.url) return;
//Así fuerzo al reinicio
store.data = null;
if (!arrayData.store?.filter?.where) {
//Cuando el cambio viene por VnSearchbar
store.url = store.url.replace(/(\d+)/, route.params.id);
} else {
// Cuando el usuario cambia en la URL
const claveFk = Object.keys(arrayData.store.filter.where).find((clave) =>
clave.endsWith('Fk')
);
if (claveFk) {
arrayData.store.filter.where[claveFk] = route.params.id;
}
}
fetch();
}
);
async function fetch() {
await arrayData.fetch({ append: false });
if (!arrayData.hasMoreData.value) {