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">
|
<div v-for="(line, index) in purchase.lines" :key="line.id">
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-text-field
|
<v-select
|
||||||
v-model="line.product"
|
v-model="line.product"
|
||||||
|
:items="products"
|
||||||
label="Producto"
|
label="Producto"
|
||||||
:rules="[rules.required]"
|
:rules="[rules.required]"
|
||||||
required
|
required
|
||||||
></v-text-field>
|
></v-select>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
@ -120,10 +121,12 @@
|
|||||||
{ title: 'Compras', route:'/compras'},
|
{ title: 'Compras', route:'/compras'},
|
||||||
],
|
],
|
||||||
clients: [],
|
clients: [],
|
||||||
|
products: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.fetchClients();
|
this.fetchClients();
|
||||||
|
this.fetchProducts();
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
calculateTotal() {
|
calculateTotal() {
|
||||||
@ -143,6 +146,17 @@
|
|||||||
console.error(error);
|
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() {
|
addLine() {
|
||||||
this.purchase.lines.push({ product: '', price: 0, quantity:0 });
|
this.purchase.lines.push({ product: '', price: 0, quantity:0 });
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user