Redone Submit/approve Process

This commit is contained in:
2025-11-10 11:07:11 +01:00
parent 06b97cbdae
commit 87aaa28d92
2 changed files with 75 additions and 13 deletions

View File

@@ -38,6 +38,20 @@ export function useStaffTime() {
})
}
async function submit(id: string) {
return await $api<StaffTimeEntry>(`/api/staff/time/${id}`, {
method: 'PUT',
body: { state: 'submitted' },
})
}
async function approve(id: string) {
return await $api<StaffTimeEntry>(`/api/staff/time/${id}`, {
method: 'PUT',
body: { state: 'approved' },
})
}
async function get(id: string) {
return await $api<StaffTimeEntry>(`/api/staff/time/${id}`, { method: 'GET' })
}
@@ -50,5 +64,5 @@ export function useStaffTime() {
return await $api(`/api/staff/time/${id}`, { method: 'PUT', body: data })
}
return { list, start, stop, get, create, update }
return { list, start, stop,submit,approve, get, create, update }
}

View File

@@ -2,7 +2,7 @@
import { useStaffTime } from '~/composables/useStaffTime'
import { useAuthStore } from '~/stores/auth'
const { list, start, stop } = useStaffTime()
const { list, start, stop, submit,approve } = useStaffTime()
const auth = useAuthStore()
const router = useRouter()
@@ -51,6 +51,16 @@ function handleEdit(entry: any) {
showModal.value = true
}
async function handleSubmit(entry: any) {
await submit(entry.id)
await load()
}
async function handleApprove(entry: any) {
await approve(entry.id)
await load()
}
onMounted(async () => {
await loadUsers()
await load()
@@ -115,14 +125,19 @@ onMounted(async () => {
/>
<!-- 🔹 Button zur Auswertung -->
<UButton
v-if="selectedUser"
color="gray"
icon="i-heroicons-chart-bar"
label="Auswertung"
variant="soft"
@click="router.push(`/staff/time/${selectedUser}/evaluate`)"
/>
<UTooltip
:text="selectedUser ? 'Anwesenheiten des Mitarbeiters auswerten' : 'Mitarbeiter für die Auswertung auswählen'"
>
<UButton
:disabled="!selectedUser"
color="gray"
icon="i-heroicons-chart-bar"
label="Auswertung"
variant="soft"
@click="router.push(`/staff/time/${selectedUser}/evaluate`)"
/>
</UTooltip>
</div>
</template>
</UDashboardToolbar>
@@ -131,15 +146,15 @@ onMounted(async () => {
<UDashboardPanelContent>
<UTable
:rows="entries"
@select="(row) => handleEdit(row)"
:columns="[
{ key: 'actions', label: '' },
{ key: 'state', label: 'Status' },
{ key: 'started_at', label: 'Start' },
{ key: 'stopped_at', label: 'Ende' },
{ key: 'duration_minutes', label: 'Dauer' },
{ key: 'description', label: 'Beschreibung' },
...(canViewAll ? [{ key: 'user_name', label: 'Benutzer' }] : []),
{ key: 'actions', label: '' },
]"
>
<template #state-data="{row}">
@@ -163,7 +178,40 @@ onMounted(async () => {
{{ row.user_id ? users.find(i => i.user_id === row.user_id).full_name : '-' }}
</template>
<template #actions-data="{ row }">
<UButton variant="ghost" icon="i-heroicons-pencil-square" @click="handleEdit(row)" />
<UTooltip
text="Zeit genehmigen"
v-if="row.state === 'submitted'"
>
<UButton
variant="ghost"
icon="i-heroicons-check-circle"
@click="handleApprove(row)"
/>
</UTooltip>
<UTooltip
text="Zeit einreichen"
v-if="row.state === 'draft'"
>
<UButton
variant="ghost"
icon="i-heroicons-arrow-right-end-on-rectangle"
@click="handleSubmit(row)"
/>
</UTooltip>
<UTooltip
text="Zeit bearbeiten"
v-if="row.state === 'draft'"
>
<UButton
variant="ghost"
icon="i-heroicons-pencil-square"
@click="handleEdit(row)"
/>
</UTooltip>
</template>
</UTable>
</UDashboardPanelContent>