fix: refs #6942 formModel & CardDescriptor
This commit is contained in:
parent
5bddc6e04d
commit
3db3d04bc9
|
@ -115,18 +115,16 @@ onMounted(async () => {
|
|||
|
||||
// Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla
|
||||
state.set($props.model, $props.formInitialData);
|
||||
if ($props.autoLoad && !$props.formInitialData && $props.url) await fetch();
|
||||
else if (arrayData.store.data) {
|
||||
state.set($props.model, arrayData.store.data);
|
||||
|
||||
emit('onFetch', state.get($props.model));
|
||||
}
|
||||
if ($props.autoLoad && !$props.formInitialData && $props.url) await fetch();
|
||||
else if (arrayData.store.data) updateAndEmit(arrayData.store.data, 'onFetch');
|
||||
|
||||
if ($props.observeFormChanges) {
|
||||
watch(
|
||||
() => formData.value,
|
||||
(val) => {
|
||||
hasChanges.value = !isResetting.value && val;
|
||||
(newVal, oldVal) => {
|
||||
if (!oldVal) return;
|
||||
hasChanges.value = !isResetting.value && newVal;
|
||||
isResetting.value = false;
|
||||
},
|
||||
{ deep: true }
|
||||
|
@ -143,7 +141,7 @@ if (!$props.url)
|
|||
watch(formUrl, async () => {
|
||||
originalData.value = null;
|
||||
reset();
|
||||
fetch();
|
||||
await fetch();
|
||||
});
|
||||
|
||||
onBeforeRouteLeave((to, from, next) => {
|
||||
|
@ -161,10 +159,7 @@ onBeforeRouteLeave((to, from, next) => {
|
|||
|
||||
onUnmounted(() => {
|
||||
// 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 (hasChanges.value) return state.set($props.model, originalData.value);
|
||||
if ($props.clearStoreOnUnmount) state.unset($props.model);
|
||||
});
|
||||
|
||||
|
|
|
@ -15,10 +15,6 @@ const $props = defineProps({
|
|||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
module: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '',
|
||||
|
@ -29,7 +25,7 @@ const $props = defineProps({
|
|||
},
|
||||
dataKey: {
|
||||
type: String,
|
||||
default: '',
|
||||
default: null,
|
||||
},
|
||||
summary: {
|
||||
type: Object,
|
||||
|
@ -40,7 +36,7 @@ const $props = defineProps({
|
|||
const state = useState();
|
||||
const { t } = useI18n();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
const arrayData = useArrayData($props.dataKey || $props.module, {
|
||||
const arrayData = useArrayData($props.dataKey || 'descriptor', {
|
||||
url: $props.url,
|
||||
filter: $props.filter,
|
||||
skip: 0,
|
||||
|
@ -51,7 +47,7 @@ const isLoading = ref(false);
|
|||
|
||||
defineExpose({ getData });
|
||||
onBeforeMount(async () => {
|
||||
await getData();
|
||||
if (!$props.dataKey) await getData();
|
||||
watch(
|
||||
() => [$props.url, $props.filter],
|
||||
async () => await getData()
|
||||
|
@ -93,7 +89,12 @@ const emit = defineEmits(['onFetch']);
|
|||
{{ t('components.smartCard.openSummary') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
<RouterLink :to="{ name: `${module}Summary`, params: { id: entity.id } }">
|
||||
<RouterLink
|
||||
:to="{
|
||||
name: `${$route.meta.moduleName}Summary`,
|
||||
params: { id: entity.id },
|
||||
}"
|
||||
>
|
||||
<QBtn
|
||||
class="link"
|
||||
color="white"
|
||||
|
|
Loading…
Reference in New Issue