From e8fed46dd10a5d51781ee7ca642c96f9fd24db10 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 23 May 2024 12:33:13 +0200 Subject: [PATCH] fix: refs #6942 cardDescriptor use store if its popup or different source data --- src/components/ui/CardDescriptor.vue | 32 ++++++++---- .../InvoiceIn/Card/InvoiceInDescriptor.vue | 50 ++++++++----------- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/components/ui/CardDescriptor.vue b/src/components/ui/CardDescriptor.vue index fbf2df813..eff1c2a38 100644 --- a/src/components/ui/CardDescriptor.vue +++ b/src/components/ui/CardDescriptor.vue @@ -5,6 +5,7 @@ import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue'; import { useArrayData } from 'composables/useArrayData'; import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { useState } from 'src/composables/useState'; +import { useRoute } from 'vue-router'; const $props = defineProps({ url: { @@ -21,12 +22,16 @@ const $props = defineProps({ }, subtitle: { type: Number, - default: 0, + default: null, }, dataKey: { type: String, default: null, }, + module: { + type: String, + default: null, + }, summary: { type: Object, default: null, @@ -36,18 +41,23 @@ const $props = defineProps({ const state = useState(); const { t } = useI18n(); const { viewSummary } = useSummaryDialog(); -const arrayData = useArrayData($props.dataKey || 'descriptor', { - url: $props.url, - filter: $props.filter, - skip: 0, -}); -const { store } = arrayData; -const entity = computed(() => (Array.isArray(store.data) ? store.data[0] : store.data)); +let arrayData; +let store; +let entity; const isLoading = ref(false); defineExpose({ getData }); + onBeforeMount(async () => { - if (!$props.dataKey) await getData(); + arrayData = useArrayData($props.dataKey, { + url: $props.url, + filter: $props.filter, + skip: 0, + }); + store = arrayData.store; + entity = computed(() => (Array.isArray(store.data) ? store.data[0] : store.data)); + + if ($props.dataKey !== useRoute().meta.moduleName) await getData(); watch( () => [$props.url, $props.filter], async () => await getData() @@ -91,7 +101,7 @@ const emit = defineEmits(['onFetch']); @@ -134,7 +144,7 @@ const emit = defineEmits(['onFetch']);
- {{ $props.title }} + {{ entity[title] ?? $props.title }} diff --git a/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue b/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue index cda0df1d6..e902d9c40 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue @@ -129,7 +129,11 @@ const correctionFormData = reactive({ }); const isNotFilled = computed(() => Object.values(correctionFormData).includes(null)); -onBeforeMount(async () => await setInvoiceCorrection(entityId.value)); +onBeforeMount(async () => { + await setInvoiceCorrection(entityId.value); + const { data } = await axios.get(`InvoiceIns/${entityId.value}/getTotals`); + totalAmount.value = data.totalDueDay; +}); watch( () => currentRoute.value.params.id, @@ -169,11 +173,6 @@ async function setInvoiceCorrection(id) { ); } -async function setTotals() { - const { data } = await axios.get(`InvoiceIns/${entityId.value}/getTotals`); - totalAmount.value = data.totalDueDay; -} - function openDialog() { quasar.dialog({ component: VnConfirm, @@ -263,7 +262,6 @@ const createInvoiceInCorrection = async () => { push({ path: `/invoice-in/${correctingId}/summary` }); }; -