This commit is contained in:
2025-09-13 17:32:21 +02:00
parent e60c0df77b
commit 18b63272b7

View File

@@ -38,13 +38,13 @@ const itemInfo = ref({
dateOfPerformance: null,
paymentDays: auth.activeTenantData.standardPaymentDays,
customSurchargePercentage: 0,
createdBy: profileStore.activeProfile.id,
createdBy: auth.user.id,
title: null,
description: null,
startText: null,
endText: null,
rows: [],
contactPerson: profileStore.activeProfile.id,
contactPerson: auth.user.id,
contactPersonName: null,
contactTel: null,
contactEMail: null,
@@ -1370,49 +1370,59 @@ const saveDocument = async (state, resetup = false) => {
if (resetup) await setupPage()
}
const selectedTab = ref(0)
const closeDocument = async () => {
loaded.value = false
if(selectedTab.value === 0) {
await generateDocument()
selectedTab.value = 1
} else {
loaded.value = false
await saveDocument("Gebucht")
await saveDocument("Gebucht")
await generateDocument()
await generateDocument()
let fileData = {}
let fileData = {}
fileData.project = itemInfo.value.project
fileData.createddocument = itemInfo.value.id
fileData.project = itemInfo.value.project
fileData.createddocument = itemInfo.value.id
let mappedType = itemInfo.value.type
let mappedType = itemInfo.value.type
if (mappedType === "advanceInvoices" || mappedType === "cancellationInvoices") {
mappedType = "invoices"
}
const folders = await useEntities("folders").select()
console.log(folders)
fileData.folder = folders.find(i => i.function === mappedType && i.year === Number(dayjs().format("YYYY"))).id
const tags = await useEntities("filetags").select()
fileData.type = tags.find(i => i.createddocumenttype === mappedType).id
function dataURLtoFile(dataurl, filename) {
var arr = dataurl.split(","),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[arr.length - 1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
if (mappedType === "advanceInvoices" || mappedType === "cancellationInvoices") {
mappedType = "invoices"
}
return new File([u8arr], filename, {type: mime});
const folders = await useEntities("folders").select()
console.log(folders)
fileData.folder = folders.find(i => i.function === mappedType && i.year === Number(dayjs().format("YYYY"))).id
const tags = await useEntities("filetags").select()
fileData.type = tags.find(i => i.createddocumenttype === mappedType).id
function dataURLtoFile(dataurl, filename) {
var arr = dataurl.split(","),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[arr.length - 1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], filename, {type: mime});
}
let file = dataURLtoFile(uri.value, `${itemInfo.value.documentNumber}.pdf`)
await useFiles().uploadFiles(fileData, [file])
await router.push(`/createDocument/show/${itemInfo.value.id}`)
}
let file = dataURLtoFile(uri.value, `${itemInfo.value.documentNumber}.pdf`)
await useFiles().uploadFiles(fileData, [file])
await router.push(`/createDocument/show/${itemInfo.value.id}`)
}
@@ -1538,7 +1548,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
@click="closeDocument"
v-if="itemInfo.id && itemInfo.type !== 'serialInvoices'"
>
Fertigstellen
{{selectedTab === 0 ? "Vorschau zeigen" : "Fertigstellen"}}
</UButton>
<UButton
icon="i-mdi-content-save"
@@ -1550,7 +1560,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
</template>
</UDashboardNavbar>
<UDashboardPanelContent>
<UTabs class="p-5" :items="tabItems" @change="onChangeTab" v-if="loaded">
<UTabs class="p-5" :items="tabItems" @change="onChangeTab" v-if="loaded" v-model="selectedTab">
<template #item="{item}">
<div v-if="item.label === 'Editor'">