Added Phases to Projects

This commit is contained in:
2024-02-15 22:49:09 +01:00
parent 2fc45b3ea0
commit 1a0b7288df
37 changed files with 2342 additions and 1483 deletions

View File

@@ -1,4 +1,8 @@
<script setup>
import HistoryDisplay from "~/components/HistoryDisplay.vue";
import DocumentList from "~/components/DocumentList.vue";
import DocumentUpload from "~/components/DocumentUpload.vue";
definePageMeta({
middleware: "auth"
})
@@ -10,7 +14,7 @@ const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
let currentProduct = null
let currentItem = ref(null)
@@ -24,10 +28,10 @@ const itemInfo = ref({
//Functions
const setupPage = () => {
if(mode.value === "show" || mode.value === "edit"){
currentProduct = dataStore.getProductById(Number(useRoute().params.id))
currentItem.value = dataStore.getProductById(Number(useRoute().params.id))
}
if(mode.value === "edit") itemInfo.value = currentProduct
if(mode.value === "edit") itemInfo.value = currentItem.value
@@ -35,7 +39,7 @@ const setupPage = () => {
const editItem = async () => {
router.push(`/products/edit/${currentProduct.id}`)
router.push(`/products/edit/${currentItem.value.id}`)
setupPage()
}
@@ -53,153 +57,164 @@ setupPage()
</script>
<template>
<div>
<UCard v-if="currentProduct && mode == 'show'" >
<template #header>
{{currentProduct.name}}
</template>
<h1
class="mb-3 truncate font-bold text-2xl"
v-if="currentItem "
>Artikel: {{currentItem.name}}</h1>
<UTabs
:items="[{label: 'Informationen'},{label: 'Logbuch'},{label: 'Bestand'},{label: 'Dokumente'}]"
v-if="mode === 'show'"
>
<template #item="{item}">
<UCard class="mt-5">
<div
v-if="item.label === 'Informationen'"
>
<Toolbar>
<UButton
v-if="mode === 'show' && currentItem.id"
@click="editItem"
>
Bearbeiten
</UButton>
</Toolbar>
<UBadge
v-for="tag in currentItem.tags"
class="mr-2"
>
{{tag}}
</UBadge>
<UDivider
class="my-2"
/>
<span v-if="currentItem.purchasePrice">Einkaufspreis: {{Number(currentItem.purchasePrice).toFixed(2)}} <br></span>
<UBadge
v-for="tag in currentProduct.tags"
class="mr-2"
>
{{tag}}
</UBadge>
</div>
<div
v-if="item.label === 'Logbuch'"
>
<HistoryDisplay
type="product"
v-if="currentItem"
:element-id="currentItem.id"
/>
</div>
<div
v-if="item.label === 'Bestand'"
>
Bestand: {{dataStore.getStockByProductId(currentItem.id)}} {{dataStore.units.find(unit => unit.id === currentItem.unit) ? dataStore.units.find(unit => unit.id === currentItem.unit).name : ""}}
</div>
<div
v-if="item.label === 'Dokumente'"
>
<Toolbar>
<DocumentUpload
type="product"
:element-id="currentItem.id"
/>
</Toolbar>
<DocumentList :documents="dataStore.getDocumentsByProductId(currentItem.id)"/>
</div>
</UCard>
</template>
</UTabs>
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
<template #header v-if="mode === 'edit'">
{{itemInfo.name}}
</template>
<UDivider
class="my-2"
<UFormGroup
label="Name:"
>
<UInput
v-model="itemInfo.name"
/>
<span v-if="currentProduct.purchasePrice">Einkaufspreis: {{Number(currentProduct.purchasePrice).toFixed(2)}} <br></span>
Bestand: {{dataStore.getStockByProductId(currentProduct.id)}} {{dataStore.units.find(unit => unit.id === currentProduct.unit) ? dataStore.units.find(unit => unit.id === currentProduct.unit).name : ""}}
<DevOnly>
<UDivider
class="my-2"
/>
{{currentProduct}}
</DevOnly>
<template #footer>
<UButton
v-if="mode === 'show' && currentProduct.id"
@click="editItem"
>
Bearbeiten
</UButton>
<UButton
color="red"
class="ml-2"
disabled
>
Archivieren
</UButton>
<!-- TODO: Produkt archivieren -->
</template>
</UCard>
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
<template #header v-if="mode === 'edit'">
{{itemInfo.name}}
</template>
<UFormGroup
label="Name:"
>
<UInput
v-model="itemInfo.name"
/>
</UFormGroup>
<UFormGroup
label="Hersteller:"
>
<UInput
v-model="itemInfo.manufacturer"
/>
</UFormGroup>
<UFormGroup
label="Einheit:"
>
<USelectMenu
</UFormGroup>
<UFormGroup
label="Hersteller:"
>
<UInput
v-model="itemInfo.manufacturer"
/>
</UFormGroup>
<UFormGroup
label="Einheit:"
>
<USelectMenu
v-model="itemInfo.unit"
:options="dataStore.units"
option-attribute="name"
value-attribute="id"
>
<template #label>
{{dataStore.units.find(unit => unit.id === itemInfo.unit) ? dataStore.units.find(unit => unit.id === itemInfo.unit).name : itemInfo.unit }}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Tags:"
>
<USelectMenu
<template #label>
{{dataStore.units.find(unit => unit.id === itemInfo.unit) ? dataStore.units.find(unit => unit.id === itemInfo.unit).name : itemInfo.unit }}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Tags:"
>
<USelectMenu
v-model="itemInfo.tags"
:options="dataStore.ownTenant.tags.products"
multiple
/>
</UFormGroup>
<UFormGroup
label="EAN:"
/>
</UFormGroup>
<UFormGroup
label="EAN:"
>
<UInput
v-model="itemInfo.ean"
/>
</UFormGroup>
<UFormGroup
label="Barcode:"
>
<UInput
v-model="itemInfo.barcode"
/>
</UFormGroup>
<UFormGroup
label="Einkaufspreis:"
>
<UInput
v-model="itemInfo.purchasePrice"
type="number"
steps="0.01"
>
<UInput
v-model="itemInfo.ean"
/>
</UFormGroup>
<UFormGroup
label="Barcode:"
>
<UInput
v-model="itemInfo.barcode"
/>
</UFormGroup>
<UFormGroup
label="Einkaufspreis:"
>
<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>
<template #trailing>
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
</template>
</UInput>
</UFormGroup>
<template #footer>
<UButton
v-if="mode == 'edit'"
@click="dataStore.updateItem('products',itemInfo)"
>
Speichern
</UButton>
<UButton
v-else-if="mode == 'create'"
@click="dataStore.createNewItem('products',itemInfo)"
>
Erstellen
</UButton>
<UButton
@click="cancelEditorCreate"
color="red"
class="ml-2"
>
Abbrechen
</UButton>
</template>
<template #footer>
<UButton
v-if="mode == 'edit'"
@click="dataStore.updateItem('products',itemInfo)"
>
Speichern
</UButton>
<UButton
v-else-if="mode == 'create'"
@click="dataStore.createNewItem('products',itemInfo)"
>
Erstellen
</UButton>
<UButton
@click="cancelEditorCreate"
color="red"
class="ml-2"
>
Abbrechen
</UButton>
</template>
</UCard>
</div>
</UCard>
</template>
<style scoped>