This commit is contained in:
2024-07-02 18:38:11 +02:00
parent d2da96eaa3
commit d327277bac
14 changed files with 288 additions and 20 deletions

View File

@@ -15,7 +15,8 @@ const inventoryChangeData = ref({
sourceProjectId: null,
destinationSpaceId: null,
destinationProjectId: null,
quantity: 1
quantity: 1,
serials: []
})
const resetInput = () => {
@@ -93,7 +94,14 @@ const createMovement = async () => {
.from("movements")
.insert(movements)
.select()
if(error) console.log(error)
if(error) {
console.log(error)
} else {
resetInput()
}
}
@@ -146,6 +154,7 @@ const findSpaceBySpaceNumber = (input) => {
const barcodeInput = ref("")
const showBarcodeTip = ref(true)
const serialInput = ref("")
const processBarcodeInput = () => {
if(findProductByBarcodeOrEAN(barcodeInput.value) && !findSpaceBySpaceNumber(barcodeInput.value)){
@@ -380,6 +389,29 @@ const processBarcodeInput = () => {
id="quantityInput"
/>
</UFormGroup>
<UFormGroup
label="Seriennummern:"
class="mt-3 w-80"
>
<InputGroup class="w-full">
<UInput
variant="outline"
color="primary"
placeholder="Seriennummern"
v-model="serialInput"
/>
<UButton
@click="inventoryChangeData.serials.push(serialInput)"
>
+
</UButton>
</InputGroup>
</UFormGroup>
<ul>
<li v-for="serial in inventoryChangeData.serials">{{serial}}</li>
</ul>
</div>
</UDashboardPanelContent>

152
pages/inventory/stocks.vue Normal file
View File

@@ -0,0 +1,152 @@
<template>
<UDashboardNavbar title="Bestände" :badge="filteredRows.length">
<template #right>
<UInput
id="searchinput"
v-model="searchString"
icon="i-heroicons-funnel"
autocomplete="off"
placeholder="Suche..."
class="hidden lg:block"
@keydown.esc="$event.target.blur()"
>
<template #trailing>
<UKbd value="/" />
</template>
</UInput>
<UButton @click="router.push(`/products/create`)">+ Artikel</UButton>
</template>
</UDashboardNavbar>
<UDashboardToolbar>
<template #right>
<USelectMenu
v-model="selectedColumns"
icon="i-heroicons-adjustments-horizontal-solid"
:options="templateColumns"
multiple
class="hidden lg:block"
by="key"
>
<template #label>
Spalten
</template>
</USelectMenu>
</template>
</UDashboardToolbar>
<UTable
:rows="filteredRows"
:columns="columns"
class="w-full"
:ui="{ divide: 'divide-gray-200 dark:divide-gray-800' }"
@select="(i) => router.push(`/products/show/${i.id}`) "
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Artikel anzuzeigen' }"
>
<template #name-data="{row}">
<span
v-if="row === filteredRows[selectedItem]"
class="text-primary-500 font-bold">{{row.name}}</span>
<span v-else>
{{row.name}}
</span>
</template>
<template #stock-data="{row}">
{{`${dataStore.getStockByProductId(row.id)} ${(dataStore.units.find(unit => unit.id === row.unit) ? dataStore.units.find(unit => unit.id === row.unit).name : "")}`}}
</template>
</UTable>
</template>
<script setup>
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {
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 selectedItem = ref(0)
const setupPage = async () => {
items.value = await useSupabaseSelect("products","*")
}
setupPage()
const templateColumns = [
{
key: "stock",
label: "Bestand"
},
{
key: "name",
label: "Name",
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>
</style>