Introduced EntityEdit.vue

Introduced EntityShow.vue

Deprecated following as non standardEntity contracts, customers, vendors, projects, plants, vehicles
This commit is contained in:
2024-12-22 16:59:18 +01:00
parent b465f4a75a
commit 565d531376
28 changed files with 1942 additions and 932 deletions

280
components/EntityEdit.vue Normal file
View File

@@ -0,0 +1,280 @@
<script setup>
import dayjs from "dayjs";
const props = defineProps({
type: {
required: true,
type: String
},
item: {
required: true,
type: Object
}
})
const {type} = props
defineShortcuts({
'backspace': () => {
router.push(`/${type}`)
},
'arrowleft': () => {
if(openTab.value > 0){
openTab.value -= 1
}
},
'arrowright': () => {
if(openTab.value < 3) {
openTab.value += 1
}
},
})
const router = useRouter()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const dataType = dataStore.dataTypes[type]
const openTab = ref(0)
const oldItem = ref(null)
const generateOldItemData = () => {
oldItem.value = JSON.parse(JSON.stringify(props.item))
}
generateOldItemData()
const setupCreate = () => {
dataType.templateColumns.forEach(datapoint => {
if(datapoint.key.includes(".")){
props.item[datapoint.key.split(".")[0]] = {}
}
if(datapoint.inputType === "editor") {
if(datapoint.key.includes(".")){
props.item[datapoint.key.split(".")[0]][datapoint.key.split(".")[1]] = {}
} else {
props.item[datapoint.key] = {}
}
}
})
}
setupCreate()
const loadedOptions = ref({})
const loadOptions = async () => {
let optionsToLoad = dataType.templateColumns.filter(i => i.selectDataType).map(i => {
return {
option: i.selectDataType,
key: i.key
}
})
for await(const option of optionsToLoad) {
if(option.option === "countrys") {
loadedOptions.value[option.option] = (await supabase.from("countrys").select()).data
} else {
loadedOptions.value[option.option] = (await useSupabaseSelect(option.option))
if(dataType.templateColumns.find(x => x.key === option.key).selectDataTypeFilter){
loadedOptions.value[option.option] = loadedOptions.value[option.option].filter(i => dataType.templateColumns.find(x => x.key === option.key).selectDataTypeFilter(i, props.item))
}
}
}
}
loadOptions()
const contentChanged = (content, datapoint) => {
if(datapoint.key.includes(".")){
props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]].html = content.html
props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]].text = content.text
props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]].json = content.json
} else {
props.item[datapoint.key].html = content.html
props.item[datapoint.key].text = content.text
props.item[datapoint.key].json = content.json
}
}
</script>
<template>
<UDashboardNavbar
:ui="{center: 'flex items-stretch gap-1.5 min-w-0'}"
>
<template #left>
<UButton
icon="i-heroicons-chevron-left"
variant="outline"
@click="router.push(`/standardEntity/${type}`)"
>
{{dataType.label}}
</UButton>
</template>
<template #center>
<h1
v-if="props.item"
:class="['text-xl','font-medium']"
>{{props.item.id ? `${dataType.labelSingle} bearbeiten` : `${dataType.labelSingle} erstellen` }}</h1>
</template>
<template #right>
<UButton
v-if="props.item.id"
@click="dataStore.updateItem(type,props.item, oldItem)"
>
Speichern
</UButton>
<UButton
v-else
@click="dataStore.createNewItem(type,props.item)"
>
Erstellen
</UButton>
<UButton
@click="router.push(props.item.id ? `/standardEntity/${type}/show/${props.item.id}` : `/standardEntity/${type}`)"
color="red"
class="ml-2"
>
Abbrechen
</UButton>
</template>
</UDashboardNavbar>
<UDashboardPanelContent>
<UForm
class="p-5"
>
<UFormGroup
v-for="datapoint in dataType.templateColumns.filter(i => i.inputType)"
:label="datapoint.label"
>
<div v-if="datapoint.key.includes('.')">
<UInput
v-if="['text','number'].includes(datapoint.inputType)"
v-model="props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]]"
:type="datapoint.inputType"
:placeholder="datapoint.inputIsNumberRange ? 'Leer lassen für automatisch generierte Nummer' : ''"
/>
<UToggle
v-else-if="datapoint.inputType === 'bool'"
v-model="props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]]"
/>
<USelectMenu
v-else-if="datapoint.inputType === 'select'"
v-model="props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]]"
:option-attribute="datapoint.selectOptionAttribute"
:value-attribute="datapoint.selectValueAttribute || 'id'"
:options="datapoint.selectManualOptions || loadedOptions[datapoint.selectDataType]"
:searchable="datapoint.selectSearchAttributes"
:search-attributes="datapoint.selectSearchAttributes"
:multiple="datapoint.selectMultiple"
/>
<UTextarea
v-else-if="datapoint.inputType === 'textarea'"
v-model="props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]]"
rows="4"
/>
<UPopover :popper="{ placement: 'bottom-start' }" v-else-if="datapoint.inputType === 'date'">
<UButton
icon="i-heroicons-calendar-days-20-solid"
:label="props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]] ? dayjs(props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]]).format('DD.MM.YYYY') : 'Datum auswählen'"
variant="outline"
/>
<template #panel="{ close }">
<LazyDatePicker v-model="props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]]" @close="close" />
</template>
</UPopover>
<Tiptap
v-else-if="datapoint.inputType === 'editor'"
@updateContent="(i) => contentChanged(i,datapoint)"
:preloadedContent="props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]].html"
/>
</div>
<div v-else>
<UInput
v-if="['text','number'].includes(datapoint.inputType)"
v-model="props.item[datapoint.key]"
:type="datapoint.inputType"
:placeholder="datapoint.inputIsNumberRange ? 'Leer lassen für automatisch generierte Nummer' : ''"
/>
<UToggle
v-else-if="datapoint.inputType === 'bool'"
v-model="props.item[datapoint.key]"
/>
<USelectMenu
v-else-if="datapoint.inputType === 'select'"
v-model="props.item[datapoint.key]"
:option-attribute="datapoint.selectOptionAttribute"
:value-attribute="datapoint.selectValueAttribute || 'id'"
:options="datapoint.selectManualOptions || loadedOptions[datapoint.selectDataType]"
:searchable="datapoint.selectSearchAttributes"
:search-attributes="datapoint.selectSearchAttributes"
:multiple="datapoint.selectMultiple"
searchable-placeholder="Suche..."
/>
<UTextarea
v-else-if="datapoint.inputType === 'textarea'"
v-model="props.item[datapoint.key]"
rows="4"
/>
<UPopover :popper="{ placement: 'bottom-start' }" v-else-if="datapoint.inputType === 'date'">
<UButton
icon="i-heroicons-calendar-days-20-solid"
:label="props.item[datapoint.key] ? dayjs(props.item[datapoint.key]).format('DD.MM.YYYY') : 'Datum auswählen'"
variant="outline"
/>
<template #panel="{ close }">
<LazyDatePicker v-model="props.item[datapoint.key]" @close="close" />
</template>
</UPopover>
<Tiptap
v-else-if="datapoint.inputType === 'editor'"
@updateContent="(i) => contentChanged(i,datapoint)"
:preloadedContent="props.item[datapoint.key].html"
/>
</div>
<div
v-if="profileStore.ownTenant.ownFields"
>
<UDivider
class="mt-3"
>Eigene Felder</UDivider>
<UFormGroup
v-for="field in profileStore.ownTenant.ownFields.contracts"
:key="field.key"
:label="field.label"
>
<UInput
v-if="field.type === 'text'"
v-model="props.item.ownFields[field.key]"
/>
<USelectMenu
v-else-if="field.type === 'select'"
:options="field.options"
v-model="props.item.ownFields[field.key]"
/>
</UFormGroup>
</div>
</UFormGroup>
</UForm>
</UDashboardPanelContent>
</template>
<style scoped>
td {
border-bottom: 1px solid lightgrey;
vertical-align: top;
padding-bottom: 0.15em;
padding-top: 0.15em;
}
</style>

View File

@@ -55,8 +55,8 @@ const dataType = dataStore.dataTypes[type]
const selectedItem = ref(0)
const selectedColumns = ref(dataType.templateColumns)
const columns = computed(() => dataType.templateColumns.filter((column) => selectedColumns.value.includes(column)))
const selectedColumns = ref(dataType.templateColumns.filter(i => !i.disabledInTable))
const columns = computed(() => dataType.templateColumns.filter((column) => !column.disabledInTable && selectedColumns.value.includes(column)))
const searchString = ref('')
@@ -114,7 +114,7 @@ const filteredRows = computed(() => {
</template>
</UInput>
<UButton v-if="useRole().checkRight(`${type}-create`)" @click="router.push(`/${type}/create`)">+ {{dataType.labelSingle}}</UButton>
<UButton v-if="useRole().checkRight(`${type}-create`)" @click="router.push(`/standardEntity/${type}/create`)">+ {{dataType.labelSingle}}</UButton>
</template>
</UDashboardNavbar>
@@ -127,10 +127,11 @@ const filteredRows = computed(() => {
<USelectMenu
v-model="selectedColumns"
icon="i-heroicons-adjustments-horizontal-solid"
:options="dataType.templateColumns"
:options="dataType.templateColumns.filter(i => !i.disabledInTable)"
multiple
class="hidden lg:block"
by="key"
:color="selectedColumns.length !== dataType.templateColumns.filter(i => !i.disabledInTable).length ? 'primary' : 'white'"
>
<template #label>
Spalten
@@ -142,6 +143,7 @@ const filteredRows = computed(() => {
multiple
v-model="selectedFilters"
:options="selectableFilters"
:color="selectedFilters.length > 0 ? 'primary' : 'white'"
>
<template #label>
Filter
@@ -154,7 +156,7 @@ const filteredRows = computed(() => {
:columns="columns"
class="w-full"
:ui="{ divide: 'divide-gray-200 dark:divide-gray-800' }"
@select="(i) => router.push(`/${type}/show/${i.id}`) "
@select="(i) => router.push(`/standardEntity/${type}/show/${i.id}`) "
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: `Keine ${dataType.label} anzuzeigen` }"
>
<template #name-data="{row}">
@@ -185,10 +187,10 @@ const filteredRows = computed(() => {
</span>
</template>
<template
v-for="column in dataType.templateColumns.filter(i => i.key !== 'name' && i.key !== 'fullName' && i.key !== 'licensePlate')"
v-for="column in dataType.templateColumns.filter(i => i.key !== 'name' && i.key !== 'fullName' && i.key !== 'licensePlate' && !i.disabledInTable)"
v-slot:[`${column.key}-data`]="{row}">
<component v-if="column.component" :is="column.component" :row="row"></component>
<span v-else>{{row[column.key]}}</span>
<span v-else>{{row[column.key] ? `${row[column.key]} ${column.unit ? column.unit : ''}`: ''}}</span>
</template>
</UTable>
</template>

352
components/EntityShow.vue Normal file
View File

@@ -0,0 +1,352 @@
<script setup>
import dayjs from "dayjs";
const props = defineProps({
type: {
required: true,
type: String
},
item: {
required: true,
type: Object
}
})
const {type} = props
defineShortcuts({
'backspace': () => {
router.push(`/${type}`)
},
'arrowleft': () => {
if(openTab.value > 0){
openTab.value -= 1
}
},
'arrowright': () => {
if(openTab.value < 3) {
openTab.value += 1
}
},
})
const router = useRouter()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const dataType = dataStore.dataTypes[type]
const openTab = ref(0)
const renderedPhases = computed(() => {
if(type === "projects" && props.item.phases) {
return props.item.phases.map((phase,index,array) => {
let isAvailable = false
if(phase.active) {
isAvailable = true
} else if(index > 0 && array[index-1].active ){
isAvailable = true
} else if(index > 1 && array[index-1].optional && array[index-2].active){
isAvailable = true
} else if(array.findIndex(i => i.active) > index) {
isAvailable = true
}
return {
...phase,
label: phase.optional ? `${phase.label}(optional)`: phase.label,
disabled: !isAvailable,
defaultOpen: phase.active ? true : false
}
})
} else {
return []
}
})
</script>
<template>
<UDashboardNavbar
:ui="{center: 'flex items-stretch gap-1.5 min-w-0'}"
>
<template #left>
<UButton
icon="i-heroicons-chevron-left"
variant="outline"
@click="router.push(`/standardEntity/${type}`)"
>
{{dataType.label}}
</UButton>
</template>
<template #center>
<h1
v-if="item"
:class="['text-xl','font-medium']"
>{{item ? `${dataType.labelSingle}: ${props.item[dataType.templateColumns.find(i => i.title).key]}`: '' }}</h1>
</template>
<template #right>
<ButtonWithConfirm
color="rose"
variant="outline"
@confirmed="dataStore.updateItem(type,{...item, archived: true})"
>
<template #button>
Archivieren
</template>
<template #header>
<span class="text-md text-black font-bold">Archivieren bestätigen</span>
</template>
Möchten Sie das Fahrzeug {{item.name}} wirklich archivieren?
</ButtonWithConfirm>
<UButton
@click="router.push(`/standardEntity/${type}/edit/${item.id}`)"
>
Bearbeiten
</UButton>
</template>
</UDashboardNavbar>
<UTabs
:items="dataType.showTabs"
v-if="props.item.id"
class="p-5"
v-model="openTab"
>
<template #item="{item}">
<div v-if="item.label === 'Informationen'" class="flex flex-row mt-5">
<UCard class="w-1/2 mr-5">
<UAlert
v-if="item.archived"
color="rose"
variant="outline"
:title="`${dataType.labelSingle} archiviert`"
icon="i-heroicons-light-bulb"
class="mb-5"
/>
<div class="text-wrap">
<table class="w-full">
<tbody>
<tr
v-for="datapoint in dataType.templateColumns"
>
<td>{{datapoint.label}}:</td>
<td>
<component v-if="datapoint.component" :is="datapoint.component" :row="props.item"></component>
<div v-else>
<span v-if="datapoint.key.includes('.')">{{props.item[datapoint.key.split('.')[0]][datapoint.key.split('.')[1]]}}{{datapoint.unit}}</span>
<span v-else>{{props.item[datapoint.key]}} {{datapoint.unit}}</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</UCard>
<UCard class="w-1/2">
<HistoryDisplay
:type="type.substring(0,type.length-1)"
v-if="props.item.id"
:element-id="props.item.id"
render-headline
/>
</UCard>
</div>
<div v-else-if="item.label === 'Dokumente'">
<UCard class="mt-5">
<!-- <Toolbar>
<DocumentUpload
type="vehicle"
:element-id="item.id"
/>
</Toolbar>
<DocumentList
:documents="dataStore.getDocumentsByVehicleId(item.id)"
/>-->
{{props.item.documents}}
</UCard>
</div>
<div v-else-if="item.label === 'Projekte'">
<UCard class="mt-5">
<Toolbar>
<UButton
@click="router.push(`/standardEntity/projects/create?${type.substring(0,type.length-1)}=${props.item.id}`)"
>
+ Projekt
</UButton>
</Toolbar>
<UTable
:rows="props.item.projects"
@select="(row) => router.push(`/standardEntity/projects/show/${row.id}`)"
:columns="[{label: 'Name', key: 'name'},{label: 'Phase', key: 'phase'}]"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen Projekte' }"
>
<template #phase-data="{row}">
{{row.phases ? row.phases.find(i => i.active).label : ""}}
</template>
</UTable>
</UCard>
</div>
<div v-else-if="item.label === 'Objekte'">
<UCard class="mt-5">
<Toolbar>
<UButton
@click="router.push(`/standardEntity/plants/create?${type.substring(0,type.length-1)}=${props.item.id}`)"
>
+ Objekt
</UButton>
</Toolbar>
<UTable
:rows="props.item.plants"
@select="(row) => router.push(`/standardEntity/plants/show/${row.id}`)"
:columns="[{label: 'Name', key: 'name'}]"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen Objekte' }"
>
</UTable>
</UCard>
</div>
<div v-else-if="item.label === 'Aufgaben'">
<UCard class="mt-5">
<Toolbar>
<UButton
@click="router.push(`/standardEntity/tasks/create?${type.substring(0,type.length-1)}=${props.item.id}`)"
>
+ Aufgabe
</UButton>
</Toolbar>
<UTable
:rows="props.item.tasks"
@select="(row) => router.push(`/standardEntity/tasks/show/${row.id}`)"
:columns="[{label: 'Name', key: 'name'}]"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen Aufgaben' }"
/>
</UCard>
</div>
<div v-else-if="item.label === 'Verträge'">
<UCard class="mt-5">
<Toolbar>
<UButton
@click="router.push(`/standardEntity/contracts/create?${type.substring(0,type.length-1)}=${props.item.id}`)"
>
+ Vertrag
</UButton>
</Toolbar>
<UTable
:rows="props.item.contracts"
@select="(row) => router.push(`/standardEntity/contracts/show/${row.id}`)"
:columns="[{label: 'Name', key: 'name'},{label: 'Aktiv', key: 'active'}]"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen Verträge' }"
></UTable>
</UCard>
</div>
<div v-else-if="item.label === 'Überprüfungen'">
<UCard class="mt-5">
<UTable
:rows="props.item.checks"
:columns="[{key:'name',label: 'Name'},{key:'rhythm',label: 'Rhythmus'},{key:'description',label: 'Beschreibung'}]"
class="w-full"
:ui="{ divide: 'divide-gray-200 dark:divide-gray-800' }"
@select="(i) => router.push(`/checks/show/${i.id}`) "
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Überprüfungen anzuzeigen' }"
>
<template #rhythm-data="{row}">
{{row.distance}}
<span v-if="row.distanceUnit === 'dayjs'">Tage</span>
<span v-if="row.distanceUnit === 'years'">Jahre</span>
</template>
</UTable>
</UCard>
</div>
<div v-else-if="item.label === 'Phasen'">
<UCard class="mt-5">
<UAccordion
:items="renderedPhases"
>
<template #default="{item,index,open}">
<UButton
variant="ghost"
:color="item.active ? 'primary' : 'white'"
class="mb-1"
:disabled="true"
>
<template #leading>
<div class="w-6 h-6 flex items-center justify-center -my-1">
<UIcon :name="item.icon" class="w-4 h-4 " />
</div>
</template>
<span class="truncate"> {{item.label}}</span>
<template #trailing>
<UIcon
name="i-heroicons-chevron-right-20-solid"
class="w-5 h-5 ms-auto transform transition-transform duration-200"
:class="[open && 'rotate-90']"
/>
</template>
</UButton>
</template>
<template #item="{item, index}">
<UCard class="mx-5">
<template #header>
<span class="text-black">{{item.label}}</span>
</template>
<InputGroup>
<!-- TODO: Reactive Change Phase -->
<UButton
v-if="!item.activated_at && index !== 0 "
@click="changeActivePhase(item.key)"
>
Phase aktivieren
</UButton>
<UButton
v-if="item.active"
v-for="button in item.quickactions"
@click="router.push(`${button.link}&customer=${itemInfo.customer.id}&project=${itemInfo.id}`)"
>
{{button.label}}
</UButton>
</InputGroup>
<div>
<p v-if="item.activated_at" class="text-black">Aktiviert am: {{dayjs(item.activated_at).format("DD.MM.YY HH:mm")}} Uhr</p>
<p v-if="item.activated_by" class="text-black">Aktiviert durch: {{profileStore.getProfileById(item.activated_by).fullName}}</p>
<p v-if="item.description" class="text-black">Beschreibung: {{item.description}}</p>
</div>
</UCard>
</template>
</UAccordion>
</UCard>
</div>
</template>
</UTabs>
</template>
<style scoped>
td {
border-bottom: 1px solid lightgrey;
vertical-align: top;
padding-bottom: 0.15em;
padding-top: 0.15em;
}
</style>

View File

@@ -72,17 +72,17 @@ const links = computed(() => {
children: [
... role.checkRight("customers") ? [{
label: "Kunden",
to: "/customers",
to: "/standardEntity/customers",
icon: "i-heroicons-user-group"
}] : [],
... role.checkRight("vendors") ? [{
label: "Lieferanten",
to: "/vendors",
to: "/standardEntity/vendors",
icon: "i-heroicons-truck"
}] : [],
... role.checkRight("contacts") ? [{
label: "Ansprechpartner",
to: "/contacts",
to: "/standardEntity/contacts",
icon: "i-heroicons-user-group"
}] : [],
]
@@ -210,17 +210,17 @@ const links = computed(() => {
},] : [],
... role.checkRight("projects") ? [{
label: "Projekte",
to: "/projects",
to: "/standardEntity/projects",
icon: "i-heroicons-clipboard-document-check"
},] : [],
... role.checkRight("contracts") ? [{
label: "Verträge",
to: "/contracts",
to: "/standardEntity/contracts",
icon: "i-heroicons-clipboard-document"
}] : [],
... role.checkRight("plants") ? [{
label: "Objekte",
to: "/plants",
to: "/standardEntity/plants",
icon: "i-heroicons-clipboard-document"
},] : [],

View File

@@ -9,5 +9,6 @@ const props = defineProps({
</script>
<template>
<span>{{props.row.active ? 'Ja' : 'Nein'}}</span>
<span v-if="props.row.active" class="text-primary">Ja</span>
<span v-else class="text-rose-600">Nein</span>
</template>

View File

@@ -0,0 +1,17 @@
<script setup>
const props = defineProps({
row: {
type: Object,
required: true,
default: {}
}
})
</script>
<template>
<span v-if="props.row.infoData.streetNumber">{{props.row.infoData.streetNumber}},</span>
<span v-if="props.row.infoData.special">{{props.row.infoData.special}},</span>
<span v-if="props.row.infoData.zip">{{props.row.infoData.zip}},</span>
<span v-if="props.row.infoData.city">{{props.row.infoData.city}}</span>
</template>

View File

@@ -0,0 +1,13 @@
<script setup>
const props = defineProps({
row: {
type: Object,
required: true,
default: {}
}
})
</script>
<template>
<span>{{props.row.contact ? props.row.contact.name : ''}}</span>
</template>

View File

@@ -0,0 +1,13 @@
<script setup>
const props = defineProps({
row: {
type: Object,
required: true,
default: {}
}
})
</script>
<template>
<div v-if="props.row.description" v-html="props.row.description.html"/>
</template>

View File

@@ -0,0 +1,13 @@
<script setup>
const props = defineProps({
row: {
type: Object,
required: true,
default: {}
}
})
</script>
<template>
<span>{{props.row.isCompany ? 'Unternehmen' : 'Privat'}}</span>
</template>

View File

@@ -0,0 +1,14 @@
<script setup>
const props = defineProps({
row: {
type: Object,
required: true,
default: {}
}
})
</script>
<template>
<span v-if="props.row.recurring">Ja</span>
<span v-else>Nein</span>
</template>

View File

@@ -0,0 +1,14 @@
<script setup>
const props = defineProps({
row: {
type: Object,
required: true,
default: {}
}
})
</script>
<template>
<span v-if="props.row.hasSEPA">Ja</span>
<span v-else>Nein</span>
</template>

View File

@@ -252,6 +252,7 @@ setup()
</template>
<table class="w-full" v-if="itemInfo.id">
<tbody>
<tr class="flex-row flex justify-between">
<td>
<span class="font-semibold">Buchungsdatum:</span>
@@ -338,6 +339,8 @@ setup()
{{itemInfo.text}}
</td>
</tr>
</tbody>
</table>
</UCard>

View File

@@ -1401,8 +1401,7 @@ setupPage()
<th v-if="itemInfo.type !== 'deliveryNotes'">Gesamt</th>
</tr>
</thead>
<tbody>
<draggable
v-model="itemInfo.rows"
handle=".handle"
@@ -1761,6 +1760,7 @@ setupPage()
</tr>
</template>
</draggable>
</tbody>
</table>
<UAlert
v-else

View File

@@ -344,17 +344,7 @@ setupPage()
label="Vertragsstart:"
class="mt-2"
>
<UPopover :popper="{ placement: 'bottom-start' }">
<UButton
icon="i-heroicons-calendar-days-20-solid"
:label="itemInfo.startDate ? dayjs(itemInfo.startDate).format('DD.MM.YYYY') : 'Datum auswählen'"
variant="outline"
/>
<template #panel="{ close }">
<LazyDatePicker v-model="itemInfo.startDate" @close="close" />
</template>
</UPopover>
</UFormGroup>
<UFormGroup
label="Vertragsende(voraussichtlich):"

View File

@@ -189,24 +189,7 @@ setupPage()
<UCard class="mt-5" v-else>
<div v-if="item.label === 'Projekte'">
<Toolbar>
<UButton
@click="router.push(`/projects/create?customer=${itemInfo.id}`)"
>
+ Projekt
</UButton>
</Toolbar>
<UTable
:rows="dataStore.getProjectsByCustomerId(itemInfo.id)"
@select="(row) => router.push(`/projects/show/${row.id}`)"
:columns="[{label: 'Name', key: 'name'},{label: 'Phase', key: 'phase'}]"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine zugehörigen Projekte' }"
>
<template #phase-data="{row}">
{{row.phases ? row.phases.find(i => i.active).label : ""}}
</template>
</UTable>
</div>
<div v-else-if="item.label === 'Objekte'">
<Toolbar>

View File

@@ -0,0 +1,236 @@
<script setup>
import dayjs from "dayjs";
import {useSupabaseSelectSingle} from "~/composables/useSupabase.js";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'backspace': () => {
router.push("/vehicles")
},
'arrowleft': () => {
if(openTab.value > 0){
openTab.value -= 1
}
},
'arrowright': () => {
if(openTab.value < 3) {
openTab.value += 1
}
},
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
const openTab = ref(0)
//Working
const mode = ref(route.params.mode || "show")
const itemInfo = ref({
name: "",
licensePlate: "",
type: "",
driver: null,
active: true
})
const oldItemInfo = ref({})
//Functions
const setupPage = async () => {
if(mode.value === "show"){
itemInfo.value = await useSupabaseSelectSingle("vehicles",route.params.id,"*, checks(*)")
} else if(mode.value === "edit"){
itemInfo.value = await useSupabaseSelectSingle("vehicles",route.params.id,"*")
}
if(itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
}
const cancelEditorCreate = () => {
if(itemInfo.value.id) {
router.push(`/vehicles/show/${itemInfo.value.id}`)
} else {
router.push(`/vehicles`)
}
}
setupPage()
</script>
<template>
<EntityEdit
v-if="mode === 'edit' || mode === 'create'"
type="vehicles"
:item="itemInfo"
/>
<!-- <UDashboardNavbar
:ui="{center: 'flex items-stretch gap-1.5 min-w-0'}"
>
<template #left>
<UButton
icon="i-heroicons-chevron-left"
variant="outline"
@click="router.push(`/vehicles`)"
>
Fahrzeuge
</UButton>
</template>
<template #center>
<h1
v-if="itemInfo"
:class="['text-xl','font-medium']"
>{{itemInfo ? `Fahrzeug: ${itemInfo.licensePlate}` : (mode === 'create' ? 'Fahrzeug erstellen' : 'Fahrzeug bearbeiten')}}</h1>
</template>
<template #right>
<ButtonWithConfirm
color="rose"
variant="outline"
@confirmed="dataStore.updateItem('vehicles',{...itemInfo, archived: true})"
v-if="mode === 'edit'"
>
<template #button>
Archivieren
</template>
<template #header>
<span class="text-md text-black font-bold">Archivieren bestätigen</span>
</template>
Möchten Sie das Fahrzeug {{itemInfo.name}} wirklich archivieren?
</ButtonWithConfirm>
<UButton
v-if="mode === 'edit'"
@click="dataStore.updateItem('vehicles',itemInfo, oldItemInfo)"
>
Speichern
</UButton>
<UButton
v-else-if="mode === 'create'"
@click="dataStore.createNewItem('vehicles',itemInfo)"
>
Erstellen
</UButton>
<UButton
@click="cancelEditorCreate"
color="red"
class="ml-2"
v-if="mode === 'edit' || mode === 'create'"
>
Abbrechen
</UButton>
</template>
</UDashboardNavbar>-->
<!-- <UForm
class="p-5"
>
<UFormGroup
label="Kennzeichen:"
>
<UInput
v-model="itemInfo.licensePlate"
/>
</UFormGroup>
<UFormGroup
label="Fahrzeug aktiv:"
>
<UCheckbox
v-model="itemInfo.active"
/>
</UFormGroup>
<UFormGroup
label="Fahrgestellnummer:"
>
<UInput
v-model="itemInfo.vin"
/>
</UFormGroup>
<UFormGroup
label="Typ:"
>
<UTextarea
v-model="itemInfo.type"
/>
</UFormGroup>
<UFormGroup
label="Fahrer:"
>
<USelectMenu
v-model="itemInfo.driver"
:options="[{id: null, fullName: 'Kein Fahrer'},...profileStore.profiles]"
option-attribute="fullName"
value-attribute="id"
>
<template #label>
{{profileStore.profiles.find(profile => profile.id === itemInfo.driver) ? profileStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer ausgewählt'}}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Tankvolumen:"
>
<UInput
v-model="itemInfo.tankSize"
type="number"
>
<template #trailing>
L
</template>
</UInput>
</UFormGroup>
<UFormGroup
label="Baujahr:"
>
<UInput
v-model="itemInfo.buildYear"
type="number"
/>
</UFormGroup>
<UFormGroup
label="Anhängelast:"
>
<UInput
v-model="itemInfo.towingCapacity"
type="number"
>
<template #trailing>kg</template>
</UInput>
</UFormGroup>
<UFormGroup
label="Farbe:"
>
<UInput
v-model="itemInfo.color"
type="text"
/>
</UFormGroup>
<UFormGroup
label="Leistung:"
>
<UInput
v-model="itemInfo.powerInKW"
type="number"
>
<template #trailing>kW</template>
</UInput>
</UFormGroup>
</UForm>-->
</template>
<style scoped>
</style>

View File

@@ -0,0 +1,33 @@
<script setup>
import {useSupabaseSelectSingle} from "~/composables/useSupabase.js";
const route = useRoute()
const itemInfo = ref({})
const tabItems = [{
label: 'Informationen',
}, {
label: 'Dokumente',
}, {
label: 'Überprüfungen',
}]
const setupPage = async () => {
itemInfo.value = await useSupabaseSelectSingle("vehicles",route.params.id,"*, checks(*), documents(*)")
console.log(itemInfo.value)
}
setupPage()
</script>
<template>
<EntityShow
type="vehicles"
:item="itemInfo"
/>
</template>
<style scoped>
</style>

View File

@@ -6,7 +6,6 @@ definePageMeta({
const supabase = useSupabaseClient()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const profileStore = useProfileStore()

View File

@@ -0,0 +1,60 @@
<script setup>
const route = useRoute()
const dataStore = useDataStore()
const type = route.params.type
const dataType = dataStore.dataTypes[route.params.type]
const loaded = ref(false)
const mode = ref("list")
const items = ref([])
const item = ref({})
const setupPage = async () => {
if(route.params.mode) mode.value = route.params.mode
if(mode.value === "show") {
//Load Data for Show
item.value = await useSupabaseSelectSingle(type, route.params.id, dataType.supabaseSelectWithInformation || "*")
} else if(mode.value === "edit") {
//Load Data for Edit
item.value = await useSupabaseSelectSingle(type, route.params.id)
} else if(mode.value === "list") {
//Load Data for List
items.value = await useSupabaseSelect(type, dataType.supabaseSelectWithInformation || "*", dataType.supabaseSortColumn)
}
loaded.value = true
}
setupPage()
</script>
<template>
<EntityShow
v-if="loaded && mode === 'show'"
:type="route.params.type"
:item="item"
/>
<EntityEdit
v-else-if="loaded && (mode === 'edit' || mode === 'create')"
:type="route.params.type"
:item="item"
/>
<EntityList
v-else-if="loaded && mode === 'list'"
:type="type"
:items="items"
/>
<UProgress
v-else
animation="carousel"
class="p-5 mt-10"
/>
</template>
<style scoped>
</style>

View File

@@ -1,406 +0,0 @@
<script setup>
import dayjs from "dayjs";
import {useSupabaseSelectSingle} from "~/composables/useSupabase.js";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'backspace': () => {
router.push("/vehicles")
},
'arrowleft': () => {
if(openTab.value > 0){
openTab.value -= 1
}
},
'arrowright': () => {
if(openTab.value < 3) {
openTab.value += 1
}
},
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
const openTab = ref(0)
//Working
const mode = ref(route.params.mode || "show")
const itemInfo = ref({
name: "",
licensePlate: "",
type: "",
driver: null,
active: true
})
const oldItemInfo = ref({})
const tabItems = [{
label: 'Informationen',
}, {
label: 'Dokumente',
}, {
label: 'Überprüfungen',
}]
const incomingInvoicesColumns = [
{
key: "state",
label: "Status",
sortable: true
},{
key: "vendor",
label: "Lieferant",
sortable: true
},{
key: "date",
label: "Datum",
sortable: true
},{
key: "description",
label: "Beschreibung",
sortable: true
},{
key: "accounts",
label: "Betrag",
sortable: true
},
]
//Functions
const setupPage = async () => {
if(mode.value === "show"){
itemInfo.value = await useSupabaseSelectSingle("vehicles",route.params.id,"*, checks(*)")
} else if(mode.value === "edit"){
itemInfo.value = await useSupabaseSelectSingle("vehicles",route.params.id,"*")
}
if(itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
}
const cancelEditorCreate = () => {
if(itemInfo.value.id) {
router.push(`/vehicles/show/${itemInfo.value.id}`)
} else {
router.push(`/vehicles`)
}
}
const getRowAmount = (row) => {
let amount = 0
row.accounts.forEach(account => {
amount += account.amountNet
amount += account.amountTax
})
return amount
}
setupPage()
</script>
<template>
<UDashboardNavbar
:title="itemInfo ? itemInfo.licensePlate : (mode === 'create' ? 'Fahrzeug erstellen' : 'Fahrzeug bearbeiten')"
:ui="{center: 'flex items-stretch gap-1.5 min-w-0'}"
>
<template #left>
<UButton
icon="i-heroicons-chevron-left"
variant="outline"
@click="router.push(`/vehicles`)"
>
Fahrzeuge
</UButton>
</template>
<template #center>
<h1
v-if="itemInfo"
:class="['text-xl','font-medium']"
>{{itemInfo ? `Fahrzeug: ${itemInfo.licensePlate}` : (mode === 'create' ? 'Fahrzeug erstellen' : 'Fahrzeug bearbeiten')}}</h1>
</template>
<template #right>
<ButtonWithConfirm
color="rose"
variant="outline"
@confirmed="dataStore.updateItem('vehicles',{...itemInfo, archived: true})"
v-if="mode === 'edit'"
>
<template #button>
Archivieren
</template>
<template #header>
<span class="text-md text-black font-bold">Archivieren bestätigen</span>
</template>
Möchten Sie das Fahrzeug {{itemInfo.name}} wirklich archivieren?
</ButtonWithConfirm>
<UButton
v-if="mode === 'edit'"
@click="dataStore.updateItem('vehicles',itemInfo, oldItemInfo)"
>
Speichern
</UButton>
<UButton
v-else-if="mode === 'create'"
@click="dataStore.createNewItem('vehicles',itemInfo)"
>
Erstellen
</UButton>
<UButton
@click="cancelEditorCreate"
color="red"
class="ml-2"
v-if="mode === 'edit' || mode === 'create'"
>
Abbrechen
</UButton>
<UButton
v-if="mode === 'show'"
@click="router.push(`/vehicles/edit/${itemInfo.id}`)"
>
Bearbeiten
</UButton>
</template>
</UDashboardNavbar>
<UTabs
:items="tabItems"
v-if="mode === 'show' && itemInfo.id"
class="p-5"
v-model="openTab"
>
<template #item="{item}">
<div v-if="item.label === 'Informationen'" class="flex flex-row mt-5">
<UCard class="w-1/2 mr-5">
<UAlert
v-if="itemInfo.archived"
color="rose"
variant="outline"
title="Objekt archiviert"
icon="i-heroicons-light-bulb"
class="mb-5"
/>
<div class="text-wrap">
<table class="w-full">
<tr>
<td>Kennzeichen: </td>
<td>{{itemInfo.licensePlate}}</td>
</tr>
<tr>
<td>Typ: </td>
<td>{{itemInfo.type}}</td>
</tr>
<tr>
<td>Fahrgestellnummer: </td>
<td>{{itemInfo.vin}}</td>
</tr>
<tr>
<td>Fahrer:</td>
<td>{{profileStore.profiles.find(profile => profile.id === itemInfo.driver) ? profileStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer gewählt'}}</td>
</tr>
<tr>
<td>Tankvolumen:</td>
<td>{{itemInfo.tankSize !== 0 ? `${itemInfo.tankSize} L` : "Kein Tank verbaut"}}</td>
</tr>
<tr>
<td>Baujahr:</td>
<td>{{itemInfo.buildYear}}</td>
</tr>
<tr>
<td>Anhänglast:</td>
<td>{{itemInfo.towingCapacity}}</td>
</tr>
<tr>
<td>Farbe:</td>
<td>{{itemInfo.color}}</td>
</tr>
<tr>
<td>Leistung:</td>
<td>{{itemInfo.powerInKW && itemInfo.powerInKW + " kW"}}</td>
</tr>
</table>
</div>
</UCard>
<UCard class="w-1/2">
<HistoryDisplay
type="vehicle"
v-if="itemInfo"
:element-id="itemInfo.id"
/>
</UCard>
</div>
<div v-else-if="item.label === 'Eingangsrechnungen'">
<UTable
:rows="dataStore.getIncomingInvoicesByVehicleId(itemInfo.id)"
:columns="incomingInvoicesColumns"
@select="(row) => router.push('/receipts/show/' + row.id)"
>
<template #vendor-data="{row}">
{{dataStore.getVendorById(row.vendor) ? dataStore.getVendorById(row.vendor).name : ""}}
</template>
<template #date-data="{row}">
{{dayjs(row.date).format("DD.MM.YYYY")}}
</template>
<template #accounts-data="{row}">
{{getRowAmount(row) ? String(getRowAmount(row).toFixed(2)).replace('.',',') + " €" : ""}}
</template>
</UTable>
</div>
<div v-else-if="item.label === 'Dokumente'">
<UCard class="mt-5">
<Toolbar>
<DocumentUpload
type="vehicle"
:element-id="itemInfo.id"
/>
</Toolbar>
<DocumentList
:documents="dataStore.getDocumentsByVehicleId(itemInfo.id)"
/>
</UCard>
</div>
<div v-else-if="item.label === 'Überprüfungen'">
<UCard class="mt-5">
<UTable
:rows="itemInfo.checks"
:columns="[{key:'name',label: 'Name'},{key:'rhythm',label: 'Rhythmus'},{key:'description',label: 'Beschreibung'}]"
class="w-full"
:ui="{ divide: 'divide-gray-200 dark:divide-gray-800' }"
@select="(i) => router.push(`/checks/show/${i.id}`) "
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Überprüfungen anzuzeigen' }"
>
<template #rhythm-data="{row}">
{{row.distance}}
<span v-if="row.distanceUnit === 'dayjs'">Tage</span>
<span v-if="row.distanceUnit === 'years'">Jahre</span>
</template>
</UTable>
</UCard>
</div>
</template>
</UTabs>
<UForm
v-else-if="mode == 'edit' || mode == 'create'"
class="p-5"
>
<UFormGroup
label="Kennzeichen:"
>
<UInput
v-model="itemInfo.licensePlate"
/>
</UFormGroup>
<UFormGroup
label="Fahrzeug aktiv:"
>
<UCheckbox
v-model="itemInfo.active"
/>
</UFormGroup>
<UFormGroup
label="Fahrgestellnummer:"
>
<UInput
v-model="itemInfo.vin"
/>
</UFormGroup>
<UFormGroup
label="Typ:"
>
<UTextarea
v-model="itemInfo.type"
/>
</UFormGroup>
<UFormGroup
label="Fahrer:"
>
<USelectMenu
v-model="itemInfo.driver"
:options="[{id: null, fullName: 'Kein Fahrer'},...profileStore.profiles]"
option-attribute="fullName"
value-attribute="id"
>
<template #label>
{{profileStore.profiles.find(profile => profile.id === itemInfo.driver) ? profileStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer ausgewählt'}}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Tankvolumen:"
>
<UInput
v-model="itemInfo.tankSize"
type="number"
>
<template #trailing>
L
</template>
</UInput>
</UFormGroup>
<UFormGroup
label="Baujahr:"
>
<UInput
v-model="itemInfo.buildYear"
type="number"
/>
</UFormGroup>
<UFormGroup
label="Anhängelast:"
>
<UInput
v-model="itemInfo.towingCapacity"
type="number"
>
<template #trailing>kg</template>
</UInput>
</UFormGroup>
<UFormGroup
label="Farbe:"
>
<UInput
v-model="itemInfo.color"
type="text"
/>
</UFormGroup>
<UFormGroup
label="Leistung:"
>
<UInput
v-model="itemInfo.powerInKW"
type="number"
>
<template #trailing>kW</template>
</UInput>
</UFormGroup>
</UForm>
</template>
<style scoped>
td {
border-bottom: 1px solid lightgrey;
vertical-align: top;
padding-bottom: 0.15em;
padding-top: 0.15em;
}
</style>

View File

@@ -7,12 +7,17 @@ import {useNumberRange} from "~/composables/useNumberRange.js";
import projecttype from "~/components/columnRenderings/projecttype.vue"
import customer from "~/components/columnRenderings/customer.vue"
import contact from "~/components/columnRenderings/contact.vue"
import plant from "~/components/columnRenderings/plant.vue"
import vendor from "~/components/columnRenderings/vendor.vue"
import active from "~/components/columnRenderings/active.vue"
import sellingPrice from "~/components/columnRenderings/sellingPrice.vue";
import unit from "~/components/columnRenderings/unit.vue";
import isCompany from "~/components/columnRenderings/isCompany.vue"
import address from "~/components/columnRenderings/address.vue"
import sepa from "~/components/columnRenderings/sepa.vue"
import recurring from "~/components/columnRenderings/recurring.vue"
import description from "~/components/columnRenderings/description.vue"
// @ts-ignore
export const useDataStore = defineStore('data', () => {
@@ -33,37 +38,112 @@ export const useDataStore = defineStore('data', () => {
customers: {
label: "Kunden",
labelSingle: "Kunde",
isStandardEntity: true,
redirect:true,
numberRangeHolder: "customerNumber",
historyItemHolder: "customer",
supabaseSortColumn: "customerNumber",
supabaseSelectWithInformation: "*, projects(*), plants(*), contracts(*), contacts(*)",
filters: [],
templateColumns: [
{
key: 'customerNumber',
label: "Kundennummer",
inputIsNumberRange: true,
inputType: "text"
},
{
key: "name",
label: "Name"
label: "Name",
title: true,
inputType: "text"
},
{
key: "isCompany",
label: "Typ"
label: "Typ",
component: isCompany,
inputType: "bool"
},
{
key: "notes",
label: "Notizen"
label: "Notizen",
inputType: "textarea"
},
{
key: "active",
label: "Aktiv",
component: active
component: active,
inputType: "bool"
},
{
key: "infoData.streetNumber",
label: "Straße + Hausnummer",
inputType: "text",
disabledInTable: true
},
{
key: "infoData.special",
label: "Adresszusatz",
inputType: "text",
disabledInTable: true
},
{
key: "infoData.zip",
label: "Postleitzahl",
inputType: "number",
disabledInTable: true
},
{
key: "infoData.city",
label: "Stadt",
inputType: "text",
disabledInTable: true
},
{
key: "infoData.country",
label: "Land",
inputType: "select",
selectDataType: "countrys",
selectOptionAttribute: "name",
selectValueAttribute: "name",
disabledInTable: true
},
{
key: "address",
label: "Adresse",
}
]
component: address
},
{
key: "infoData.tel",
label: "Telefon",
inputType: "text"
},
{
key: "infoData.email",
label: "E-Mail",
inputType: "text"
},
{
key: "infoData.web",
label: "Web",
inputType: "text"
},
{
key: "infoData.ustid",
label: "USt-Id",
inputType: "text"
},
{
key: "profiles",
label: "Berechtigte Benutzer",
inputType: "select",
selectDataType: "profiles",
selectOptionAttribute: "fullName",
selectSearchAttributes: ['fullName'],
selectMultiple: true
},
],
showTabs: [{label: 'Informationen'},{label: 'Dokumente'},{label: 'Projekte'},{label: 'Objekte'},{label: 'Verträge'}]
},
contacts: {
label: "Kontakte",
@@ -116,21 +196,103 @@ export const useDataStore = defineStore('data', () => {
contracts: {
label: "Verträge",
labelSingle: "Vertrag",
isStandardEntity: true,
redirect:true,
filters:[],
supabaseSelectWithInformation: "*, customer(*), documents(*)",
templateColumns: [
{
key: "name",
label: "Name"
label: "Name",
title: true,
inputType: "text"
},{
key: "active",
label: "Aktiv",
component: active,
inputType: "bool"
},{
key: "recurring",
label: "Wiederkehrend",
component: recurring,
inputType: "bool"
},{
key: 'customer',
label: "Kunde",
component: customer
component: customer,
inputType: "select",
selectDataType: "customers",
selectOptionAttribute: "name",
selectSearchAttributes: ['name'],
},{
key: 'contact',
label: "Ansprechpartner",
component: contact,
inputType: "select",
selectDataType: "contacts",
selectDataTypeFilter: function (i,item) {
return i.customer === item.customer
},
selectOptionAttribute: "fullName",
selectSearchAttributes: ['fullName'],
},{
key: 'duration',
label: "mindest Vertragslaufzeit",
inputType: "select",
selectManualOptions: ['12 Monate','24 Monate','36 Monate','48 Monate']
},{
key: 'invoiceDispatch',
label: "Rechnungsversand",
inputType: "select",
selectManualOptions: ['E-Mail','Post']
},{
key: 'paymentType',
label: "Zahlungsart",
inputType: "select",
selectManualOptions: ['Einzug','Überweisung']
},{
key: 'startDate',
label: "Vertragsstart",
inputType: "date",
},{
key: 'endDate',
label: "Vertragsende",
inputType: "date",
},{
key: 'signDate',
label: "Unterschrieben am",
inputType: "date",
},{
key: 'sepaDate',
label: "SEPA Datum",
inputType: "date",
},{
key: 'sepaRef',
label: "Mandatsreferenz",
inputType: "text",
},{
key: 'bankingIban',
label: "IBAN",
inputType: "text",
},{
key: 'bankingOwner',
label: "Inhaber",
inputType: "text",
},{
key: 'bankingName',
label: "Bank",
inputType: "text",
},{
key: 'bankinBIC',
label: "BIC",
inputType: "text",
},{
key: "notes",
label: "Notizen"
label: "Notizen",
inputType: "textarea"
}
]
],
showTabs: [{label: 'Informationen'},{label: 'Dokumente'}]
},
absencerequests: {
label: "Abwesenheitsanträge",
@@ -140,20 +302,43 @@ export const useDataStore = defineStore('data', () => {
plants: {
label: "Objekte",
labelSingle: "Objekt",
isStandardEntity: true,
redirect:true,
historyItemHolder: "plant",
supabaseSelectWithInformation: "*, customer(id,name)",
filters: [],
templateColumns: [
{
key: "name",
label: "Name"
label: "Name",
inputType: "text",
title: true
},
{
key: "customer",
label: "Kunde",
component: customer
}
]
component: customer,
inputType: "select",
selectDataType: "customers",
selectOptionAttribute: "name",
selectSearchAttributes: ['name'],
},{
key: "description",
label: "Beschreibung",
inputType:"editor",
component: description
},
],
showTabs: [
{
label: "Informationen"
},{
label: "Projekte"
},{
label: "Aufgaben"
},{
label: "Dokumente"
}]
},
products: {
label: "Artikel",
@@ -196,9 +381,12 @@ export const useDataStore = defineStore('data', () => {
projects: {
label: "Projekte",
labelSingle: "Projekt",
isStandardEntity: true,
redirect:true,
historyItemHolder: "project",
numberRangeHolder: "projectNumber",
supabaseSelectWithInformation: "*, customer(name), plant(name), projecttype(name, id), tasks(*), documents(*)",
supabaseSortColumn: "projectNumber",
filters: [
{
name: "Abgeschlossen",
@@ -221,80 +409,273 @@ export const useDataStore = defineStore('data', () => {
{
key: "projecttype",
label: "Typ",
component: projecttype
component: projecttype,
inputType: "select",
selectDataType: "projecttypes",
selectOptionAttribute: "name",
selectSearchAttributes: ['name'],
},{
key: "phase",
label: "Phase"
},{
key: "name",
label: "Name"
label: "Name",
title: true,
inputType: "text"
},
{
key: "customer",
label: "Kunde",
component: customer
component: customer,
inputType: "select",
selectDataType: "customers",
selectOptionAttribute: "name",
selectSearchAttributes: ['name'],
},
{
key: "notes",
label: "Notizen",
inputType: "textarea"
},
{
key: "plant",
label: "Objekt",
component: plant
component: plant,
inputType: "select",
selectDataType: "plants",
selectOptionAttribute: "name",
selectSearchAttributes: ['name'],
},
{
key: "profiles",
label: "Benutzer"
}]
label: "Berechtigte Benutzer",
inputType: "select",
selectDataType: "profiles",
selectOptionAttribute: "fullName",
selectSearchAttributes: ['fullName'],
selectMultiple: true
},],
showTabs: [
{
key: "information",
label: "Informationen"
},
{
key: "phases",
label: "Phasen"
},{
key: "tasks",
label: "Aufgaben"
},{
key: "documents",
label: "Dokumente"
}/*,{
key: "timetracking",
label: "Zeiterfassung"
},{
key: "events",
label: "Termine"
},{
key: "material",
label: "Material"
}*/]
},
vehicles: {
label: "Fahrzeuge",
labelSingle: "Fahrzeug",
isStandardEntity: true,
redirect:true,
historyItemHolder: "vehicle",
supabaseSelectWithInformation: "*, checks(*), documents(*)",
filters:[],
templateColumns:[
{
key: 'active',
label: "Aktiv",
component: active
component: active,
inputType: "bool"
},{
key: 'licensePlate',
label: "Kennzeichen"
label: "Kennzeichen",
inputType: "text",
title: true
},{
key: 'vin',
label: "Identifikationnummer"
label: "Identifikationnummer",
inputType: "text"
},
{
key: "type",
label: "Typ",
inputType: "text"
},
{
key: "driver",
label: "Fahrer",
inputType: "select",
selectDataType: "profiles",
selectOptionAttribute: "fullName"
},
{
key: "tankSize",
label: "Tankvolumen",
unit: "L",
inputType: "number"
},
{
key: "buildYear",
label: "Baujahr",
inputType: "number"
},
{
key: "towingCapacity",
label: "Anhängelast",
unit: "kG",
inputType: "number"
},
{
key: "color",
label: "Farbe",
inputType: "text"
},
{
key: "powerInKW",
label: "Leistung",
unit: "kW",
inputType: "number"
},
{
key: "profiles",
label: "Berechtigte Benutzer",
inputType: "select",
selectDataType: "profiles",
selectOptionAttribute: "fullName",
selectSearchAttributes: ['fullName'],
selectMultiple: true
},
],
showTabs: [
{
label: 'Informationen',
}, {
label: 'Dokumente',
}, {
label: 'Überprüfungen',
}
]
},
vendors: {
label: "Lieferanten",
labelSingle: "Lieferant",
isStandardEntity: true,
redirect:true,
numberRangeHolder: "vendorNumber",
historyItemHolder: "vendor",
filters: [],
supabaseSortColumn: "vendorNumber",
supabaseSelectWithInformation: "*, contacts(*)",
filters: [{
name: "SEPA nicht erteilt",
"filterFunction": function (row) {
return !row.hasSEPA
}
}],
templateColumns: [
{
key: 'vendorNumber',
label: "Lieferantennummer",
inputType: "text",
inputIsNumberRange: true
},
{
key: "name",
label: "Name"
label: "Name",
title: true,
inputType: "text"
},
{
key: "infoData.streetNumber",
label: "Straße + Hausnummer",
inputType: "text",
disabledInTable: true
},
{
key: "infoData.special",
label: "Adresszusatz",
inputType: "text",
disabledInTable: true
},
{
key: "infoData.zip",
label: "Postleitzahl",
inputType: "number",
disabledInTable: true
},
{
key: "infoData.city",
label: "Stadt",
inputType: "text",
disabledInTable: true
},
{
key: "infoData.country",
label: "Land",
inputType: "select",
selectDataType: "countrys",
selectOptionAttribute: "name",
selectValueAttribute: "name",
disabledInTable: true
},
{
key: "address",
label: "Adresse"
label: "Adresse",
component: address
},
{
key: "infoData.tel",
label: "Telefon",
inputType: "text"
},
{
key: "infoData.email",
label: "E-Mail",
inputType: "text"
},
{
key: "infoData.web",
label: "Web",
inputType: "text"
},
{
key: "infoData.ustid",
label: "USt-Id",
inputType: "text"
},
{
key: "hasSEPA",
label: "SEPA Mandat erteilt",
inputType: "bool",
component: sepa
},
{
key: "notes",
label: "Notizen"
label: "Notizen",
inputType: "textarea"
},
{
key: "profiles",
label: "Berechtigte Benutzer",
inputType: "select",
selectDataType: "profiles",
selectOptionAttribute: "fullName",
selectSearchAttributes: ['fullName'],
selectMultiple: true
},
],
showTabs: [
{
label: 'Informationen',
}, {
label: 'Dokumente',
}
]
},
@@ -798,8 +1179,8 @@ export const useDataStore = defineStore('data', () => {
name = "Kategorie"
} else if(key === "profile") {
name = "Mitarbeiter"
if(prop.data.o) oldVal = profiles.value.find(i => i.id === prop.data.o).fullName
if(prop.data.n) newVal = profiles.value.find(i => i.id === prop.data.n).fullName
if(prop.data.o) oldVal = profileStore.profiles.find(i => i.id === prop.data.o).fullName
if(prop.data.n) newVal = profileStore.profiles.find(i => i.id === prop.data.n).fullName
} else if(key === "plant") {
name = "Objekt"
if(prop.data.o) oldVal = plants.value.find(i => i.id === prop.data.o).name
@@ -822,8 +1203,8 @@ export const useDataStore = defineStore('data', () => {
name = "Leistung"
} else if(key === "driver") {
name = "Fahrer"
if(prop.data.o) oldVal = profiles.value.find(i => i.id === prop.data.o).fullName
if(prop.data.n) newVal = profiles.value.find(i => i.id === prop.data.n).fullName
if(prop.data.o) oldVal = profileStore.profiles.find(i => i.id === prop.data.o).fullName
if(prop.data.n) newVal = profileStore.profiles.find(i => i.id === prop.data.n).fullName
} else if(key === "projecttype") {
name = "Projekttyp"
@@ -856,7 +1237,7 @@ export const useDataStore = defineStore('data', () => {
let historyItem = {
text: text,
createdBy: activeProfile.value.id,
createdBy: profileStore.activeProfile.id,
oldVal: prop.data.o,
newVal: prop.data.n,
tenant: profileStore.currentTenant
@@ -971,7 +1352,13 @@ export const useDataStore = defineStore('data', () => {
toast.add({title: `${dataTypes[dataType].labelSingle} hinzugefügt`})
if(dataTypes[dataType].redirect) await router.push(`/${dataType}/show/${supabaseData[0].id}`)
if(dataTypes[dataType].redirect) {
if(dataTypes[dataType].isStandardEntity) {
await router.push(dataTypes[dataType].redirectToList ? `/standardEntity/${dataType}` : `/standardEntity/${dataType}/show/${data.id}`)
} else {
await router.push(dataTypes[dataType].redirectToList ? `/${dataType}` : `/${dataType}/show/${data.id}`)
}
}
return supabaseData
}
}
@@ -1022,9 +1409,15 @@ export const useDataStore = defineStore('data', () => {
toast.add({title: `Fehler beim Speichern`, color: 'rose'})
} else if(supabaseData) {
//await eval(dataType + '.value[' + dataType + '.value.findIndex(i => i.id === ' + JSON.stringify(data.id) + ')] = ' + JSON.stringify(supabaseData[0]))
if(dataType === 'profiles') await fetchProfiles()
//if(dataType === 'profiles') await fetchProfiles()
toast.add({title: `${dataTypes[dataType].labelSingle} gespeichert`})
if(dataTypes[dataType].redirect) await router.push(dataTypes[dataType].redirectToList ? `/${dataType}` : `/${dataType}/show/${data.id}`)
if(dataTypes[dataType].redirect) {
if(dataTypes[dataType].isStandardEntity) {
await router.push(dataTypes[dataType].redirectToList ? `/standardEntity/${dataType}` : `/standardEntity/${dataType}/show/${data.id}`)
} else {
await router.push(dataTypes[dataType].redirectToList ? `/${dataType}` : `/${dataType}/show/${data.id}`)
}
}
return supabaseData
}
}
@@ -1441,19 +1834,19 @@ export const useDataStore = defineStore('data', () => {
})
const getEventTypes = computed(() => {
return ownTenant.value.calendarConfig.eventTypes
return profileStore.ownTenant.calendarConfig.eventTypes
})
const getTimeTypes = computed(() => {
return ownTenant.value.timeConfig.timeTypes
return profileStore.ownTenant.timeConfig.timeTypes
})
const getDocumentTags = computed(() => {
return ownTenant.value.tags.documents
return profileStore.ownTenant.tags.documents
})
const getMeasures = computed(() => {
return ownTenant.value.measures
return profileStore.ownTenant.measures
})
const getResources = computed(() => {
@@ -1511,7 +1904,7 @@ export const useDataStore = defineStore('data', () => {
const getEvents = computed(() => {
return [
...events.value.map(event => {
let eventColor = ownTenant.value.calendarConfig.eventTypes.find(type => type.label === event.type).color
let eventColor = profileStore.ownTenant.calendarConfig.eventTypes.find(type => type.label === event.type).color
let title = ""
if(event.title) {
@@ -1548,7 +1941,7 @@ export const useDataStore = defineStore('data', () => {
console.log(event)
event.resources.forEach(resource => {
console.log(resource)
let eventColor = ownTenant.value.calendarConfig.eventTypes.find(type => type.label === event.type).color
let eventColor = profileStore.ownTenant.calendarConfig.eventTypes.find(type => type.label === event.type).color
let title = ""
if(event.title) {
@@ -1580,7 +1973,7 @@ export const useDataStore = defineStore('data', () => {
/*...events.value.map(event => {
let eventColor = ownTenant.value.calendarConfig.eventTypes.find(type => type.label === event.type).color
let eventColor = profileStore.ownTenant.calendarConfig.eventTypes.find(type => type.label === event.type).color
return {
...event,