Added Preparing
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
import dayjs from "dayjs"
|
||||
import {useSum} from "~/composables/useSum.js";
|
||||
|
||||
// Zugriff auf API und Toast
|
||||
const { $api } = useNuxtApp()
|
||||
const toast = useToast()
|
||||
|
||||
defineShortcuts({
|
||||
'/': () => {
|
||||
@@ -47,6 +50,9 @@ const sort = ref({
|
||||
direction: 'desc'
|
||||
})
|
||||
|
||||
// Status für den Button
|
||||
const isPreparing = ref(false)
|
||||
|
||||
const type = "incominginvoices"
|
||||
const dataType = dataStore.dataTypes[type]
|
||||
|
||||
@@ -54,6 +60,34 @@ const setupPage = async () => {
|
||||
items.value = await useEntities(type).select("*, vendor(id,name), statementallocations(id,amount)",sort.value.column,sort.value.direction === "asc")
|
||||
}
|
||||
|
||||
// Funktion zum Vorbereiten der Belege
|
||||
const prepareInvoices = async () => {
|
||||
isPreparing.value = true
|
||||
try {
|
||||
await $api('/api/functions/services/prepareincominginvoices', { method: 'POST' })
|
||||
|
||||
toast.add({
|
||||
title: 'Erfolg',
|
||||
description: 'Eingangsbelege wurden vorbereitet.',
|
||||
icon: 'i-heroicons-check-circle',
|
||||
color: 'green'
|
||||
})
|
||||
|
||||
// Liste neu laden
|
||||
await setupPage()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
toast.add({
|
||||
title: 'Fehler',
|
||||
description: 'Beim Vorbereiten der Belege ist ein Fehler aufgetreten.',
|
||||
icon: 'i-heroicons-exclamation-circle',
|
||||
color: 'red'
|
||||
})
|
||||
} finally {
|
||||
isPreparing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
setupPage()
|
||||
|
||||
const selectedColumns = ref(tempStore.columns[type] ? tempStore.columns[type] : dataType.templateColumns.filter(i => !i.disabledInTable))
|
||||
@@ -128,6 +162,17 @@ const selectIncomingInvoice = (invoice) => {
|
||||
<template>
|
||||
<UDashboardNavbar title="Eingangsbelege" :badge="filteredRows.length">
|
||||
<template #right>
|
||||
|
||||
<UButton
|
||||
label="Belege vorbereiten"
|
||||
icon="i-heroicons-sparkles"
|
||||
color="primary"
|
||||
variant="solid"
|
||||
:loading="isPreparing"
|
||||
@click="prepareInvoices"
|
||||
class="mr-2"
|
||||
/>
|
||||
|
||||
<UInput
|
||||
id="searchinput"
|
||||
v-model="searchString"
|
||||
@@ -150,7 +195,6 @@ const selectIncomingInvoice = (invoice) => {
|
||||
v-if="searchString.length > 0"
|
||||
/>
|
||||
|
||||
<!-- <UButton @click="router.push(`/incomingInvoices/create`)">+ Beleg</UButton>-->
|
||||
</template>
|
||||
</UDashboardNavbar>
|
||||
<UDashboardToolbar>
|
||||
@@ -193,8 +237,8 @@ const selectIncomingInvoice = (invoice) => {
|
||||
<template #default="{item}">
|
||||
{{item.label}}
|
||||
<UBadge
|
||||
variant="outline"
|
||||
class="ml-2"
|
||||
variant="outline"
|
||||
class="ml-2"
|
||||
>
|
||||
{{filteredRows.filter(i => item.label === 'Gebucht' ? i.state === 'Gebucht' : i.state !== 'Gebucht' ).length}}
|
||||
</UBadge>
|
||||
|
||||
Reference in New Issue
Block a user