Improve reactivity of card descriptor
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
90bfba0290
commit
740eedbe44
|
@ -59,6 +59,10 @@ const $props = defineProps({
|
||||||
type: Function,
|
type: Function,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
clearStoreOnUnmount: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
const emit = defineEmits(['onFetch', 'onDataSaved']);
|
||||||
|
@ -91,7 +95,12 @@ onMounted(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
state.unset($props.model);
|
// Restauramos los datos originales en el store si se realizaron cambios en el formulario pero no se guardaron, evitando modificaciones erróneas.
|
||||||
|
if (hasChanges.value) {
|
||||||
|
state.set($props.model, originalData.value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($props.clearStoreDataOnUnmount) state.unset($props.model);
|
||||||
});
|
});
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
|
@ -61,6 +61,7 @@ const onFilterTravelSelected = (formData, id) => {
|
||||||
:url-update="`Entries/${route.params.id}`"
|
:url-update="`Entries/${route.params.id}`"
|
||||||
model="entry"
|
model="entry"
|
||||||
auto-load
|
auto-load
|
||||||
|
:clear-store-on-unmount="false"
|
||||||
>
|
>
|
||||||
<template #form="{ data }">
|
<template #form="{ data }">
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
|
|
|
@ -97,17 +97,6 @@ const getEntryRedirectionFilter = (entry) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const refetchEntryDescriptorData = async () => {
|
|
||||||
await entryDescriptorRef.value.getData();
|
|
||||||
};
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => route.name,
|
|
||||||
async (_, from) => {
|
|
||||||
if (from === 'EntryBasicData') await refetchEntryDescriptorData();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const showEntryReport = () => {
|
const showEntryReport = () => {
|
||||||
openReport(`Entries/${route.params.id}/entry-order-pdf`);
|
openReport(`Entries/${route.params.id}/entry-order-pdf`);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue