Many Changes
This commit is contained in:
@@ -3,7 +3,9 @@ import dayjs from "dayjs"
|
||||
const dataStore = useDataStore()
|
||||
const user = useSupabaseUser()
|
||||
const route = useRoute()
|
||||
|
||||
const router = useRouter()
|
||||
const supabase = useSupabaseClient()
|
||||
import {decode} from 'base64-arraybuffer'
|
||||
|
||||
|
||||
|
||||
@@ -35,10 +37,8 @@ const itemInfo = ref({
|
||||
createdBy: user.value.id,
|
||||
title: null,
|
||||
description: null,
|
||||
startText: "Sehr geehrte Frau Sindern,\n" +
|
||||
"wir bedanken uns für Ihr entgegengebrachtes Vertrauen und Ihren Auftrag und stellen Ihnen\n" +
|
||||
"folgende Positionen in Rechnung: ",
|
||||
endText: "Bitte überweisen Sie den Rechnungsbetrag unter Angabe der Rechnungsnummer im Verwendungszweck innerhalb von 10 Tagen auf das unten angegebene Konto. Wir bedanken uns für das entgegengebrachte Vertrauen und freuen uns auf eine weitere gute Zusammenarbeit.",
|
||||
startText: null,
|
||||
endText: null,
|
||||
rows: [
|
||||
|
||||
]
|
||||
@@ -257,19 +257,58 @@ const saveDocument = async () => {
|
||||
rows: itemInfo.value.rows
|
||||
}
|
||||
|
||||
let data = null
|
||||
|
||||
if(route.params.id) {
|
||||
await dataStore.updateItem("createdDocuments", {...createData, id: itemInfo.value.id})
|
||||
data = await dataStore.updateItem("createddocuments", {...createData, id: itemInfo.value.id})
|
||||
} else {
|
||||
await dataStore.createNewItem("createdDocuments", createData)
|
||||
data = await dataStore.createNewItem("createddocuments", createData)
|
||||
}
|
||||
|
||||
await router.push(`/createDocument/edit/${data[0].id}`)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
const closeDocument = () => {
|
||||
generateDocument()
|
||||
console.log(uri)
|
||||
const closeDocument = async () => {
|
||||
|
||||
await saveDocument()
|
||||
|
||||
await generateDocument()
|
||||
|
||||
|
||||
let fileData = {
|
||||
tags: [],
|
||||
project: null
|
||||
}
|
||||
|
||||
fileData.project = itemInfo.value.project
|
||||
fileData.createdDocument = itemInfo.value.id
|
||||
fileData.tags.push(dataStore.documentTypesForCreation[itemInfo.value.type].labelSingle)
|
||||
|
||||
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 dataStore.uploadFiles(fileData, [file], true)
|
||||
|
||||
|
||||
//console.log(uri)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,55 +38,12 @@ const filteredDocuments = computed(() => {
|
||||
})
|
||||
|
||||
const uploadFiles = async () => {
|
||||
const uploadSingleFile = async (file) => {
|
||||
uploadInProgress.value = true;
|
||||
|
||||
const {data, error} = await supabase
|
||||
.storage
|
||||
.from("files")
|
||||
.upload(`${user.value.app_metadata.tenant}/${file.name}`, file)
|
||||
|
||||
if (error) {
|
||||
console.log(error)
|
||||
} else if (data) {
|
||||
const returnPath = data.path
|
||||
|
||||
if (error) {
|
||||
|
||||
} else {
|
||||
const files = (await supabase.storage.from('files').list(`${user.value.app_metadata.tenant}/`, {
|
||||
limit: 100,
|
||||
offset: 0,
|
||||
sortBy: {column: 'name', order: 'asc'}
|
||||
})).data
|
||||
|
||||
fileUploadFormData.value.path = returnPath
|
||||
|
||||
const {data, error} = await supabase
|
||||
.from("documents")
|
||||
.insert([fileUploadFormData.value])
|
||||
.select()
|
||||
if(error) console.log(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uploadInProgress.value = true
|
||||
|
||||
let files = document.getElementById("fileUploadInput").files
|
||||
|
||||
if(files.length === 1) {
|
||||
await uploadSingleFile(files[0])
|
||||
} else if( files.length > 1) {
|
||||
|
||||
for(let i = 0; i < files.length; i++){
|
||||
uploadSingleFile(files[i])
|
||||
}
|
||||
|
||||
}
|
||||
await dataStore.uploadFiles(fileUploadFormData.value, document.getElementById("fileUploadInput").files)
|
||||
|
||||
uploadModalOpen.value = false;
|
||||
uploadInProgress.value = false;
|
||||
dataStore.fetchDocuments()
|
||||
}
|
||||
|
||||
const downloadSelected = async () => {
|
||||
@@ -152,7 +109,7 @@ const downloadSelected = async () => {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="flex items-center gap-2">
|
||||
<InputGroup>
|
||||
<UButton @click="uploadModalOpen = true">Hochladen</UButton>
|
||||
<UButton
|
||||
@click="downloadSelected"
|
||||
@@ -170,7 +127,7 @@ const downloadSelected = async () => {
|
||||
</USelectMenu>
|
||||
|
||||
|
||||
</div>
|
||||
</InputGroup>
|
||||
<div >
|
||||
<USlideover
|
||||
v-model="uploadModalOpen"
|
||||
@@ -219,13 +176,9 @@ const downloadSelected = async () => {
|
||||
</template>
|
||||
</UCard>
|
||||
</USlideover>
|
||||
<div class="documentList" >
|
||||
<DocumentDisplay
|
||||
:document="i"
|
||||
:key="i.id"
|
||||
v-for="i in filteredDocuments"
|
||||
/>
|
||||
</div>
|
||||
<DocumentList
|
||||
:documents="filteredDocuments"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -7,7 +7,18 @@ definePageMeta({
|
||||
const supabase = useSupabaseClient()
|
||||
const user = useSupabaseUser()
|
||||
const router = useRouter()
|
||||
const {fetchData} = useDataStore()
|
||||
const colorMode = useColorMode()
|
||||
const dataStore = useDataStore()
|
||||
|
||||
const isLight = computed({
|
||||
get () {
|
||||
return colorMode.value !== 'dark'
|
||||
},
|
||||
set () {
|
||||
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const email = ref("")
|
||||
const password = ref("")
|
||||
@@ -36,7 +47,7 @@ const onSubmit = async (data) => {
|
||||
alert(error.toString())
|
||||
} else {
|
||||
console.log("Login Successful")
|
||||
fetchData()
|
||||
dataStore.changeTenant()
|
||||
router.push("/")
|
||||
|
||||
|
||||
@@ -74,11 +85,16 @@ const onSubmit = async (data) => {
|
||||
|
||||
</div>-->
|
||||
<UCard class="max-w-sm w-full mx-auto mt-5">
|
||||
<img
|
||||
:src="!isLight ? '/spaces.svg' : '/spaces_hell.svg'"
|
||||
alt="Logo"
|
||||
class="w-full mx-auto"
|
||||
/>
|
||||
|
||||
<UAuthForm
|
||||
title="Login"
|
||||
description="Geben Sie Ihre Anmeldedaten ein um Zugriff auf Ihren Account zu bekommen"
|
||||
align="bottom"
|
||||
icon="i-heroicons-user-circle"
|
||||
:fields="fields"
|
||||
:loading="false"
|
||||
@submit="onSubmit"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<script setup>
|
||||
import HistoryDisplay from "~/components/HistoryDisplay.vue";
|
||||
import DocumentList from "~/components/DocumentList.vue";
|
||||
import DocumentUpload from "~/components/DocumentUpload.vue";
|
||||
|
||||
definePageMeta({
|
||||
middleware: "auth"
|
||||
@@ -17,7 +19,7 @@ const editor = useEditor({
|
||||
extensions: [TiptapStarterKit],
|
||||
});
|
||||
|
||||
let currentItem = null
|
||||
let currentItem = ref(null)
|
||||
|
||||
//Working
|
||||
const mode = ref(route.params.mode || "show")
|
||||
@@ -30,6 +32,8 @@ const tabItems = [
|
||||
label: "Projekte"
|
||||
},{
|
||||
label: "Aufgaben"
|
||||
},{
|
||||
label: "Dokumente"
|
||||
},{
|
||||
label: "Dokumentation"
|
||||
}
|
||||
@@ -38,10 +42,10 @@ const tabItems = [
|
||||
//Functions
|
||||
const setupPage = () => {
|
||||
if(mode.value === "show" || mode.value === "edit"){
|
||||
currentItem = dataStore.getPlantById(Number(useRoute().params.id))
|
||||
currentItem.value = dataStore.getPlantById(Number(useRoute().params.id))
|
||||
}
|
||||
|
||||
if(mode.value === "edit") itemInfo.value = currentItem
|
||||
if(mode.value === "edit") itemInfo.value = currentItem.value
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +54,7 @@ const setupPage = () => {
|
||||
|
||||
|
||||
const editItem = async () => {
|
||||
router.push(`/plants/edit/${currentItem.id}`)
|
||||
await router.push(`/plants/edit/${currentItem.value.id}`)
|
||||
setupPage()
|
||||
}
|
||||
|
||||
@@ -100,6 +104,78 @@ setupPage()
|
||||
|
||||
</UTable>
|
||||
</div>
|
||||
<div v-else-if="item.label === 'Dokumente'" class="space-y-3">
|
||||
<InputGroup>
|
||||
<DocumentUpload
|
||||
type="plant"
|
||||
:element-id="currentItem.id"
|
||||
/>
|
||||
</InputGroup>
|
||||
|
||||
<!-- <UModal
|
||||
v-model="uploadModalOpen"
|
||||
>
|
||||
<UCard class="p-4">
|
||||
|
||||
<template #header>
|
||||
Datei hochladen
|
||||
</template>
|
||||
|
||||
<UFormGroup
|
||||
label="Datei:"
|
||||
>
|
||||
<UInput
|
||||
type="file"
|
||||
id="fileUploadInput"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<!– <UFormGroup
|
||||
label="Name:"
|
||||
class="mt-3"
|
||||
>
|
||||
<UInput
|
||||
v-model="fileUploadFormData.name"
|
||||
/>
|
||||
</UFormGroup>–>
|
||||
<UFormGroup
|
||||
label="Tags:"
|
||||
class="mt-3"
|
||||
>
|
||||
<USelectMenu
|
||||
multiple
|
||||
searchable
|
||||
searchable-placeholder="Suchen..."
|
||||
:options="tags"
|
||||
v-model="fileUploadFormData.tags"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<!–<UFormGroup
|
||||
label="Ordner:"
|
||||
class="mt-3"
|
||||
>
|
||||
<USelectMenu
|
||||
:options="folders"
|
||||
v-model="fileUploadFormData.folder"
|
||||
value-attribute="label"
|
||||
|
||||
/>
|
||||
</UFormGroup>–>
|
||||
|
||||
<template #footer>
|
||||
<UButton
|
||||
class="mt-3"
|
||||
@click="uploadFiles"
|
||||
>Hochladen</UButton>
|
||||
</template>
|
||||
|
||||
|
||||
</UCard>
|
||||
|
||||
</UModal>-->
|
||||
|
||||
<DocumentList :documents="dataStore.getDocumentsByPlantId(currentItem.id)"/>
|
||||
|
||||
</div>
|
||||
<div v-if="item.label === 'Dokumentation'">
|
||||
|
||||
<Editor/>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<script setup>
|
||||
import dayjs from "dayjs";
|
||||
import HistoryDisplay from "~/components/HistoryDisplay.vue";
|
||||
import DocumentUpload from "~/components/DocumentUpload.vue";
|
||||
import DocumentList from "~/components/DocumentList.vue";
|
||||
|
||||
definePageMeta({
|
||||
middleware: "auth"
|
||||
@@ -94,10 +96,7 @@ const itemInfo = ref({
|
||||
const uploadModalOpen = ref(false)
|
||||
const fileUploadFormData = ref({
|
||||
tags: ["Dokument"],
|
||||
folder: "Projekte",
|
||||
usedInResource: {
|
||||
type: "Projekt",
|
||||
}
|
||||
project: null
|
||||
})
|
||||
const tags = dataStore.getDocumentTags
|
||||
|
||||
@@ -153,39 +152,13 @@ const updateItem = async () => {
|
||||
dataStore.fetchProjects()
|
||||
}
|
||||
|
||||
const uploadFile = async () => {
|
||||
const file = document.getElementById("fileUploadInput").files[0]
|
||||
const uploadFiles = async () => {
|
||||
//uploadInProgress.value = true;
|
||||
|
||||
const {data,error} = await supabase
|
||||
.storage
|
||||
.from("documents")
|
||||
.upload(`${user.value.app_metadata.tenant}/${fileUploadFormData.value.folder}/${currentProject.id}/${file.name}`,file)
|
||||
|
||||
console.log(data)
|
||||
const returnPath = data.path
|
||||
|
||||
if(error) {
|
||||
|
||||
} else {
|
||||
console.log(returnPath)
|
||||
const files = (await supabase.storage.from('documents').list(`${user.value.app_metadata.tenant}/${fileUploadFormData.value.folder}/${currentProject.id}/`, {limit: 100, offset: 0, sortBy: { column: 'name', order: 'asc' }})).data
|
||||
console.log(files)
|
||||
const fileId = files.find(temp => returnPath.includes(temp.name)).id
|
||||
|
||||
fileUploadFormData.value.object = fileId
|
||||
fileUploadFormData.value.path = returnPath
|
||||
fileUploadFormData.value.usedInResource.id = currentProject.id
|
||||
console.log(fileUploadFormData.value)
|
||||
|
||||
const {data,error} = await supabase
|
||||
.from("documents")
|
||||
.insert([fileUploadFormData.value])
|
||||
.select()
|
||||
console.log(data)
|
||||
console.log(error)
|
||||
}
|
||||
await dataStore.uploadFiles({...fileUploadFormData.value, project: currentItem.value.id}, document.getElementById("fileUploadInput").files)
|
||||
|
||||
uploadModalOpen.value = false;
|
||||
//uploadInProgress.value = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +168,7 @@ const projectHours = () => {
|
||||
hours += Number(dayjs(item.end).diff(item.start,'hour',true).toFixed(2))
|
||||
})
|
||||
|
||||
return hours
|
||||
return hours.toFixed(2)
|
||||
}
|
||||
|
||||
|
||||
@@ -256,6 +229,7 @@ setupPage()
|
||||
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div v-else-if="item.key === 'forms'" class="space-y-3">
|
||||
<UButton
|
||||
@click="formModalOpen = true"
|
||||
@@ -308,13 +282,13 @@ setupPage()
|
||||
</template>
|
||||
</UAccordion>
|
||||
</div>
|
||||
-->
|
||||
<div v-else-if="item.key === 'documents'" class="space-y-3">
|
||||
<InputGroup>
|
||||
<UButton
|
||||
@click="uploadModalOpen = true"
|
||||
>
|
||||
Hochladen
|
||||
</UButton>
|
||||
<DocumentUpload
|
||||
type="project"
|
||||
:element-id="currentItem.id"
|
||||
/>
|
||||
<UButton
|
||||
@click="router.push(`/createDocument/edit?project=${currentItem.id}&type=quotes&customer=${currentItem.customer}`)"
|
||||
>
|
||||
@@ -327,7 +301,7 @@ setupPage()
|
||||
</UButton>
|
||||
</InputGroup>
|
||||
|
||||
<UModal
|
||||
<!-- <UModal
|
||||
v-model="uploadModalOpen"
|
||||
>
|
||||
<UCard class="p-4">
|
||||
@@ -344,14 +318,14 @@ setupPage()
|
||||
id="fileUploadInput"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<!-- <UFormGroup
|
||||
<!– <UFormGroup
|
||||
label="Name:"
|
||||
class="mt-3"
|
||||
>
|
||||
<UInput
|
||||
v-model="fileUploadFormData.name"
|
||||
/>
|
||||
</UFormGroup>-->
|
||||
</UFormGroup>–>
|
||||
<UFormGroup
|
||||
label="Tags:"
|
||||
class="mt-3"
|
||||
@@ -364,7 +338,7 @@ setupPage()
|
||||
v-model="fileUploadFormData.tags"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<!--<UFormGroup
|
||||
<!–<UFormGroup
|
||||
label="Ordner:"
|
||||
class="mt-3"
|
||||
>
|
||||
@@ -374,27 +348,22 @@ setupPage()
|
||||
value-attribute="label"
|
||||
|
||||
/>
|
||||
</UFormGroup>-->
|
||||
</UFormGroup>–>
|
||||
|
||||
<template #footer>
|
||||
<UButton
|
||||
class="mt-3"
|
||||
@click="uploadFile"
|
||||
@click="uploadFiles"
|
||||
>Hochladen</UButton>
|
||||
</template>
|
||||
|
||||
|
||||
</UCard>
|
||||
|
||||
</UModal>
|
||||
</UModal>-->
|
||||
|
||||
<DocumentList :documents="dataStore.getDocumentsByProjectId(currentItem.id)"/>
|
||||
|
||||
<div class="documentList">
|
||||
<DocumentDisplay
|
||||
v-for="document in dataStore.getDocumentsByProjectId(currentItem.id)"
|
||||
:document="document"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="item.key === 'timetracking'" class="space-y-3">
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
<template>
|
||||
<div id="main">
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
<InputGroup>
|
||||
<UButton @click="router.push(`/incominginvoices/create/`)">+ Eingangsrechnung</UButton>
|
||||
<UButton
|
||||
@click="router.push(`/createDocument/edit?type=quotes`)"
|
||||
>
|
||||
+ Angebot
|
||||
</UButton>
|
||||
<UButton
|
||||
@click="router.push(`/createDocument/edit?type=invoices`)"
|
||||
>
|
||||
+ Rechnung
|
||||
</UButton>
|
||||
|
||||
<UInput
|
||||
v-model="searchString"
|
||||
@@ -13,7 +23,7 @@
|
||||
v-model="showDrafts"
|
||||
label="Entwürfe Anzeigen"
|
||||
/>
|
||||
</div>
|
||||
</InputGroup>
|
||||
|
||||
|
||||
|
||||
@@ -172,9 +182,9 @@ const searchString = ref('')
|
||||
const showDrafts = ref(false)
|
||||
|
||||
const filteredRows = computed(() => {
|
||||
let items = [...dataStore.incomingInvoices.map(i => {return {...i, type: "incomingInvoice"}}),...dataStore.createdDocuments]
|
||||
let items = [...dataStore.incomingInvoices.map(i => {return {...i, type: "incomingInvoice"}}),...dataStore.createddocuments]
|
||||
|
||||
console.log(dataStore.createdDocuments)
|
||||
console.log(dataStore.createddocuments)
|
||||
|
||||
if(showDrafts.value === true) {
|
||||
items = items.filter(i => i.state === "Entwurf")
|
||||
|
||||
@@ -19,11 +19,10 @@ let currentItem = ref(null)
|
||||
//Working
|
||||
const mode = ref(route.params.mode || "show")
|
||||
const itemInfo = ref({
|
||||
id: 0,
|
||||
name: "",
|
||||
licensePlate: "",
|
||||
type: "",
|
||||
driver: ""
|
||||
driver: null
|
||||
})
|
||||
|
||||
const tabItems = [{
|
||||
|
||||
Reference in New Issue
Block a user