70 lines
1.2 KiB
Vue
70 lines
1.2 KiB
Vue
<template>
|
|
|
|
<Toolbar>
|
|
<UButton @click="router.push(`/customers/create/`)">+ Kunde</UButton>
|
|
|
|
<UInput
|
|
v-model="searchString"
|
|
placeholder="Suche..."
|
|
/>
|
|
</Toolbar>
|
|
|
|
<div class="table">
|
|
<UTable
|
|
:rows="filteredRows"
|
|
:columns="customerColumns"
|
|
@select="selectCustomer"
|
|
|
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
|
|
definePageMeta({
|
|
middleware: "auth"
|
|
})
|
|
|
|
const dataStore = useDataStore()
|
|
const router = useRouter()
|
|
const mode = ref("show")
|
|
|
|
const customerColumns = [
|
|
{
|
|
key: 'customerNumber',
|
|
label: "Kundennr.",
|
|
sortable: true
|
|
},
|
|
{
|
|
key: "name",
|
|
label: "Name",
|
|
sortable: true
|
|
}
|
|
]
|
|
|
|
|
|
const selectCustomer = (customer) => {
|
|
console.log(customer)
|
|
router.push(`/customers/show/${customer.id} `)
|
|
}
|
|
|
|
|
|
const searchString = ref('')
|
|
|
|
const filteredRows = computed(() => {
|
|
if(!searchString.value) {
|
|
return dataStore.customers
|
|
}
|
|
|
|
return dataStore.customers.filter(item => {
|
|
return Object.values(item).some((value) => {
|
|
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
|
})
|
|
})
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
|
|
</style> |