vuetify_set_unit_price_automatically_#37 #38
@@ -45,6 +45,7 @@
 | 
				
			|||||||
              <v-select
 | 
					              <v-select
 | 
				
			||||||
                v-model="line.product"
 | 
					                v-model="line.product"
 | 
				
			||||||
                :items="products"
 | 
					                :items="products"
 | 
				
			||||||
 | 
					                @update:modelValue="onProductChange(index)"
 | 
				
			||||||
                item-title="name"
 | 
					                item-title="name"
 | 
				
			||||||
                item-value="id"
 | 
					                item-value="id"
 | 
				
			||||||
                label="Producto"
 | 
					                label="Producto"
 | 
				
			||||||
@@ -58,7 +59,9 @@
 | 
				
			|||||||
                label="Precio"
 | 
					                label="Precio"
 | 
				
			||||||
                type="number"
 | 
					                type="number"
 | 
				
			||||||
                :rules="[rules.required]"
 | 
					                :rules="[rules.required]"
 | 
				
			||||||
 | 
					                prefix="$"
 | 
				
			||||||
                required
 | 
					                required
 | 
				
			||||||
 | 
					                readonly
 | 
				
			||||||
              ></v-text-field>
 | 
					              ></v-text-field>
 | 
				
			||||||
            </v-col>
 | 
					            </v-col>
 | 
				
			||||||
            <v-col>
 | 
					            <v-col>
 | 
				
			||||||
@@ -72,9 +75,12 @@
 | 
				
			|||||||
            </v-col>
 | 
					            </v-col>
 | 
				
			||||||
            <v-col>
 | 
					            <v-col>
 | 
				
			||||||
              <v-text-field
 | 
					              <v-text-field
 | 
				
			||||||
 | 
					                type="number"
 | 
				
			||||||
                :value="calculateSubtotal(line)"
 | 
					                :value="calculateSubtotal(line)"
 | 
				
			||||||
                label="Subtotal"
 | 
					                label="Subtotal"
 | 
				
			||||||
 | 
					                prefix="$"
 | 
				
			||||||
                readonly
 | 
					                readonly
 | 
				
			||||||
 | 
					                disable
 | 
				
			||||||
              ></v-text-field>
 | 
					              ></v-text-field>
 | 
				
			||||||
            </v-col>
 | 
					            </v-col>
 | 
				
			||||||
            <v-col>
 | 
					            <v-col>
 | 
				
			||||||
@@ -91,6 +97,7 @@
 | 
				
			|||||||
        <v-text-field
 | 
					        <v-text-field
 | 
				
			||||||
          :value="calculateTotal"
 | 
					          :value="calculateTotal"
 | 
				
			||||||
          label="Total"
 | 
					          label="Total"
 | 
				
			||||||
 | 
					          prefix="$"
 | 
				
			||||||
          readonly
 | 
					          readonly
 | 
				
			||||||
        ></v-text-field>
 | 
					        ></v-text-field>
 | 
				
			||||||
        <v-btn @click="submit" color="green">Comprar</v-btn>
 | 
					        <v-btn @click="submit" color="green">Comprar</v-btn>
 | 
				
			||||||
@@ -138,6 +145,11 @@
 | 
				
			|||||||
      },
 | 
					      },
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    methods: {
 | 
					    methods: {
 | 
				
			||||||
 | 
					      onProductChange(index) {
 | 
				
			||||||
 | 
					        const selectedProductId = this.purchase.saleline_set[index].product;
 | 
				
			||||||
 | 
					        const selectedProduct = this.products.find(p => p.id == selectedProductId);
 | 
				
			||||||
 | 
					        this.purchase.saleline_set[index].unit_price = selectedProduct.price;
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
      fetchClients() {
 | 
					      fetchClients() {
 | 
				
			||||||
        fetch('/don_confiao/api/customers/')
 | 
					        fetch('/don_confiao/api/customers/')
 | 
				
			||||||
          .then(response => response.json())
 | 
					          .then(response => response.json())
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user