Se hacen mejoras al momento de hacer las peticiones y se refresca la data actualizada
This commit is contained in:
parent
c21afccf75
commit
dd8373ea22
|
@ -26,21 +26,6 @@ const workerId = ref(0);
|
|||
|
||||
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 = {
|
||||
client: {
|
||||
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) => {
|
||||
workerId.value = 0;
|
||||
customerId.value = id;
|
||||
|
@ -185,9 +189,14 @@ const viewAddObservation = (rowsSelected) => {
|
|||
component: CustomerDefaulterAddObservation,
|
||||
componentProps: {
|
||||
clients: rowsSelected,
|
||||
promise: refreshData,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const refreshData = () => {
|
||||
getArrayData();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -3,6 +3,7 @@ import { ref } from 'vue';
|
|||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import axios from 'axios';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
|
||||
|
@ -11,22 +12,42 @@ const $props = defineProps({
|
|||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
promise: {
|
||||
type: Function,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const quasar = useQuasar();
|
||||
|
||||
const newObservation = ref(null);
|
||||
|
||||
const onSubmit = async () => {
|
||||
const data = $props.clients.map((item) => {
|
||||
return { clientFk: item.clientFk, text: newObservation.value };
|
||||
});
|
||||
await axios.post('ClientObservations', data);
|
||||
const payload = {
|
||||
defaulters: $props.clients,
|
||||
observation: newObservation.value,
|
||||
};
|
||||
await axios.post('Defaulters/observationEmail', payload);
|
||||
try {
|
||||
const data = $props.clients.map((item) => {
|
||||
return { clientFk: item.clientFk, text: newObservation.value };
|
||||
});
|
||||
await axios.post('ClientObservations', data);
|
||||
|
||||
const payload = {
|
||||
defaulters: $props.clients,
|
||||
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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue