Merge pull request 'Feat: issue #26' (#61) from MeasurementUnitField into main

Reviewed-on: OneTeam/don_confiao#61
This commit is contained in:
Rodia 2024-11-02 13:59:12 -05:00
commit 02a010b50d

View File

@ -82,6 +82,14 @@
required required
></v-text-field> ></v-text-field>
</v-col> </v-col>
<v-col>
<v-text-field
v-model="line.measuring_unit"
label="UdM"
persistent-placeholder="true"
readonly
></v-text-field>
</v-col>
<v-col> <v-col>
<v-text-field <v-text-field
type="number" type="number"
@ -133,7 +141,7 @@
date: this.getCurrentDate(), date: this.getCurrentDate(),
customer: null, customer: null,
notes: '', notes: '',
saleline_set: [{product:'', unit_price: 0, quantity: 0}], saleline_set: [{product:'', unit_price: 0, quantity: 0, unit: ''}],
}, },
rules: { rules: {
required: value => !!value || 'Requerido.', required: value => !!value || 'Requerido.',
@ -196,6 +204,8 @@
const selectedProductId = this.purchase.saleline_set[index].product; const selectedProductId = this.purchase.saleline_set[index].product;
const selectedProduct = this.products.find(p => p.id == selectedProductId); const selectedProduct = this.products.find(p => p.id == selectedProductId);
this.purchase.saleline_set[index].unit_price = selectedProduct.price; this.purchase.saleline_set[index].unit_price = selectedProduct.price;
console.log(selectedProduct.measuring_unit);
this.purchase.saleline_set[index].measuring_unit = selectedProduct.measuring_unit;
}, },
fetchClients() { fetchClients() {
fetch('/don_confiao/api/customers/') fetch('/don_confiao/api/customers/')
@ -223,7 +233,7 @@
}); });
}, },
addLine() { addLine() {
this.purchase.saleline_set.push({ product: '', unit_price: 0, quantity:0 }); this.purchase.saleline_set.push({ product: '', unit_price: 0, quantity:0, measuring_unit: ''});
}, },
removeLine(index) { removeLine(index) {
// Solo elimina si hay más de una línea // Solo elimina si hay más de una línea