Rebuild Document Copy Process
This commit is contained in:
106
components/copyCreatedDocumentModal.vue
Normal file
106
components/copyCreatedDocumentModal.vue
Normal file
@@ -0,0 +1,106 @@
|
||||
<script setup>
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const modal = useModal()
|
||||
const router = useRouter()
|
||||
const props = defineProps({
|
||||
id: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
|
||||
const emit = defineEmits(["updateNeeded","returnData"])
|
||||
|
||||
const documentTypeToUse = ref("invoices")
|
||||
const optionsToImport = ref({
|
||||
taxType: true,
|
||||
customer: true,
|
||||
letterhead: true,
|
||||
contact: true,
|
||||
deliveryDateType: true,
|
||||
deliveryDate: true,
|
||||
deliveryDateEnd: true,
|
||||
documentDate: false,
|
||||
paymentDays: true,
|
||||
customSurchargePercentage: true,
|
||||
contactPerson: true,
|
||||
plant: true,
|
||||
project:true,
|
||||
title: true,
|
||||
description: true,
|
||||
startText: true,
|
||||
rows: true,
|
||||
endText: true,
|
||||
})
|
||||
|
||||
const mappings = ref({
|
||||
customer: "Kunde",
|
||||
taxType: "Steuertyp",
|
||||
letterhead: "Briefpapier",
|
||||
contact: "Ansprechpartner",
|
||||
deliveryDateType: "Lieferdatumsart",
|
||||
deliveryDate: "Lieferdatum / Lieferzeitraum Start",
|
||||
deliveryDateEnd: "Lieferzeitraum Ende",
|
||||
documentDate: "Belegdatum",
|
||||
paymentDays: "Zahlungsziel in Tagen",
|
||||
customSurchargePercentage: "Individueller Aufschlag",
|
||||
contactPerson: "Ansprechpartner Mitarbeiter",
|
||||
plant: "Objekt",
|
||||
project: "Projekt",
|
||||
title: "Titel",
|
||||
description: "Beschreibung",
|
||||
startText: "Einleitung",
|
||||
rows: "Positionen",
|
||||
endText: "Nachbemerkung",
|
||||
})
|
||||
|
||||
const startImport = () => {
|
||||
router.push(`/createDocument/edit/?linkedDocument=${props.id}&type=${documentTypeToUse.value}&optionsToImport=${encodeURIComponent(JSON.stringify(optionsToImport.value))}`)
|
||||
modal.close()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UModal :fullscreen="false">
|
||||
<UCard>
|
||||
<template #header>
|
||||
Erstelltes Dokument Kopieren
|
||||
</template>
|
||||
|
||||
<UFormGroup
|
||||
label="Dokumententyp:"
|
||||
class="mb-3"
|
||||
>
|
||||
<USelectMenu
|
||||
:options="Object.keys(dataStore.documentTypesForCreation).map(key => { return { ...dataStore.documentTypesForCreation[key], key}})"
|
||||
value-attribute="key"
|
||||
option-attribute="labelSingle"
|
||||
v-model="documentTypeToUse"
|
||||
>
|
||||
|
||||
</USelectMenu>
|
||||
</UFormGroup>
|
||||
<UCheckbox
|
||||
v-for="key in Object.keys(optionsToImport)"
|
||||
v-model="optionsToImport[key]"
|
||||
:label="mappings[key]"/>
|
||||
|
||||
|
||||
<template #footer>
|
||||
<UButton
|
||||
@click="startImport"
|
||||
>
|
||||
Kopieren
|
||||
</UButton>
|
||||
</template>
|
||||
|
||||
</UCard>
|
||||
</UModal>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -198,19 +198,60 @@ const setupPage = async () => {
|
||||
|
||||
if(route.query.linkedDocument) {
|
||||
itemInfo.value.linkedDocument = route.query.linkedDocument
|
||||
|
||||
let linkedDocument = await useSupabaseSelectSingle("createddocuments",itemInfo.value.linkedDocument)
|
||||
|
||||
itemInfo.value.rows = linkedDocument.rows
|
||||
itemInfo.value.customer = linkedDocument.customer
|
||||
itemInfo.value.project = linkedDocument.project
|
||||
itemInfo.value.contact = linkedDocument.contact
|
||||
itemInfo.value.description = linkedDocument.description
|
||||
itemInfo.value.deliveryDate = linkedDocument.deliveryDate
|
||||
itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType
|
||||
|
||||
if(route.query.optionsToImport) {
|
||||
//Import only true
|
||||
let optionsToImport = JSON.parse(route.query.optionsToImport)
|
||||
|
||||
console.log(optionsToImport)
|
||||
console.log(linkedDocument)
|
||||
|
||||
if(optionsToImport.taxType) itemInfo.value.taxType = linkedDocument.taxType
|
||||
if(optionsToImport.customer) itemInfo.value.customer = linkedDocument.customer
|
||||
if(optionsToImport.letterhead) itemInfo.value.letterhead = linkedDocument.letterhead
|
||||
if(optionsToImport.contact) itemInfo.value.contact = linkedDocument.contact
|
||||
if(optionsToImport.deliveryDateType) itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType
|
||||
if(optionsToImport.deliveryDate) itemInfo.value.deliveryDate = linkedDocument.deliveryDate
|
||||
if(optionsToImport.deliveryDateEnd) itemInfo.value.deliveryDateEnd = linkedDocument.deliveryDateEnd
|
||||
if(optionsToImport.documentDate) itemInfo.value.documentDate = linkedDocument.documentDate
|
||||
if(optionsToImport.paymentDays) itemInfo.value.paymentDays = linkedDocument.paymentDays
|
||||
if(optionsToImport.customSurchargePercentage) itemInfo.value.customSurchargePercentage = linkedDocument.customSurchargePercentage
|
||||
if(optionsToImport.contactPerson) itemInfo.value.contactPerson = linkedDocument.contactPerson
|
||||
if(optionsToImport.plant) itemInfo.value.plant = linkedDocument.plant
|
||||
if(optionsToImport.project) itemInfo.value.project = linkedDocument.project
|
||||
if(optionsToImport.title) itemInfo.value.title = linkedDocument.title
|
||||
if(optionsToImport.description) itemInfo.value.description = linkedDocument.description
|
||||
if(optionsToImport.startText) itemInfo.value.startText = linkedDocument.startText
|
||||
if(optionsToImport.rows) itemInfo.value.rows = linkedDocument.rows
|
||||
if(optionsToImport.endText) itemInfo.value.endText = linkedDocument.endText
|
||||
|
||||
} else {
|
||||
// Import all
|
||||
|
||||
itemInfo.value.taxType = linkedDocument.taxType
|
||||
itemInfo.value.customer = linkedDocument.customer
|
||||
itemInfo.value.letterhead = linkedDocument.letterhead
|
||||
itemInfo.value.contact = linkedDocument.contact
|
||||
itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType
|
||||
itemInfo.value.deliveryDate = linkedDocument.deliveryDate
|
||||
itemInfo.value.deliveryDateEnd = linkedDocument.deliveryDateEnd
|
||||
itemInfo.value.documentDate = linkedDocument.documentDate
|
||||
itemInfo.value.paymentDays = linkedDocument.paymentDays
|
||||
itemInfo.value.customSurchargePercentage = linkedDocument.customSurchargePercentage
|
||||
itemInfo.value.contactPerson = linkedDocument.contactPerson
|
||||
itemInfo.value.plant = linkedDocument.plant
|
||||
itemInfo.value.project = linkedDocument.project
|
||||
itemInfo.value.title = linkedDocument.title
|
||||
itemInfo.value.description = linkedDocument.description
|
||||
itemInfo.value.startText = linkedDocument.startText
|
||||
itemInfo.value.rows = linkedDocument.rows
|
||||
itemInfo.value.endText = linkedDocument.endText
|
||||
}
|
||||
|
||||
|
||||
setCustomerData()
|
||||
setCustomerData(null,true)
|
||||
|
||||
if(route.query.loadMode === "storno") {
|
||||
itemInfo.value.rows.forEach(row => {
|
||||
@@ -323,7 +364,7 @@ const setTaxType = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const setCustomerData = async (customerId) => {
|
||||
const setCustomerData = async (customerId, loadOnlyAdress = false) => {
|
||||
|
||||
if(customerId){
|
||||
itemInfo.value.customer = customerId
|
||||
@@ -341,11 +382,11 @@ const setCustomerData = async (customerId) => {
|
||||
itemInfo.value.address.city = customer.infoData.city
|
||||
itemInfo.value.address.special = customer.infoData.special
|
||||
|
||||
if(customer.customPaymentDays) itemInfo.value.paymentDays = customer.customPaymentDays
|
||||
if(!loadOnlyAdress && customer.customPaymentDays) itemInfo.value.paymentDays = customer.customPaymentDays
|
||||
|
||||
if(customer.customSurchargePercentage) itemInfo.value.customSurchargePercentage = customer.customSurchargePercentage
|
||||
if(!loadOnlyAdress && customer.customSurchargePercentage) itemInfo.value.customSurchargePercentage = customer.customSurchargePercentage
|
||||
|
||||
if(contacts.value.filter(i => i.customer === itemInfo.value.customer).length === 1) {
|
||||
if(!loadOnlyAdress && contacts.value.filter(i => i.customer === itemInfo.value.customer).length === 1) {
|
||||
itemInfo.value.contact = contacts.value.filter(i => i.customer === itemInfo.value.customer)[0].id
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script setup>
|
||||
import CopyCreatedDocumentModal from "~/components/copyCreatedDocumentModal.vue";
|
||||
|
||||
definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
@@ -10,7 +12,7 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const modal = useModal()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const route = useRoute()
|
||||
@@ -68,7 +70,16 @@ const openEmail = () => {
|
||||
: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>-->
|
||||
<UTooltip
|
||||
<UButton
|
||||
icon="i-heroicons-arrow-right-end-on-rectangle"
|
||||
@click="modal.open(CopyCreatedDocumentModal, {
|
||||
id: itemInfo.id,
|
||||
})"
|
||||
variant="outline"
|
||||
>
|
||||
Kopieren
|
||||
</UButton>
|
||||
<!-- <UTooltip
|
||||
text="Kopieren in Angebot"
|
||||
>
|
||||
<UButton
|
||||
@@ -122,7 +133,7 @@ const openEmail = () => {
|
||||
>
|
||||
Rechnung
|
||||
</UButton>
|
||||
</UTooltip>
|
||||
</UTooltip>-->
|
||||
<UButton
|
||||
@click="openEmail"
|
||||
icon="i-heroicons-envelope"
|
||||
|
||||
Reference in New Issue
Block a user