Restructured Pages

Added parent Spaces
This commit is contained in:
2024-07-20 14:50:58 +02:00
parent 013ae3c69c
commit 269c5f4b59
3 changed files with 216 additions and 98 deletions

View File

@@ -290,7 +290,7 @@ const calculateDocSum = (rows) => {
rows.forEach(row => {
if(row.mode !== "pagebreak") {
sum += row.price * row.quantity * ( row.taxPercent + 100)/100
sum += row.price * row.quantity * ( Number(row.taxPercent) + 100)/100
}
})

View File

@@ -106,6 +106,11 @@ setupPage()
v-else-if="mode == 'edit' || mode == 'create'"
class="p-5"
>
<div class="flex flex-row">
<div class="w-1/2 mr-5">
<UDivider>
Allgemeines
</UDivider>
<UFormGroup
label="Name:"
>
@@ -113,6 +118,14 @@ setupPage()
v-model="itemInfo.name"
/>
</UFormGroup>
<UFormGroup
label="Artikelnummer:"
>
<UInput
v-model="itemInfo.articleNumber"
/>
</UFormGroup>
<UFormGroup
label="Lagerplatz:"
>
@@ -146,11 +159,23 @@ setupPage()
v-model="itemInfo.quantity"
/>
</UFormGroup>
</div>
<div class="w-1/2">
<UDivider>
Anschaffung
</UDivider>
<UFormGroup
label="Artikelnummer:"
label="Hersteller:"
>
<UInput
v-model="itemInfo.articleNumber"
v-model="itemInfo.manufacturer"
/>
</UFormGroup>
<UFormGroup
label="Herstellernr.:"
>
<UInput
v-model="itemInfo.manufacturerNumber"
/>
</UFormGroup>
<UFormGroup
@@ -180,6 +205,23 @@ setupPage()
</template>
</UPopover>
</UFormGroup>
<UFormGroup
label="Kaufpreis:"
>
<UInput
v-model="itemInfo.purchasePrice"
type="number"
steps="0.01"
>
<template #trailing>
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
</template>
</UInput>
</UFormGroup>
</div>
</div>
<UFormGroup
label="Beschreibung:"
>

View File

@@ -11,38 +11,54 @@ const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
let currentItem = ref(null)
//Working
const mode = ref(route.params.mode || "show")
const itemInfo = ref({
spaceNumber: ""
spaceNumber: "",
address: {
streetNumber: "",
city: "",
zip:""
}
})
const spaceTypes = ["Regalplatz", "Kiste", "Palettenplatz", "Sonstiges"]
const spaceProducts = ref([])
const spaceMovements = ref([])
const spaces = ref([])
//Functions
const setupPage = async () => {
console.log("Called Setup")
if(mode.value === "show" || mode.value === "edit"){
currentItem.value = await dataStore.getSpaceById(Number(useRoute().params.id))
if(mode.value === "show"){
itemInfo.value = await useSupabaseSelectSingle("spaces",route.params.id,"*, parentSpace(*)")
spaceMovements.value = await dataStore.getMovementsBySpace(currentItem.value.id)
spaceMovements.value = await dataStore.getMovementsBySpace(itemInfo.value.id)
spaceProducts.value = []
spaceMovements.value.forEach(movement => {
if(spaceProducts.value.filter(product => product.id === movement.productId).length === 0) spaceProducts.value.push(dataStore.getProductById(movement.productId))
})
} else if(mode.value === "edit") {
itemInfo.value = await useSupabaseSelectSingle("spaces",route.params.id,"*")
}
if(mode.value === "edit") itemInfo.value = currentItem.value
if(mode.value === "edit" || mode.value === "create"){
if(itemInfo.value){
spaces.value = (await useSupabaseSelect("spaces",'*')).filter(i => i.id !== itemInfo.value.id)
} else {
spaces.value = (await useSupabaseSelect("spaces",'*'))
}
}
}
const cancelEditorCreate = () => {
if(currentItem.value) {
router.push(`/spaces/show/${currentItem.value.id}`)
if(itemInfo.value) {
router.push(`/spaces/show/${itemInfo.value.id}`)
} else {
router.push(`/spaces/`)
}
@@ -59,18 +75,25 @@ function getSpaceProductCount(productId) {
/*
const printSpaceLabel = async () => {
axios
.post(`http://${dataStore.ownTenant.value.labelPrinterIp}/pstprnt`, `^XA^FO10,20^BCN,100^FD${currentItem.value.spaceNumber}^XZ` )
.post(`http://${dataStore.ownTenant.value.labelPrinterIp}/pstprnt`, `^XA^FO10,20^BCN,100^FD${itemInfo.value.spaceNumber}^XZ` )
.then(console.log)
.catch(console.log)
}
*/
const cityLoading = ref(false)
const setCityByZip = async () => {
cityLoading.value = true
itemInfo.value.address.city = await useZipCheck(itemInfo.value.address.zip)
cityLoading.value = false
}
setupPage()
</script>
<template>
<UDashboardNavbar :title="currentItem ? currentItem.name : (mode === 'create' ? 'Lagerplatz erstellen' : 'Lagerplatz bearbeiten')">
<UDashboardNavbar :title="itemInfo ? itemInfo.name : (mode === 'create' ? 'Lagerplatz erstellen' : 'Lagerplatz bearbeiten')">
<template #right>
<UButton
v-if="mode === 'edit'"
@@ -94,7 +117,7 @@ setupPage()
</UButton>
<UButton
v-if="mode === 'show'"
@click=" router.push(`/inventory/spaces/edit/${currentItem.id}`)"
@click=" router.push(`/spaces/edit/${itemInfo.id}`)"
>
Bearbeiten
</UButton>
@@ -102,14 +125,15 @@ setupPage()
</UDashboardNavbar>
<UTabs
:items="[{label: 'Informationen'},{label: 'Logbuch'},{label: 'Bestand'}]"
v-if="currentItem && mode == 'show'"
v-if="itemInfo && mode == 'show'"
class="p-5"
>
<template #item="{item}">
<UCard class="mt-5">
<div v-if="item.label === 'Informationen'">
<div class="truncate">
<span>Beschreibung: {{currentItem.description}}</span>
<p>Übergeordneter Lagerplatz: <router-link v-if="itemInfo.parentSpace" :to="`/spaces/show/${itemInfo.parentSpace.id}`">{{itemInfo.parentSpace.spaceNumber}} - {{itemInfo.parentSpace.description}}</router-link></p>
<p>Beschreibung: <br>{{itemInfo.description}}</p>
</div>
@@ -144,6 +168,11 @@ setupPage()
v-else-if="mode === 'edit' || mode === 'create'"
class="p-5"
>
<div class="flex flex-row">
<div class="w-1/2 mr-5">
<UDivider>
Allgemeines
</UDivider>
<UFormGroup
label="Typ:"
>
@@ -154,6 +183,53 @@ setupPage()
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Übergeordneter Lagerplatz:"
>
<USelectMenu
:options="spaces"
option-attribute="spaceNumber"
value-attribute="id"
v-model="itemInfo.parentSpace"
>
</USelectMenu>
</UFormGroup>
</div>
<div class="w-1/2">
<UDivider>
Ort
</UDivider>
<UFormGroup
label="Straße + Hausnummer:"
>
<UInput
v-model="itemInfo.address.streetNumber"
/>
</UFormGroup>
<UFormGroup
label="PLZ + Ort:"
>
<InputGroup class="w-full">
<UInput
v-model="itemInfo.address.zip"
placeholder="PLZ"
@focusout="setCityByZip"
/>
<UInput
v-model="itemInfo.address.city"
placeholder="Ort"
class="flex-auto"
:disabled="cityLoading"
/>
</InputGroup>
</UFormGroup>
</div>
</div>
<UFormGroup
label="Beschreibung:"
>