Reffractored vendors,vehicles,services,servicecategories,products,productcategories, projects, plants, customers, contracts, contacts
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
<template>
|
||||
<UDashboardNavbar title="Artikel" :badge="filteredRows.length">
|
||||
<EntityList
|
||||
:items="items"
|
||||
type="products"
|
||||
/>
|
||||
<!-- <UDashboardNavbar title="Artikel" :badge="filteredRows.length">
|
||||
<template #right>
|
||||
<UInput
|
||||
id="searchinput"
|
||||
@@ -87,7 +91,7 @@
|
||||
<template #productcategories-data="{row}">
|
||||
{{row.productcategories.map(i => productcategories.find(x => x.id === i).name).join(", ")}}
|
||||
</template>
|
||||
</UTable>
|
||||
</UTable>-->
|
||||
|
||||
</template>
|
||||
|
||||
@@ -97,122 +101,15 @@ definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
|
||||
defineShortcuts({
|
||||
'/': () => {
|
||||
//console.log(searchinput)
|
||||
//searchinput.value.focus()
|
||||
document.getElementById("searchinput").focus()
|
||||
},
|
||||
'+': () => {
|
||||
router.push("/products/create")
|
||||
},
|
||||
'Enter': {
|
||||
usingInput: true,
|
||||
handler: () => {
|
||||
router.push(`/products/show/${filteredRows.value[selectedItem.value].id}`)
|
||||
}
|
||||
},
|
||||
'arrowdown': () => {
|
||||
if(selectedItem.value < filteredRows.value.length - 1) {
|
||||
selectedItem.value += 1
|
||||
} else {
|
||||
selectedItem.value = 0
|
||||
}
|
||||
},
|
||||
'arrowup': () => {
|
||||
if(selectedItem.value === 0) {
|
||||
selectedItem.value = filteredRows.value.length - 1
|
||||
} else {
|
||||
selectedItem.value -= 1
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const router = useRouter()
|
||||
|
||||
const items = ref([])
|
||||
const productcategories = ref([])
|
||||
const selectedItem = ref(0)
|
||||
|
||||
const setupPage = async () => {
|
||||
items.value = await useSupabaseSelect("products","*")
|
||||
items.value = await useSupabaseSelect("products","*, unit(name)")
|
||||
productcategories.value = await useSupabaseSelect("productcategories", "*")
|
||||
}
|
||||
|
||||
setupPage()
|
||||
|
||||
|
||||
const templateColumns = [
|
||||
{
|
||||
key: "stock",
|
||||
label: "Bestand"
|
||||
},
|
||||
{
|
||||
key: "name",
|
||||
label: "Name",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "description",
|
||||
label: "Beschreibung",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "manufacturer",
|
||||
label: "Hersteller",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "unit",
|
||||
label: "Einheit",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "sellingPrice",
|
||||
label: "Verkaufpreispreis",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "tags",
|
||||
label: "Tags",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "productcategories",
|
||||
label: "Artikelkategorien",
|
||||
sortable: true
|
||||
}
|
||||
]
|
||||
const selectedColumns = ref(templateColumns)
|
||||
const columns = computed(() => templateColumns.filter((column) => selectedColumns.value.includes(column)))
|
||||
|
||||
const templateTags = computed(() => {
|
||||
let temp = []
|
||||
|
||||
dataStore.products.forEach(row => {
|
||||
row.tags.forEach(tag => {
|
||||
if(!temp.includes(tag)) temp.push(tag)
|
||||
})
|
||||
})
|
||||
|
||||
return temp
|
||||
|
||||
})
|
||||
const selectedTags = ref(templateTags.value)
|
||||
|
||||
|
||||
const searchString = ref('')
|
||||
|
||||
const filteredRows = computed(() => {
|
||||
let temp = items.value.filter(i => i.tags.some(x => selectedTags.value.includes(x)) || i.tags.length === 0)
|
||||
|
||||
return useSearch(searchString.value, temp)
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user