This commit is contained in:
Florian Federspiel
2023-11-25 16:53:52 +01:00
commit 677030f712
685 changed files with 148719 additions and 0 deletions

View 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>

View File

@@ -0,0 +1,126 @@
<script setup>
definePageMeta({
middleware: "auth"
})
const {find,create, update} = useStrapi4()
const spaces = (await find('spaces',{populate: "*"})).data
const movements = (await find('movements',{populate: "*"})).data
const products = (await find('products',{populate: "*"})).data
let selectedItem = ref({})
const showCreateSpace = ref(false)
const selectItem = (item) => {
selectedItem.value = item
spaceMovements.value = movements.filter(movement => movement.attributes.spaceId === selectedItem.value.attributes.spaceNumber)
spaceMovements.value.forEach(movement => {
if(!spaceProducts.value.includes(movement.attributes.productId)) spaceProducts.value.push(movement.attributes.productId)
})
}
const spaceTypes = ["Regalplatz", "Kiste", "Palettenplatz"]
const createSpaceData = ref({})
const createSpace = async () => {
let lastSpaceNumber = 0
spaces.forEach(space => {
if(space.attributes.spaceNumber > lastSpaceNumber) lastSpaceNumber = space.attributes.spaceNumber
})
await create('spaces', {...createSpaceData.value, spaceNumber: String(Number(lastSpaceNumber)+1)})
showCreateSpace.value = false
createSpaceData.value = {}
}
const spaceProducts = ref([])
const spaceMovements = ref([])
function getSpaceProductCount(productId) {
let productMovements = spaceMovements.value.filter(movement => movement.attributes.productId === productId)
let count = 0;
productMovements.forEach(movement => count += movement.attributes.quantity)
return count
}
</script>
<template>
<div id="main">
<div id="left">
<UButton @click="showCreateSpace = true">
Erstellen
</UButton>
<UModal v-model="showCreateSpace">
<UCard>
<template #header>
Lagerplatz erstellen
</template>
<UFormGroup
label="Beschreibung:"
>
<UTextarea
v-model="createSpaceData.description"
/>
</UFormGroup>
<UFormGroup
label="Typ:"
>
<USelectMenu
v-model="createSpaceData.type"
:options="spaceTypes"
/>
</UFormGroup>
<template #footer>
<UButton @click="createSpace">Erstellen</UButton>
</template>
</UCard>
</UModal>
<a v-for="item in spaces" @click="selectItem(item)">
<UCard class="listItem">
{{item.attributes.spaceNumber}} - {{item.attributes.type}}
</UCard>
</a>
</div>
<div id="right">
<UCard v-if="selectedItem.attributes">
<template #header>
<UBadge class="mr-1">{{selectedItem.attributes.spaceNumber}}</UBadge>{{selectedItem.attributes.type}}
</template>
{{selectedItem.attributes.description}}
</UCard>
<p class="mt-5">Artikel in diesem Lagerplatz</p>
<p v-for="product in spaceProducts">{{products.find(productItem => Number(productItem.id) === Number(product)).attributes.name}} - {{getSpaceProductCount(product)}} {{products.find(productItem => Number(productItem.id) === Number(product)).attributes.unit}}</p>
</div>
</div>
</template>
<style scoped>
#main {
display: flex;
flex-direction: row;
}
#left {
width: 25vw;
}
#right {
width: 60vw;
padding-left: 3vw;
}
</style>