93 lines
2.3 KiB
Vue
93 lines
2.3 KiB
Vue
<script setup>
|
|
definePageMeta({
|
|
middleware: "auth"
|
|
})
|
|
|
|
defineShortcuts({
|
|
'backspace': () => {
|
|
router.push("/createDocument")
|
|
},
|
|
})
|
|
|
|
const supabase = useSupabaseClient()
|
|
|
|
const dataStore = useDataStore()
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
|
|
const itemInfo = ref({})
|
|
const linkedDocument =ref({})
|
|
const currentTenant = ref({})
|
|
const setupPage = async () => {
|
|
if(route.params) {
|
|
if(route.params.id) itemInfo.value = await useSupabaseSelectSingle("createddocuments",route.params.id,"*")
|
|
const {data,error} = await supabase.from("documents").select("id").eq("createdDocument", route.params.id).order("id",{ascending:true})
|
|
linkedDocument.value = data[data.length -1]
|
|
|
|
}
|
|
|
|
currentTenant.value = (await supabase.from("tenants").select().eq("id",dataStore.currentTenant).single()).data
|
|
console.log(currentTenant.value)
|
|
|
|
}
|
|
|
|
setupPage()
|
|
|
|
const openEmail = () => {
|
|
if(["invoices","advanceInvoices"].includes(itemInfo.value.type)){
|
|
router.push(`/email/new?loadDocuments=[${linkedDocument.value.id}]&bcc=${encodeURIComponent(currentTenant.value.standardEmailForInvoices)}`)
|
|
} else {
|
|
router.push(`/email/new?loadDocuments=[${linkedDocument.value.id}]`)
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<UDashboardNavbar
|
|
title="Erstelltes Dokument anzeigen"
|
|
>
|
|
|
|
</UDashboardNavbar>
|
|
<UDashboardToolbar>
|
|
<template #left>
|
|
<UButton
|
|
@click="router.push(`/createDocument/edit/${itemInfo.id}`)"
|
|
>
|
|
Bearbeiten
|
|
</UButton>
|
|
<UButton
|
|
:to="dataStore.documents.find(i => i.createdDocument === itemInfo.id) ? dataStore.documents.find(i => i.createdDocument === itemInfo.id).url : ''"
|
|
target="_blank"
|
|
>In neuen Tab anzeigen</UButton>
|
|
<UButton
|
|
@click="router.push(`/createDocument/edit/?linkedDocument=${itemInfo.id}`)"
|
|
>
|
|
Übernehmen
|
|
</UButton>
|
|
<UButton
|
|
@click="openEmail"
|
|
icon="i-heroicons-envelope"
|
|
>
|
|
E-Mail
|
|
</UButton>
|
|
</template>
|
|
</UDashboardToolbar>
|
|
|
|
<object
|
|
:data="dataStore.documents.find(i => i.createdDocument === itemInfo.id) ? dataStore.documents.find(i => i.createdDocument === itemInfo.id).url : ''"
|
|
class="h-full"
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- <DocumentDisplay
|
|
:document-data="dataStore.documents.find(i => i.createdDocument === itemInfo.id)"
|
|
/>-->
|
|
|
|
</template>
|
|
|
|
<style scoped>
|
|
|
|
</style> |