approach
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2024-06-07 23:08:15 +02:00
parent 464cf47a39
commit a23eb0a5ad
3 changed files with 25 additions and 17 deletions

View File

@ -36,10 +36,10 @@ const $props = defineProps({
const emit = defineEmits(['onFetch']); const emit = defineEmits(['onFetch']);
defineExpose({ fetch }); defineExpose({ fetch });
const fetchData = useFetchData({ ...$props });
onMounted(async () => { onMounted(async () => {
if ($props.autoLoad) { if ($props.autoLoad) {
await useFetchData(...$props).fetch(); await fetchData.fetch();
} }
}); });

View File

@ -2,7 +2,6 @@
import { ref, toRefs, computed, watch, h } from 'vue'; import { ref, toRefs, computed, watch, h } from 'vue';
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import FetchData from 'src/components/FetchData.vue';
const emit = defineEmits(['update:modelValue', 'update:options']); const emit = defineEmits(['update:modelValue', 'update:options']);
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import { useFetchData } from 'src/composables/useFetchData'; import { useFetchData } from 'src/composables/useFetchData';
@ -78,18 +77,6 @@ const dataRef = ref(
fields: $props.fields, fields: $props.fields,
}) })
); );
// const fetchDataComponent = ref(null);
// fetchDataComponent.value = h(FetchData, {
// url: $props.url,
// where: $props.where,
// limit: $props.limit,
// sortBy: $props.sortBy,
// fields: $props.fields,
// onFetch: (data) => {
// setOptions(data); // Tu función para manejar los datos
// },
// });
// const dataRef = ref(null);
const selectValue = computed({ const selectValue = computed({
get() { get() {
return $props.modelValue; return $props.modelValue;
@ -108,10 +95,10 @@ const useURL = computed(() => $props.url?.length > 0);
const arrayData = useURL.value const arrayData = useURL.value
? useArrayData($props.url, { ? useArrayData($props.url, {
url: $props.url, url: $props.url,
fields: $props.fields,
where: $props.where, where: $props.where,
sortBy: $props.sortBy,
limit: $props.limit, limit: $props.limit,
sortBy: $props.sortBy,
fields: $props.fields,
}) })
: ref(null); : ref(null);
onMounted(async () => { onMounted(async () => {

View File

@ -0,0 +1,21 @@
import axios from 'axios';
export function useAxios() {
const fetch = async (url, filter, params) => {
axios.get(url, { params: { ...params, ...filter } });
};
const push = async (url, method = 'PUT', filter, params) => {
axios({ url, method, params: { ...params, ...filter } });
};
const pop = async (url, filter, params) => {
axios.delete(url, { params: { ...params, ...filter } });
};
return {
fetch,
push,
pop,
};
}