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` }); }; -