Changed STore Type and corrected all Pages

Added HistoryDisplay.vue
Added NumberRanges
This commit is contained in:
2023-12-27 21:52:55 +01:00
parent 9e092823e4
commit c41b99f29d
33 changed files with 1094 additions and 812 deletions

View File

@@ -31,18 +31,11 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const router = useRouter()
const {bankAccounts} = storeToRefs(useDataStore())
const mode = ref("show")
const itemColumns = [
{
key: "name",
label: "Name",
sortable: true
},
{
key: "iban",
label: "IBAN",
@@ -69,13 +62,13 @@ const selectItem = (item) => {
const searchString = ref('')
const filteredRows = computed(() => {
bankAccounts.value = bankAccounts.value.filter(account => account.used)
dataStore.bankAccounts = dataStore.bankAccounts.filter(account => account.used)
if(!searchString.value) {
return bankAccounts.value
return dataStore.bankAccounts
}
return bankAccounts.value.filter(item => {
return dataStore.bankAccounts.filter(item => {
return Object.values(item).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})

View File

@@ -4,21 +4,20 @@ import * as dayjs from "dayjs";
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const route = useRoute()
const supabase = useSupabaseClient()
const {bankStatements,bankAccounts} = storeToRefs(useDataStore())
const searchString = ref("")
const showAssigned = ref(false)
const selectedAccount = ref(0)
const filteredRows = computed(() => {
let statements = bankStatements.value
let statements = dataStore.bankStatements
if(!showAssigned.value) {
statements = statements.filter(statement => !(statement.customerInvoice || statement.vendorInvoice))
statements = statements.filter(statement => !statement.customerInvoice || !statement.vendorInvoice)
}
if(selectedAccount.value !== 0) {
@@ -26,17 +25,14 @@ const filteredRows = computed(() => {
}
if(searchString.value.length > 0) {
return statements.value.filter(item => {
statements = statements.filter(item => {
return Object.values(item).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})
})
} else {
return statements
}
return statements
})
@@ -91,19 +87,19 @@ const statementColumns = [
</USlideover>
<InputGroup gap="2">
<InputGroup :gap="2">
<UInput
v-model="searchString"
placeholder="Suche..."
/>
<USelectMenu
:options="bankAccounts.filter(account => account.used)"
:options="dataStore.bankAccounts.filter(account => account.used)"
v-model="selectedAccount"
option-attribute="iban"
value-attribute="id"
>
<template #label>
{{bankAccounts.find(account => account.id === selectedAccount) ? bankAccounts.find(account => account.id === selectedAccount).iban : "Kontoauswählen"}}
{{dataStore.bankAccounts.find(account => account.id === selectedAccount) ? dataStore.bankAccounts.find(account => account.id === selectedAccount).iban : "Kontoauswählen"}}
</template>
</USelectMenu>
<UCheckbox
@@ -113,7 +109,7 @@ const statementColumns = [
</InputGroup>
<UTable
:rows="bankStatements"
:rows="filteredRows"
:columns="statementColumns"
@select="selectStatement"
>

View File

@@ -11,9 +11,7 @@ const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
//Store
const {customers, vendors, contacts } = storeToRefs(useDataStore())
const {fetchContacts, getContactById} = useDataStore()
const dataStore = useDataStore()
let currentContact = null
@@ -27,7 +25,7 @@ const itemInfo = ref({
//Functions
const setupPage = () => {
if(mode.value === "show" || mode.value === "edit"){
currentContact = getContactById(Number(useRoute().params.id))
currentContact = dataStore.getContactById(Number(useRoute().params.id))
}
if(mode.value === "edit") itemInfo.value = currentContact
@@ -53,7 +51,7 @@ const createItem = async () => {
id: 0,
}
toast.add({title: "Kontakt erfolgreich erstellt"})
await fetchContacts()
await dataStore.fetchContacts()
router.push(`/contacts/show/${data[0].id}`)
setupPage()
}
@@ -84,7 +82,7 @@ const updateCustomer = async () => {
name: "",
}
toast.add({title: "Kontakt erfolgreich gespeichert"})
fetchContacts()
dataStore.fetchContacts()
}
@@ -125,8 +123,8 @@ setupPage()
</UButton>
</InputGroup>
<span v-if="currentContact.customer">Kunde: {{customers.find(customer => customer.id === currentContact.customer) ? customers.find(customer => customer.id === currentContact.customer).name : "" }}</span><br>
<span v-if="currentContact.vendor">Lieferant: {{vendors.find(vendor => vendor.id === currentContact.vendor) ? vendors.find(vendor => vendor.id === currentContact.vendor).name : ""}}</span><br>
<span v-if="currentContact.customer">Kunde: {{dataStore.customers.find(customer => customer.id === currentContact.customer) ? dataStore.customers.find(customer => customer.id === currentContact.customer).name : "" }}</span><br>
<span v-if="currentContact.vendor">Lieferant: {{dataStore.vendors.find(vendor => vendor.id === currentContact.vendor) ? dataStore.vendors.find(vendor => vendor.id === currentContact.vendor).name : ""}}</span><br>
<span>E-Mail: {{currentContact.email}}</span><br>
<span>Mobil: {{currentContact.phoneMobile}}</span><br>
@@ -201,7 +199,7 @@ setupPage()
:search-attributes="['name']"
>
<template #label>
{{customers.find(customer => customer.id === itemInfo.customer) ? customers.find(customer => customer.id === itemInfo.customer).name : "Kunde auswählen"}}
{{dataStore.customers.find(customer => customer.id === itemInfo.customer) ? dataStore.customers.find(customer => customer.id === itemInfo.customer).name : "Kunde auswählen"}}
</template>
</USelectMenu>
</UFormGroup>
@@ -217,7 +215,7 @@ setupPage()
:search-attributes="['name']"
>
<template #label>
{{vendors.find(vendor => vendor.id === itemInfo.vendor) ? vendors.find(vendor => vendor.id === itemInfo.vendor).name : "Lieferant auswählen"}}
{{dataStore.vendors.find(vendor => vendor.id === itemInfo.vendor) ? dataStore.vendors.find(vendor => vendor.id === itemInfo.vendor).name : "Lieferant auswählen"}}
</template>
</USelectMenu>
</UFormGroup>

View File

@@ -20,10 +20,10 @@
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
>
<template #customer-data="{row}">
{{customers.find(customer => customer.id === row.customer) ? customers.find(customer => customer.id === row.customer).name : ''}}
{{dataStore.customers.find(customer => customer.id === row.customer) ? dataStore.customers.find(customer => customer.id === row.customer).name : ''}}
</template>
<template #vendor-data="{row}">
{{vendors.find(vendor => vendor.id === row.vendor) ? vendors.find(vendor => vendor.id === row.vendor).name : ''}}
{{dataStore.vendors.find(vendor => vendor.id === row.vendor) ? dataStore.vendors.find(vendor => vendor.id === row.vendor).name : ''}}
</template>
</UTable>
@@ -36,9 +36,8 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const router = useRouter()
const {contacts,customers,vendors} = storeToRefs(useDataStore())
const mode = ref("show")
const itemColumns = [
@@ -74,10 +73,10 @@ const searchString = ref('')
const filteredRows = computed(() => {
if(!searchString.value) {
return contacts.value
return dataStore.contacts
}
return contacts.value.filter(item => {
return dataStore.contacts.filter(item => {
return Object.values(item).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})

View File

@@ -3,7 +3,7 @@ definePageMeta({
middleware: "auth"
})
//
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
@@ -12,7 +12,6 @@ const id = ref(route.params.id ? route.params.id : null )
//Store
const {customers, contracts } = storeToRefs(useDataStore())
const {fetchCustomers, getCustomerById, getContractById, fetchContracts} = useDataStore()
let currentContract = null
@@ -29,7 +28,7 @@ const itemInfo = ref({
//Functions
const setupPage = () => {
if(mode.value === "show" || mode.value === "edit"){
currentContract = getContractById(Number(useRoute().params.id))
currentContract = dataStore.getContractById(Number(useRoute().params.id))
}
if(mode.value === "edit") itemInfo.value = currentContract
@@ -53,7 +52,7 @@ const createItem = async () => {
name: ""
}
toast.add({title: "Vertrag erfolgreich erstellt"})
await fetchContracts()
await dataStore.fetchContracts()
router.push(`/contracts/show/${data[0].id}`)
setupPage()
}
@@ -84,7 +83,7 @@ const updateCustomer = async () => {
name: "",
}
toast.add({title: "Vertrag erfolgreich gespeichert"})
fetchContracts()
dataStore.fetchContracts()
}
@@ -110,7 +109,7 @@ setupPage()
{{currentContract.name}}
</template>
Kundennummer: {{currentContract.customer}} <br>
Kundennummer: {{dataStore.customers.find(customer => customer.id === currentContract.customer) ? dataStore.customers.find(customer => customer.id === currentContract.customer).name : ""}} <br>
<UDivider
class="my-2"
@@ -169,7 +168,7 @@ setupPage()
:search-attributes="['name']"
>
<template #label>
{{customers.find(customer => customer.id === itemInfo.customer) ? customers.find(customer => customer.id === itemInfo.customer).name : itemInfo.customer}}
{{dataStore.customers.find(customer => customer.id === itemInfo.customer) ? dataStore.customers.find(customer => customer.id === itemInfo.customer).name : itemInfo.customer}}
</template>
</USelectMenu>
</UFormGroup>

View File

@@ -20,7 +20,7 @@
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
>
<template #customer-data="{row}">
{{customers.find(customer => customer.id === row.customer) ? customers.find(customer => customer.id === row.customer).name : row.customer }}
{{dataStore.customers.find(customer => customer.id === row.customer) ? dataStore.customers.find(customer => customer.id === row.customer).name : row.customer }}
</template>
</UTable>
@@ -33,9 +33,8 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const router = useRouter()
const {contracts, customers } = storeToRefs(useDataStore())
const mode = ref("show")
const itemColumns = [
@@ -65,10 +64,10 @@ const searchString = ref('')
const filteredRows = computed(() => {
if(!searchString.value) {
return contracts.value
return dataStore.contracts
}
return contracts.value.filter(item => {
return dataStore.contracts.filter(item => {
return Object.values(item).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})

View File

@@ -1,20 +1,19 @@
<script setup>
import HistoryDisplay from "~/components/HistoryDisplay.vue";
definePageMeta({
middleware: "auth"
})
//
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
const numberRange = useNumberRange("customers")
const dataStore = useDataStore()
//Store
const {customers, contacts } = storeToRefs(useDataStore())
const {fetchCustomers, getCustomerById, getContactsByCustomerId} = useDataStore()
let currentCustomer = null
let currentCustomer = ref(null)
@@ -22,24 +21,26 @@ let currentCustomer = null
const mode = ref(route.params.mode || "show")
const customerInfo = ref({
name: "",
customerNumber: 0,
infoData: {},
active: true
})
//Functions
const setupPage = () => {
const setupPage = async () => {
if(mode.value === "show" || mode.value === "edit"){
currentCustomer = getCustomerById(Number(useRoute().params.id))
currentCustomer.value = await dataStore.getCustomerById(Number(useRoute().params.id))
}
if(mode.value === "edit") customerInfo.value = currentCustomer
if(mode.value === "edit") customerInfo.value = currentCustomer.value
}
const createCustomer = async () => {
if(!customerInfo.value.customerNumber) customerInfo.value.customerNumber = await numberRange.useNextNumber()
const {data,error} = await supabase
.from("customers")
.insert([customerInfo.value])
@@ -55,14 +56,14 @@ const createCustomer = async () => {
infoData: {}
}
toast.add({title: "Kunde erfolgreich erstellt"})
await fetchCustomers()
await dataStore.fetchCustomers()
router.push(`/customers/show/${data[0].id}`)
setupPage()
}
}
const editCustomer = async () => {
router.push(`/customers/edit/${currentCustomer.id}`)
router.push(`/customers/edit/${currentCustomer.value.id}`)
setupPage()
}
@@ -88,7 +89,7 @@ const updateCustomer = async () => {
infoData: {}
}
toast.add({title: "Kunde erfolgreich gespeichert"})
fetchCustomers()
dataStore.fetchCustomers()
}
@@ -97,203 +98,194 @@ setupPage()
</script>
<template>
<div>
<UCard v-if="currentCustomer && mode == 'show'" >
<template #header>
<UBadge
v-if="currentCustomer.active"
>
Kunde aktiv
</UBadge>
<UBadge
<UCard v-if="currentCustomer && mode == 'show'" >
<template #header>
<UBadge
v-if="currentCustomer.active"
>
Kunde aktiv
</UBadge>
<UBadge
v-else
color="red"
>
Kunde gesperrt
</UBadge>
{{currentCustomer.name}}
</template>
>
Kunde gesperrt
</UBadge>
{{currentCustomer.name}}
</template>
Kundennummer: {{currentCustomer.customerNumber}} <br>
Kundennummer: {{currentCustomer.customerNumber}} <br>
<UDivider
class="my-2"
/>
Informationen:<br>
{{currentCustomer.infoData}}<br>
<UDivider
<UDivider
class="my-2"
/>
/>
Notizen:<br>
{{currentCustomer.notes}}<br>
Informationen:<br>
{{currentCustomer.infoData}}<br>
<UDivider
<UDivider
class="my-2"
/>
Notizen:<br>
{{currentCustomer.notes}}<br>
<UDivider
class="my-2"
/>
Kontakte: <br>
<ul>
<li
v-for="contact in dataStore.getContactsByCustomerId(currentCustomer.id)"
>
<router-link :to="'/contacts/show/' + contact.id">{{contact.salutation}} {{contact.fullName}} - {{contact.role}}</router-link>
</li>
</ul>
<template #footer>
<UButton
v-if="mode == 'show' && currentCustomer.id"
@click="editCustomer"
>
Bearbeiten
</UButton>
<UButton
color="red"
class="ml-2"
disabled
>
Archivieren
</UButton>
<!-- TODO: Kunde archivieren -->
</template>
</UCard>
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
<template #header v-if="mode === 'edit'">
<UBadge>{{customerInfo.customerNumber}}</UBadge>{{customerInfo.name}}
</template>
<UFormGroup
label="Name:"
>
<UInput
v-model="customerInfo.name"
/>
</UFormGroup>
Kontakte: <br>
<table>
<tr>
<th>Anrede</th>
<th>Name</th>
<th>Rolle</th>
</tr>
<tr v-for="contact in getContactsByCustomerId(currentCustomer.id)">
<td>{{contact.salutation}}</td>
<td>{{contact.fullName}}</td>
<td>{{contact.role}}</td>
</tr>
</table>
<!-- Kontakte:<br>
&lt;!&ndash; <ul>
<li v-for="contact in currentCustomer.contacts.data">{{contact.lastName}}, {{contact.firstName}}</li>
</ul>&ndash;&gt;
&lt;!&ndash; {{currentCustomer.contacts.data}}&ndash;&gt;
<br>
Projekte:<br>
&lt;!&ndash; <ul>
<li v-for="project in currentCustomer.projects.data"><router-link :to="'/projects?id=' + project.id">{{project.name}}</router-link></li>
</ul>&ndash;&gt;-->
<template #footer>
<UButton
v-if="mode == 'show' && currentCustomer.id"
@click="editCustomer"
>
Bearbeiten
</UButton>
<UButton
color="red"
class="ml-2"
disabled
>
Archivieren
</UButton>
<!-- TODO: Kunde archivieren -->
</template>
</UCard>
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
<template #header>
<UBadge>{{customerInfo.customerNumber}}</UBadge> {{customerInfo.name}}
</template>
<UFormGroup
label="Kundennummer:"
>
<UInput
v-model="customerInfo.customerNumber"
placeholder="Leer lassen für automatisch generierte Nummer"
/>
</UFormGroup>
<UTooltip text="Ist ein Kunde nicht aktiv so wird er für neue Aufträge gesperrt">
<UFormGroup
label="Name:"
label="Kunde aktiv:"
>
<UInput
v-model="customerInfo.name"
<UCheckbox
v-model="customerInfo.active"
/>
</UFormGroup>
</UTooltip>
<UFormGroup
label="Notizen:"
>
<UTextarea
v-model="customerInfo.notes"
/>
</UFormGroup>
<UFormGroup
label="Kundennummer:"
>
<UInput
v-model="customerInfo.customerNumber"
/>
</UFormGroup>
<UFormGroup
label="Straße + Hausnummer"
>
<UInput
v-model="customerInfo.infoData.street"
/>
</UFormGroup>
<UFormGroup
label="Postleitzahl"
>
<UInput
v-model="customerInfo.infoData.zip"
/>
</UFormGroup>
<UFormGroup
label="Ort"
>
<UInput
v-model="customerInfo.infoData.city"
/>
</UFormGroup>
<UTooltip text="Ist ein Kunde nicht aktiv so wird er für neue Aufträge gesperrt">
<UFormGroup
label="Kunde aktiv:"
>
<UCheckbox
v-model="customerInfo.active"
/>
</UFormGroup>
</UTooltip>
<UFormGroup
label="Notizen:"
>
<UTextarea
v-model="customerInfo.notes"
/>
</UFormGroup>
<UFormGroup
label="Telefon:"
>
<UInput
v-model="customerInfo.infoData.tel"
/>
</UFormGroup>
<UFormGroup
label="E-Mail:"
>
<UInput
v-model="customerInfo.infoData.email"
/>
</UFormGroup>
<UFormGroup
label="Webseite:"
>
<UInput
v-model="customerInfo.infoData.web"
/>
</UFormGroup>
<UFormGroup
label="USt-Id:"
>
<UInput
v-model="customerInfo.infoData.ustid"
/>
</UFormGroup>
<UFormGroup
label="Straße + Hausnummer"
<template #footer>
<UButton
v-if="mode == 'edit'"
@click="updateCustomer"
>
<UInput
v-model="customerInfo.infoData.street"
/>
</UFormGroup>
<UFormGroup
label="Postleitzahl"
Speichern
</UButton>
<UButton
v-else-if="mode == 'create'"
@click="createCustomer"
>
<UInput
v-model="customerInfo.infoData.zip"
/>
</UFormGroup>
<UFormGroup
label="Ort"
Erstellen
</UButton>
<UButton
@click="cancelEditorCreate"
color="red"
class="ml-2"
>
<UInput
v-model="customerInfo.infoData.city"
/>
</UFormGroup>
Abbrechen
</UButton>
</template>
<UFormGroup
label="Telefon:"
>
<UInput
v-model="customerInfo.infoData.tel"
/>
</UFormGroup>
<UFormGroup
label="E-Mail:"
>
<UInput
v-model="customerInfo.infoData.email"
/>
</UFormGroup>
<UFormGroup
label="Webseite:"
>
<UInput
v-model="customerInfo.infoData.web"
/>
</UFormGroup>
<UFormGroup
label="USt-Id:"
>
<UInput
v-model="customerInfo.infoData.ustid"
/>
</UFormGroup>
</UCard>
<template #footer>
<UButton
v-if="mode == 'edit'"
@click="updateCustomer"
>
Speichern
</UButton>
<UButton
v-else-if="mode == 'create'"
@click="createCustomer"
>
Erstellen
</UButton>
<UButton
@click="cancelEditorCreate"
color="red"
class="ml-2"
>
Abbrechen
</UButton>
</template>
</UCard>
</div>
<HistoryDisplay
type="customer"
v-if="currentCustomer"
:element-id="currentCustomer.id"
/>
</template>
<style scoped>

View File

@@ -30,9 +30,8 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const router = useRouter()
const {customers } = storeToRefs(useDataStore())
const mode = ref("show")
const customerColumns = [
@@ -59,10 +58,10 @@ const searchString = ref('')
const filteredRows = computed(() => {
if(!searchString.value) {
return customers.value
return dataStore.customers
}
return customers.value.filter(item => {
return dataStore.customers.filter(item => {
return Object.values(item).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})

View File

@@ -5,14 +5,12 @@ import {BlobReader, BlobWriter, ZipWriter} from "@zip.js/zip.js";
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const user = useSupabaseUser()
const toast = useToast()
const {documents, projects, customers} = storeToRefs(useDataStore())
const {fetchDocuments, getDocumentTags} = useDataStore()
fetchDocuments()
dataStore.fetchDocuments()
const uploadModalOpen = ref(false)
const uploadInProgress = ref(false)
@@ -24,13 +22,13 @@ const fileUploadFormData = ref({
})
let tags = getDocumentTags
let tags = dataStore.getDocumentTags
const selectedTags = ref(["Eingang"])
const filteredDocuments = computed(() => {
return documents.value.filter(doc => doc.tags.filter(tag => selectedTags.value.find(t => t === tag)).length > 0)
return dataStore.documents.filter(doc => doc.tags.filter(tag => selectedTags.value.find(t => t === tag)).length > 0)
})
@@ -84,14 +82,14 @@ const uploadFiles = async () => {
uploadModalOpen.value = false;
uploadInProgress.value = false;
fetchDocuments()
dataStore.fetchDocuments()
}
const downloadSelected = async () => {
const bucket = "files";
let files = []
documents.value.filter(doc => doc.selected).forEach(doc => files.push(doc.path))
dataStore.documents.filter(doc => doc.selected).forEach(doc => files.push(doc.path))
console.log(files)
@@ -154,7 +152,7 @@ const downloadSelected = async () => {
<UButton @click="uploadModalOpen = true">Hochladen</UButton>
<UButton
@click="downloadSelected"
:disabled="documents.filter(doc => doc.selected).length === 0"
:disabled="dataStore.documents.filter(doc => doc.selected).length === 0"
>Herunterladen</UButton>
<USelectMenu

View File

@@ -11,20 +11,20 @@ const route = useRoute()
const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
const numberRange = useNumberRange("spaces")
//Store
const {spaces,movements,products,units,ownTenant} = storeToRefs(useDataStore())
const {fetchSpaces, getSpaceById, movementsBySpace, getProductById} = useDataStore()
let currentItem = null
const {spaces,movements,products,units,ownTenant, numberRanges} = storeToRefs(useDataStore())
const {fetchSpaces, getSpaceById, movementsBySpace, getProductById, fetchNumberRanges} = useDataStore()
let currentItem = ref(null)
let currentNumberRange = null
//Working
const mode = ref(route.params.mode || "show")
const itemInfo = ref({
spaceNumber: 0
spaceNumber: ""
})
const spaceTypes = ["Regalplatz", "Kiste", "Palettenplatz"]
const spaceProducts = ref([])
@@ -32,11 +32,11 @@ const spaceMovements = ref([])
//Functions
const setupPage = async () => {
console.log("Called Setup")
if(mode.value === "show" || mode.value === "edit"){
currentItem = await getSpaceById(Number(useRoute().params.id))
console.log(currentItem)
currentItem.value = await getSpaceById(Number(useRoute().params.id))
spaceMovements.value = movementsBySpace(currentItem.id)
spaceMovements.value = await movementsBySpace(currentItem.value.id)
spaceProducts.value = []
spaceMovements.value.forEach(movement => {
if(spaceProducts.value.filter(product => product.id === movement.productId).length === 0) spaceProducts.value.push(getProductById(movement.productId))
@@ -44,23 +44,13 @@ const setupPage = async () => {
}
if(mode.value === "edit") itemInfo.value = currentItem
if(mode.value === "create") {
let lastSpaceNumber = 0
spaces.value.forEach(space => {
if(space.spaceNumber > lastSpaceNumber) lastSpaceNumber = space.spaceNumber
})
itemInfo.value.spaceNumber = lastSpaceNumber + 1
}
if(mode.value === "edit") itemInfo.value = currentItem.value
}
const createItem = async () => {
if(!itemInfo.value.spaceNumber) itemInfo.value.spaceNumber = await numberRange.useNextNumber()
const {data,error} = await supabase
.from("spaces")
@@ -70,17 +60,20 @@ const createItem = async () => {
if(error) {
console.log(error)
} else {
console.log(data[0])
mode.value = "show"
itemInfo.value = {}
toast.add({title: "Lagerplatz erfolgreich erstellt"})
await fetchSpaces()
router.push(`/inventory/spaces/show/${data[0].id}`)
setupPage()
//setupPage()
}
}
const editItem = async () => {
router.push(`/inventory/spaces/edit/${currentItem.id}`)
router.push(`/inventory/spaces/edit/${currentItem.value.id}`)
setupPage()
}
@@ -118,7 +111,7 @@ const printSpaceLabel = async () => {
axios
.post(`http://${ownTenant.value.labelPrinterIp}/pstprnt`, `^XA^FO10,20^BCN,100^FD${currentItem.spaceNumber}^XZ` )
.post(`http://${ownTenant.value.labelPrinterIp}/pstprnt`, `^XA^FO10,20^BCN,100^FD${currentItem.value.spaceNumber}^XZ` )
.then(console.log)
.catch(console.log)
}
@@ -129,6 +122,10 @@ setupPage()
<template>
<div>
<DevOnly>
{{currentItem}}
{{mode}}
</DevOnly>
<UCard v-if="currentItem && mode == 'show'" >
<template #header>
<UBadge>{{currentItem.spaceNumber}}</UBadge> {{currentItem.type}}
@@ -187,8 +184,8 @@ setupPage()
</UCard>
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
<template #header>
<UCard v-else-if="mode === 'edit' || mode === 'create'" >
<template #header v-if="mode === 'edit'">
<UBadge>{{itemInfo.spaceNumber}}</UBadge>{{itemInfo.type}}
</template>

View File

@@ -30,9 +30,8 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const router = useRouter()
const {spaces } = storeToRefs(useDataStore())
const mode = ref("show")
const itemColumns = [
@@ -64,10 +63,10 @@ const searchString = ref('')
const filteredRows = computed(() => {
if(!searchString.value) {
return spaces.value
return dataStore.spaces
}
return spaces.value.filter(item => {
return dataStore.spaces.filter(item => {
return Object.values(item).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})

View File

@@ -3,21 +3,15 @@ definePageMeta({
middleware: "auth"
})
//
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
//Store
const {jobs, customers} = storeToRefs(useDataStore())
const {fetchJobs, getJobById} = useDataStore()
let currentItem = null
//Working
const mode = ref(route.params.mode || "show")
const itemInfo = ref({
@@ -30,7 +24,7 @@ const states = ["Offen", "In Bearbeitung", "Erledigt"]
//Functions
const setupPage = () => {
if(mode.value === "show" || mode.value === "edit"){
currentItem = getJobById(Number(useRoute().params.id))
currentItem = dataStore.getJobById(Number(useRoute().params.id))
}
if(mode.value === "edit") itemInfo.value = currentItem
@@ -54,7 +48,7 @@ const createItem = async () => {
title: "",
}
toast.add({title: "Job erfolgreich erstellt"})
await fetchJobs()
await dataStore.fetchJobs()
router.push(`/jobs/show/${data[0].id}`)
setupPage()
}
@@ -85,7 +79,7 @@ const updateItem = async () => {
title: ""
}
toast.add({title: "Job erfolgreich gespeichert"})
fetchJobs()
dataStore.fetchJobs()
}
@@ -109,17 +103,6 @@ setupPage()
<!-- Kontakte:<br>
&lt;!&ndash; <ul>
<li v-for="contact in currentCustomer.contacts.data">{{contact.lastName}}, {{contact.firstName}}</li>
</ul>&ndash;&gt;
&lt;!&ndash; {{currentCustomer.contacts.data}}&ndash;&gt;
<br>
Projekte:<br>
&lt;!&ndash; <ul>
<li v-for="project in currentCustomer.projects.data"><router-link :to="'/projects?id=' + project.id">{{project.name}}</router-link></li>
</ul>&ndash;&gt;-->
<template #footer>
@@ -169,14 +152,14 @@ setupPage()
>
<USelectMenu
v-model="itemInfo.customer"
:options="customers"
:options="dataStore.customers"
option-attribute="name"
value-attribute="id"
searchable
:search-attributes="['name']"
>
<template #label>
{{customers.find(customer => customer.id === itemInfo.customer) ? customers.find(customer => customer.id === itemInfo.customer).name : "Kunde auswählen"}}
{{dataStore.customers.find(customer => customer.id === itemInfo.customer) ? dataStore.customers.find(customer => customer.id === itemInfo.customer).name : "Kunde auswählen"}}
</template>
</USelectMenu>
</UFormGroup>

View File

@@ -4,7 +4,7 @@
<UButton @click="router.push(`/jobs/create/`)">+ Job</UButton>
<UTable
:rows="jobs"
:rows="dataStore.jobs"
:columns="columns"
@select="selectJob"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
@@ -19,8 +19,8 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const router = useRouter()
const {jobs } = storeToRefs(useDataStore())
const mode = ref("show")
const columns = [

View File

@@ -13,11 +13,10 @@ watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
})
const supabase = useSupabaseClient()
const {getResources, getEvents, getEventTypes, fetchEvents} = useDataStore()
const resources = getResources
const eventTypes = getEventTypes
const events = getEvents
const dataStore = useDataStore()
const resources = dataStore.getResources
const eventTypes = dataStore.getEventTypes
const events = dataStore.getEvents
const openNewEventModal = ref(false)
const newEventData = ref({
@@ -39,7 +38,7 @@ const createEvent = async () => {
} else {
openNewEventModal.value = false
newEventData.value = {}
fetchEvents()
dataStore.fetchEvents()
}

View File

@@ -3,18 +3,13 @@ definePageMeta({
middleware: "auth"
})
//
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
//Store
const {products, units, ownTenant } = storeToRefs(useDataStore())
const {fetchProducts, getProductById, getStockByProductId} = useDataStore()
let currentProduct = null
@@ -29,7 +24,7 @@ const itemInfo = ref({
//Functions
const setupPage = () => {
if(mode.value === "show" || mode.value === "edit"){
currentProduct = getProductById(Number(useRoute().params.id))
currentProduct = dataStore.getProductById(Number(useRoute().params.id))
}
if(mode.value === "edit") itemInfo.value = currentProduct
@@ -53,7 +48,7 @@ const createItem = async () => {
name: ""
}
toast.add({title: "Artikel erfolgreich erstellt"})
await fetchProducts()
await dataStore.fetchProducts()
router.push(`/products/show/${data[0].id}`)
setupPage()
}
@@ -87,7 +82,7 @@ const updateItem = async () => {
name: "",
}
toast.add({title: "Artikel erfolgreich gespeichert"})
fetchProducts()
dataStore.fetchProducts()
}
@@ -116,20 +111,22 @@ setupPage()
class="my-2"
/>
Bestand: {{getStockByProductId(currentProduct.id)}} {{units.find(unit => unit.id === currentProduct.unit) ? units.find(unit => unit.id === currentProduct.unit).name : ""}}
Bestand: {{dataStore.getStockByProductId(currentProduct.id)}} {{dataStore.units.find(unit => unit.id === currentProduct.unit) ? dataStore.units.find(unit => unit.id === currentProduct.unit).name : ""}}
<DevOnly>
<UDivider
class="my-2"
/>
<UDivider
class="my-2"
/>
{{currentProduct}}
</DevOnly>
{{currentProduct}}
<template #footer>
<UButton
v-if="mode == 'show' && currentProduct.id"
v-if="mode === 'show' && currentProduct.id"
@click="editItem"
>
Bearbeiten
@@ -148,7 +145,7 @@ setupPage()
</UCard>
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
<template #header>
<template #header v-if="mode === 'edit'">
{{itemInfo.name}}
</template>
@@ -171,12 +168,12 @@ setupPage()
>
<USelectMenu
v-model="itemInfo.unit"
:options="units"
:options="dataStore.units"
option-attribute="name"
value-attribute="id"
>
<template #label>
{{units.find(unit => unit.id === itemInfo.unit) ? units.find(unit => unit.id === itemInfo.unit).name : itemInfo.unit }}
{{dataStore.units.find(unit => unit.id === itemInfo.unit) ? dataStore.units.find(unit => unit.id === itemInfo.unit).name : itemInfo.unit }}
</template>
</USelectMenu>
</UFormGroup>
@@ -185,7 +182,7 @@ setupPage()
>
<USelectMenu
v-model="itemInfo.tags"
:options="ownTenant.tags.products"
:options="dataStore.ownTenant.tags.products"
multiple
/>
</UFormGroup>

View File

@@ -29,7 +29,7 @@
<span v-else>-</span>
</template>
<template #unit-data="{row}">
{{units.find(unit => unit.id === row.unit) ? units.find(unit => unit.id === row.unit).name : row.unit}}
{{dataStore.units.find(unit => unit.id === row.unit) ? dataStore.units.find(unit => unit.id === row.unit).name : row.unit}}
</template>
</UTable>
@@ -42,10 +42,9 @@
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const router = useRouter()
const {products,units} = storeToRefs(useDataStore())
const itemColumns = [
{
@@ -79,10 +78,10 @@ const searchString = ref('')
const filteredRows = computed(() => {
if(!searchString.value) {
return products.value
return dataStore.products
}
return products.value.filter(product => {
return dataStore.products.filter(product => {
return Object.values(product).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})

View File

@@ -19,7 +19,7 @@
>
<USelectMenu
v-model="createProjectData.customer"
:options="customers"
:options="dataStore.customers"
option-attribute="name"
value-attribute="id"
searchable
@@ -45,103 +45,17 @@
</UModal>
<!-- TODO: USelect im Modal anpassen -->
<UTable
:rows="projects"
:rows="dataStore.projects"
:columns="projectColumns"
@select="selectProject"
>
<template #customer-data="{row}">
{{customers.find(customer => customer.id == row.customer ) ? customers.find(customer => customer.id == row.customer ).name : row.id}}
{{dataStore.customers.find(customer => customer.id == row.customer ) ? dataStore.customers.find(customer => customer.id == row.customer ).name : row.id}}
</template>
</UTable>
<!-- <div id="left">
<UButton @click="showCreateProject = true">+ Projekt</UButton>
<UModal v-model="showCreateProject">
<UCard>
<template #header>
Projekt erstellen
</template>
<UFormGroup
label="Name:"
>
<UInput
v-model="createProjectData.name"
/>
</UFormGroup>
<UFormGroup
label="Kunde:"
>
<USelectMenu
v-model="createProjectData.customer"
:options="customers"
option-attribute="name"
value-attribute="id"
searchable
:search-attributes="['name']"
/>
</UFormGroup>
<UFormGroup
label="Notizen:"
>
<UTextarea
v-model="createProjectData.notes"
/>
</UFormGroup>
<template #footer>
<UButton
@click="createProject"
>
Erstellen
</UButton>
</template>
</UCard>
</UModal>
<UTable
:rows="projects"
@select="selectCustomer"
/>
&lt;!&ndash; <router-link v-for="item in projects" :to="`/projects/${item.id}`">
<UCard class="listItem">
<UBadge>{{item.id}}</UBadge> {{item.name}}
</UCard>
</router-link>&ndash;&gt;
</div>
<div id="right">
{{selectedItem}}
<UCard v-if="selectedItem.id">
<template #header>
<UBadge>{{selectedItem.id}}</UBadge> {{selectedItem.name}}
</template>
Kunde:<br>
{{selectedItem.customer.data.name}}<br>
Notizen: <br>
{{selectedItem.notes}}
&lt;!&ndash; Lieferantenrechnungen: <br>
<UTable :rows="dataStore.getVendorInvoicesByProjectId(selectedItem.id)"></UTable>
{{dataStore.getVendorInvoicesByProjectId(selectedItem.id)}}&ndash;&gt;
</UCard>
</div>-->
</div>
</template>
@@ -152,10 +66,9 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const router = useRouter()
const {projects,customers} = storeToRefs(useDataStore())
const {fetchProjects} = useDataStore()
const projectColumns = [
{
@@ -184,10 +97,6 @@ const selectProject = (project) => {
router.push(`/projects/${project.id} `)
}
//const projects = (await supabase.from("projects").select()).data
//const customers = (await supabase.from("customers").select()).data
const showCreateProject = ref(false)
const createProjectData = ref({
phases: []
@@ -210,7 +119,7 @@ const createProject = async () => {
showCreateProject.value = false
createProjectData.value = {phases: []}
fetchProjects()
dataStore.fetchProjects()
}

View File

@@ -0,0 +1,102 @@
<script setup>
definePageMeta({
middleware: "auth"
})
const supabase = useSupabaseClient()
const dataStore = useDataStore()
const showAddModal = ref(false)
const columns = [
{
key: "resourceType",
label: "Typ"
},{
key: "prefix",
label: "Prefix"
},{
key:"nextNumber",
label:"Nächste Nummer"
},{
key: "suffix",
label: "Suffix"
}
]
const resources = {
customers: {
label: "Kunden"
},
vendors: {
label: "Lieferanten"
},
spaces: {
label: "Lagerplätze"
}
}
const updateNumberRange = async (range) => {
console.log(range)
const {data,error} = await supabase
.from("numberRanges")
.update(range)
.eq('id',range.id)
await dataStore.fetchNumberRanges()
}
</script>
<template>
<UModal
v-model="showAddModal"
>
</UModal>
<UAlert
title="Änderungen an diesen Werten betreffen nur neu Erstellte Einträge."
color="rose"
variant="outline"
icon="i-heroicons-exclamation-triangle"
/>
<UTable
:rows="dataStore.numberRanges"
:columns="columns"
>
<template #resourceType-data="{row}">
{{resources[row.resourceType] ? resources[row.resourceType].label : ""}}
</template>
<template #prefix-data="{row}">
<UInput
v-model="row.prefix"
@focusout="updateNumberRange(row)"
/>
</template>
<template #suffix-data="{row}">
<UInput
v-model="row.suffix"
@focusout="updateNumberRange(row)"
/>
</template>
<template #nextNumber-data="{row}">
<UInput
v-model="row.nextNumber"
@focusout="updateNumberRange(row)"
/>
</template>
</UTable>
<DevOnly>
{{dataStore.numberRanges}}
</DevOnly>
</template>
<style scoped>
</style>

View File

@@ -2,13 +2,12 @@
definePageMeta({
middleware: "auth"
})
const {profiles} = storeToRefs(useDataStore())
const dataStore = useDataStore()
</script>
<template>
{{profiles}}
{{dataStore.profiles}}
</template>
<style scoped>

View File

@@ -90,14 +90,14 @@
label="Benutzer ändern:"
>
<USelectMenu
:options="profiles"
:options="dataStore.profiles"
@change="updateTask"
v-model="taskData.user"
option-attribute="firstName"
value-attribute="id"
>
<template #label>
{{profiles.find(profile => profile.id === taskData.user) ? profiles.find(profile => profile.id === taskData.user).firstName : 'Kein Benutzer ausgewählt'}}
{{dataStore.profiles.find(profile => profile.id === taskData.user) ? dataStore.profiles.find(profile => profile.id === taskData.user).fullName : 'Kein Benutzer ausgewählt'}}
</template>
</USelectMenu>
</UFormGroup>
@@ -130,7 +130,7 @@
{{ dayjs(row.created_at).format("DD.MM.YY HH:mm") }}
</template>
<template #user-data="{row}">
{{profiles.find(profile => profile.id === row.user ) ? profiles.find(profile => profile.id === row.user ).firstName : row.user}}
{{dataStore.profiles.find(profile => profile.id === row.user ) ? dataStore.profiles.find(profile => profile.id === row.user ).fullName : row.user}}
</template>
</UTable>
@@ -148,10 +148,9 @@ definePageMeta({
middleware: "auth",
})
const dataStore = useDataStore()
const toast = useToast()
const supabase = useSupabaseClient()
const {tasks, profiles} = storeToRefs(useDataStore())
const {fetchTasks} = useDataStore()
const taskColumns = [
{
@@ -185,7 +184,7 @@ const showDoneTasks = ref(false)
const searchString = ref("")
const filteredRows = computed(() => {
let filteredTasks = tasks.value.filter(task => !showDoneTasks.value ? task.categorie !== "Erledigt" : task.categorie === "Erledigt")
let filteredTasks = dataStore.tasks.value.filter(task => !showDoneTasks.value ? task.categorie !== "Erledigt" : task.categorie === "Erledigt")
if(!searchString.value) {
return filteredTasks
@@ -224,7 +223,7 @@ const createTask = async () => {
showCreateTask.value = false
createTaskData.value = {}
fetchTasks()
dataStore.fetchTasks()
}
const updateTask = async () => {
@@ -243,7 +242,7 @@ const updateTask = async () => {
toast.add({title: "Aufgabe aktualisiert"})
taskData.value = {}
showTaskModal.value = false
fetchTasks()
dataStore.fetchTasks()
}
}

View File

@@ -8,13 +8,12 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const user = useSupabaseUser()
const toast = useToast()
const {times, projects, profiles, jobs} = storeToRefs(useDataStore())
const {fetchTimes, getTimeTypes} = useDataStore()
const timeTypes = getTimeTypes
const timeTypes = dataStore.getTimeTypes
const timeInfo = ref({
user: "",
start: "",
@@ -100,7 +99,7 @@ const startTime = async () => {
console.log(error)
} else if(data) {
timeInfo.value = data[0]
await fetchTimes()
await dataStore.fetchTimes()
runningTimeInfo.value = times.value.find(time => time.user == user.value.id && !time.end)
}
@@ -128,7 +127,7 @@ const stopStartedTime = async () => {
} else {
toast.add({title: "Zeit erfolgreich gestoppt"})
runningTimeInfo.value = {}
fetchTimes()
dataStore.fetchTimes()
}
}
@@ -149,7 +148,7 @@ const createTime = async () => {
createTimeInfo.value = {}
toast.add({title: "Zeit erfolgreich erstellt"})
showAddTimeModal.value = false
await fetchTimes()
await dataStore.fetchTimes()
}
}
@@ -211,13 +210,13 @@ const selectStartedTime = () => {
label="Projekt:"
>
<USelectMenu
:options="projects"
:options="dataStore.projects"
option-attribute="name"
value-attribute="id"
v-model="runningTimeInfo.projectId"
>
<template #label>
{{ projects.find(project => project.id === runningTimeInfo.projectId) ? projects.find(project => project.id === runningTimeInfo.projectId).name : "Projekt auswählen" }}
{{ dataStore.projects.find(project => project.id === runningTimeInfo.projectId) ? dataStore.projects.find(project => project.id === runningTimeInfo.projectId).name : "Projekt auswählen" }}
</template>
</USelectMenu>
</UFormGroup>
@@ -226,13 +225,13 @@ const selectStartedTime = () => {
label="Job:"
>
<USelectMenu
:options="jobs"
:options="dataStore.jobs"
option-attribute="title"
value-attribute="id"
v-model="runningTimeInfo.job"
>
<template #label>
{{ jobs.find(job => job.id === runningTimeInfo.job) ? jobs.find(job => job.id === runningTimeInfo.job).title : "Job auswählen" }}
{{ dataStore.jobs.find(job => job.id === runningTimeInfo.job) ? dataStore.jobs.find(job => job.id === runningTimeInfo.job).title : "Job auswählen" }}
</template>
</USelectMenu>
</UFormGroup>
@@ -302,13 +301,13 @@ const selectStartedTime = () => {
label="Benutzer:"
>
<USelectMenu
:options="profiles"
:options="dataStore.profiles"
v-model="createTimeInfo.user"
option-attribute="firstName"
value-attribute="id"
>
<template #label>
{{profiles.find(profile => profile.id === createTimeInfo.user) ? profiles.find(profile => profile.id === createTimeInfo.user).firstName : "Benutzer auswählen"}}
{{dataStore.profiles.find(profile => profile.id === createTimeInfo.user) ? dataStore.profiles.find(profile => profile.id === createTimeInfo.user).firstName : "Benutzer auswählen"}}
</template>
</USelectMenu>
</UFormGroup>
@@ -316,13 +315,13 @@ const selectStartedTime = () => {
label="Projekt:"
>
<USelectMenu
:options="projects"
:options="dataStore.projects"
v-model="createTimeInfo.projectId"
option-attribute="name"
value-attribute="id"
>
<template #label>
{{projects.find(project => project.id === createTimeInfo.projectId) ? projects.find(project => project.id === createTimeInfo.projectId).name : "Projekt auswählen"}}
{{dataStore.projects.find(project => project.id === createTimeInfo.projectId) ? dataStore.projects.find(project => project.id === createTimeInfo.projectId).name : "Projekt auswählen"}}
</template>
</USelectMenu>
</UFormGroup>
@@ -330,13 +329,13 @@ const selectStartedTime = () => {
label="Job:"
>
<USelectMenu
:options="jobs"
:options="dataStore.jobs"
option-attribute="title"
value-attribute="id"
v-model="createTimeInfo.job"
>
<template #label>
{{ jobs.find(job => job.id === runningTimeInfo.job) ? jobs.find(job => job.id === runningTimeInfo.job).title : "Job auswählen" }}
{{ dataStore.jobs.find(job => job.id === runningTimeInfo.job) ? dataStore.jobs.find(job => job.id === runningTimeInfo.job).title : "Job auswählen" }}
</template>
</USelectMenu>
</UFormGroup>
@@ -382,7 +381,7 @@ const selectStartedTime = () => {
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
>
<template #user-data="{row}">
{{profiles.find(profile => profile.id === row.user) ? profiles.find(profile => profile.id === row.user).firstName + " " + profiles.find(profile => profile.id === row.user).lastName : row.user }}
{{dataStore.profiles.find(profile => profile.id === row.user) ? dataStore.profiles.find(profile => profile.id === row.user).firstName + " " + profiles.find(profile => profile.id === row.user).lastName : row.user }}
</template>
<template #start-data="{row}">

View File

@@ -3,17 +3,13 @@ definePageMeta({
middleware: "auth"
})
//
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
//Store
const {vehicles, profiles } = storeToRefs(useDataStore())
const {fetchVehicles, getVehicleById} = useDataStore()
let currentItem = null
@@ -31,7 +27,7 @@ const itemInfo = ref({
//Functions
const setupPage = () => {
if(mode.value === "show" || mode.value === "edit"){
currentItem = getVehicleById(Number(useRoute().params.id))
currentItem = dataStore.getVehicleById(Number(useRoute().params.id))
}
if(mode.value === "edit") itemInfo.value = currentItem
@@ -55,7 +51,7 @@ const createItem = async () => {
name: ""
}
toast.add({title: "Fahrzeug erfolgreich erstellt"})
await fetchVehicles()
await dataStore.fetchVehicles()
router.push(`/vehicles/show/${data[0].id}`)
setupPage()
}
@@ -92,14 +88,10 @@ const updateCustomer = async () => {
type: ""
}
toast.add({title: "Fahrzeug erfolgreich gespeichert"})
fetchVehicles()
dataStore.fetchVehicles()
}
}
setupPage()
</script>
@@ -122,7 +114,7 @@ setupPage()
</template>
Typ: {{currentItem.type}} <br>
Fahrer: {{profiles.find(profile => profile.id === currentItem.driver) ? profiles.find(profile => profile.id === currentItem.driver).fullName : 'Kein Fahrer gewählt'}} <br>
Fahrer: {{dataStore.profiles.find(profile => profile.id === currentItem.driver) ? dataStore.profiles.find(profile => profile.id === currentItem.driver).fullName : 'Kein Fahrer gewählt'}} <br>
@@ -147,7 +139,7 @@ setupPage()
</UCard>
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
<template #header>
<template #header v-if="mode === 'edit'">
{{itemInfo.licensePlate}}
</template>
@@ -180,13 +172,13 @@ setupPage()
>
<USelectMenu
v-model="itemInfo.driver"
:options="profiles"
:options="dataStore.profiles"
option-attribute="fullName"
value-attribute="id"
>
<template #label>
{{profiles.find(profile => profile.id === itemInfo.driver) ? profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer ausgewählt'}}
{{dataStore.profiles.find(profile => profile.id === itemInfo.driver) ? dataStore.profiles.find(profile => profile.id === itemInfo.driver).fullName : 'Kein Fahrer ausgewählt'}}
</template>
</USelectMenu>
</UFormGroup>

View File

@@ -30,7 +30,7 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const router = useRouter()
const {vehicles } = storeToRefs(useDataStore())
const mode = ref("show")
@@ -58,10 +58,10 @@ const searchString = ref('')
const filteredRows = computed(() => {
if(!searchString.value) {
return vehicles.value
return dataStore.vehicles
}
return vehicles.value.filter(item => {
return dataStore.vehicles.filter(item => {
return Object.values(item).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})

View File

@@ -1,11 +1,6 @@
<template>
<div id="main">
<div
class="previewDoc"
>
@@ -22,14 +17,14 @@
<UFormGroup label="Lieferant:" required>
<USelectMenu
v-model="itemInfo.vendor"
:options="vendors"
:options="dataStore.vendors"
option-attribute="name"
value-attribute="id"
searchable
:search-attributes="['name','vendorNumber']"
>
<template #label>
{{vendors.find(vendor => vendor.id === itemInfo.vendor) ? vendors.find(vendor => vendor.id === itemInfo.vendor).name : 'Lieferant auswählen'}}
{{dataStore.vendors.find(vendor => vendor.id === itemInfo.vendor) ? dataStore.vendors.find(vendor => vendor.id === itemInfo.vendor).name : 'Lieferant auswählen'}}
</template>
</USelectMenu>
</UFormGroup>
@@ -109,12 +104,13 @@
import InputGroup from "~/components/InputGroup.vue";
import * as dayjs from "dayjs";
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const route = useRoute()
const toast = useToast()
const {vendors} = storeToRefs(useDataStore())
const {getVendorInvoiceById, getDocumentById, fetchVendorInvoices} = useDataStore()
const {fetchVendorInvoices} = useDataStore()
let currentVendorInvoice = null
let currentDocument = ref(null)
@@ -125,14 +121,11 @@ const mode = ref(route.params.mode || "show")
//Functions
const setupPage = async () => {
if(mode.value === "show" || mode.value === "edit"){
currentVendorInvoice = await getVendorInvoiceById(Number(useRoute().params.id))
currentDocument.value = await getDocumentById(currentVendorInvoice.document)
currentVendorInvoice = await dataStore.getVendorInvoiceById(Number(useRoute().params.id))
currentDocument.value = await dataStore.getDocumentById(currentVendorInvoice.document)
}
if(mode.value === "edit") itemInfo.value = currentVendorInvoice
}
@@ -162,7 +155,7 @@ const updateItem = async () => {
id: 0,
}*/
toast.add({title: "Eingangsrechnung erfolgreich gespeichert"})
fetchVendorInvoices()
dataStore.fetchVendorInvoices()
}
}

View File

@@ -33,7 +33,7 @@
</span>
</template>
<template #vendor-data="{row}">
{{vendors.find(vendor => vendor.id === row.vendor) ? vendors.find(vendor => vendor.id === row.vendor).name : ''}}
{{dataStore.vendors.find(vendor => vendor.id === row.vendor) ? dataStore.vendors.find(vendor => vendor.id === row.vendor).name : ''}}
</template>
<template #date-data="{row}">
{{row.date ? dayjs(row.date).format("DD.MM.YY") : ''}}
@@ -58,9 +58,8 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const router = useRouter()
const {vendorInvoices, vendors} = storeToRefs(useDataStore())
const mode = ref("show")
const itemColumns = [
@@ -107,10 +106,10 @@ const searchString = ref('')
const filteredRows = computed(() => {
if(!searchString.value) {
return vendorInvoices.value
return dataStore.vendorInvoices
}
return vendorInvoices.value.filter(item => {
return dataStore.vendorInvoices.filter(item => {
return Object.values(item).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})

View File

@@ -3,18 +3,13 @@ definePageMeta({
middleware: "auth"
})
//
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
//Store
const {vendors } = storeToRefs(useDataStore())
const {fetchVendors, getVendorById} = useDataStore()
let currentItem = null
@@ -26,7 +21,7 @@ const itemInfo = ref({})
//Functions
const setupPage = () => {
if(mode.value === "show" || mode.value === "edit"){
currentItem = getVendorById(Number(useRoute().params.id))
currentItem = dataStore.getVendorById(Number(useRoute().params.id))
}
if(mode.value === "edit") itemInfo.value = currentItem
@@ -47,7 +42,7 @@ const createItem = async () => {
mode.value = "show"
itemInfo.value = {}
toast.add({title: "Lieferant erfolgreich erstellt"})
await fetchVendors()
await dataStore.fetchVendors()
router.push(`/vendors/show/${data[0].id}`)
setupPage()
}
@@ -74,7 +69,7 @@ const updateItem = async () => {
mode.value = "show"
itemInfo.value = {}
toast.add({title: "Lieferant erfolgreich gespeichert"})
fetchVendors()
dataStore.fetchVendors()
}

View File

@@ -29,9 +29,8 @@ definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const router = useRouter()
const {vendors } = storeToRefs(useDataStore())
const mode = ref("show")
const itemColumns = [
@@ -58,10 +57,10 @@ const searchString = ref('')
const filteredRows = computed(() => {
if(!searchString.value) {
return vendors.value
return dataStore.vendors
}
return vendors.value.filter(item => {
return dataStore.vendors.filter(item => {
return Object.values(item).some((value) => {
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
})