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 />
</v-col>
</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-col cols="6">
<v-text-field label="Code" v-model="p.code"></v-text-field>
{{p.name }}
<v-autocomplete
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 cols="4">
<v-text-field type="number" label="Price" v-model="p.price"></v-text-field>
@ -98,11 +108,6 @@ export default {
setcontract(newval) {
this.contract = newval
},
product_search(val) {
if (val && val.length > 1) {
this.searchProducts(val)
}
},
customer_search(val) {
if (val && val.length > 2) {
this.searchCustomers(val)
@ -175,8 +180,9 @@ export default {
console.log(err)
})
},
searchProducts(code) {
let url = this.$api_url + "/products/search/" + code
searchProducts() {
console.log("Searching for " & this.product_search)
let url = this.$api_url + "/products/search/" + this.product_search
axios.get(url)
.then(resp => {
console.log(resp)
@ -184,7 +190,6 @@ export default {
})
.catch(err => {
console.log(err)
this.products = [{code:"NoProductsFound", name:"No Products Found"}]
})
},
productCodeName(p) {