This commit is contained in:
2024-10-08 16:08:30 +02:00
parent 2cbc30de6f
commit ca15cfbd0b
2 changed files with 30 additions and 10 deletions

View File

@@ -61,6 +61,7 @@ const itemInfo = ref({
const letterheads = ref([]) const letterheads = ref([])
const createdDocuments = ref([]) const createdDocuments = ref([])
const projects = ref([])
const products = ref([]) const products = ref([])
const productcategories = ref([]) const productcategories = ref([])
const selectedProductcategorie = ref(null) const selectedProductcategorie = ref(null)
@@ -72,6 +73,7 @@ const setupPage = async () => {
letterheads.value = (await useSupabaseSelect("letterheads","*")).filter(i => i.documentTypes.length === 0 || i.documentTypes.includes(itemInfo.value.type)) letterheads.value = (await useSupabaseSelect("letterheads","*")).filter(i => i.documentTypes.length === 0 || i.documentTypes.includes(itemInfo.value.type))
createdDocuments.value = (await useSupabaseSelect("createddocuments","*")) createdDocuments.value = (await useSupabaseSelect("createddocuments","*"))
projects.value = (await useSupabaseSelect("projects","*"))
services.value = (await useSupabaseSelect("services","*")) services.value = (await useSupabaseSelect("services","*"))
servicecategories.value = (await useSupabaseSelect("servicecategories","*")) servicecategories.value = (await useSupabaseSelect("servicecategories","*"))
products.value = (await useSupabaseSelect("products","*")) products.value = (await useSupabaseSelect("products","*"))
@@ -304,6 +306,7 @@ const findDocumentErrors = computed(() => {
let errors = [] let errors = []
if(itemInfo.value.customer === null) errors.push({message: "Es ist kein Kunde ausgewählt", type: "breaking"}) if(itemInfo.value.customer === null) errors.push({message: "Es ist kein Kunde ausgewählt", type: "breaking"})
if(itemInfo.value.contact === null) errors.push({message: "Es ist kein Kontakt ausgewählt", type: "info"})
if(itemInfo.value.letterhead === null) errors.push({message: "Es ist kein Briefpapier ausgewählt", type: "breaking"}) if(itemInfo.value.letterhead === null) errors.push({message: "Es ist kein Briefpapier ausgewählt", type: "breaking"})
if(itemInfo.value.address.street === null) errors.push({message: "Es ist keine Straße im Adressat angegeben", type: "breaking"}) if(itemInfo.value.address.street === null) errors.push({message: "Es ist keine Straße im Adressat angegeben", type: "breaking"})
if(itemInfo.value.address.zip === null) errors.push({message: "Es ist keine Postleitzahl im Adressat angegeben", type: "breaking"}) if(itemInfo.value.address.zip === null) errors.push({message: "Es ist keine Postleitzahl im Adressat angegeben", type: "breaking"})
@@ -311,12 +314,19 @@ const findDocumentErrors = computed(() => {
if(itemInfo.value.project === null) errors.push({message: "Es ist kein Projekt ausgewählt", type: "info"}) if(itemInfo.value.project === null) errors.push({message: "Es ist kein Projekt ausgewählt", type: "info"})
itemInfo.value.rows.forEach(row => { if(itemInfo.value.rows.length === 0) {
if(row.mode === "normal" && !row.product) errors.push({message: `In Position ${row.pos} ist kein Artikel ausgewählt`, type: "breaking"}) errors.push({message: "Es sind keine Positionen angegeben", type: "breaking"})
if(row.mode === "service" && !row.service) errors.push({message: `In Position ${row.pos} ist keine Leistung ausgewählt`, type: "breaking"}) } else {
if(row.mode === "title" && !row.text) errors.push({message: `In Position ${row.pos} ist kein Titel hinterlegt`, type: "breaking"}) itemInfo.value.rows.forEach(row => {
if(row.mode === "text" && !row.text) errors.push({message: `In einer Freitext Position ist kein Titel hinterlegt`, type: "breaking"}) if(row.mode === "normal" && !row.product) errors.push({message: `In Position ${row.pos} ist kein Artikel ausgewählt`, type: "breaking"})
}) if(row.mode === "service" && !row.service) errors.push({message: `In Position ${row.pos} ist keine Leistung ausgewählt`, type: "breaking"})
if(row.mode === "title" && !row.text) errors.push({message: `In Position ${row.pos} ist kein Titel hinterlegt`, type: "breaking"})
if(row.mode === "text" && !row.text) errors.push({message: `In einer Freitext Position ist kein Titel hinterlegt`, type: "breaking"})
})
}
if(itemInfo.value.type === "serialInvoices") { if(itemInfo.value.type === "serialInvoices") {
if(!itemInfo.value.serialConfig.intervall) errors.push({message: `Kein Intervall für die Ausführung festgelegt`, type: "breaking"}) if(!itemInfo.value.serialConfig.intervall) errors.push({message: `Kein Intervall für die Ausführung festgelegt`, type: "breaking"})
@@ -326,7 +336,7 @@ const findDocumentErrors = computed(() => {
} }
return errors return errors.sort((a,b) => (a.type === "breaking") ? -1 : 1)
}) })
const tabItems = computed(() => { const tabItems = computed(() => {
@@ -975,7 +985,7 @@ setupPage()
> >
<InputGroup> <InputGroup>
<USelectMenu <USelectMenu
:options="dataStore.projects" :options="projects.filter(i => i.customer === itemInfo.customer)"
v-model="itemInfo.project" v-model="itemInfo.project"
value-attribute="id" value-attribute="id"
option-attribute="name" option-attribute="name"
@@ -983,6 +993,7 @@ setupPage()
searchable-placeholder="Suche..." searchable-placeholder="Suche..."
:search-attributes="['name']" :search-attributes="['name']"
class="w-full" class="w-full"
:disabled="!itemInfo.customer"
> >
<template #label> <template #label>
{{dataStore.getProjectById(itemInfo.project) ? dataStore.getProjectById(itemInfo.project).name : "Kein Projekt ausgewählt"}} {{dataStore.getProjectById(itemInfo.project) ? dataStore.getProjectById(itemInfo.project).name : "Kein Projekt ausgewählt"}}
@@ -1159,7 +1170,7 @@ setupPage()
class="my-3" class="my-3"
/> />
<table class="w-full"> <table class="w-full" v-if="itemInfo.rows.length > 0">
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
@@ -1491,6 +1502,13 @@ setupPage()
</template> </template>
</draggable> </draggable>
</table> </table>
<UAlert
v-else
title="Keine Positionen hinzugefügt"
color="rose"
variant="outline"
icon="i-heroicons-light-bulb"
></UAlert>
<InputGroup> <InputGroup>
<UButton <UButton

View File

@@ -570,7 +570,9 @@ export const useDataStore = defineStore('data', () => {
let oldVal = prop.data.o || "-" let oldVal = prop.data.o || "-"
let newVal = prop.data.n || "-" let newVal = prop.data.n || "-"
/*console.log(key)
console.log(oldVal)
console.log(newVal)*/
if(key === "project") { if(key === "project") {
name = "Projekt" name = "Projekt"