Restructuring

This commit is contained in:
2025-01-29 18:11:39 +01:00
parent 335a01d448
commit 5098332d20

View File

@@ -10,24 +10,9 @@ 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,
@@ -56,19 +41,16 @@ const itemInfo = ref({
const currentDocument = ref(null)
const loading = ref(true)
const setupPage = async () => {
if((mode.value === "show" || mode.value === "edit" ) && route.params.id){
itemInfo.value = await useSupabaseSelectSingle("incominginvoices",route.params.id,"*, files(*)")
if((mode.value === "show") && route.params.id){
itemInfo.value = await useSupabaseSelectSingle("incominginvoices",route.params.id,"*, files(*), vendor(*)")
currentDocument.value = await useFiles().selectDocument(itemInfo.value.files[0].id)
}
console.log(itemInfo.value)
loading.value = false
}
const setState = async (newState) => {
if(mode.value === 'show') {
await dataStore.updateItem('incominginvoices',{...itemInfo.value, state: newState})
@@ -95,7 +77,7 @@ setupPage()
</UButton>
</template>
</UDashboardNavbar>
<UDashboardPanelContent>
<UDashboardPanelContent v-if="!loading">
<div
class="flex justify-between mt-5"
@@ -111,7 +93,7 @@ setupPage()
<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 v-if="itemInfo.vendor">Lieferant: <nuxt-link :to="`/standardEntity/vendors/show/${itemInfo.vendor}`">{{itemInfo.vendor.name}}</nuxt-link></p>
<p>Bezahlt: {{itemInfo.paid ? "Ja" : "Nein"}}</p>
<p>Beschreibung: {{itemInfo.description}}</p>
@@ -130,6 +112,7 @@ setupPage()
</div>
</div>
</UDashboardPanelContent>
<UProgress class="mt-3 mx-3" v-else animation="carousel"/>