Feat: Cargar ultimo cliente creado

This commit is contained in:
sinergia 2024-11-02 10:54:14 -05:00
parent 2ea8cc7fd8
commit eeb9821675
2 changed files with 7 additions and 3 deletions

View File

@ -82,7 +82,7 @@
if (response.ok) { if (response.ok) {
const data = await response.json(); const data = await response.json();
console.log('Cliente Guardado:', data); console.log('Cliente Guardado:', data);
this.$emit('customerCreated'); this.$emit('customerCreated', data);
this.closeModal(); this.closeModal();
} else { } else {
console.error('Error al Crear el Cliente:', response.statusText); console.error('Error al Crear el Cliente:', response.statusText);

View File

@ -16,7 +16,7 @@
class="mr-4" class="mr-4"
></v-autocomplete> ></v-autocomplete>
<v-btn color="primary" @click="openModal">Agregar Cliente</v-btn> <v-btn color="primary" @click="openModal">Agregar Cliente</v-btn>
<CreateCustomerModal ref="customerModal" @customerCreated="fetchClients"/> <CreateCustomerModal ref="customerModal" @customerCreated="handleNewCustomer"/>
</v-col> </v-col>
<v-col <v-col
lg="2" lg="2"
@ -131,7 +131,7 @@
product_search: '', product_search: '',
purchase: { purchase: {
date: this.getCurrentDate(), date: this.getCurrentDate(),
client: null, customer: null,
notes: '', notes: '',
saleline_set: [{product:'', unit_price: 0, quantity: 0}], saleline_set: [{product:'', unit_price: 0, quantity: 0}],
}, },
@ -207,6 +207,10 @@
console.error(error); console.error(error);
}); });
}, },
handleNewCustomer(newCustomer){
this.clients.push(newCustomer);
this.purchase.customer = newCustomer.id;
},
fetchProducts() { fetchProducts() {
fetch('/don_confiao/api/products/') fetch('/don_confiao/api/products/')
.then(response => response.json()) .then(response => response.json())