cmc_fe/src/views/customers/CustomerList.vue

132 lines
4.7 KiB
Vue
Raw Normal View History

2023-01-19 12:44:49 +00:00
<template>
2023-03-20 18:13:10 +00:00
<v-text-field
clearable
label="Search"
variant="outlined"
v-model="searchQuery"
density="compact"
append-inner-icon="mdi-magnify"></v-text-field>
<v-row>
<v-col cols="12" sm=12 lg=6>
<h3>Customer List</h3>
<v-progress-linear color="blue" :active="customers_loading" indeterminate>
</v-progress-linear>
<v-list>
<RecycleScroller
class="scroller"
:items="filteredCustomers"
2023-03-21 13:02:06 +00:00
:item-size="60"
2023-03-20 18:13:10 +00:00
key-field="acc_no"
v-slot="{ item }"
>
2023-03-21 15:06:42 +00:00
<v-list-item >
<template v-slot:title >
2023-03-21 16:57:39 +00:00
<v-card @click="getCustomerInfo(item)">
{{ item.acc_no }} - {{ item.name }}:
<span class="text-caption">{{ item.address.line_1 }}, {{ item.address.line_2 }}, <br/>
{{ item.address.city }}, {{ item.address.county}}, {{ item.address.postcode }},
</span>
2023-03-21 15:06:42 +00:00
</v-card>
2023-03-21 13:02:06 +00:00
</template>
2023-03-21 16:57:39 +00:00
<template v-slot:append>
2023-03-24 12:55:23 +00:00
<v-btn @click.prevent="goToContracts(item)" class="text-none" color="blue-lighten-1" title="View Contracts">
2023-03-21 16:57:39 +00:00
Contracts
2023-03-24 12:55:23 +00:00
<v-badge v-if="item.contract_count > 0" color="blue-lighten-4" floating :content="item.contract_count">
2023-03-21 16:57:39 +00:00
</v-badge>
</v-btn>
2023-03-24 12:55:23 +00:00
<v-btn @click.prevent="goToMedFeeds(item)" class="text-none" color="orange-lighten-1" title="View Med Feeds">
2023-03-21 16:57:39 +00:00
Med Feeds
2023-03-24 12:55:23 +00:00
<v-badge v-if="item.medfeed_count > 0" color="orange-lighten-4" floating :content="item.medfeed_count">
2023-03-21 16:57:39 +00:00
</v-badge>
</v-btn>
</template>
2023-03-20 18:13:10 +00:00
</v-list-item>
</RecycleScroller>
</v-list>
<RecentOrders :customer="selected_cust" doc_status="0"></RecentOrders>
2023-03-20 18:13:10 +00:00
</v-col>
<v-col cols="12" sm=12 lg=6>
<CustomerComments :customer="selected_cust"></CustomerComments>
2023-03-24 12:55:23 +00:00
<br/>
2023-03-22 13:13:29 +00:00
<RecentOrders :customer="selected_cust" doc_status="2"></RecentOrders>
2023-03-20 18:13:10 +00:00
</v-col>
</v-row>
2023-01-19 12:44:49 +00:00
</template>
<script>
import axios from 'axios';
2023-03-21 16:57:39 +00:00
import RecentOrders from '@/components/RecentOrders.vue'
import CustomerComments from '@/components/CustomerComments.vue'
import Customer from '@/types/CustomerType.vue'
2023-01-19 12:44:49 +00:00
export default {
props: {
site_info: {},
user_info: {}
},
data() {
return {
searchQuery: "",
2023-03-20 18:13:10 +00:00
customer_list: [],
customers_loading: null,
2023-03-21 16:57:39 +00:00
selected_cust: new Customer(),
2023-01-19 12:44:49 +00:00
limit: 5000,
2023-03-20 18:13:10 +00:00
listreceived: false,
2023-01-19 12:44:49 +00:00
}
},
components: {
2023-03-21 16:57:39 +00:00
RecentOrders,
CustomerComments
2023-01-19 12:44:49 +00:00
},
computed: {
filteredCustomers() {
let query = this.searchQuery.toLowerCase()
if (!this.listreceived){
this.getCustomerList()
}
2023-03-20 18:13:10 +00:00
let clist = this.customer_list.filter(q =>
2023-01-19 12:44:49 +00:00
q.name.toLowerCase().includes(query) ||
2023-03-21 13:02:06 +00:00
q.acc_no.includes(query) ||
q.address.line_1.toLowerCase().includes(query) ||
q.address.line_2.toLowerCase().includes(query) ||
q.address.city.toLowerCase().includes(query) ||
q.address.postcode.toLowerCase().includes(query)
2023-01-19 12:44:49 +00:00
)
return clist
},
},
methods: {
2023-03-21 16:57:39 +00:00
getCustomerInfo(c) {
this.selected_cust = c
},
2023-03-21 15:06:42 +00:00
goToContracts(c){
this.$router.push('/customers/contracts/list/' + c.id)
2023-03-21 15:06:42 +00:00
},
goToMedFeeds(c){
this.$router.push('/customers/medicated-feeds/list/' + c.id)
2023-03-21 15:06:42 +00:00
},
2023-01-19 12:44:49 +00:00
async getCustomerList() {
2023-03-20 18:13:10 +00:00
this.customers_loading = true
2023-01-19 12:44:49 +00:00
let url = this.$api_url + "/customers/list"
axios
.get(url,{
params: { limit: this.limit, query: this.searchQuery }})
.then(resp => {
2023-03-20 18:13:10 +00:00
this.customer_list = resp.data
2023-01-19 12:44:49 +00:00
this.listreceived = true
})
.catch(error => (console.log(error)))
2023-03-20 18:13:10 +00:00
.finally(() => {
this.customers_loading = false
})
2023-01-19 12:44:49 +00:00
}
}
}
</script>
<style>
2023-01-19 12:44:49 +00:00
.scroller {
2023-03-23 17:05:16 +00:00
height: 300px;
2023-01-19 12:44:49 +00:00
}
2023-03-20 18:13:10 +00:00
.scroller.small {
height: 200px;
2023-01-19 12:44:49 +00:00
}
</style>