forked from verdnatura/salix-front
Solucion a comentarios 25
This commit is contained in:
parent
0a33b8d92a
commit
e56aa6587f
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue