Added Preparing
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
import dayjs from "dayjs"
|
import dayjs from "dayjs"
|
||||||
import {useSum} from "~/composables/useSum.js";
|
import {useSum} from "~/composables/useSum.js";
|
||||||
|
|
||||||
|
// Zugriff auf API und Toast
|
||||||
|
const { $api } = useNuxtApp()
|
||||||
|
const toast = useToast()
|
||||||
|
|
||||||
defineShortcuts({
|
defineShortcuts({
|
||||||
'/': () => {
|
'/': () => {
|
||||||
@@ -47,6 +50,9 @@ const sort = ref({
|
|||||||
direction: 'desc'
|
direction: 'desc'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Status für den Button
|
||||||
|
const isPreparing = ref(false)
|
||||||
|
|
||||||
const type = "incominginvoices"
|
const type = "incominginvoices"
|
||||||
const dataType = dataStore.dataTypes[type]
|
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")
|
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()
|
setupPage()
|
||||||
|
|
||||||
const selectedColumns = ref(tempStore.columns[type] ? tempStore.columns[type] : dataType.templateColumns.filter(i => !i.disabledInTable))
|
const selectedColumns = ref(tempStore.columns[type] ? tempStore.columns[type] : dataType.templateColumns.filter(i => !i.disabledInTable))
|
||||||
@@ -128,6 +162,17 @@ const selectIncomingInvoice = (invoice) => {
|
|||||||
<template>
|
<template>
|
||||||
<UDashboardNavbar title="Eingangsbelege" :badge="filteredRows.length">
|
<UDashboardNavbar title="Eingangsbelege" :badge="filteredRows.length">
|
||||||
<template #right>
|
<template #right>
|
||||||
|
|
||||||
|
<UButton
|
||||||
|
label="Belege vorbereiten"
|
||||||
|
icon="i-heroicons-sparkles"
|
||||||
|
color="primary"
|
||||||
|
variant="solid"
|
||||||
|
:loading="isPreparing"
|
||||||
|
@click="prepareInvoices"
|
||||||
|
class="mr-2"
|
||||||
|
/>
|
||||||
|
|
||||||
<UInput
|
<UInput
|
||||||
id="searchinput"
|
id="searchinput"
|
||||||
v-model="searchString"
|
v-model="searchString"
|
||||||
@@ -150,7 +195,6 @@ const selectIncomingInvoice = (invoice) => {
|
|||||||
v-if="searchString.length > 0"
|
v-if="searchString.length > 0"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- <UButton @click="router.push(`/incomingInvoices/create`)">+ Beleg</UButton>-->
|
|
||||||
</template>
|
</template>
|
||||||
</UDashboardNavbar>
|
</UDashboardNavbar>
|
||||||
<UDashboardToolbar>
|
<UDashboardToolbar>
|
||||||
|
|||||||
Reference in New Issue
Block a user