From 0caeb1d8598e0bbf822e178201496f34c4157f78 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Mon, 20 Mar 2023 22:04:16 +0000 Subject: [PATCH] created customer search component --- src/components/CustomerSearch.vue | 67 ++++++++++++++++++++++++++++ src/views/contracts/ContractEdit.vue | 54 ++++------------------ 2 files changed, 75 insertions(+), 46 deletions(-) create mode 100644 src/components/CustomerSearch.vue diff --git a/src/components/CustomerSearch.vue b/src/components/CustomerSearch.vue new file mode 100644 index 0000000..3a8b2fb --- /dev/null +++ b/src/components/CustomerSearch.vue @@ -0,0 +1,67 @@ + + diff --git a/src/views/contracts/ContractEdit.vue b/src/views/contracts/ContractEdit.vue index c2543a7..1cf405e 100644 --- a/src/views/contracts/ContractEdit.vue +++ b/src/views/contracts/ContractEdit.vue @@ -102,26 +102,7 @@ - - - - - - - - - - {{ item.acc_no }} - {{ item.name }} - - - - - + @@ -134,6 +115,7 @@ import ErrorBanner from '@/components/ErrorBanner.vue' import methods from '@/CommonMethods.vue' import Product from '@/types/ProductType.vue' import ProductSearch from '@/components/ProductSearch.vue' +import CustomerSearch from '@/components/CustomerSearch.vue' export default { props: { setcontract: {} @@ -141,7 +123,8 @@ export default { components: { DatePicker, ErrorBanner, - ProductSearch + ProductSearch, + CustomerSearch }, watch: { setcontract(newval) { @@ -165,17 +148,6 @@ export default { } }, computed: { - filteredCustomers(){ - if (this.customer_search == null){ - return [] - } - let query = this.customer_search.toLowerCase() - let clist = this.customers.filter(q => - q.name.toLowerCase().includes(query) || - q.acc_no.includes(query) - ) - return clist - }, title() { if ( this.contract.isNew ) { return "New Contract" @@ -229,20 +201,6 @@ export default { this.saving = false }) }, - async searchCustomers() { - this.customers_loading = true - let url = this.$api_url + "/customers/search/" + this.customer_search - axios.get(url) - .then(resp => { - this.customers = resp.data - }) - .catch(err => { - console.log(err) - }) - .finally(() => { - this.customers_loading = false - }) - }, productCodeName(p) { return p.code + ' - ' + p.name }, @@ -251,6 +209,10 @@ export default { p.price = q.price this.contract.products[this.searchProdIndex] = p this.search[1] = false + }, + setCustomer(c){ + this.contract.customer = c + this.search[0] = false } } }