0
0
Fork 0
This commit is contained in:
Carlos Satorres 2023-10-22 07:19:33 +02:00
parent cea811903e
commit dfa29875d5
3 changed files with 15 additions and 5 deletions

View File

@ -1,10 +1,12 @@
<script setup> <script setup>
import { onMounted, useSlots, ref, watch } from 'vue'; import { onMounted, useSlots, ref, watch, watchEffect } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios'; import axios from 'axios';
import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue'; import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue';
import { useArrayData } from 'src/composables/useArrayData';
const $props = defineProps({ const $props = defineProps({
dataKey: { type: String, default: null },
url: { url: {
type: String, type: String,
default: '', default: '',
@ -26,14 +28,17 @@ const $props = defineProps({
default: 0, default: 0,
}, },
}); });
const arrayData = useArrayData('claimData');
console.log('arraydata en descriptor', arrayData.store.data);
const slots = useSlots(); const slots = useSlots();
const { t } = useI18n(); const { t } = useI18n();
const entity = ref(null); const entity = ref(null);
let lastUrl = ref(null); let lastUrl = ref(null);
entity.value = arrayData.store.data;
///
onMounted(async () => { onMounted(async () => {
await fetch(); //await fetch();
}); });
const emit = defineEmits(['onFetch']); const emit = defineEmits(['onFetch']);
@ -53,7 +58,11 @@ async function fetch() {
watch($props, async () => { watch($props, async () => {
if (lastUrl.value == $props.url) return; if (lastUrl.value == $props.url) return;
entity.value = null; entity.value = null;
await fetch(); /* await fetch(); */
});
watchEffect(() => {
entity.value = arrayData.store.data;
}); });
</script> </script>

View File

@ -65,6 +65,7 @@ let salixUrl;
onMounted(async () => { onMounted(async () => {
salixUrl = await getUrl(`claim/${entityId.value}`); salixUrl = await getUrl(`claim/${entityId.value}`);
await arrayData.fetch({ append: false }); await arrayData.fetch({ append: false });
console.log('store', arrayData.store.data);
}); });
</script> </script>
<template> <template>

View File

@ -18,7 +18,7 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => {
skip: 0, skip: 0,
order: '', order: '',
data: ref(), data: ref(),
isLoading: false isLoading: false,
}; };
} }