#6942 improve invoiceIn #220

Merged
jorgep merged 63 commits from 6942-improveInvoceIn into dev 2024-05-29 07:03:46 +00:00
3 changed files with 13 additions and 21 deletions
Showing only changes of commit b6638e3545 - Show all commits

View File

@ -179,7 +179,7 @@ async function fetch() {
}
}
async function save(emit = true) {
async function save() {
if ($props.observeFormChanges && !hasChanges.value)
return notify('globals.noChanges', 'negative');
@ -199,7 +199,7 @@ async function save(emit = true) {
hasChanges.value = false;
isLoading.value = false;
if (emit) updateAndEmit(response?.data, 'onDataSaved');
updateAndEmit(response?.data, 'onDataSaved');
} catch (err) {
console.error(err);
notify('errors.writeRequest', 'negative');
@ -207,7 +207,7 @@ async function save(emit = true) {
}
async function saveAndGo() {
await save(null);
await save();
push({ path: $props.goTo });
}
@ -242,7 +242,7 @@ function updateAndEmit(val, evt) {
emit(evt, state.get($props.model));
}
defineExpose({ save, saveAndGo, isLoading, hasChanges });
defineExpose({ save, isLoading, hasChanges });
</script>
<template>
<div class="column items-center full-width">

View File

@ -56,7 +56,7 @@ onBeforeMount(async () => {
});
store = arrayData.store;
entity = computed(() => (Array.isArray(store.data) ? store.data[0] : store.data));
// It enables to load data only once if the module is the same as the dataKey
if ($props.dataKey !== useRoute().meta.moduleName) await getData();
Review

Permite cargar los datos solo una vez si el módulo es el mismo que dataKey

Permite cargar los datos solo una vez si el módulo es el mismo que dataKey
Review

Se podría poner el comentario en código?

Se podría poner el comentario en código?
watch(
() => [$props.url, $props.filter],
Review

Solo interesa ver cambios en estas 2 props.

Solo interesa ver cambios en estas 2 props.
@ -99,12 +99,7 @@ const emit = defineEmits(['onFetch']);
{{ t('components.smartCard.openSummary') }}
</QTooltip>
</QBtn>
<RouterLink
:to="{
name: `${module}Summary`,
params: { id: entity.id },
}"
>
<RouterLink :to="{ name: `${module}Summary`, params: { id: entity.id } }">
<QBtn
class="link"
color="white"

View File

@ -1,6 +1,6 @@
<script setup>
import { ref, reactive, computed, onBeforeMount, watch } from 'vue';
import { useRouter } from 'vue-router';
import { ref, reactive, computed, onBeforeMount } from 'vue';
import { useRouter, onBeforeRouteLeave } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import axios from 'axios';
@ -135,14 +135,11 @@ onBeforeMount(async () => {
totalAmount.value = data.totalDueDay;
});
watch(
() => currentRoute.value.params.id,
async (newId) => {
invoiceInCorrection.correcting.length = 0;
invoiceInCorrection.corrected = null;
if (newId) await setInvoiceCorrection(entityId.value);
}
);
onBeforeRouteLeave(async (to, from) => {
invoiceInCorrection.correcting.length = 0;
invoiceInCorrection.corrected = null;
if (to.params.id !== from.params.id) await setInvoiceCorrection(entityId.value);
});
async function setInvoiceCorrection(id) {
const [{ data: correctingData }, { data: correctedData }] = await Promise.all([