0
0
Fork 0

Solucion a comentarios 25

This commit is contained in:
carlosfonseca 2024-02-28 06:37:15 -05:00
parent 0a33b8d92a
commit e56aa6587f
1 changed files with 24 additions and 8 deletions

View File

@ -43,19 +43,35 @@ watch(
);
const getData = async (id) => {
const filter = { clientFk: id };
try {
const { data } = await axios.get(`ClientUnpaids/${id}`);
unpaidClient.value = true;
amount.value = data.amount;
dated.value = data.dated;
initialData.value = data;
const { data } = await axios.get('ClientUnpaids', {
params: { filter: JSON.stringify(filter) },
});
const unpaid = data.find((element) => element.clientFk == id);
if (unpaid) {
setValues(unpaid);
} else {
defaultValues();
}
} catch (error) {
unpaidClient.value = false;
initialData.value.amount = null;
setInitialData();
defaultValues();
}
};
const setValues = (data) => {
unpaidClient.value = true;
amount.value = data.amount;
dated.value = data.dated;
initialData.value = data;
};
const defaultValues = () => {
unpaidClient.value = false;
initialData.value.amount = null;
setInitialData();
};
const setInitialData = () => {
amount.value = initialData.value.amount;
dated.value = initialData.value.dated;