Changed STore Type and corrected all Pages
Added HistoryDisplay.vue Added NumberRanges
This commit is contained in:
@@ -9,11 +9,23 @@ const route = useRoute()
|
|||||||
const colorMode = useColorMode()
|
const colorMode = useColorMode()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const tenants = (await supabase.from("tenants").select()).data
|
const tenants = (await supabase.from("tenants").select()).data
|
||||||
const {loaded, profiles} = storeToRefs(useDataStore())
|
|
||||||
const {fetchData, getProfileById, clearStore} = useDataStore()
|
const dataStore = useDataStore()
|
||||||
const userProfile = (user.value ? getProfileById(user.value.id) : {})
|
|
||||||
|
|
||||||
|
const userProfile = (user.value ? dataStore.getProfileById(user.value.id) : {})
|
||||||
//console.log(userProfile)
|
//console.log(userProfile)
|
||||||
|
|
||||||
|
|
||||||
|
const isLight = computed({
|
||||||
|
get () {
|
||||||
|
return colorMode.value !== 'dark'
|
||||||
|
},
|
||||||
|
set () {
|
||||||
|
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const viewport = useViewport()
|
const viewport = useViewport()
|
||||||
|
|
||||||
watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
|
watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
|
||||||
@@ -21,7 +33,7 @@ watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
fetchData()
|
dataStore.fetchData()
|
||||||
|
|
||||||
const navLinks = [
|
const navLinks = [
|
||||||
{
|
{
|
||||||
@@ -57,8 +69,13 @@ const navLinks = [
|
|||||||
{
|
{
|
||||||
label: "Eingangsrechnungen",
|
label: "Eingangsrechnungen",
|
||||||
to: "/vendorinvoices",
|
to: "/vendorinvoices",
|
||||||
icon: "i-heroicons-user-group"
|
icon: "i-heroicons-document-text"
|
||||||
},
|
},
|
||||||
|
/*{
|
||||||
|
label: "Ausgangsrechnungen",
|
||||||
|
to: "/customerinvoices",
|
||||||
|
icon: "i-heroicons-document-text"
|
||||||
|
},*/
|
||||||
{
|
{
|
||||||
label: "Bank",
|
label: "Bank",
|
||||||
to: "/banking",
|
to: "/banking",
|
||||||
@@ -215,6 +232,10 @@ const items = [
|
|||||||
label: 'Externe Geräte',
|
label: 'Externe Geräte',
|
||||||
icon: 'i-heroicons-cog-8-tooth',
|
icon: 'i-heroicons-cog-8-tooth',
|
||||||
to: "/settings/externalDevices"
|
to: "/settings/externalDevices"
|
||||||
|
},{
|
||||||
|
label: 'Nummernkreise',
|
||||||
|
icon: 'i-heroicons-cog-8-tooth',
|
||||||
|
to: "/settings/numberRanges"
|
||||||
},{
|
},{
|
||||||
label: 'Benutzer',
|
label: 'Benutzer',
|
||||||
icon: 'i-heroicons-user-group',
|
icon: 'i-heroicons-user-group',
|
||||||
@@ -233,7 +254,7 @@ const items = [
|
|||||||
icon: 'i-heroicons-arrow-left-on-rectangle',
|
icon: 'i-heroicons-arrow-left-on-rectangle',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await supabase.auth.signOut()
|
await supabase.auth.signOut()
|
||||||
await clearStore()
|
await dataStore.clearStore()
|
||||||
await router.push("/login")
|
await router.push("/login")
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -247,14 +268,8 @@ const items = [
|
|||||||
<template #logo>
|
<template #logo>
|
||||||
<div id="logo">
|
<div id="logo">
|
||||||
<img
|
<img
|
||||||
v-if="colorMode.value === 'light'"
|
:src="!isLight ? '/spaces.svg' : '/spaces_hell.svg'"
|
||||||
alt="Logo Hell"
|
alt="Logo"
|
||||||
src="/spaces_hell.svg"
|
|
||||||
/>
|
|
||||||
<img
|
|
||||||
v-else
|
|
||||||
src="/spaces.svg"
|
|
||||||
alt="Logo Dunkel"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -265,7 +280,19 @@ const items = [
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #right v-if="user">
|
<template #right v-if="user">
|
||||||
<UColorModeButton/>
|
<ClientOnly>
|
||||||
|
<UButton
|
||||||
|
:icon="!isLight ? 'i-heroicons-moon-20-solid' : 'i-heroicons-sun-20-solid'"
|
||||||
|
color="gray"
|
||||||
|
variant="ghost"
|
||||||
|
aria-label="Theme"
|
||||||
|
@click="isLight = !isLight"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<template #fallback>
|
||||||
|
<div class="w-8 h-8" />
|
||||||
|
</template>
|
||||||
|
</ClientOnly>
|
||||||
<UDropdown :items="items" :ui="{ item: { disabled: 'cursor-text select-text' } }" :popper="{ placement: 'bottom-start' }">
|
<UDropdown :items="items" :ui="{ item: { disabled: 'cursor-text select-text' } }" :popper="{ placement: 'bottom-start' }">
|
||||||
<UAvatar
|
<UAvatar
|
||||||
:alt="userProfile ? userProfile.firstName + ' ' + userProfile.lastName : '' "
|
:alt="userProfile ? userProfile.firstName + ' ' + userProfile.lastName : '' "
|
||||||
@@ -275,7 +302,7 @@ const items = [
|
|||||||
<template #account="{ item }">
|
<template #account="{ item }">
|
||||||
<div class="text-left">
|
<div class="text-left">
|
||||||
<p>
|
<p>
|
||||||
Signed in as
|
Eingeloggt als
|
||||||
</p>
|
</p>
|
||||||
<p class="truncate font-medium text-gray-900 dark:text-white">
|
<p class="truncate font-medium text-gray-900 dark:text-white">
|
||||||
{{ item.label }}
|
{{ item.label }}
|
||||||
@@ -415,4 +442,8 @@ const items = [
|
|||||||
border: 1px solid #69c350;
|
border: 1px solid #69c350;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: #69c350
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
153
spaces/components/HistoryDisplay.vue
Normal file
153
spaces/components/HistoryDisplay.vue
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
<script setup>
|
||||||
|
import * as dayjs from "dayjs"
|
||||||
|
const props = defineProps({
|
||||||
|
type: {
|
||||||
|
required: true,
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
elementId: {
|
||||||
|
required: true,
|
||||||
|
type: String
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const user = useSupabaseUser()
|
||||||
|
const supabase = useSupabaseClient()
|
||||||
|
const toast = useToast()
|
||||||
|
const {type, elementId} = props
|
||||||
|
const showAddHistoryItemModal = ref(false)
|
||||||
|
const colorMode = useColorMode()
|
||||||
|
/*const historyItems = ref([
|
||||||
|
{
|
||||||
|
user: "86e67794-0ea8-41b0-985a-1072e84f56e9",
|
||||||
|
text: "<a class='text-primary-500'>@marielesindern</a> magst du die einmal anschauen",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
user: "3b795486-6b71-4ed8-a1f6-dbc52360d826",
|
||||||
|
text: "<a class='text-primary-500'>@florianfederspiel</a> Jo alles bestens",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
user: "Spaces Bot",
|
||||||
|
text: "Erstellt",
|
||||||
|
}
|
||||||
|
])*/
|
||||||
|
|
||||||
|
const {profiles} = storeToRefs(useDataStore())
|
||||||
|
const {getHistoryItemsByCustomer, fetchHistoryItems} = useDataStore()
|
||||||
|
|
||||||
|
const historyItems = computed(() => {
|
||||||
|
|
||||||
|
let items = []
|
||||||
|
|
||||||
|
if(type === "customer") {
|
||||||
|
items = getHistoryItemsByCustomer(elementId)
|
||||||
|
}
|
||||||
|
|
||||||
|
return items.reverse()
|
||||||
|
|
||||||
|
})
|
||||||
|
const addHistoryItemData = ref({
|
||||||
|
text: "",
|
||||||
|
user: ""
|
||||||
|
})
|
||||||
|
|
||||||
|
const addHistoryItem = async () => {
|
||||||
|
addHistoryItemData.value.user = user.value.id
|
||||||
|
|
||||||
|
if(type === "customer") {
|
||||||
|
addHistoryItemData.value.customer = elementId
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const {data,error} = await supabase
|
||||||
|
.from("historyItems")
|
||||||
|
.insert([addHistoryItemData.value])
|
||||||
|
.select()
|
||||||
|
|
||||||
|
if(error) {
|
||||||
|
console.log(error)
|
||||||
|
} else {
|
||||||
|
toast.add({title: "Eintrag erfolgreich erstellt"})
|
||||||
|
showAddHistoryItemModal.value = false
|
||||||
|
await fetchHistoryItems()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const renderText = (text) => {
|
||||||
|
const regex = /(@\w*)/g
|
||||||
|
|
||||||
|
text = text.replaceAll(regex, "<a class='text-primary-500'>$&</a>")
|
||||||
|
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UModal
|
||||||
|
v-model="showAddHistoryItemModal"
|
||||||
|
>
|
||||||
|
<UCard>
|
||||||
|
<template #header>
|
||||||
|
Eintrag hinzufügen
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<UFormGroup
|
||||||
|
label="Text:"
|
||||||
|
>
|
||||||
|
<UTextarea
|
||||||
|
v-model="addHistoryItemData.text"
|
||||||
|
/>
|
||||||
|
</UFormGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<UButton @click="addHistoryItem">Hinzufügen</UButton>
|
||||||
|
</template>
|
||||||
|
</UCard>
|
||||||
|
</UModal>
|
||||||
|
<UCard class="mt-5">
|
||||||
|
<template #header>
|
||||||
|
<InputGroup>
|
||||||
|
<UButton
|
||||||
|
@click="showAddHistoryItemModal = true"
|
||||||
|
>
|
||||||
|
+ Eintrag
|
||||||
|
</UButton>
|
||||||
|
</InputGroup>
|
||||||
|
</template>
|
||||||
|
<div
|
||||||
|
v-if="historyItems.length > 0"
|
||||||
|
v-for="(item,index) in historyItems"
|
||||||
|
>
|
||||||
|
<UDivider
|
||||||
|
class="my-3"
|
||||||
|
v-if="index !== 0"
|
||||||
|
/>
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<UAvatar
|
||||||
|
v-if="!item.user"
|
||||||
|
:src="colorMode.value === 'light' ? '/spaces_hell.svg' : '/spaces.svg' "
|
||||||
|
/>
|
||||||
|
<UAvatar
|
||||||
|
:alt="profiles.find(profile => profile.id === item.user).fullName"
|
||||||
|
v-else
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
<h3 v-if="item.user">{{profiles.find(profile => profile.id === item.user) ? profiles.find(profile => profile.id === item.user).fullName : ""}}</h3>
|
||||||
|
<h3 v-else>Spaces Bot</h3>
|
||||||
|
<span v-html="renderText(item.text)"/><br>
|
||||||
|
<span class="text-gray-500">{{dayjs(item.created_at).format("DD:MM:YY HH:mm")}}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</UCard>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
29
spaces/composables/useNumberRange.js
Normal file
29
spaces/composables/useNumberRange.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
export const useNumberRange = (resourceType) => {
|
||||||
|
const supabase = useSupabaseClient()
|
||||||
|
|
||||||
|
const {numberRanges} = storeToRefs(useDataStore())
|
||||||
|
const {fetchNumberRanges} = useDataStore()
|
||||||
|
|
||||||
|
const numberRange = numberRanges.value.find(range => range.resourceType === resourceType)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const useNextNumber = async () => {
|
||||||
|
|
||||||
|
let nextNumber = numberRange.nextNumber
|
||||||
|
|
||||||
|
const {data,error} = await supabase
|
||||||
|
.from("numberRanges")
|
||||||
|
.update({nextNumber: nextNumber + 1})
|
||||||
|
.eq('id',numberRange.id)
|
||||||
|
|
||||||
|
fetchNumberRanges()
|
||||||
|
|
||||||
|
return (numberRange.prefix ? numberRange.prefix : "") + nextNumber + (numberRange.suffix ? numberRange.suffix : "")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return { useNextNumber}
|
||||||
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
const {loaded, profiles} = storeToRefs(useDataStore())
|
const dataStore = useDataStore()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
||||||
|
|
||||||
<slot v-if="loaded"/>
|
<slot v-if="dataStore.loaded"/>
|
||||||
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"socket.io-client": "^4.7.2",
|
"socket.io-client": "^4.7.2",
|
||||||
"uuidv4": "^6.2.13",
|
"uuidv4": "^6.2.13",
|
||||||
"v-calendar": "^3.1.2"
|
"v-calendar": "^3.1.2",
|
||||||
|
"vuedraggable": "^4.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,18 +31,11 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {bankAccounts} = storeToRefs(useDataStore())
|
|
||||||
const mode = ref("show")
|
const mode = ref("show")
|
||||||
|
|
||||||
const itemColumns = [
|
const itemColumns = [
|
||||||
|
|
||||||
{
|
|
||||||
key: "name",
|
|
||||||
label: "Name",
|
|
||||||
sortable: true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: "iban",
|
key: "iban",
|
||||||
label: "IBAN",
|
label: "IBAN",
|
||||||
@@ -69,13 +62,13 @@ const selectItem = (item) => {
|
|||||||
const searchString = ref('')
|
const searchString = ref('')
|
||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
bankAccounts.value = bankAccounts.value.filter(account => account.used)
|
dataStore.bankAccounts = dataStore.bankAccounts.filter(account => account.used)
|
||||||
|
|
||||||
if(!searchString.value) {
|
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 Object.values(item).some((value) => {
|
||||||
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,21 +4,20 @@ import * as dayjs from "dayjs";
|
|||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
const dataStore = useDataStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
|
|
||||||
const {bankStatements,bankAccounts} = storeToRefs(useDataStore())
|
|
||||||
|
|
||||||
const searchString = ref("")
|
const searchString = ref("")
|
||||||
const showAssigned = ref(false)
|
const showAssigned = ref(false)
|
||||||
const selectedAccount = ref(0)
|
const selectedAccount = ref(0)
|
||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
let statements = bankStatements.value
|
let statements = dataStore.bankStatements
|
||||||
|
|
||||||
if(!showAssigned.value) {
|
if(!showAssigned.value) {
|
||||||
statements = statements.filter(statement => !(statement.customerInvoice || statement.vendorInvoice))
|
statements = statements.filter(statement => !statement.customerInvoice || !statement.vendorInvoice)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selectedAccount.value !== 0) {
|
if(selectedAccount.value !== 0) {
|
||||||
@@ -26,17 +25,14 @@ const filteredRows = computed(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(searchString.value.length > 0) {
|
if(searchString.value.length > 0) {
|
||||||
return statements.value.filter(item => {
|
statements = statements.filter(item => {
|
||||||
return Object.values(item).some((value) => {
|
return Object.values(item).some((value) => {
|
||||||
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
return statements
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return statements
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -91,19 +87,19 @@ const statementColumns = [
|
|||||||
|
|
||||||
</USlideover>
|
</USlideover>
|
||||||
|
|
||||||
<InputGroup gap="2">
|
<InputGroup :gap="2">
|
||||||
<UInput
|
<UInput
|
||||||
v-model="searchString"
|
v-model="searchString"
|
||||||
placeholder="Suche..."
|
placeholder="Suche..."
|
||||||
/>
|
/>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="bankAccounts.filter(account => account.used)"
|
:options="dataStore.bankAccounts.filter(account => account.used)"
|
||||||
v-model="selectedAccount"
|
v-model="selectedAccount"
|
||||||
option-attribute="iban"
|
option-attribute="iban"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
<UCheckbox
|
<UCheckbox
|
||||||
@@ -113,7 +109,7 @@ const statementColumns = [
|
|||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
<UTable
|
<UTable
|
||||||
:rows="bankStatements"
|
:rows="filteredRows"
|
||||||
:columns="statementColumns"
|
:columns="statementColumns"
|
||||||
@select="selectStatement"
|
@select="selectStatement"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ const toast = useToast()
|
|||||||
const id = ref(route.params.id ? route.params.id : null )
|
const id = ref(route.params.id ? route.params.id : null )
|
||||||
|
|
||||||
//Store
|
//Store
|
||||||
const {customers, vendors, contacts } = storeToRefs(useDataStore())
|
const dataStore = useDataStore()
|
||||||
const {fetchContacts, getContactById} = useDataStore()
|
|
||||||
|
|
||||||
let currentContact = null
|
let currentContact = null
|
||||||
|
|
||||||
|
|
||||||
@@ -27,7 +25,7 @@ const itemInfo = ref({
|
|||||||
//Functions
|
//Functions
|
||||||
const setupPage = () => {
|
const setupPage = () => {
|
||||||
if(mode.value === "show" || mode.value === "edit"){
|
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
|
if(mode.value === "edit") itemInfo.value = currentContact
|
||||||
@@ -53,7 +51,7 @@ const createItem = async () => {
|
|||||||
id: 0,
|
id: 0,
|
||||||
}
|
}
|
||||||
toast.add({title: "Kontakt erfolgreich erstellt"})
|
toast.add({title: "Kontakt erfolgreich erstellt"})
|
||||||
await fetchContacts()
|
await dataStore.fetchContacts()
|
||||||
router.push(`/contacts/show/${data[0].id}`)
|
router.push(`/contacts/show/${data[0].id}`)
|
||||||
setupPage()
|
setupPage()
|
||||||
}
|
}
|
||||||
@@ -84,7 +82,7 @@ const updateCustomer = async () => {
|
|||||||
name: "",
|
name: "",
|
||||||
}
|
}
|
||||||
toast.add({title: "Kontakt erfolgreich gespeichert"})
|
toast.add({title: "Kontakt erfolgreich gespeichert"})
|
||||||
fetchContacts()
|
dataStore.fetchContacts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -125,8 +123,8 @@ setupPage()
|
|||||||
</UButton>
|
</UButton>
|
||||||
</InputGroup>
|
</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.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: {{vendors.find(vendor => vendor.id === currentContact.vendor) ? vendors.find(vendor => vendor.id === currentContact.vendor).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>E-Mail: {{currentContact.email}}</span><br>
|
||||||
<span>Mobil: {{currentContact.phoneMobile}}</span><br>
|
<span>Mobil: {{currentContact.phoneMobile}}</span><br>
|
||||||
@@ -201,7 +199,7 @@ setupPage()
|
|||||||
:search-attributes="['name']"
|
:search-attributes="['name']"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -217,7 +215,7 @@ setupPage()
|
|||||||
:search-attributes="['name']"
|
:search-attributes="['name']"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|||||||
@@ -20,10 +20,10 @@
|
|||||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
|
||||||
>
|
>
|
||||||
<template #customer-data="{row}">
|
<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>
|
||||||
<template #vendor-data="{row}">
|
<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>
|
||||||
</UTable>
|
</UTable>
|
||||||
|
|
||||||
@@ -36,9 +36,8 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {contacts,customers,vendors} = storeToRefs(useDataStore())
|
|
||||||
const mode = ref("show")
|
const mode = ref("show")
|
||||||
|
|
||||||
const itemColumns = [
|
const itemColumns = [
|
||||||
@@ -74,10 +73,10 @@ const searchString = ref('')
|
|||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
if(!searchString.value) {
|
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 Object.values(item).some((value) => {
|
||||||
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
//
|
const dataStore = useDataStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -12,7 +12,6 @@ const id = ref(route.params.id ? route.params.id : null )
|
|||||||
|
|
||||||
//Store
|
//Store
|
||||||
const {customers, contracts } = storeToRefs(useDataStore())
|
const {customers, contracts } = storeToRefs(useDataStore())
|
||||||
const {fetchCustomers, getCustomerById, getContractById, fetchContracts} = useDataStore()
|
|
||||||
|
|
||||||
let currentContract = null
|
let currentContract = null
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ const itemInfo = ref({
|
|||||||
//Functions
|
//Functions
|
||||||
const setupPage = () => {
|
const setupPage = () => {
|
||||||
if(mode.value === "show" || mode.value === "edit"){
|
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
|
if(mode.value === "edit") itemInfo.value = currentContract
|
||||||
@@ -53,7 +52,7 @@ const createItem = async () => {
|
|||||||
name: ""
|
name: ""
|
||||||
}
|
}
|
||||||
toast.add({title: "Vertrag erfolgreich erstellt"})
|
toast.add({title: "Vertrag erfolgreich erstellt"})
|
||||||
await fetchContracts()
|
await dataStore.fetchContracts()
|
||||||
router.push(`/contracts/show/${data[0].id}`)
|
router.push(`/contracts/show/${data[0].id}`)
|
||||||
setupPage()
|
setupPage()
|
||||||
}
|
}
|
||||||
@@ -84,7 +83,7 @@ const updateCustomer = async () => {
|
|||||||
name: "",
|
name: "",
|
||||||
}
|
}
|
||||||
toast.add({title: "Vertrag erfolgreich gespeichert"})
|
toast.add({title: "Vertrag erfolgreich gespeichert"})
|
||||||
fetchContracts()
|
dataStore.fetchContracts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -110,7 +109,7 @@ setupPage()
|
|||||||
{{currentContract.name}}
|
{{currentContract.name}}
|
||||||
</template>
|
</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
|
<UDivider
|
||||||
class="my-2"
|
class="my-2"
|
||||||
@@ -169,7 +168,7 @@ setupPage()
|
|||||||
:search-attributes="['name']"
|
:search-attributes="['name']"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
|
||||||
>
|
>
|
||||||
<template #customer-data="{row}">
|
<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>
|
</template>
|
||||||
</UTable>
|
</UTable>
|
||||||
|
|
||||||
@@ -33,9 +33,8 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {contracts, customers } = storeToRefs(useDataStore())
|
|
||||||
const mode = ref("show")
|
const mode = ref("show")
|
||||||
|
|
||||||
const itemColumns = [
|
const itemColumns = [
|
||||||
@@ -65,10 +64,10 @@ const searchString = ref('')
|
|||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
if(!searchString.value) {
|
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 Object.values(item).some((value) => {
|
||||||
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
import HistoryDisplay from "~/components/HistoryDisplay.vue";
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
//
|
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const id = ref(route.params.id ? route.params.id : null )
|
const id = ref(route.params.id ? route.params.id : null )
|
||||||
|
const numberRange = useNumberRange("customers")
|
||||||
|
const dataStore = useDataStore()
|
||||||
|
|
||||||
//Store
|
let currentCustomer = ref(null)
|
||||||
const {customers, contacts } = storeToRefs(useDataStore())
|
|
||||||
const {fetchCustomers, getCustomerById, getContactsByCustomerId} = useDataStore()
|
|
||||||
|
|
||||||
let currentCustomer = null
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -22,24 +21,26 @@ let currentCustomer = null
|
|||||||
const mode = ref(route.params.mode || "show")
|
const mode = ref(route.params.mode || "show")
|
||||||
const customerInfo = ref({
|
const customerInfo = ref({
|
||||||
name: "",
|
name: "",
|
||||||
customerNumber: 0,
|
|
||||||
infoData: {},
|
infoData: {},
|
||||||
active: true
|
active: true
|
||||||
})
|
})
|
||||||
|
|
||||||
//Functions
|
//Functions
|
||||||
const setupPage = () => {
|
const setupPage = async () => {
|
||||||
if(mode.value === "show" || mode.value === "edit"){
|
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 () => {
|
const createCustomer = async () => {
|
||||||
|
|
||||||
|
if(!customerInfo.value.customerNumber) customerInfo.value.customerNumber = await numberRange.useNextNumber()
|
||||||
|
|
||||||
|
|
||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
.from("customers")
|
.from("customers")
|
||||||
.insert([customerInfo.value])
|
.insert([customerInfo.value])
|
||||||
@@ -55,14 +56,14 @@ const createCustomer = async () => {
|
|||||||
infoData: {}
|
infoData: {}
|
||||||
}
|
}
|
||||||
toast.add({title: "Kunde erfolgreich erstellt"})
|
toast.add({title: "Kunde erfolgreich erstellt"})
|
||||||
await fetchCustomers()
|
await dataStore.fetchCustomers()
|
||||||
router.push(`/customers/show/${data[0].id}`)
|
router.push(`/customers/show/${data[0].id}`)
|
||||||
setupPage()
|
setupPage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const editCustomer = async () => {
|
const editCustomer = async () => {
|
||||||
router.push(`/customers/edit/${currentCustomer.id}`)
|
router.push(`/customers/edit/${currentCustomer.value.id}`)
|
||||||
setupPage()
|
setupPage()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ const updateCustomer = async () => {
|
|||||||
infoData: {}
|
infoData: {}
|
||||||
}
|
}
|
||||||
toast.add({title: "Kunde erfolgreich gespeichert"})
|
toast.add({title: "Kunde erfolgreich gespeichert"})
|
||||||
fetchCustomers()
|
dataStore.fetchCustomers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -97,203 +98,194 @@ setupPage()
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<UCard v-if="currentCustomer && mode == 'show'" >
|
||||||
<UCard v-if="currentCustomer && mode == 'show'" >
|
<template #header>
|
||||||
<template #header>
|
<UBadge
|
||||||
<UBadge
|
v-if="currentCustomer.active"
|
||||||
v-if="currentCustomer.active"
|
>
|
||||||
>
|
Kunde aktiv
|
||||||
Kunde aktiv
|
</UBadge>
|
||||||
</UBadge>
|
<UBadge
|
||||||
<UBadge
|
|
||||||
v-else
|
v-else
|
||||||
color="red"
|
color="red"
|
||||||
>
|
>
|
||||||
Kunde gesperrt
|
Kunde gesperrt
|
||||||
</UBadge>
|
</UBadge>
|
||||||
{{currentCustomer.name}}
|
{{currentCustomer.name}}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
Kundennummer: {{currentCustomer.customerNumber}} <br>
|
Kundennummer: {{currentCustomer.customerNumber}} <br>
|
||||||
|
|
||||||
<UDivider
|
<UDivider
|
||||||
class="my-2"
|
|
||||||
/>
|
|
||||||
|
|
||||||
Informationen:<br>
|
|
||||||
{{currentCustomer.infoData}}<br>
|
|
||||||
|
|
||||||
<UDivider
|
|
||||||
class="my-2"
|
class="my-2"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
Notizen:<br>
|
Informationen:<br>
|
||||||
{{currentCustomer.notes}}<br>
|
{{currentCustomer.infoData}}<br>
|
||||||
|
|
||||||
<UDivider
|
<UDivider
|
||||||
class="my-2"
|
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>
|
<UFormGroup
|
||||||
<table>
|
label="Kundennummer:"
|
||||||
<tr>
|
>
|
||||||
<th>Anrede</th>
|
<UInput
|
||||||
<th>Name</th>
|
v-model="customerInfo.customerNumber"
|
||||||
<th>Rolle</th>
|
placeholder="Leer lassen für automatisch generierte Nummer"
|
||||||
</tr>
|
/>
|
||||||
<tr v-for="contact in getContactsByCustomerId(currentCustomer.id)">
|
</UFormGroup>
|
||||||
<td>{{contact.salutation}}</td>
|
|
||||||
<td>{{contact.fullName}}</td>
|
|
||||||
<td>{{contact.role}}</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<!-- Kontakte:<br>
|
|
||||||
<!– <ul>
|
|
||||||
<li v-for="contact in currentCustomer.contacts.data">{{contact.lastName}}, {{contact.firstName}}</li>
|
|
||||||
</ul>–>
|
|
||||||
<!– {{currentCustomer.contacts.data}}–>
|
|
||||||
<br>
|
|
||||||
Projekte:<br>
|
|
||||||
<!– <ul>
|
|
||||||
<li v-for="project in currentCustomer.projects.data"><router-link :to="'/projects?id=' + project.id">{{project.name}}</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>
|
|
||||||
<UBadge>{{customerInfo.customerNumber}}</UBadge> {{customerInfo.name}}
|
|
||||||
</template>
|
|
||||||
|
|
||||||
|
<UTooltip text="Ist ein Kunde nicht aktiv so wird er für neue Aufträge gesperrt">
|
||||||
<UFormGroup
|
<UFormGroup
|
||||||
label="Name:"
|
label="Kunde aktiv:"
|
||||||
>
|
>
|
||||||
<UInput
|
<UCheckbox
|
||||||
v-model="customerInfo.name"
|
v-model="customerInfo.active"
|
||||||
/>
|
/>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
</UTooltip>
|
||||||
|
<UFormGroup
|
||||||
|
label="Notizen:"
|
||||||
|
>
|
||||||
|
<UTextarea
|
||||||
|
v-model="customerInfo.notes"
|
||||||
|
/>
|
||||||
|
</UFormGroup>
|
||||||
|
|
||||||
<UFormGroup
|
<UFormGroup
|
||||||
label="Kundennummer:"
|
label="Straße + Hausnummer"
|
||||||
>
|
>
|
||||||
<UInput
|
<UInput
|
||||||
v-model="customerInfo.customerNumber"
|
v-model="customerInfo.infoData.street"
|
||||||
/>
|
/>
|
||||||
</UFormGroup>
|
</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
|
||||||
<UFormGroup
|
label="Telefon:"
|
||||||
label="Kunde aktiv:"
|
>
|
||||||
>
|
<UInput
|
||||||
<UCheckbox
|
v-model="customerInfo.infoData.tel"
|
||||||
v-model="customerInfo.active"
|
/>
|
||||||
/>
|
</UFormGroup>
|
||||||
</UFormGroup>
|
<UFormGroup
|
||||||
</UTooltip>
|
label="E-Mail:"
|
||||||
<UFormGroup
|
>
|
||||||
label="Notizen:"
|
<UInput
|
||||||
>
|
v-model="customerInfo.infoData.email"
|
||||||
<UTextarea
|
/>
|
||||||
v-model="customerInfo.notes"
|
</UFormGroup>
|
||||||
/>
|
<UFormGroup
|
||||||
</UFormGroup>
|
label="Webseite:"
|
||||||
|
>
|
||||||
|
<UInput
|
||||||
|
v-model="customerInfo.infoData.web"
|
||||||
|
/>
|
||||||
|
</UFormGroup>
|
||||||
|
<UFormGroup
|
||||||
|
label="USt-Id:"
|
||||||
|
>
|
||||||
|
<UInput
|
||||||
|
v-model="customerInfo.infoData.ustid"
|
||||||
|
/>
|
||||||
|
</UFormGroup>
|
||||||
|
|
||||||
<UFormGroup
|
<template #footer>
|
||||||
label="Straße + Hausnummer"
|
<UButton
|
||||||
|
v-if="mode == 'edit'"
|
||||||
|
@click="updateCustomer"
|
||||||
>
|
>
|
||||||
<UInput
|
Speichern
|
||||||
v-model="customerInfo.infoData.street"
|
</UButton>
|
||||||
/>
|
<UButton
|
||||||
</UFormGroup>
|
v-else-if="mode == 'create'"
|
||||||
<UFormGroup
|
@click="createCustomer"
|
||||||
label="Postleitzahl"
|
|
||||||
>
|
>
|
||||||
<UInput
|
Erstellen
|
||||||
v-model="customerInfo.infoData.zip"
|
</UButton>
|
||||||
/>
|
<UButton
|
||||||
</UFormGroup>
|
@click="cancelEditorCreate"
|
||||||
<UFormGroup
|
color="red"
|
||||||
label="Ort"
|
class="ml-2"
|
||||||
>
|
>
|
||||||
<UInput
|
Abbrechen
|
||||||
v-model="customerInfo.infoData.city"
|
</UButton>
|
||||||
/>
|
</template>
|
||||||
</UFormGroup>
|
|
||||||
|
|
||||||
<UFormGroup
|
</UCard>
|
||||||
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>
|
|
||||||
|
|
||||||
<template #footer>
|
<HistoryDisplay
|
||||||
<UButton
|
type="customer"
|
||||||
v-if="mode == 'edit'"
|
v-if="currentCustomer"
|
||||||
@click="updateCustomer"
|
:element-id="currentCustomer.id"
|
||||||
>
|
/>
|
||||||
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>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -30,9 +30,8 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {customers } = storeToRefs(useDataStore())
|
|
||||||
const mode = ref("show")
|
const mode = ref("show")
|
||||||
|
|
||||||
const customerColumns = [
|
const customerColumns = [
|
||||||
@@ -59,10 +58,10 @@ const searchString = ref('')
|
|||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
if(!searchString.value) {
|
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 Object.values(item).some((value) => {
|
||||||
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,14 +5,12 @@ import {BlobReader, BlobWriter, ZipWriter} from "@zip.js/zip.js";
|
|||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
const dataStore = useDataStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
const {documents, projects, customers} = storeToRefs(useDataStore())
|
dataStore.fetchDocuments()
|
||||||
const {fetchDocuments, getDocumentTags} = useDataStore()
|
|
||||||
|
|
||||||
fetchDocuments()
|
|
||||||
|
|
||||||
const uploadModalOpen = ref(false)
|
const uploadModalOpen = ref(false)
|
||||||
const uploadInProgress = 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 selectedTags = ref(["Eingang"])
|
||||||
|
|
||||||
const filteredDocuments = computed(() => {
|
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;
|
uploadModalOpen.value = false;
|
||||||
uploadInProgress.value = false;
|
uploadInProgress.value = false;
|
||||||
fetchDocuments()
|
dataStore.fetchDocuments()
|
||||||
}
|
}
|
||||||
|
|
||||||
const downloadSelected = async () => {
|
const downloadSelected = async () => {
|
||||||
const bucket = "files";
|
const bucket = "files";
|
||||||
|
|
||||||
let 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)
|
console.log(files)
|
||||||
|
|
||||||
@@ -154,7 +152,7 @@ const downloadSelected = async () => {
|
|||||||
<UButton @click="uploadModalOpen = true">Hochladen</UButton>
|
<UButton @click="uploadModalOpen = true">Hochladen</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
@click="downloadSelected"
|
@click="downloadSelected"
|
||||||
:disabled="documents.filter(doc => doc.selected).length === 0"
|
:disabled="dataStore.documents.filter(doc => doc.selected).length === 0"
|
||||||
>Herunterladen</UButton>
|
>Herunterladen</UButton>
|
||||||
|
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
|
|||||||
@@ -11,20 +11,20 @@ const route = useRoute()
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const id = ref(route.params.id ? route.params.id : null )
|
const id = ref(route.params.id ? route.params.id : null )
|
||||||
|
const numberRange = useNumberRange("spaces")
|
||||||
|
|
||||||
//Store
|
//Store
|
||||||
const {spaces,movements,products,units,ownTenant} = storeToRefs(useDataStore())
|
const {spaces,movements,products,units,ownTenant, numberRanges} = storeToRefs(useDataStore())
|
||||||
const {fetchSpaces, getSpaceById, movementsBySpace, getProductById} = useDataStore()
|
const {fetchSpaces, getSpaceById, movementsBySpace, getProductById, fetchNumberRanges} = useDataStore()
|
||||||
|
|
||||||
let currentItem = null
|
|
||||||
|
|
||||||
|
|
||||||
|
let currentItem = ref(null)
|
||||||
|
let currentNumberRange = null
|
||||||
|
|
||||||
//Working
|
//Working
|
||||||
const mode = ref(route.params.mode || "show")
|
const mode = ref(route.params.mode || "show")
|
||||||
const itemInfo = ref({
|
const itemInfo = ref({
|
||||||
spaceNumber: 0
|
spaceNumber: ""
|
||||||
})
|
})
|
||||||
const spaceTypes = ["Regalplatz", "Kiste", "Palettenplatz"]
|
const spaceTypes = ["Regalplatz", "Kiste", "Palettenplatz"]
|
||||||
const spaceProducts = ref([])
|
const spaceProducts = ref([])
|
||||||
@@ -32,11 +32,11 @@ const spaceMovements = ref([])
|
|||||||
|
|
||||||
//Functions
|
//Functions
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
|
console.log("Called Setup")
|
||||||
if(mode.value === "show" || mode.value === "edit"){
|
if(mode.value === "show" || mode.value === "edit"){
|
||||||
currentItem = await getSpaceById(Number(useRoute().params.id))
|
currentItem.value = await getSpaceById(Number(useRoute().params.id))
|
||||||
console.log(currentItem)
|
|
||||||
|
|
||||||
spaceMovements.value = movementsBySpace(currentItem.id)
|
spaceMovements.value = await movementsBySpace(currentItem.value.id)
|
||||||
spaceProducts.value = []
|
spaceProducts.value = []
|
||||||
spaceMovements.value.forEach(movement => {
|
spaceMovements.value.forEach(movement => {
|
||||||
if(spaceProducts.value.filter(product => product.id === movement.productId).length === 0) spaceProducts.value.push(getProductById(movement.productId))
|
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 === "edit") itemInfo.value = currentItem.value
|
||||||
|
|
||||||
if(mode.value === "create") {
|
|
||||||
let lastSpaceNumber = 0
|
|
||||||
spaces.value.forEach(space => {
|
|
||||||
if(space.spaceNumber > lastSpaceNumber) lastSpaceNumber = space.spaceNumber
|
|
||||||
})
|
|
||||||
itemInfo.value.spaceNumber = lastSpaceNumber + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const createItem = async () => {
|
const createItem = async () => {
|
||||||
|
|
||||||
|
if(!itemInfo.value.spaceNumber) itemInfo.value.spaceNumber = await numberRange.useNextNumber()
|
||||||
|
|
||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
.from("spaces")
|
.from("spaces")
|
||||||
@@ -70,17 +60,20 @@ const createItem = async () => {
|
|||||||
if(error) {
|
if(error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
} else {
|
} else {
|
||||||
|
console.log(data[0])
|
||||||
mode.value = "show"
|
mode.value = "show"
|
||||||
itemInfo.value = {}
|
|
||||||
toast.add({title: "Lagerplatz erfolgreich erstellt"})
|
toast.add({title: "Lagerplatz erfolgreich erstellt"})
|
||||||
await fetchSpaces()
|
await fetchSpaces()
|
||||||
router.push(`/inventory/spaces/show/${data[0].id}`)
|
router.push(`/inventory/spaces/show/${data[0].id}`)
|
||||||
setupPage()
|
|
||||||
|
|
||||||
|
|
||||||
|
//setupPage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const editItem = async () => {
|
const editItem = async () => {
|
||||||
router.push(`/inventory/spaces/edit/${currentItem.id}`)
|
router.push(`/inventory/spaces/edit/${currentItem.value.id}`)
|
||||||
setupPage()
|
setupPage()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +111,7 @@ const printSpaceLabel = async () => {
|
|||||||
|
|
||||||
|
|
||||||
axios
|
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)
|
.then(console.log)
|
||||||
.catch(console.log)
|
.catch(console.log)
|
||||||
}
|
}
|
||||||
@@ -129,6 +122,10 @@ setupPage()
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<DevOnly>
|
||||||
|
{{currentItem}}
|
||||||
|
{{mode}}
|
||||||
|
</DevOnly>
|
||||||
<UCard v-if="currentItem && mode == 'show'" >
|
<UCard v-if="currentItem && mode == 'show'" >
|
||||||
<template #header>
|
<template #header>
|
||||||
<UBadge>{{currentItem.spaceNumber}}</UBadge> {{currentItem.type}}
|
<UBadge>{{currentItem.spaceNumber}}</UBadge> {{currentItem.type}}
|
||||||
@@ -187,8 +184,8 @@ setupPage()
|
|||||||
|
|
||||||
|
|
||||||
</UCard>
|
</UCard>
|
||||||
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
|
<UCard v-else-if="mode === 'edit' || mode === 'create'" >
|
||||||
<template #header>
|
<template #header v-if="mode === 'edit'">
|
||||||
<UBadge>{{itemInfo.spaceNumber}}</UBadge>{{itemInfo.type}}
|
<UBadge>{{itemInfo.spaceNumber}}</UBadge>{{itemInfo.type}}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,8 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {spaces } = storeToRefs(useDataStore())
|
|
||||||
const mode = ref("show")
|
const mode = ref("show")
|
||||||
|
|
||||||
const itemColumns = [
|
const itemColumns = [
|
||||||
@@ -64,10 +63,10 @@ const searchString = ref('')
|
|||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
if(!searchString.value) {
|
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 Object.values(item).some((value) => {
|
||||||
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,21 +3,15 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
//
|
const dataStore = useDataStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const id = ref(route.params.id ? route.params.id : null )
|
const id = ref(route.params.id ? route.params.id : null )
|
||||||
|
|
||||||
//Store
|
|
||||||
const {jobs, customers} = storeToRefs(useDataStore())
|
|
||||||
const {fetchJobs, getJobById} = useDataStore()
|
|
||||||
|
|
||||||
let currentItem = null
|
let currentItem = null
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Working
|
//Working
|
||||||
const mode = ref(route.params.mode || "show")
|
const mode = ref(route.params.mode || "show")
|
||||||
const itemInfo = ref({
|
const itemInfo = ref({
|
||||||
@@ -30,7 +24,7 @@ const states = ["Offen", "In Bearbeitung", "Erledigt"]
|
|||||||
//Functions
|
//Functions
|
||||||
const setupPage = () => {
|
const setupPage = () => {
|
||||||
if(mode.value === "show" || mode.value === "edit"){
|
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
|
if(mode.value === "edit") itemInfo.value = currentItem
|
||||||
@@ -54,7 +48,7 @@ const createItem = async () => {
|
|||||||
title: "",
|
title: "",
|
||||||
}
|
}
|
||||||
toast.add({title: "Job erfolgreich erstellt"})
|
toast.add({title: "Job erfolgreich erstellt"})
|
||||||
await fetchJobs()
|
await dataStore.fetchJobs()
|
||||||
router.push(`/jobs/show/${data[0].id}`)
|
router.push(`/jobs/show/${data[0].id}`)
|
||||||
setupPage()
|
setupPage()
|
||||||
}
|
}
|
||||||
@@ -85,7 +79,7 @@ const updateItem = async () => {
|
|||||||
title: ""
|
title: ""
|
||||||
}
|
}
|
||||||
toast.add({title: "Job erfolgreich gespeichert"})
|
toast.add({title: "Job erfolgreich gespeichert"})
|
||||||
fetchJobs()
|
dataStore.fetchJobs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -109,17 +103,6 @@ setupPage()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Kontakte:<br>
|
|
||||||
<!– <ul>
|
|
||||||
<li v-for="contact in currentCustomer.contacts.data">{{contact.lastName}}, {{contact.firstName}}</li>
|
|
||||||
</ul>–>
|
|
||||||
<!– {{currentCustomer.contacts.data}}–>
|
|
||||||
<br>
|
|
||||||
Projekte:<br>
|
|
||||||
<!– <ul>
|
|
||||||
<li v-for="project in currentCustomer.projects.data"><router-link :to="'/projects?id=' + project.id">{{project.name}}</router-link></li>
|
|
||||||
</ul>–>-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@@ -169,14 +152,14 @@ setupPage()
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="itemInfo.customer"
|
v-model="itemInfo.customer"
|
||||||
:options="customers"
|
:options="dataStore.customers"
|
||||||
option-attribute="name"
|
option-attribute="name"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
searchable
|
searchable
|
||||||
:search-attributes="['name']"
|
:search-attributes="['name']"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<UButton @click="router.push(`/jobs/create/`)">+ Job</UButton>
|
<UButton @click="router.push(`/jobs/create/`)">+ Job</UButton>
|
||||||
|
|
||||||
<UTable
|
<UTable
|
||||||
:rows="jobs"
|
:rows="dataStore.jobs"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
@select="selectJob"
|
@select="selectJob"
|
||||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
|
||||||
@@ -19,8 +19,8 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {jobs } = storeToRefs(useDataStore())
|
|
||||||
const mode = ref("show")
|
const mode = ref("show")
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
|
|||||||
@@ -13,11 +13,10 @@ watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
|
const dataStore = useDataStore()
|
||||||
const {getResources, getEvents, getEventTypes, fetchEvents} = useDataStore()
|
const resources = dataStore.getResources
|
||||||
const resources = getResources
|
const eventTypes = dataStore.getEventTypes
|
||||||
const eventTypes = getEventTypes
|
const events = dataStore.getEvents
|
||||||
const events = getEvents
|
|
||||||
|
|
||||||
const openNewEventModal = ref(false)
|
const openNewEventModal = ref(false)
|
||||||
const newEventData = ref({
|
const newEventData = ref({
|
||||||
@@ -39,7 +38,7 @@ const createEvent = async () => {
|
|||||||
} else {
|
} else {
|
||||||
openNewEventModal.value = false
|
openNewEventModal.value = false
|
||||||
newEventData.value = {}
|
newEventData.value = {}
|
||||||
fetchEvents()
|
dataStore.fetchEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,18 +3,13 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
//
|
const dataStore = useDataStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const id = ref(route.params.id ? route.params.id : null )
|
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
|
let currentProduct = null
|
||||||
|
|
||||||
|
|
||||||
@@ -29,7 +24,7 @@ const itemInfo = ref({
|
|||||||
//Functions
|
//Functions
|
||||||
const setupPage = () => {
|
const setupPage = () => {
|
||||||
if(mode.value === "show" || mode.value === "edit"){
|
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
|
if(mode.value === "edit") itemInfo.value = currentProduct
|
||||||
@@ -53,7 +48,7 @@ const createItem = async () => {
|
|||||||
name: ""
|
name: ""
|
||||||
}
|
}
|
||||||
toast.add({title: "Artikel erfolgreich erstellt"})
|
toast.add({title: "Artikel erfolgreich erstellt"})
|
||||||
await fetchProducts()
|
await dataStore.fetchProducts()
|
||||||
router.push(`/products/show/${data[0].id}`)
|
router.push(`/products/show/${data[0].id}`)
|
||||||
setupPage()
|
setupPage()
|
||||||
}
|
}
|
||||||
@@ -87,7 +82,7 @@ const updateItem = async () => {
|
|||||||
name: "",
|
name: "",
|
||||||
}
|
}
|
||||||
toast.add({title: "Artikel erfolgreich gespeichert"})
|
toast.add({title: "Artikel erfolgreich gespeichert"})
|
||||||
fetchProducts()
|
dataStore.fetchProducts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -116,20 +111,22 @@ setupPage()
|
|||||||
class="my-2"
|
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
|
{{currentProduct}}
|
||||||
class="my-2"
|
</DevOnly>
|
||||||
/>
|
|
||||||
|
|
||||||
{{currentProduct}}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<UButton
|
<UButton
|
||||||
v-if="mode == 'show' && currentProduct.id"
|
v-if="mode === 'show' && currentProduct.id"
|
||||||
@click="editItem"
|
@click="editItem"
|
||||||
>
|
>
|
||||||
Bearbeiten
|
Bearbeiten
|
||||||
@@ -148,7 +145,7 @@ setupPage()
|
|||||||
|
|
||||||
</UCard>
|
</UCard>
|
||||||
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
|
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
|
||||||
<template #header>
|
<template #header v-if="mode === 'edit'">
|
||||||
{{itemInfo.name}}
|
{{itemInfo.name}}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -171,12 +168,12 @@ setupPage()
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="itemInfo.unit"
|
v-model="itemInfo.unit"
|
||||||
:options="units"
|
:options="dataStore.units"
|
||||||
option-attribute="name"
|
option-attribute="name"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -185,7 +182,7 @@ setupPage()
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="itemInfo.tags"
|
v-model="itemInfo.tags"
|
||||||
:options="ownTenant.tags.products"
|
:options="dataStore.ownTenant.tags.products"
|
||||||
multiple
|
multiple
|
||||||
/>
|
/>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<span v-else>-</span>
|
<span v-else>-</span>
|
||||||
</template>
|
</template>
|
||||||
<template #unit-data="{row}">
|
<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>
|
</template>
|
||||||
</UTable>
|
</UTable>
|
||||||
|
|
||||||
@@ -42,10 +42,9 @@
|
|||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
const dataStore = useDataStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {products,units} = storeToRefs(useDataStore())
|
|
||||||
|
|
||||||
const itemColumns = [
|
const itemColumns = [
|
||||||
{
|
{
|
||||||
@@ -79,10 +78,10 @@ const searchString = ref('')
|
|||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
if(!searchString.value) {
|
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 Object.values(product).some((value) => {
|
||||||
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="createProjectData.customer"
|
v-model="createProjectData.customer"
|
||||||
:options="customers"
|
:options="dataStore.customers"
|
||||||
option-attribute="name"
|
option-attribute="name"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
searchable
|
searchable
|
||||||
@@ -45,103 +45,17 @@
|
|||||||
</UModal>
|
</UModal>
|
||||||
<!-- TODO: USelect im Modal anpassen -->
|
<!-- TODO: USelect im Modal anpassen -->
|
||||||
<UTable
|
<UTable
|
||||||
:rows="projects"
|
:rows="dataStore.projects"
|
||||||
:columns="projectColumns"
|
:columns="projectColumns"
|
||||||
@select="selectProject"
|
@select="selectProject"
|
||||||
|
|
||||||
>
|
>
|
||||||
<template #customer-data="{row}">
|
<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>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
</UTable>
|
</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"
|
|
||||||
|
|
||||||
/>
|
|
||||||
|
|
||||||
|
|
||||||
<!– <router-link v-for="item in projects" :to="`/projects/${item.id}`">
|
|
||||||
<UCard class="listItem">
|
|
||||||
<UBadge>{{item.id}}</UBadge> {{item.name}}
|
|
||||||
</UCard>
|
|
||||||
</router-link>–>
|
|
||||||
|
|
||||||
|
|
||||||
</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}}
|
|
||||||
|
|
||||||
<!– Lieferantenrechnungen: <br>
|
|
||||||
<UTable :rows="dataStore.getVendorInvoicesByProjectId(selectedItem.id)"></UTable>
|
|
||||||
{{dataStore.getVendorInvoicesByProjectId(selectedItem.id)}}–>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</UCard>
|
|
||||||
</div>-->
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
@@ -152,10 +66,9 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {projects,customers} = storeToRefs(useDataStore())
|
|
||||||
const {fetchProjects} = useDataStore()
|
|
||||||
|
|
||||||
const projectColumns = [
|
const projectColumns = [
|
||||||
{
|
{
|
||||||
@@ -184,10 +97,6 @@ const selectProject = (project) => {
|
|||||||
router.push(`/projects/${project.id} `)
|
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 showCreateProject = ref(false)
|
||||||
const createProjectData = ref({
|
const createProjectData = ref({
|
||||||
phases: []
|
phases: []
|
||||||
@@ -210,7 +119,7 @@ const createProject = async () => {
|
|||||||
|
|
||||||
showCreateProject.value = false
|
showCreateProject.value = false
|
||||||
createProjectData.value = {phases: []}
|
createProjectData.value = {phases: []}
|
||||||
fetchProjects()
|
dataStore.fetchProjects()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
102
spaces/pages/settings/numberRanges.vue
Normal file
102
spaces/pages/settings/numberRanges.vue
Normal 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>
|
||||||
@@ -2,13 +2,12 @@
|
|||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
const dataStore = useDataStore()
|
||||||
const {profiles} = storeToRefs(useDataStore())
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
{{profiles}}
|
{{dataStore.profiles}}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -90,14 +90,14 @@
|
|||||||
label="Benutzer ändern:"
|
label="Benutzer ändern:"
|
||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="profiles"
|
:options="dataStore.profiles"
|
||||||
@change="updateTask"
|
@change="updateTask"
|
||||||
v-model="taskData.user"
|
v-model="taskData.user"
|
||||||
option-attribute="firstName"
|
option-attribute="firstName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -130,7 +130,7 @@
|
|||||||
{{ dayjs(row.created_at).format("DD.MM.YY HH:mm") }}
|
{{ dayjs(row.created_at).format("DD.MM.YY HH:mm") }}
|
||||||
</template>
|
</template>
|
||||||
<template #user-data="{row}">
|
<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>
|
</template>
|
||||||
</UTable>
|
</UTable>
|
||||||
|
|
||||||
@@ -148,10 +148,9 @@ definePageMeta({
|
|||||||
middleware: "auth",
|
middleware: "auth",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const {tasks, profiles} = storeToRefs(useDataStore())
|
|
||||||
const {fetchTasks} = useDataStore()
|
|
||||||
|
|
||||||
const taskColumns = [
|
const taskColumns = [
|
||||||
{
|
{
|
||||||
@@ -185,7 +184,7 @@ const showDoneTasks = ref(false)
|
|||||||
const searchString = ref("")
|
const searchString = ref("")
|
||||||
const filteredRows = computed(() => {
|
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) {
|
if(!searchString.value) {
|
||||||
return filteredTasks
|
return filteredTasks
|
||||||
@@ -224,7 +223,7 @@ const createTask = async () => {
|
|||||||
|
|
||||||
showCreateTask.value = false
|
showCreateTask.value = false
|
||||||
createTaskData.value = {}
|
createTaskData.value = {}
|
||||||
fetchTasks()
|
dataStore.fetchTasks()
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateTask = async () => {
|
const updateTask = async () => {
|
||||||
@@ -243,7 +242,7 @@ const updateTask = async () => {
|
|||||||
toast.add({title: "Aufgabe aktualisiert"})
|
toast.add({title: "Aufgabe aktualisiert"})
|
||||||
taskData.value = {}
|
taskData.value = {}
|
||||||
showTaskModal.value = false
|
showTaskModal.value = false
|
||||||
fetchTasks()
|
dataStore.fetchTasks()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,12 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const user = useSupabaseUser()
|
const user = useSupabaseUser()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
const {times, projects, profiles, jobs} = storeToRefs(useDataStore())
|
const timeTypes = dataStore.getTimeTypes
|
||||||
const {fetchTimes, getTimeTypes} = useDataStore()
|
|
||||||
const timeTypes = getTimeTypes
|
|
||||||
const timeInfo = ref({
|
const timeInfo = ref({
|
||||||
user: "",
|
user: "",
|
||||||
start: "",
|
start: "",
|
||||||
@@ -100,7 +99,7 @@ const startTime = async () => {
|
|||||||
console.log(error)
|
console.log(error)
|
||||||
} else if(data) {
|
} else if(data) {
|
||||||
timeInfo.value = data[0]
|
timeInfo.value = data[0]
|
||||||
await fetchTimes()
|
await dataStore.fetchTimes()
|
||||||
runningTimeInfo.value = times.value.find(time => time.user == user.value.id && !time.end)
|
runningTimeInfo.value = times.value.find(time => time.user == user.value.id && !time.end)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +127,7 @@ const stopStartedTime = async () => {
|
|||||||
} else {
|
} else {
|
||||||
toast.add({title: "Zeit erfolgreich gestoppt"})
|
toast.add({title: "Zeit erfolgreich gestoppt"})
|
||||||
runningTimeInfo.value = {}
|
runningTimeInfo.value = {}
|
||||||
fetchTimes()
|
dataStore.fetchTimes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +148,7 @@ const createTime = async () => {
|
|||||||
createTimeInfo.value = {}
|
createTimeInfo.value = {}
|
||||||
toast.add({title: "Zeit erfolgreich erstellt"})
|
toast.add({title: "Zeit erfolgreich erstellt"})
|
||||||
showAddTimeModal.value = false
|
showAddTimeModal.value = false
|
||||||
await fetchTimes()
|
await dataStore.fetchTimes()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,13 +210,13 @@ const selectStartedTime = () => {
|
|||||||
label="Projekt:"
|
label="Projekt:"
|
||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="projects"
|
:options="dataStore.projects"
|
||||||
option-attribute="name"
|
option-attribute="name"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
v-model="runningTimeInfo.projectId"
|
v-model="runningTimeInfo.projectId"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -226,13 +225,13 @@ const selectStartedTime = () => {
|
|||||||
label="Job:"
|
label="Job:"
|
||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="jobs"
|
:options="dataStore.jobs"
|
||||||
option-attribute="title"
|
option-attribute="title"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
v-model="runningTimeInfo.job"
|
v-model="runningTimeInfo.job"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -302,13 +301,13 @@ const selectStartedTime = () => {
|
|||||||
label="Benutzer:"
|
label="Benutzer:"
|
||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="profiles"
|
:options="dataStore.profiles"
|
||||||
v-model="createTimeInfo.user"
|
v-model="createTimeInfo.user"
|
||||||
option-attribute="firstName"
|
option-attribute="firstName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -316,13 +315,13 @@ const selectStartedTime = () => {
|
|||||||
label="Projekt:"
|
label="Projekt:"
|
||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="projects"
|
:options="dataStore.projects"
|
||||||
v-model="createTimeInfo.projectId"
|
v-model="createTimeInfo.projectId"
|
||||||
option-attribute="name"
|
option-attribute="name"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -330,13 +329,13 @@ const selectStartedTime = () => {
|
|||||||
label="Job:"
|
label="Job:"
|
||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="jobs"
|
:options="dataStore.jobs"
|
||||||
option-attribute="title"
|
option-attribute="title"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
v-model="createTimeInfo.job"
|
v-model="createTimeInfo.job"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -382,7 +381,7 @@ const selectStartedTime = () => {
|
|||||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
|
||||||
>
|
>
|
||||||
<template #user-data="{row}">
|
<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>
|
||||||
|
|
||||||
<template #start-data="{row}">
|
<template #start-data="{row}">
|
||||||
|
|||||||
@@ -3,17 +3,13 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
//
|
const dataStore = useDataStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const id = ref(route.params.id ? route.params.id : null )
|
const id = ref(route.params.id ? route.params.id : null )
|
||||||
|
|
||||||
//Store
|
|
||||||
const {vehicles, profiles } = storeToRefs(useDataStore())
|
|
||||||
const {fetchVehicles, getVehicleById} = useDataStore()
|
|
||||||
|
|
||||||
let currentItem = null
|
let currentItem = null
|
||||||
|
|
||||||
|
|
||||||
@@ -31,7 +27,7 @@ const itemInfo = ref({
|
|||||||
//Functions
|
//Functions
|
||||||
const setupPage = () => {
|
const setupPage = () => {
|
||||||
if(mode.value === "show" || mode.value === "edit"){
|
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
|
if(mode.value === "edit") itemInfo.value = currentItem
|
||||||
@@ -55,7 +51,7 @@ const createItem = async () => {
|
|||||||
name: ""
|
name: ""
|
||||||
}
|
}
|
||||||
toast.add({title: "Fahrzeug erfolgreich erstellt"})
|
toast.add({title: "Fahrzeug erfolgreich erstellt"})
|
||||||
await fetchVehicles()
|
await dataStore.fetchVehicles()
|
||||||
router.push(`/vehicles/show/${data[0].id}`)
|
router.push(`/vehicles/show/${data[0].id}`)
|
||||||
setupPage()
|
setupPage()
|
||||||
}
|
}
|
||||||
@@ -92,14 +88,10 @@ const updateCustomer = async () => {
|
|||||||
type: ""
|
type: ""
|
||||||
}
|
}
|
||||||
toast.add({title: "Fahrzeug erfolgreich gespeichert"})
|
toast.add({title: "Fahrzeug erfolgreich gespeichert"})
|
||||||
fetchVehicles()
|
dataStore.fetchVehicles()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setupPage()
|
setupPage()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -122,7 +114,7 @@ setupPage()
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
Typ: {{currentItem.type}} <br>
|
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>
|
||||||
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
|
<UCard v-else-if="mode == 'edit' || mode == 'create'" >
|
||||||
<template #header>
|
<template #header v-if="mode === 'edit'">
|
||||||
{{itemInfo.licensePlate}}
|
{{itemInfo.licensePlate}}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -180,13 +172,13 @@ setupPage()
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="itemInfo.driver"
|
v-model="itemInfo.driver"
|
||||||
:options="profiles"
|
:options="dataStore.profiles"
|
||||||
option-attribute="fullName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
|
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {vehicles } = storeToRefs(useDataStore())
|
const {vehicles } = storeToRefs(useDataStore())
|
||||||
const mode = ref("show")
|
const mode = ref("show")
|
||||||
@@ -58,10 +58,10 @@ const searchString = ref('')
|
|||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
if(!searchString.value) {
|
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 Object.values(item).some((value) => {
|
||||||
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="previewDoc"
|
class="previewDoc"
|
||||||
>
|
>
|
||||||
@@ -22,14 +17,14 @@
|
|||||||
<UFormGroup label="Lieferant:" required>
|
<UFormGroup label="Lieferant:" required>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="itemInfo.vendor"
|
v-model="itemInfo.vendor"
|
||||||
:options="vendors"
|
:options="dataStore.vendors"
|
||||||
option-attribute="name"
|
option-attribute="name"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
searchable
|
searchable
|
||||||
:search-attributes="['name','vendorNumber']"
|
:search-attributes="['name','vendorNumber']"
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -109,12 +104,13 @@
|
|||||||
import InputGroup from "~/components/InputGroup.vue";
|
import InputGroup from "~/components/InputGroup.vue";
|
||||||
import * as dayjs from "dayjs";
|
import * as dayjs from "dayjs";
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
const {vendors} = storeToRefs(useDataStore())
|
const {vendors} = storeToRefs(useDataStore())
|
||||||
const {getVendorInvoiceById, getDocumentById, fetchVendorInvoices} = useDataStore()
|
const {fetchVendorInvoices} = useDataStore()
|
||||||
|
|
||||||
let currentVendorInvoice = null
|
let currentVendorInvoice = null
|
||||||
let currentDocument = ref(null)
|
let currentDocument = ref(null)
|
||||||
@@ -125,14 +121,11 @@ const mode = ref(route.params.mode || "show")
|
|||||||
//Functions
|
//Functions
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
if(mode.value === "show" || mode.value === "edit"){
|
if(mode.value === "show" || mode.value === "edit"){
|
||||||
currentVendorInvoice = await getVendorInvoiceById(Number(useRoute().params.id))
|
currentVendorInvoice = await dataStore.getVendorInvoiceById(Number(useRoute().params.id))
|
||||||
currentDocument.value = await getDocumentById(currentVendorInvoice.document)
|
currentDocument.value = await dataStore.getDocumentById(currentVendorInvoice.document)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mode.value === "edit") itemInfo.value = currentVendorInvoice
|
if(mode.value === "edit") itemInfo.value = currentVendorInvoice
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -162,7 +155,7 @@ const updateItem = async () => {
|
|||||||
id: 0,
|
id: 0,
|
||||||
}*/
|
}*/
|
||||||
toast.add({title: "Eingangsrechnung erfolgreich gespeichert"})
|
toast.add({title: "Eingangsrechnung erfolgreich gespeichert"})
|
||||||
fetchVendorInvoices()
|
dataStore.fetchVendorInvoices()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<template #vendor-data="{row}">
|
<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>
|
||||||
<template #date-data="{row}">
|
<template #date-data="{row}">
|
||||||
{{row.date ? dayjs(row.date).format("DD.MM.YY") : ''}}
|
{{row.date ? dayjs(row.date).format("DD.MM.YY") : ''}}
|
||||||
@@ -58,9 +58,8 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {vendorInvoices, vendors} = storeToRefs(useDataStore())
|
|
||||||
const mode = ref("show")
|
const mode = ref("show")
|
||||||
|
|
||||||
const itemColumns = [
|
const itemColumns = [
|
||||||
@@ -107,10 +106,10 @@ const searchString = ref('')
|
|||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
if(!searchString.value) {
|
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 Object.values(item).some((value) => {
|
||||||
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
||||||
})
|
})
|
||||||
|
|||||||
13
spaces/pages/vendors/[mode]/[[id]].vue
vendored
13
spaces/pages/vendors/[mode]/[[id]].vue
vendored
@@ -3,18 +3,13 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
//
|
const dataStore = useDataStore()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const id = ref(route.params.id ? route.params.id : null )
|
const id = ref(route.params.id ? route.params.id : null )
|
||||||
|
|
||||||
|
|
||||||
//Store
|
|
||||||
const {vendors } = storeToRefs(useDataStore())
|
|
||||||
const {fetchVendors, getVendorById} = useDataStore()
|
|
||||||
|
|
||||||
let currentItem = null
|
let currentItem = null
|
||||||
|
|
||||||
|
|
||||||
@@ -26,7 +21,7 @@ const itemInfo = ref({})
|
|||||||
//Functions
|
//Functions
|
||||||
const setupPage = () => {
|
const setupPage = () => {
|
||||||
if(mode.value === "show" || mode.value === "edit"){
|
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
|
if(mode.value === "edit") itemInfo.value = currentItem
|
||||||
@@ -47,7 +42,7 @@ const createItem = async () => {
|
|||||||
mode.value = "show"
|
mode.value = "show"
|
||||||
itemInfo.value = {}
|
itemInfo.value = {}
|
||||||
toast.add({title: "Lieferant erfolgreich erstellt"})
|
toast.add({title: "Lieferant erfolgreich erstellt"})
|
||||||
await fetchVendors()
|
await dataStore.fetchVendors()
|
||||||
router.push(`/vendors/show/${data[0].id}`)
|
router.push(`/vendors/show/${data[0].id}`)
|
||||||
setupPage()
|
setupPage()
|
||||||
}
|
}
|
||||||
@@ -74,7 +69,7 @@ const updateItem = async () => {
|
|||||||
mode.value = "show"
|
mode.value = "show"
|
||||||
itemInfo.value = {}
|
itemInfo.value = {}
|
||||||
toast.add({title: "Lieferant erfolgreich gespeichert"})
|
toast.add({title: "Lieferant erfolgreich gespeichert"})
|
||||||
fetchVendors()
|
dataStore.fetchVendors()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
7
spaces/pages/vendors/index.vue
vendored
7
spaces/pages/vendors/index.vue
vendored
@@ -29,9 +29,8 @@ definePageMeta({
|
|||||||
middleware: "auth"
|
middleware: "auth"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const dataStore = useDataStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {vendors } = storeToRefs(useDataStore())
|
|
||||||
const mode = ref("show")
|
const mode = ref("show")
|
||||||
|
|
||||||
const itemColumns = [
|
const itemColumns = [
|
||||||
@@ -58,10 +57,10 @@ const searchString = ref('')
|
|||||||
|
|
||||||
const filteredRows = computed(() => {
|
const filteredRows = computed(() => {
|
||||||
if(!searchString.value) {
|
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 Object.values(item).some((value) => {
|
||||||
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,288 +2,424 @@ import {defineStore} from 'pinia'
|
|||||||
|
|
||||||
import {createClient} from '@supabase/supabase-js'
|
import {createClient} from '@supabase/supabase-js'
|
||||||
|
|
||||||
const supabase = createClient('https://uwppvcxflrcsibuzsbil.supabase.co','eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV3cHB2Y3hmbHJjc2lidXpzYmlsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDA5MzgxOTQsImV4cCI6MjAxNjUxNDE5NH0.CkxYSQH0uLfwx9GVUlO6AYMU2FMLAxGMrwEKvyPv7Oo')
|
//const supabase = createClient('https://uwppvcxflrcsibuzsbil.supabase.co','eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV3cHB2Y3hmbHJjc2lidXpzYmlsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDA5MzgxOTQsImV4cCI6MjAxNjUxNDE5NH0.CkxYSQH0uLfwx9GVUlO6AYMU2FMLAxGMrwEKvyPv7Oo')
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
export const useDataStore = defineStore('data', {
|
export const useDataStore = defineStore('data', () => {
|
||||||
state: () => ({
|
|
||||||
loaded: false,
|
const supabase = useSupabaseClient()
|
||||||
ownTenant: {
|
const user = useSupabaseUser()
|
||||||
calendarConfig: {
|
const toast = useToast()
|
||||||
eventTypes: [] as any[]
|
|
||||||
},
|
const loaded = ref(false)
|
||||||
timeConfig: {
|
const ownTenant = ref({
|
||||||
timeTypes: [] as any[]
|
calendarConfig: {
|
||||||
},
|
eventTypes: [] as any[]
|
||||||
tags: {
|
},
|
||||||
documents: [] as any[],
|
timeConfig: {
|
||||||
|
timeTypes: [] as any[]
|
||||||
|
},
|
||||||
|
tags: {
|
||||||
|
documents: [] as any[],
|
||||||
products: [] as any[]
|
products: [] as any[]
|
||||||
}
|
|
||||||
},
|
|
||||||
profiles: [] as any[],
|
|
||||||
events: [] as any[],
|
|
||||||
customers: [] as any[],
|
|
||||||
tasks: [] as any[],
|
|
||||||
projects: [] as any[],
|
|
||||||
documents: [] as any[],
|
|
||||||
spaces: [] as any[],
|
|
||||||
units: [] as any[],
|
|
||||||
times: [] as any[],
|
|
||||||
products: [] as any[],
|
|
||||||
movements: [] as any[],
|
|
||||||
forms: [] as any[],
|
|
||||||
contracts: [] as any[],
|
|
||||||
jobs: [] as any[],
|
|
||||||
formSubmits: [] as any[],
|
|
||||||
contacts: [] as any[],
|
|
||||||
vehicles: [] as any[],
|
|
||||||
vendors: [] as any[],
|
|
||||||
vendorInvoices: [] as any[],
|
|
||||||
bankAccounts: [] as any[],
|
|
||||||
bankStatements: [] as any[]
|
|
||||||
}),
|
|
||||||
actions: {
|
|
||||||
async fetchData() {
|
|
||||||
this.fetchDocuments()
|
|
||||||
await this.fetchOwnTenant()
|
|
||||||
await this.fetchProfiles()
|
|
||||||
await this.fetchEvents()
|
|
||||||
await this.fetchTasks()
|
|
||||||
await this.fetchProjects()
|
|
||||||
await this.fetchTimes()
|
|
||||||
await this.fetchJobs()
|
|
||||||
this.loaded = true
|
|
||||||
|
|
||||||
|
|
||||||
await this.fetchCustomers()
|
|
||||||
await this.fetchContracts()
|
|
||||||
await this.fetchContacts()
|
|
||||||
await this.fetchForms()
|
|
||||||
await this.fetchFormSubmits()
|
|
||||||
await this.fetchProducts()
|
|
||||||
await this.fetchUnits()
|
|
||||||
//await this.fetchDocuments()
|
|
||||||
await this.fetchMovements()
|
|
||||||
await this.fetchSpaces()
|
|
||||||
await this.fetchVehicles()
|
|
||||||
await this.fetchVendors()
|
|
||||||
await this.fetchVendorInvoices()
|
|
||||||
await this.fetchBankAccounts()
|
|
||||||
await this.fetchBankStatements()
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
async clearStore() {
|
|
||||||
console.log("Clear")
|
|
||||||
this.loaded = false
|
|
||||||
this.ownTenant = {}
|
|
||||||
this.profiles= []
|
|
||||||
this.events= []
|
|
||||||
this.customers= []
|
|
||||||
this.tasks= []
|
|
||||||
this.projects= []
|
|
||||||
this.documents= []
|
|
||||||
this.spaces= []
|
|
||||||
this.units= []
|
|
||||||
this.times= []
|
|
||||||
this.products= []
|
|
||||||
this.movements= []
|
|
||||||
this.forms= []
|
|
||||||
this.contracts= []
|
|
||||||
this.jobs= []
|
|
||||||
this.formSubmits= []
|
|
||||||
this.contacts= []
|
|
||||||
this.vehicles= []
|
|
||||||
this.vendors= []
|
|
||||||
this.vendorInvoices= []
|
|
||||||
this.bankAccounts= []
|
|
||||||
this.bankStatements= []
|
|
||||||
},
|
|
||||||
async fetchOwnTenant() {
|
|
||||||
//TODO: Tenant ID Dynamisch machen
|
|
||||||
// @ts-ignore
|
|
||||||
this.ownTenant = (await supabase.from("tenants").select().eq('id', 1)).data[0]
|
|
||||||
},
|
|
||||||
async fetchProfiles() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.profiles = (await supabase.from("profiles").select()).data
|
|
||||||
},
|
|
||||||
async fetchBankAccounts() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.bankAccounts = (await supabase.from("bankAccounts").select()).data
|
|
||||||
},
|
|
||||||
async fetchBankStatements() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.bankStatements = (await supabase.from("bankStatements").select()).data
|
|
||||||
},
|
|
||||||
async fetchEvents() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.events = (await supabase.from("events").select()).data
|
|
||||||
},
|
|
||||||
async fetchContracts() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.contracts = (await supabase.from("contracts").select()).data
|
|
||||||
},
|
|
||||||
async fetchContacts() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.contacts = (await supabase.from("contacts").select()).data
|
|
||||||
},
|
|
||||||
async fetchCustomers() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.customers = (await supabase.from("customers").select().order('customerNumber', {ascending: true})).data
|
|
||||||
},
|
|
||||||
async fetchTasks() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.tasks = (await supabase.from("tasks").select()).data
|
|
||||||
},
|
|
||||||
async fetchForms() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.forms = (await supabase.from("forms").select()).data
|
|
||||||
},
|
|
||||||
async fetchFormSubmits() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.formSubmits = (await supabase.from("formSubmits").select()).data
|
|
||||||
},
|
|
||||||
async fetchProducts() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.products = (await supabase.from("products").select().order('id',{ascending: true})).data
|
|
||||||
},
|
|
||||||
async fetchUnits() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.units = (await supabase.from("units").select()).data
|
|
||||||
},
|
|
||||||
async fetchProjects() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.projects = (await supabase.from("projects").select()).data
|
|
||||||
},
|
|
||||||
async fetchSpaces() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.spaces = (await supabase.from("spaces").select().order('spaceNumber', {ascending: true})).data
|
|
||||||
},
|
|
||||||
async fetchMovements() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.movements = (await supabase.from("movements").select()).data
|
|
||||||
},
|
|
||||||
async fetchVehicles() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.vehicles = (await supabase.from("vehicles").select()).data
|
|
||||||
},
|
|
||||||
async fetchTimes() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.times = (await supabase.from("times").select()).data
|
|
||||||
},
|
|
||||||
async fetchJobs() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.jobs = (await supabase.from("jobs").select()).data
|
|
||||||
},
|
|
||||||
async fetchVendors() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.vendors = (await supabase.from("vendors").select().order('vendorNumber',{ascending: true})).data
|
|
||||||
},
|
|
||||||
async fetchVendorInvoices() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.vendorInvoices = (await supabase.from("vendorInvoices").select()).data
|
|
||||||
},
|
|
||||||
async fetchDocuments() {
|
|
||||||
// @ts-ignore
|
|
||||||
this.documents = (await supabase.from("documents").select()).data
|
|
||||||
|
|
||||||
for(const [index,doc] of this.documents.entries()){
|
|
||||||
// @ts-ignore
|
|
||||||
this.documents[index].url = (await supabase.storage.from('files').createSignedUrl(doc.path, 60 * 60)).data.signedUrl
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
getters: {
|
const profiles = ref([])
|
||||||
getProfileById: (state) => (userUid:string) => state.profiles.find(profile => profile.id === userUid),
|
const events = ref([])
|
||||||
getOpenTasksCount: (state) => state.tasks.filter(task => task.categorie != "Erledigt").length,
|
const customers = ref([])
|
||||||
movementsBySpace: (state) => (spaceId:number) => state.movements.filter(move => move.spaceId === spaceId),
|
const tasks = ref([])
|
||||||
getStockByProductId: (state) => (productId:number) => {
|
const projects = ref([])
|
||||||
let movements = state.movements.filter((movement:any) => movement.productId === productId)
|
const documents = ref([])
|
||||||
|
const spaces = ref([])
|
||||||
|
const units = ref([])
|
||||||
|
const times = ref([])
|
||||||
|
const products = ref([])
|
||||||
|
const movements = ref([])
|
||||||
|
const forms = ref([])
|
||||||
|
const contracts = ref([])
|
||||||
|
const jobs = ref([])
|
||||||
|
const formSubmits = ref([])
|
||||||
|
const contacts = ref([])
|
||||||
|
const vehicles = ref([])
|
||||||
|
const vendors = ref([])
|
||||||
|
const vendorInvoices = ref([])
|
||||||
|
const bankAccounts = ref([])
|
||||||
|
const bankStatements = ref([])
|
||||||
|
const historyItems = ref([])
|
||||||
|
const numberRanges = ref([])
|
||||||
|
|
||||||
let count = 0
|
async function fetchData () {
|
||||||
|
fetchDocuments()
|
||||||
movements.forEach(movement => count += movement.quantity)
|
await fetchOwnTenant()
|
||||||
|
await fetchProfiles()
|
||||||
return count
|
await fetchEvents()
|
||||||
|
await fetchTasks()
|
||||||
},
|
await fetchProjects()
|
||||||
getProductById: (state) => (productId:number) => state.products.find(product => product.id === productId),
|
await fetchTimes()
|
||||||
getVendorById: (state) => (itemId:number) => state.vendors.find(item => item.id === itemId),
|
await fetchJobs()
|
||||||
getVendorInvoiceById: (state) => (itemId:number) => state.vendorInvoices.find(item => item.id === itemId),
|
await fetchCustomers()
|
||||||
getContractById: (state) => (itemId:number) => state.contracts.find(item => item.id === itemId),
|
await fetchContracts()
|
||||||
getContactById: (state) => (itemId:number) => state.contacts.find(item => item.id === itemId),
|
await fetchContacts()
|
||||||
getVehicleById: (state) => (itemId:number) => state.vehicles.find(item => item.id === itemId),
|
await fetchForms()
|
||||||
getDocumentById: (state) => (itemId:number) => state.documents.find(item => item.id === itemId),
|
await fetchFormSubmits()
|
||||||
getSpaceById: (state) => (itemId:number) => state.spaces.find(item => item.id === itemId),
|
await fetchProducts()
|
||||||
getProjectById: (state) => (projectId:number) => {
|
await fetchUnits()
|
||||||
let project = state.projects.find(project => project.id === projectId)
|
//await fetchDocuments()
|
||||||
|
await fetchMovements()
|
||||||
let projectHours = 0
|
await fetchSpaces()
|
||||||
|
await fetchVehicles()
|
||||||
let projectTimes = state.times.filter(time => time.projectId === projectId)
|
await fetchVendors()
|
||||||
projectTimes.forEach(time => projectHours += time.duration)
|
await fetchVendorInvoices()
|
||||||
|
await fetchBankAccounts()
|
||||||
project.projectHours = projectHours
|
await fetchBankStatements()
|
||||||
|
await fetchHistoryItems()
|
||||||
return project
|
await fetchNumberRanges()
|
||||||
|
loaded.value = true
|
||||||
},
|
|
||||||
getCustomerById: (state) => (customerId:number) => state.customers.find(customer => customer.id === customerId),
|
|
||||||
getJobById: (state) => (jobId:number) => state.jobs.find(job => job.id === jobId),
|
|
||||||
getContactsByCustomerId: (state) => (customerId) => state.contacts.filter(contact => contact.customer === customerId),
|
|
||||||
getTimesByProjectId: (state) => (projectId:number) => {
|
|
||||||
let times = state.times.filter(time => time.projectId === projectId)
|
|
||||||
console.log(times.length)
|
|
||||||
|
|
||||||
/*const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
|
|
||||||
((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
|
|
||||||
|
|
||||||
times.forEach((time,index) => {
|
|
||||||
times[index].duration = Math.round(mapNumRange(Math.abs(new Date(time.end) - new Date(time.start))/1000/60,0,60,0,1)*100)/100
|
|
||||||
|
|
||||||
})*/
|
|
||||||
|
|
||||||
return times
|
|
||||||
|
|
||||||
},
|
|
||||||
getDocumentsByProjectId:(state) => (itemId: number) => state.documents.filter(item => item.project == itemId ),
|
|
||||||
getFormSubmitsWithLabelProp: (state) => (state.formSubmits.map(submit => {return{...submit, label: submit.id}})),
|
|
||||||
getResources: (state) => {
|
|
||||||
return [
|
|
||||||
...state.profiles.map(profile => {
|
|
||||||
return {
|
|
||||||
type: 'person',
|
|
||||||
title: profile.firstName + ' ' + profile.lastName,
|
|
||||||
id: profile.id
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
...state.vehicles.map(vehicle => {
|
|
||||||
return {
|
|
||||||
type: 'vehicle',
|
|
||||||
title: vehicle.licensePlate,
|
|
||||||
id: vehicle.licensePlate
|
|
||||||
}
|
|
||||||
})
|
|
||||||
]
|
|
||||||
},
|
|
||||||
getEvents: (state) => {
|
|
||||||
|
|
||||||
return [
|
|
||||||
...state.events.map(event => {
|
|
||||||
let eventColor = state.ownTenant.calendarConfig.eventTypes.find(type => type.label === event.type).color
|
|
||||||
|
|
||||||
return {
|
|
||||||
...event,
|
|
||||||
borderColor: eventColor,
|
|
||||||
textColor: eventColor,
|
|
||||||
backgroundColor: "black"
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
]
|
|
||||||
},
|
|
||||||
getEventTypes: (state) => state.ownTenant.calendarConfig.eventTypes,
|
|
||||||
getTimeTypes: (state) => state.ownTenant.timeConfig.timeTypes,
|
|
||||||
getDocumentTags: (state) => state.ownTenant.tags.documents,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearStore () {
|
||||||
|
console.log("Clear")
|
||||||
|
loaded.value = false
|
||||||
|
ownTenant.value = {}
|
||||||
|
profiles.value= []
|
||||||
|
events.value= []
|
||||||
|
customers.value= []
|
||||||
|
tasks.value= []
|
||||||
|
projects.value= []
|
||||||
|
documents.value= []
|
||||||
|
spaces.value= []
|
||||||
|
units.value= []
|
||||||
|
times.value= []
|
||||||
|
products.value= []
|
||||||
|
movements.value= []
|
||||||
|
forms.value= []
|
||||||
|
contracts.value= []
|
||||||
|
jobs.value= []
|
||||||
|
formSubmits.value= []
|
||||||
|
contacts.value= []
|
||||||
|
vehicles.value= []
|
||||||
|
vendors.value= []
|
||||||
|
vendorInvoices.value= []
|
||||||
|
bankAccounts.value= []
|
||||||
|
bankStatements.value= []
|
||||||
|
historyItems.value = []
|
||||||
|
numberRanges.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchOwnTenant () {
|
||||||
|
ownTenant.value = (await supabase.from("tenants").select().eq('id', user.value?.app_metadata.tenant)).data[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchProfiles () {
|
||||||
|
profiles.value = (await supabase.from("profiles").select()).data
|
||||||
|
}
|
||||||
|
async function fetchBankAccounts () {
|
||||||
|
bankAccounts.value = (await supabase.from("bankAccounts").select()).data
|
||||||
|
}
|
||||||
|
async function fetchBankStatements () {
|
||||||
|
bankStatements.value = (await supabase.from("bankStatements").select()).data
|
||||||
|
}
|
||||||
|
async function fetchEvents () {
|
||||||
|
events.value = (await supabase.from("events").select()).data
|
||||||
|
}
|
||||||
|
async function fetchContracts () {
|
||||||
|
contracts.value = (await supabase.from("contracts").select()).data
|
||||||
|
}
|
||||||
|
async function fetchContacts () {
|
||||||
|
contacts.value = (await supabase.from("contacts").select()).data
|
||||||
|
}
|
||||||
|
async function fetchCustomers () {
|
||||||
|
customers.value = (await supabase.from("customers").select().order("customerNumber", {ascending:true})).data
|
||||||
|
}
|
||||||
|
async function fetchTasks () {
|
||||||
|
tasks.value = (await supabase.from("tasks").select()).data
|
||||||
|
}
|
||||||
|
async function fetchForms () {
|
||||||
|
forms.value = (await supabase.from("forms").select()).data
|
||||||
|
}
|
||||||
|
async function fetchFormSubmits () {
|
||||||
|
formSubmits.value = (await supabase.from("formSubmits").select()).data
|
||||||
|
}
|
||||||
|
async function fetchProducts () {
|
||||||
|
products.value = (await supabase.from("products").select()).data
|
||||||
|
}
|
||||||
|
async function fetchUnits () {
|
||||||
|
units.value = (await supabase.from("units").select()).data
|
||||||
|
}
|
||||||
|
async function fetchProjects () {
|
||||||
|
projects.value = (await supabase.from("projects").select()).data
|
||||||
|
}
|
||||||
|
async function fetchSpaces () {
|
||||||
|
spaces.value = (await supabase.from("spaces").select()).data
|
||||||
|
}
|
||||||
|
async function fetchMovements () {
|
||||||
|
movements.value = (await supabase.from("movements").select()).data
|
||||||
|
}
|
||||||
|
async function fetchVehicles () {
|
||||||
|
vehicles.value = (await supabase.from("vehicles").select()).data
|
||||||
|
}
|
||||||
|
async function fetchTimes () {
|
||||||
|
times.value = (await supabase.from("times").select()).data
|
||||||
|
}
|
||||||
|
async function fetchJobs () {
|
||||||
|
jobs.value = (await supabase.from("jobs").select()).data
|
||||||
|
}
|
||||||
|
async function fetchHistoryItems () {
|
||||||
|
historyItems.value = (await supabase.from("historyItems").select()).data
|
||||||
|
}
|
||||||
|
async function fetchVendors () {
|
||||||
|
vendors.value = (await supabase.from("vendors").select()).data
|
||||||
|
}
|
||||||
|
async function fetchVendorInvoices () {
|
||||||
|
vendorInvoices.value = (await supabase.from("vendorInvoices").select()).data
|
||||||
|
}
|
||||||
|
async function fetchNumberRanges () {
|
||||||
|
numberRanges.value = (await supabase.from("numberRanges").select()).data
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchDocuments () {
|
||||||
|
documents.value = (await supabase.from("documents").select()).data
|
||||||
|
|
||||||
|
for(const [index,doc] of documents.value.entries()){
|
||||||
|
// @ts-ignore
|
||||||
|
documents.value[index].url = (await supabase.storage.from('files').createSignedUrl(doc.path, 60 * 60)).data.signedUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function addHistoryItem(text: String, user: String, elementId: String, resourceType: String) {
|
||||||
|
let data = {
|
||||||
|
user: user,
|
||||||
|
text: text
|
||||||
|
}
|
||||||
|
|
||||||
|
if(resourceType === "customers") {
|
||||||
|
data.customer = elementId
|
||||||
|
}
|
||||||
|
|
||||||
|
const {data:insertData,error:insertError} = await supabase
|
||||||
|
.from("historyItems")
|
||||||
|
.insert([addHistoryItemData.value])
|
||||||
|
.select()
|
||||||
|
|
||||||
|
if(insertError) {
|
||||||
|
console.log(insertError)
|
||||||
|
} else {
|
||||||
|
toast.add({title: "Eintrag erfolgreich erstellt"})
|
||||||
|
await fetchHistoryItems()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Getters
|
||||||
|
|
||||||
|
const getOpenTasksCount = computed(() => {
|
||||||
|
return tasks.value.filter(task => task.categorie != "Erledigt").length
|
||||||
|
})
|
||||||
|
|
||||||
|
const getMovementsBySpace = computed(() => (spaceId:string) => {
|
||||||
|
return movements.value.filter(movement => movement.spaceId === spaceId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getContactsByCustomerId = computed(() => (customerId:string) => {
|
||||||
|
return contacts.value.filter(item => item.customer === customerId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getDocumentsByProjectId = computed(() => (projectId:string) => {
|
||||||
|
return documents.value.filter(item => item.project === projectId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getTimesByProjectId = computed(() => (projectId:string) => {
|
||||||
|
return times.value.filter(time => time.projectId === projectId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getHistoryItemsByCustomer = computed(() => (customerId:string) => {
|
||||||
|
return historyItems.value.filter(item => item.customer === customerId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getEventTypes = computed(() => {
|
||||||
|
return ownTenant.value.calendarConfig.eventTypes
|
||||||
|
})
|
||||||
|
|
||||||
|
const getTimeTypes = computed(() => {
|
||||||
|
return ownTenant.value.timeConfig.timeTypes
|
||||||
|
})
|
||||||
|
|
||||||
|
const getDocumentTags = computed(() => {
|
||||||
|
return ownTenant.value.tags.documents
|
||||||
|
})
|
||||||
|
|
||||||
|
const getResources = computed(() => {
|
||||||
|
return [
|
||||||
|
...profiles.value.map(profile => {
|
||||||
|
return {
|
||||||
|
type: 'person',
|
||||||
|
title: profile.fullName,
|
||||||
|
id: profile.id
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
...vehicles.value.map(vehicle => {
|
||||||
|
return {
|
||||||
|
type: 'vehicle',
|
||||||
|
title: vehicle.licensePlate,
|
||||||
|
id: vehicle.licensePlate
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
const getEvents = computed(() => {
|
||||||
|
return [
|
||||||
|
...events.value.map(event => {
|
||||||
|
let eventColor = ownTenant.value.calendarConfig.eventTypes.find(type => type.label === event.type).color
|
||||||
|
|
||||||
|
return {
|
||||||
|
...event,
|
||||||
|
borderColor: eventColor,
|
||||||
|
textColor: eventColor,
|
||||||
|
backgroundColor: "black"
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
//Get Item By Id
|
||||||
|
const getProductById = computed(() => (itemId:string) => {
|
||||||
|
return products.value.find(item => item.id === itemId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getVendorById = computed(() => (itemId:string) => {
|
||||||
|
return vendors.value.find(item => item.id === itemId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getVendorInvoiceById = computed(() => (itemId:string) => {
|
||||||
|
return vendorInvoices.value.find(item => item.id === itemId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getContractById = computed(() => (itemId:string) => {
|
||||||
|
return contracts.value.find(item => item.id === itemId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getContactById = computed(() => (itemId:string) => {
|
||||||
|
return contacts.value.find(item => item.id === itemId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getVehiclesById = computed(() => (itemId:string) => {
|
||||||
|
return vehicles.value.find(item => item.id === itemId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getDocumentById = computed(() => (itemId:string) => {
|
||||||
|
return documents.value.find(item => item.id === itemId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getSpaceById = computed(() => (itemId:string) => {
|
||||||
|
return spaces.value.find(item => item.id === itemId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getCustomerById = computed(() => (itemId:number) => {
|
||||||
|
return customers.value.find(item => item.id === itemId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getJobById = computed(() => (itemId:string) => {
|
||||||
|
return jobs.value.find(item => item.id === itemId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getProfileById = computed(() => (itemId:string) => {
|
||||||
|
return profiles.value.find(item => item.id === itemId)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getProjectById = computed(() => (itemId:string) => {
|
||||||
|
let project = projects.value.find(project => project.id === itemId)
|
||||||
|
|
||||||
|
let projectHours = 0
|
||||||
|
|
||||||
|
let projectTimes = times.value.filter(time => time.projectId === itemId)
|
||||||
|
projectTimes.forEach(time => projectHours += time.duration)
|
||||||
|
|
||||||
|
project.projectHours = projectHours
|
||||||
|
|
||||||
|
return project
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
loaded,
|
||||||
|
ownTenant,
|
||||||
|
profiles,
|
||||||
|
events,
|
||||||
|
customers,
|
||||||
|
tasks,
|
||||||
|
projects,
|
||||||
|
documents,
|
||||||
|
spaces,
|
||||||
|
units,
|
||||||
|
times,
|
||||||
|
products,
|
||||||
|
movements,
|
||||||
|
forms,
|
||||||
|
contracts,
|
||||||
|
jobs,
|
||||||
|
formSubmits,
|
||||||
|
contacts,
|
||||||
|
vehicles,
|
||||||
|
vendors,
|
||||||
|
vendorInvoices,
|
||||||
|
bankAccounts,
|
||||||
|
bankStatements,
|
||||||
|
historyItems,
|
||||||
|
numberRanges,
|
||||||
|
//Functions
|
||||||
|
fetchData,
|
||||||
|
clearStore,
|
||||||
|
fetchOwnTenant,
|
||||||
|
fetchProfiles,
|
||||||
|
fetchBankAccounts,
|
||||||
|
fetchBankStatements,
|
||||||
|
fetchEvents,
|
||||||
|
fetchContracts,
|
||||||
|
fetchContacts,
|
||||||
|
fetchCustomers,
|
||||||
|
fetchTasks,
|
||||||
|
fetchForms,
|
||||||
|
fetchFormSubmits,
|
||||||
|
fetchProducts,
|
||||||
|
fetchUnits,
|
||||||
|
fetchProjects,
|
||||||
|
fetchSpaces,
|
||||||
|
fetchMovements,
|
||||||
|
fetchVehicles,
|
||||||
|
fetchTimes,
|
||||||
|
fetchJobs,
|
||||||
|
fetchHistoryItems,
|
||||||
|
fetchVendors,
|
||||||
|
fetchVendorInvoices,
|
||||||
|
fetchNumberRanges,
|
||||||
|
fetchDocuments,
|
||||||
|
addHistoryItem,
|
||||||
|
//Getters
|
||||||
|
getOpenTasksCount,
|
||||||
|
getMovementsBySpace,
|
||||||
|
getContactsByCustomerId,
|
||||||
|
getDocumentsByProjectId,
|
||||||
|
getTimesByProjectId,
|
||||||
|
getHistoryItemsByCustomer,
|
||||||
|
getEventTypes,
|
||||||
|
getTimeTypes,
|
||||||
|
getDocumentTags,
|
||||||
|
getResources,
|
||||||
|
getEvents,
|
||||||
|
getProductById,
|
||||||
|
getVendorById,
|
||||||
|
getVendorInvoiceById,
|
||||||
|
getContractById,
|
||||||
|
getContactById,
|
||||||
|
getVehiclesById,
|
||||||
|
getDocumentById,
|
||||||
|
getSpaceById,
|
||||||
|
getCustomerById,
|
||||||
|
getJobById,
|
||||||
|
getProjectById,
|
||||||
|
getProfileById
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user