Cahnges in Show Document

This commit is contained in:
2025-01-27 18:14:43 +01:00
parent eb1eacdad9
commit 7ea5da8d0f

View File

@@ -0,0 +1,164 @@
<script setup>
import dayjs from "dayjs";
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
const toast = useToast()
const availableDocuments = ref([])
const setup = async () => {
let filetype = (await supabase.from("filetags").select().eq("tenant",profileStore.currentTenant).eq("incomingDocumentType","invoices").single()).data.id
console.log(filetype)
let ids = (await supabase.from("files").select("id").eq("tenant",profileStore.currentTenant).eq("type", filetype)).data.map(i => i.id)
availableDocuments.value = await useFiles().selectSomeDocuments(ids)
}
setup()
//let currentDocument = ref(null)
//Working
const mode = ref(route.params.mode || "show")
const useNetMode = ref(false)
const itemInfo = ref({
vendor: 0,
expense: true,
reference: "",
date: null,
dueDate: null,
paymentType: "Überweisung",
description: "",
state: "Entwurf",
accounts: [
{
account: null,
amountNet: null,
amountTax: null,
taxType: "19",
costCentre: null
}
]
})
//Functions
const currentDocument = ref(null)
const setupPage = async () => {
if((mode.value === "show" || mode.value === "edit" ) && route.params.id){
itemInfo.value = await useSupabaseSelectSingle("incominginvoices",route.params.id,"*, files(*)")
currentDocument.value = await useFiles().selectDocument(itemInfo.value.files[0].id)
}
console.log(itemInfo.value)
}
const setState = async (newState) => {
if(mode.value === 'show') {
await dataStore.updateItem('incominginvoices',{...itemInfo.value, state: newState})
} else if(mode.value === 'edit') {
await dataStore.updateItem('incominginvoices',{...itemInfo.value, state: newState})
}
await router.push("/incomingInvoices")
}
setupPage()
</script>
<template>
<UDashboardNavbar :title="'Eingangsbeleg anzeigen'">
<template #right>
<UButton
@click="setState('Gebucht')"
v-if="itemInfo.state !== 'Gebucht'"
color="rose"
>
Status auf Gebucht
</UButton>
</template>
</UDashboardNavbar>
<UDashboardPanelContent>
<div
class="flex justify-between mt-5"
>
<object
v-if="currentDocument ? currentDocument.url : false"
:data="currentDocument.url + '#toolbar=0&navpanes=0&scrollbar=0&statusbar=0&messages=0&scrollbar=0'"
type="application/pdf"
class="mx-5 w-2/5 documentPreview"
/>
<div class="w-1/2 mx-5">
<UCard class="truncate mb-5">
<p>Status: {{itemInfo.state}}</p>
<p>Datum: {{dayjs(itemInfo.date).format('DD.MM.YYYY')}}</p>
<p>Fälligkeitsdatum: {{dayjs(itemInfo.dueDate).format('DD.MM.YYYY')}}</p>
<p v-if="itemInfo.vendor">Lieferant: <nuxt-link :to="`/standardEntity/vendors/show/${itemInfo.vendor}`">{{dataStore.getVendorById(itemInfo.vendor).name}}</nuxt-link></p>
<p>Bezahlt: {{itemInfo.paid ? "Ja" : "Nein"}}</p>
<p>Beschreibung: {{itemInfo.description}}</p>
<!-- TODO: Buchungszeilen darstellen -->
</UCard>
<UCard class="scrollContainer">
<HistoryDisplay
type="incomingInvoice"
v-if="itemInfo"
:element-id="itemInfo.id"
render-headline
/>
</UCard>
</div>
</div>
</UDashboardPanelContent>
</template>
<style scoped>
.documentPreview {
aspect-ratio: 1 / 1.414;
}
.scrollContainer {
overflow-y: scroll;
padding-left: 1em;
padding-right: 1em;
height: 75vh;
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
.scrollContainer::-webkit-scrollbar {
display: none;
}
.lineItemRow {
display: flex;
flex-direction: row;
}
</style>