forked from verdnatura/salix-front
refs #6772 feat: fix approach
This commit is contained in:
parent
f38b5845ff
commit
2e86cdfe52
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue