Added Archiving & Some Tidying in Vehicles

This commit is contained in:
2024-11-08 18:38:54 +01:00
parent c67c4a70c4
commit a61382486f
2 changed files with 115 additions and 43 deletions

View File

@@ -43,11 +43,7 @@ const oldItemInfo = ref({})
const tabItems = [{ const tabItems = [{
label: 'Informationen', label: 'Informationen',
},{ }, {
label: "Logbuch"
},/* {
label: 'Eingangsrechnungen',
},*/ {
label: 'Dokumente', label: 'Dokumente',
}] }]
@@ -130,6 +126,20 @@ setupPage()
>{{itemInfo ? `Fahrzeug: ${itemInfo.licensePlate}` : (mode === 'create' ? 'Fahrzeug erstellen' : 'Fahrzeug bearbeiten')}}</h1> >{{itemInfo ? `Fahrzeug: ${itemInfo.licensePlate}` : (mode === 'create' ? 'Fahrzeug erstellen' : 'Fahrzeug bearbeiten')}}</h1>
</template> </template>
<template #right> <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 <UButton
v-if="mode === 'edit'" v-if="mode === 'edit'"
@click="dataStore.updateItem('vehicles',itemInfo, oldItemInfo)" @click="dataStore.updateItem('vehicles',itemInfo, oldItemInfo)"
@@ -165,50 +175,80 @@ setupPage()
v-model="openTab" v-model="openTab"
> >
<template #item="{item}"> <template #item="{item}">
<UCard class="mt-5"> <div v-if="item.label === 'Informationen'" class="flex flex-row mt-5">
<div class="truncate" v-if="item.label === 'Informationen'"> <UCard class="w-1/2 mr-5">
<p>Typ: {{itemInfo.type}}</p> <UAlert
<p>Fahrgestellnummer: {{itemInfo.vin}}</p> v-if="itemInfo.archived"
<p>Fahrer: {{dataStore.profiles.find(profile => profile.id === itemInfo.driver) ? dataStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer gewählt'}}</p> color="rose"
</div> variant="outline"
<div v-else-if="item.label === 'Eingangsrechnungen'"> title="Objekt archiviert"
<UTable icon="i-heroicons-light-bulb"
:rows="dataStore.getIncomingInvoicesByVehicleId(itemInfo.id)" class="mb-5"
:columns="incomingInvoicesColumns" />
@select="(row) => router.push('/receipts/show/' + row.id)" <div class="text-wrap">
> <table class="w-full">
<template #vendor-data="{row}"> <tr>
{{dataStore.getVendorById(row.vendor) ? dataStore.getVendorById(row.vendor).name : ""}} <td>Kennzeichen: </td>
</template> <td>{{itemInfo.licensePlate}}</td>
<template #date-data="{row}"> </tr>
{{dayjs(row.date).format("DD.MM.YYYY")}} <tr>
</template> <td>Typ: </td>
<template #accounts-data="{row}"> <td>{{itemInfo.type}}</td>
{{getRowAmount(row) ? String(getRowAmount(row).toFixed(2)).replace('.',',') + " €" : ""}} </tr>
</template> <tr>
</UTable> <td>Fahrgestellnummer: </td>
<td>{{itemInfo.vin}}</td>
</tr>
<tr>
<td>Fahrer:</td>
<td>{{dataStore.profiles.find(profile => profile.id === itemInfo.driver) ? dataStore.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>
</table>
</div>
</div> </UCard>
<div v-else-if="item.label === 'Logbuch'"> <UCard class="w-1/2">
<HistoryDisplay <HistoryDisplay
type="vehicle" type="vehicle"
v-if="itemInfo" v-if="itemInfo"
:element-id="itemInfo.id" :element-id="itemInfo.id"
/> />
</div> </UCard>
<div v-else-if="item.label === 'Dokumente'"> </div>
<Toolbar> <div v-else-if="item.label === 'Eingangsrechnungen'">
<DocumentUpload <UTable
type="vehicle" :rows="dataStore.getIncomingInvoicesByVehicleId(itemInfo.id)"
:element-id="itemInfo.id" :columns="incomingInvoicesColumns"
/> @select="(row) => router.push('/receipts/show/' + row.id)"
</Toolbar> >
<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>
<DocumentList </div>
:documents="dataStore.getDocumentsByVehicleId(itemInfo.id)" <div v-else-if="item.label === 'Dokumente'">
<Toolbar>
<DocumentUpload
type="vehicle"
:element-id="itemInfo.id"
/> />
</div> </Toolbar>
</UCard>
<DocumentList
:documents="dataStore.getDocumentsByVehicleId(itemInfo.id)"
/>
</div>
</template> </template>
@@ -264,9 +304,26 @@ setupPage()
</template> </template>
</USelectMenu> </USelectMenu>
</UFormGroup> </UFormGroup>
<UFormGroup
label="Tankvolumen:"
>
<UInput
v-model="itemInfo.tankSize"
type="number"
>
<template #trailing>
L
</template>
</UInput>
</UFormGroup>
</UForm> </UForm>
</template> </template>
<style scoped> <style scoped>
td {
border-bottom: 1px solid lightgrey;
vertical-align: top;
padding-bottom: 0.15em;
padding-top: 0.15em;
}
</style> </style>

View File

@@ -43,6 +43,13 @@
@select="(i) => router.push(`/vehicles/show/${i.id}`) " @select="(i) => router.push(`/vehicles/show/${i.id}`) "
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Fahrzeuge anzuzeigen' }" :empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Fahrzeuge anzuzeigen' }"
> >
<template #active-data="{row}">
<UIcon
:name="row.active ? 'i-heroicons-check' : 'i-heroicons-x-mark'"
:class="['w-5', 'h-5', ... row.active ? ['text-primary-500'] : ['text-rose-600'] ]"
/>
</template>
<template #licensePlate-data="{row}"> <template #licensePlate-data="{row}">
<span v-if="row === filteredRows[selectedItem]" class="font-bold text-primary-500">{{row.licensePlate}}</span> <span v-if="row === filteredRows[selectedItem]" class="font-bold text-primary-500">{{row.licensePlate}}</span>
<span v-else>{{row.licensePlate}}</span> <span v-else>{{row.licensePlate}}</span>
@@ -101,9 +108,17 @@ setupPage()
const templateColumns = [ const templateColumns = [
{ {
key: 'active',
label: "Aktiv:",
sortable: true
},{
key: 'licensePlate', key: 'licensePlate',
label: "Kennzeichen:", label: "Kennzeichen:",
sortable: true sortable: true
},{
key: 'vin',
label: "Identifikationnr.:",
sortable: true
}, },
{ {
key: "type", key: "type",
@@ -117,7 +132,7 @@ const columns = computed(() => templateColumns.filter((column) => selectedColumn
const searchString = ref('') const searchString = ref('')
const filteredRows = computed(() => { const filteredRows = computed(() => {
return useSearch(searchString.value, items.value) return useListFilter(searchString.value, items.value)
}) })
</script> </script>