view(Purchase): add products to purchase.
This commit is contained in:
parent
98d173bf00
commit
f2befda953
@ -42,12 +42,13 @@
|
||||
<div v-for="(line, index) in purchase.lines" :key="line.id">
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-text-field
|
||||
<v-select
|
||||
v-model="line.product"
|
||||
:items="products"
|
||||
label="Producto"
|
||||
:rules="[rules.required]"
|
||||
required
|
||||
></v-text-field>
|
||||
></v-select>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-text-field
|
||||
@ -120,10 +121,12 @@
|
||||
{ title: 'Compras', route:'/compras'},
|
||||
],
|
||||
clients: [],
|
||||
products: [],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.fetchClients();
|
||||
this.fetchProducts();
|
||||
},
|
||||
computed: {
|
||||
calculateTotal() {
|
||||
@ -143,6 +146,17 @@
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
fetchProducts() {
|
||||
fetch('/don_confiao/api/products/')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
this.products = data.map(product => product.name);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
addLine() {
|
||||
this.purchase.lines.push({ product: '', price: 0, quantity:0 });
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user