Initial
This commit is contained in:
126
spaces/pages/inventory/index.vue
Normal file
126
spaces/pages/inventory/index.vue
Normal file
@@ -0,0 +1,126 @@
|
||||
<script setup>
|
||||
definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
|
||||
const {find,create} = useStrapi4()
|
||||
const spaces = (await find('spaces',{populate: "*"})).data
|
||||
const products = (await find('products',{populate: "*"})).data
|
||||
const movements = (await find('movements',{populate: "*"})).data
|
||||
|
||||
const searchinput = ref("")
|
||||
const mode = ref("")
|
||||
|
||||
const toast = useToast()
|
||||
|
||||
const inventoryChangeData = ref({
|
||||
productId: "",
|
||||
spaceId: "",
|
||||
quantity: 0
|
||||
})
|
||||
|
||||
const createMovement = async () => {
|
||||
if(mode.value === 'incoming'){
|
||||
await create('movements', inventoryChangeData.value)
|
||||
} else if (mode.value === 'outgoing'){
|
||||
inventoryChangeData.value.quantity *= -1
|
||||
await create('movements', inventoryChangeData.value)
|
||||
} else if (mode.value === 'change'){}
|
||||
|
||||
inventoryChangeData.value = {
|
||||
productId: "",
|
||||
spaceId: "",
|
||||
quantity: 0
|
||||
}
|
||||
alert("Created")
|
||||
}
|
||||
|
||||
function checkArticle(productId) {
|
||||
return products.filter(product => product.id === Number(productId)).length > 0;
|
||||
}
|
||||
function checkSpaceId(spaceId) {
|
||||
return spaces.filter(space => space.attributes.spaceNumber === spaceId).length > 0;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div id="main">
|
||||
<router-link to="/inventory/spaces"><UButton>Lagerplätze</UButton></router-link>
|
||||
|
||||
<!--<UInput
|
||||
icon="i-heroicons-magnifying-glass-20-solid"
|
||||
variant="outline"
|
||||
color="primary"
|
||||
placeholder="Barcode / Suche"
|
||||
v-model="searchinput"
|
||||
/>-->
|
||||
|
||||
<UButton @click="mode = 'incoming'" class="ml-3" >Wareneingang</UButton>
|
||||
<UButton @click="mode = 'outgoing'" class="ml-1">Warenausgang</UButton>
|
||||
<UButton @click="mode = 'change'" class="ml-1" disabled>Umlagern</UButton>
|
||||
|
||||
<UFormGroup
|
||||
label="Artikel:"
|
||||
class="mt-3"
|
||||
>
|
||||
<UInput
|
||||
variant="outline"
|
||||
:color="checkArticle(inventoryChangeData.productId) ? 'primary' : 'rose'"
|
||||
placeholder="Barcode / Suche"
|
||||
v-model="inventoryChangeData.productId"
|
||||
/>
|
||||
</UFormGroup>
|
||||
|
||||
<UFormGroup
|
||||
label="Lagerplatz:"
|
||||
class="mt-3"
|
||||
>
|
||||
<UInput
|
||||
variant="outline"
|
||||
:color="checkSpaceId(inventoryChangeData.spaceId) ? 'primary' : 'rose'"
|
||||
placeholder="Barcode / Suche"
|
||||
v-model="inventoryChangeData.spaceId"
|
||||
/>
|
||||
</UFormGroup>
|
||||
|
||||
<UFormGroup
|
||||
label="Anzahl:"
|
||||
class="mt-3"
|
||||
>
|
||||
<UInput
|
||||
variant="outline"
|
||||
color="primary"
|
||||
placeholder="Anzahl"
|
||||
v-model="inventoryChangeData.quantity"
|
||||
type="number"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<UButton
|
||||
@click="createMovement"
|
||||
:disabled="mode === '' && checkSpaceId(inventoryChangeData.spaceId) && checkArticle(inventoryChangeData.productId)"
|
||||
class="mt-3"
|
||||
>
|
||||
Bestätigen
|
||||
</UButton>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
#main {
|
||||
/*display: flex;
|
||||
flex-direction: row;*/
|
||||
}
|
||||
#left {
|
||||
width: 25vw;
|
||||
}
|
||||
|
||||
#right {
|
||||
width: 60vw;
|
||||
padding-left: 3vw;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user