fixed product search in contracts edit

This commit is contained in:
Paul Wilde 2023-02-14 15:20:54 +00:00
parent c50feca092
commit c9829b5d76

View file

@ -32,11 +32,21 @@
</label><br /> </label><br />
</v-col> </v-col>
</v-row> </v-row>
<template v-for="p in contract.products" :key="p.code"> <template v-for="(p, index) in contract.products" :key="index">
<v-row> <v-row>
<v-col cols="6"> <v-col cols="6">
<v-text-field label="Code" v-model="p.code"></v-text-field> <v-autocomplete
{{p.name }} label="Product Code"
@keyup.enter="searchProducts()"
:items="products"
item-title="code"
item-value="code"
v-model="p.code"
v-model:search="product_search"
append-icon="mdi-magnify"
no-data-text="No results (press Enter to search)"
cache-items
@click:append="searchProducts()"></v-autocomplete>
</v-col> </v-col>
<v-col cols="4"> <v-col cols="4">
<v-text-field type="number" label="Price" v-model="p.price"></v-text-field> <v-text-field type="number" label="Price" v-model="p.price"></v-text-field>
@ -98,11 +108,6 @@ export default {
setcontract(newval) { setcontract(newval) {
this.contract = newval this.contract = newval
}, },
product_search(val) {
if (val && val.length > 1) {
this.searchProducts(val)
}
},
customer_search(val) { customer_search(val) {
if (val && val.length > 2) { if (val && val.length > 2) {
this.searchCustomers(val) this.searchCustomers(val)
@ -175,8 +180,9 @@ export default {
console.log(err) console.log(err)
}) })
}, },
searchProducts(code) { searchProducts() {
let url = this.$api_url + "/products/search/" + code console.log("Searching for " & this.product_search)
let url = this.$api_url + "/products/search/" + this.product_search
axios.get(url) axios.get(url)
.then(resp => { .then(resp => {
console.log(resp) console.log(resp)
@ -184,7 +190,6 @@ export default {
}) })
.catch(err => { .catch(err => {
console.log(err) console.log(err)
this.products = [{code:"NoProductsFound", name:"No Products Found"}]
}) })
}, },
productCodeName(p) { productCodeName(p) {