2023-01-19 13:44:49 +01:00
|
|
|
<script>
|
|
|
|
import moment from 'moment'
|
2023-01-30 13:48:31 +01:00
|
|
|
import axios from 'axios'
|
2023-02-14 15:28:57 +01:00
|
|
|
import Error from '@/types/ErrorType.vue'
|
2023-01-19 13:44:49 +01:00
|
|
|
export default {
|
2023-01-30 13:48:31 +01:00
|
|
|
data() {
|
|
|
|
return {
|
2023-02-14 15:28:57 +01:00
|
|
|
customer_list: [],
|
|
|
|
errors: {}
|
2023-01-30 13:48:31 +01:00
|
|
|
}
|
|
|
|
},
|
2023-01-19 13:44:49 +01:00
|
|
|
methods:{
|
|
|
|
formatDate(d,f) {
|
|
|
|
return moment(String(d)).format(f)
|
|
|
|
},
|
|
|
|
formatNumber(num,chars) {
|
|
|
|
return parseFloat(num).toFixed(chars)
|
|
|
|
},
|
|
|
|
getDateNow() {
|
|
|
|
let now = new Date()
|
|
|
|
return now.toLocaleString('en-GB', {
|
|
|
|
day: '2-digit',
|
|
|
|
month: 'long',
|
|
|
|
year: 'numeric'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getTimeNow() {
|
|
|
|
let now = new Date()
|
|
|
|
return now.toLocaleString('en-GB', {
|
|
|
|
month: 'long',
|
|
|
|
day: '2-digit',
|
|
|
|
year: 'numeric',
|
|
|
|
hour: '2-digit',
|
|
|
|
minute: '2-digit',
|
|
|
|
second: '2-digit'})
|
|
|
|
},
|
2023-02-14 15:28:57 +01:00
|
|
|
async error(msg) {
|
|
|
|
let e = new Error()
|
|
|
|
e.msg = msg
|
|
|
|
e.id = crypto.randomUUID()
|
|
|
|
this.errors[e.id] = e
|
|
|
|
setTimeout(() => {
|
|
|
|
delete this.errors[e.id]
|
|
|
|
}, 10000)
|
|
|
|
},
|
2023-01-30 13:48:31 +01:00
|
|
|
async getCustomerList(name) {
|
|
|
|
console.log("searching customers...")
|
|
|
|
if (this.customer_list.length == 0) {
|
|
|
|
console.log("getting new customers...")
|
|
|
|
let url = this.$api_url + "/customers/full_list"
|
|
|
|
axios.get(url)
|
|
|
|
.then(resp => {
|
|
|
|
this.customer_list = resp.data
|
|
|
|
console.log(this.customer_list)
|
|
|
|
return this.customer_list.filter(x => {
|
|
|
|
x.name.contains(name) || x.acc_no.contains(name)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
return this.customer_list
|
|
|
|
}
|
|
|
|
}
|
2023-01-19 13:44:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|