Se hacen mejoras al momento de hacer las peticiones y se refresca la data actualizada

This commit is contained in:
carlosfonseca 2024-01-08 17:28:56 -05:00
parent c21afccf75
commit dd8373ea22
2 changed files with 54 additions and 24 deletions

View File

@ -26,21 +26,6 @@ const workerId = ref(0);
const rows = computed(() => arrayData.value.store.data); const rows = computed(() => arrayData.value.store.data);
onBeforeMount(async () => {
arrayData.value = useArrayData('CustomerDefaulter', {
url: 'Defaulters/filter',
limit: 0,
});
await arrayData.value.fetch({ append: false });
balanceDueTotal.value = arrayData.value.store.data.reduce(
(accumulator, currentValue) => {
return accumulator + (currentValue['amount'] || 0);
},
0
);
stateStore.rightDrawer = true;
});
const tableColumnComponents = { const tableColumnComponents = {
client: { client: {
component: QBtn, component: QBtn,
@ -170,6 +155,25 @@ const columns = computed(() => [
}, },
]); ]);
onBeforeMount(() => {
getArrayData();
});
const getArrayData = async () => {
arrayData.value = useArrayData('CustomerDefaulter', {
url: 'Defaulters/filter',
limit: 0,
});
await arrayData.value.fetch({ append: false });
balanceDueTotal.value = arrayData.value.store.data.reduce(
(accumulator, currentValue) => {
return accumulator + (currentValue['amount'] || 0);
},
0
);
stateStore.rightDrawer = true;
};
const selectCustomerId = (id) => { const selectCustomerId = (id) => {
workerId.value = 0; workerId.value = 0;
customerId.value = id; customerId.value = id;
@ -185,9 +189,14 @@ const viewAddObservation = (rowsSelected) => {
component: CustomerDefaulterAddObservation, component: CustomerDefaulterAddObservation,
componentProps: { componentProps: {
clients: rowsSelected, clients: rowsSelected,
promise: refreshData,
}, },
}); });
}; };
const refreshData = () => {
getArrayData();
};
</script> </script>
<template> <template>

View File

@ -3,6 +3,7 @@ import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios'; import axios from 'axios';
import { useQuasar } from 'quasar';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
@ -11,22 +12,42 @@ const $props = defineProps({
type: Array, type: Array,
required: true, required: true,
}, },
promise: {
type: Function,
required: true,
},
}); });
const { t } = useI18n(); const { t } = useI18n();
const quasar = useQuasar();
const newObservation = ref(null); const newObservation = ref(null);
const onSubmit = async () => { const onSubmit = async () => {
const data = $props.clients.map((item) => { try {
return { clientFk: item.clientFk, text: newObservation.value }; const data = $props.clients.map((item) => {
}); return { clientFk: item.clientFk, text: newObservation.value };
await axios.post('ClientObservations', data); });
const payload = { await axios.post('ClientObservations', data);
defaulters: $props.clients,
observation: newObservation.value, const payload = {
}; defaulters: $props.clients,
await axios.post('Defaulters/observationEmail', payload); observation: newObservation.value,
};
await axios.post('Defaulters/observationEmail', payload);
await $props.promise();
quasar.notify({
message: t('globals.dataSaved'),
type: 'positive',
});
} catch (error) {
quasar.notify({
message: t(`${error.message}`),
type: 'negative',
});
}
}; };
</script> </script>