Merge branch 'refs/heads/beta'
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
|
import EntityShowSubTimes from "~/components/EntityShowSubTimes.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
type: {
|
type: {
|
||||||
required: true,
|
required: true,
|
||||||
@@ -251,6 +253,12 @@ const onTabChange = (index) => {
|
|||||||
v-else-if="tab.label === 'Buchungen'"
|
v-else-if="tab.label === 'Buchungen'"
|
||||||
:platform="platform"
|
:platform="platform"
|
||||||
/>
|
/>
|
||||||
|
<EntityShowSubTimes
|
||||||
|
:top-level-type="type"
|
||||||
|
:item="props.item"
|
||||||
|
v-else-if="tab.label === 'Zeiten'"
|
||||||
|
:platform="platform"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
<EntityShowSub
|
<EntityShowSub
|
||||||
|
|||||||
117
components/EntityShowSubTimes.vue
Normal file
117
components/EntityShowSubTimes.vue
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
<script setup>
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
const supabase = useSupabaseClient()
|
||||||
|
const route = useRoute()
|
||||||
|
const router = useRouter()
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
queryStringData: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
item: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
topLevelType: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
platform: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const setup = async () => {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
setup()
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
key:"state",
|
||||||
|
label: "Status",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "user",
|
||||||
|
label: "Benutzer",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key:"startDate",
|
||||||
|
label:"Start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "endDate",
|
||||||
|
label: "Ende",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "duration",
|
||||||
|
label: "Dauer",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key:"type",
|
||||||
|
label:"Typ",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "project",
|
||||||
|
label: "Projekt",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "notes",
|
||||||
|
label: "Notizen",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UCard class="mt-5">
|
||||||
|
<UTable
|
||||||
|
class="mt-3"
|
||||||
|
:columns="columns"
|
||||||
|
:rows="props.item.times"
|
||||||
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
|
||||||
|
>
|
||||||
|
<template #state-data="{row}">
|
||||||
|
<span
|
||||||
|
v-if="row.state === 'Entwurf'"
|
||||||
|
class="text-rose-500"
|
||||||
|
>{{row.state}}</span>
|
||||||
|
<span
|
||||||
|
v-if="row.state === 'Eingereicht'"
|
||||||
|
class="text-cyan-500"
|
||||||
|
>{{row.state}}</span>
|
||||||
|
<span
|
||||||
|
v-if="row.state === 'Bestätigt'"
|
||||||
|
class="text-primary-500"
|
||||||
|
>{{row.state}}</span>
|
||||||
|
</template>
|
||||||
|
<template #user-data="{row}">
|
||||||
|
{{row.profile ? row.profile.fullName : "" }}
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #startDate-data="{row}">
|
||||||
|
{{dayjs(row.startDate).format("DD.MM.YY HH:mm")}}
|
||||||
|
</template>
|
||||||
|
<template #endDate-data="{row}">
|
||||||
|
{{dayjs(row.endDate).format("DD.MM.YY HH:mm")}}
|
||||||
|
</template>
|
||||||
|
<template #duration-data="{row}">
|
||||||
|
{{Math.floor(dayjs(row.endDate).diff(row.startDate, "minutes")/60)}}:{{String(dayjs(row.endDate).diff(row.startDate, "minutes") % 60).padStart(2,"0")}} h
|
||||||
|
|
||||||
|
</template>
|
||||||
|
<template #project-data="{row}">
|
||||||
|
{{row.project ? row.project.name : "" }}
|
||||||
|
</template>
|
||||||
|
</UTable>
|
||||||
|
</UCard>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -126,7 +126,7 @@ const links = computed(() => {
|
|||||||
children: [
|
children: [
|
||||||
... profileStore.ownTenant.features.timeTracking ? [{
|
... profileStore.ownTenant.features.timeTracking ? [{
|
||||||
label: "Zeiterfassung",
|
label: "Zeiterfassung",
|
||||||
to: "/employees/timetracking",
|
to: "/times",
|
||||||
icon: "i-heroicons-clock"
|
icon: "i-heroicons-clock"
|
||||||
}] : [],
|
}] : [],
|
||||||
... profileStore.ownTenant.features.workingTimeTracking ? [{
|
... profileStore.ownTenant.features.workingTimeTracking ? [{
|
||||||
@@ -319,6 +319,10 @@ const links = computed(() => {
|
|||||||
label: "Projekttypen",
|
label: "Projekttypen",
|
||||||
to: "/projecttypes",
|
to: "/projecttypes",
|
||||||
icon: "i-heroicons-clipboard-document-list"
|
icon: "i-heroicons-clipboard-document-list"
|
||||||
|
},{
|
||||||
|
label: "Export",
|
||||||
|
to: "/export",
|
||||||
|
icon: "i-heroicons-clipboard-document-list"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ setupPage()
|
|||||||
<template>
|
<template>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Offene Rechnungen:</td>
|
<td class="break-all">Offene Rechnungen:</td>
|
||||||
<td
|
<td
|
||||||
v-if="unpaidInvoicesSum > 0"
|
v-if="unpaidInvoicesSum > 0"
|
||||||
class="text-orange-500 font-bold text-nowrap"
|
class="text-orange-500 font-bold text-nowrap"
|
||||||
@@ -60,7 +60,7 @@ setupPage()
|
|||||||
<td v-else class="text-primary-500 font-bold text-no-wrap">0 Stk / 0,00€</td>
|
<td v-else class="text-primary-500 font-bold text-no-wrap">0 Stk / 0,00€</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Überfällige Rechnungen:</td>
|
<td class="break-all">Überfällige Rechnungen:</td>
|
||||||
<td
|
<td
|
||||||
v-if="unpaidOverdueInvoicesSum > 0"
|
v-if="unpaidOverdueInvoicesSum > 0"
|
||||||
class="text-rose-600 font-bold text-nowrap"
|
class="text-rose-600 font-bold text-nowrap"
|
||||||
@@ -68,7 +68,7 @@ setupPage()
|
|||||||
<td v-else class="text-primary-500 font-bold text-no-wrap">0 Stk / 0,00€</td>
|
<td v-else class="text-primary-500 font-bold text-no-wrap">0 Stk / 0,00€</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Angelegte Rechnungsentwürfe:</td>
|
<td class="break-all">Angelegte Rechnungsentwürfe:</td>
|
||||||
<td
|
<td
|
||||||
v-if="draftInvoicesSum > 0"
|
v-if="draftInvoicesSum > 0"
|
||||||
class="text-orange-500 font-bold text-nowrap"
|
class="text-orange-500 font-bold text-nowrap"
|
||||||
@@ -76,7 +76,7 @@ setupPage()
|
|||||||
<td v-else class="text-primary-500 font-bold text-no-wrap">0 Stk / 0,00€</td>
|
<td v-else class="text-primary-500 font-bold text-no-wrap">0 Stk / 0,00€</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>ToDo Eingangsrechnungsrechnungen:</td>
|
<td class="break-all">ToDo Eingangsrechnungsrechnungen:</td>
|
||||||
<td
|
<td
|
||||||
v-if="countUnfinishedOpenIncomingInvoices > 0"
|
v-if="countUnfinishedOpenIncomingInvoices > 0"
|
||||||
class="text-orange-500 font-bold text-nowrap"
|
class="text-orange-500 font-bold text-nowrap"
|
||||||
|
|||||||
@@ -7,9 +7,18 @@ const toast = useToast()
|
|||||||
|
|
||||||
const runningTimeInfo = ref({})
|
const runningTimeInfo = ref({})
|
||||||
|
|
||||||
|
const projects = ref([])
|
||||||
|
const platform = ref("default")
|
||||||
|
|
||||||
const setupPage = async () => {
|
const setupPage = async () => {
|
||||||
runningTimeInfo.value = (await supabase.from("workingtimes").select().eq("profile", profileStore.activeProfile.id).is("endDate", null).single()).data || {}
|
runningTimeInfo.value = (await supabase.from("times").select().eq("profile", profileStore.activeProfile.id).is("endDate", null).single()).data || {}
|
||||||
console.log(runningTimeInfo.value)
|
|
||||||
|
projects.value = (await useSupabaseSelect("projects"))
|
||||||
|
|
||||||
|
if(await useCapacitor().getIsPhone()) {
|
||||||
|
platform.value = "mobile"
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setupPage()
|
setupPage()
|
||||||
@@ -24,12 +33,12 @@ const startTime = async () => {
|
|||||||
profile: profileStore.activeProfile.id,
|
profile: profileStore.activeProfile.id,
|
||||||
startDate: dayjs(),
|
startDate: dayjs(),
|
||||||
tenant: profileStore.currentTenant,
|
tenant: profileStore.currentTenant,
|
||||||
state: "Im Web gestartet",
|
state: platform.value === "mobile" ? "In der App gestartet" : "Im Web gestartet",
|
||||||
source: "Dashboard"
|
source: "Dashboard"
|
||||||
}
|
}
|
||||||
|
|
||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
.from("workingtimes")
|
.from("times")
|
||||||
.insert([runningTimeInfo.value])
|
.insert([runningTimeInfo.value])
|
||||||
.select()
|
.select()
|
||||||
if(error) {
|
if(error) {
|
||||||
@@ -38,16 +47,16 @@ const startTime = async () => {
|
|||||||
} else if(data) {
|
} else if(data) {
|
||||||
toast.add({title: "Zeit erfolgreich gestartet"})
|
toast.add({title: "Zeit erfolgreich gestartet"})
|
||||||
runningTimeInfo.value = data[0]
|
runningTimeInfo.value = data[0]
|
||||||
console.log(runningTimeInfo.value)
|
//console.log(runningTimeInfo.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const stopStartedTime = async () => {
|
const stopStartedTime = async () => {
|
||||||
runningTimeInfo.value.endDate = dayjs()
|
runningTimeInfo.value.endDate = dayjs()
|
||||||
runningTimeInfo.value.state = "Im Web gestoppt"
|
runningTimeInfo.value.state = platform.value === "mobile" ? "In der App gestoppt" : "Im Web gestoppt"
|
||||||
|
|
||||||
const {error,status} = await supabase
|
const {error,status} = await supabase
|
||||||
.from("workingtimes")
|
.from("times")
|
||||||
.update(runningTimeInfo.value)
|
.update(runningTimeInfo.value)
|
||||||
.eq('id',runningTimeInfo.value.id)
|
.eq('id',runningTimeInfo.value.id)
|
||||||
|
|
||||||
@@ -79,6 +88,20 @@ const stopStartedTime = async () => {
|
|||||||
v-model="runningTimeInfo.notes"
|
v-model="runningTimeInfo.notes"
|
||||||
/>
|
/>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
|
<UFormGroup
|
||||||
|
class="mt-2"
|
||||||
|
label="Projekt:"
|
||||||
|
>
|
||||||
|
<USelectMenu
|
||||||
|
v-model="runningTimeInfo.project"
|
||||||
|
:options="projects"
|
||||||
|
searchable
|
||||||
|
:search-attributes="['name','notes','customer']"
|
||||||
|
searchable-placeholder="Suche"
|
||||||
|
value-attribute="id"
|
||||||
|
option-attribute="name"
|
||||||
|
/>
|
||||||
|
</UFormGroup>
|
||||||
<UButton
|
<UButton
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
@click="stopStartedTime"
|
@click="stopStartedTime"
|
||||||
@@ -88,7 +111,7 @@ const stopStartedTime = async () => {
|
|||||||
</UButton>
|
</UButton>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<p>Keine Anwesenheit gestartet</p>
|
<p>Keine Zeit gestartet</p>
|
||||||
<UButton
|
<UButton
|
||||||
class="mt-3"
|
class="mt-3"
|
||||||
@click="startTime"
|
@click="startTime"
|
||||||
|
|||||||
101
components/displayRunningWorkingTime.vue
Normal file
101
components/displayRunningWorkingTime.vue
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<script setup>
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
const profileStore = useProfileStore();
|
||||||
|
const supabase = useSupabaseClient()
|
||||||
|
const toast = useToast()
|
||||||
|
|
||||||
|
const runningTimeInfo = ref({})
|
||||||
|
|
||||||
|
const setupPage = async () => {
|
||||||
|
runningTimeInfo.value = (await supabase.from("workingtimes").select().eq("profile", profileStore.activeProfile.id).is("endDate", null).single()).data || {}
|
||||||
|
console.log(runningTimeInfo.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
setupPage()
|
||||||
|
|
||||||
|
/*if(dataStore.workingtimes.find(time => time.profile === profileStore.activeProfile.id && !time.endDate)) {
|
||||||
|
runningTimeInfo.value = dataStore.workingtimes.find(time => time.profile === profileStore.activeProfile.id && !time.end)
|
||||||
|
}*/
|
||||||
|
|
||||||
|
const startTime = async () => {
|
||||||
|
console.log("started")
|
||||||
|
runningTimeInfo.value = {
|
||||||
|
profile: profileStore.activeProfile.id,
|
||||||
|
startDate: dayjs(),
|
||||||
|
tenant: profileStore.currentTenant,
|
||||||
|
state: "Im Web gestartet",
|
||||||
|
source: "Dashboard"
|
||||||
|
}
|
||||||
|
|
||||||
|
const {data,error} = await supabase
|
||||||
|
.from("workingtimes")
|
||||||
|
.insert([runningTimeInfo.value])
|
||||||
|
.select()
|
||||||
|
if(error) {
|
||||||
|
console.log(error)
|
||||||
|
toast.add({title: "Fehler beim starten der Zeit",color:"rose"})
|
||||||
|
} else if(data) {
|
||||||
|
toast.add({title: "Anwesenheit erfolgreich gestartet"})
|
||||||
|
runningTimeInfo.value = data[0]
|
||||||
|
console.log(runningTimeInfo.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const stopStartedTime = async () => {
|
||||||
|
runningTimeInfo.value.endDate = dayjs()
|
||||||
|
runningTimeInfo.value.state = "Im Web gestoppt"
|
||||||
|
|
||||||
|
const {error,status} = await supabase
|
||||||
|
.from("workingtimes")
|
||||||
|
.update(runningTimeInfo.value)
|
||||||
|
.eq('id',runningTimeInfo.value.id)
|
||||||
|
|
||||||
|
if(error) {
|
||||||
|
console.log(error)
|
||||||
|
let errorId = await useError().logError(`${status} - ${JSON.stringify(error)}`)
|
||||||
|
toast.add({title: errorId ? `Fehler beim stoppen der Anwesenheit (Fehler ID: ${errorId})` : `Fehler beim stoppen der Anwesenheit`,color:"rose"})
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
toast.add({title: "Anwesenheit erfolgreich gestoppt"})
|
||||||
|
runningTimeInfo.value = {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div v-if="runningTimeInfo.startDate">
|
||||||
|
<p>Start: {{dayjs(runningTimeInfo.startDate).format("HH:mm")}}</p>
|
||||||
|
<p>Dauer: {{dayjs().diff(dayjs(runningTimeInfo.startDate),'minutes') > 59 ? `${Math.floor(dayjs().diff(dayjs(runningTimeInfo.startDate),'minutes') / 60)}:${dayjs().diff(dayjs(runningTimeInfo.startDate),'minutes') % 60} h` : dayjs().diff(dayjs(runningTimeInfo.startDate),'minutes') + ' min' }}</p>
|
||||||
|
|
||||||
|
<UFormGroup
|
||||||
|
class="mt-2"
|
||||||
|
label="Notizen:"
|
||||||
|
>
|
||||||
|
<UTextarea
|
||||||
|
v-model="runningTimeInfo.notes"
|
||||||
|
/>
|
||||||
|
</UFormGroup>
|
||||||
|
<UButton
|
||||||
|
class="mt-3"
|
||||||
|
@click="stopStartedTime"
|
||||||
|
:disabled="!runningTimeInfo.id"
|
||||||
|
>
|
||||||
|
Stop
|
||||||
|
</UButton>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<p>Keine Anwesenheit gestartet</p>
|
||||||
|
<UButton
|
||||||
|
class="mt-3"
|
||||||
|
@click="startTime"
|
||||||
|
>Starten</UButton>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -47,6 +47,10 @@
|
|||||||
>
|
>
|
||||||
<display-running-time/>
|
<display-running-time/>
|
||||||
</UDashboardCard>
|
</UDashboardCard>
|
||||||
|
<UDashboardCard
|
||||||
|
>
|
||||||
|
<display-running-working-time/>
|
||||||
|
</UDashboardCard>
|
||||||
<UDashboardCard
|
<UDashboardCard
|
||||||
title="Aufgaben"
|
title="Aufgaben"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ const profileStore = useProfileStore()
|
|||||||
</UDashboardCard>
|
</UDashboardCard>
|
||||||
<UDashboardCard
|
<UDashboardCard
|
||||||
title="Anwesenheit"
|
title="Anwesenheit"
|
||||||
|
>
|
||||||
|
<display-running-working-time/>
|
||||||
|
</UDashboardCard>
|
||||||
|
<UDashboardCard
|
||||||
|
title="Zeit"
|
||||||
>
|
>
|
||||||
<display-running-time/>
|
<display-running-time/>
|
||||||
</UDashboardCard>
|
</UDashboardCard>
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ definePageMeta({
|
|||||||
layout: 'mobile',
|
layout: 'mobile',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -38,6 +40,17 @@ definePageMeta({
|
|||||||
Objekte
|
Objekte
|
||||||
</UButton>
|
</UButton>
|
||||||
|
|
||||||
|
<UDivider class="my-5">Unternehmen wechseln</UDivider>
|
||||||
|
|
||||||
|
<UButton
|
||||||
|
v-for="option in profileStore.ownProfiles"
|
||||||
|
class="my-1"
|
||||||
|
variant="outline"
|
||||||
|
@click="profileStore.changeProfile(option.id)"
|
||||||
|
>
|
||||||
|
{{profileStore.tenants.find(i => i.id === option.tenant).name}}
|
||||||
|
</UButton>
|
||||||
|
|
||||||
|
|
||||||
</UDashboardPanelContent>
|
</UDashboardPanelContent>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const user = useSupabaseUser()
|
|||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
|
|
||||||
const timeTypes = dataStore.getTimeTypes
|
const timeTypes = profileStore.ownTenant.timeConfig.timeTypes
|
||||||
const timeInfo = ref({
|
const timeInfo = ref({
|
||||||
profile: "",
|
profile: "",
|
||||||
startDate: "",
|
startDate: "",
|
||||||
@@ -28,9 +28,21 @@ const timeInfo = ref({
|
|||||||
const filterUser = ref(profileStore.activeProfile.id || "")
|
const filterUser = ref(profileStore.activeProfile.id || "")
|
||||||
|
|
||||||
const times = ref([])
|
const times = ref([])
|
||||||
|
const runningTimeInfo = ref({})
|
||||||
|
const showConfigTimeModal = ref(false)
|
||||||
|
const configTimeMode = ref("create")
|
||||||
|
|
||||||
const setup = async () => {
|
const setup = async () => {
|
||||||
times.value = await useSupabaseSelect("times","*, profile(*)")
|
times.value = await useSupabaseSelect("times","*, profile(*), project(id, name)")
|
||||||
|
|
||||||
|
runningTimeInfo.value = (await supabase
|
||||||
|
.from("times")
|
||||||
|
.select()
|
||||||
|
.eq("tenant", profileStore.currentTenant)
|
||||||
|
.eq("profile", profileStore.activeProfile.id)
|
||||||
|
.is("endDate",null)
|
||||||
|
.single()).data
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup()
|
setup()
|
||||||
@@ -60,7 +72,7 @@ const itemInfo = ref({
|
|||||||
start: new Date(),
|
start: new Date(),
|
||||||
end: "",
|
end: "",
|
||||||
notes: null,
|
notes: null,
|
||||||
projectId: null,
|
project: null,
|
||||||
type: null,
|
type: null,
|
||||||
state: "Entwurf"
|
state: "Entwurf"
|
||||||
})
|
})
|
||||||
@@ -87,10 +99,6 @@ const columns = [
|
|||||||
key:"type",
|
key:"type",
|
||||||
label:"Typ",
|
label:"Typ",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: "duration",
|
|
||||||
label: "Dauer",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: "project",
|
key: "project",
|
||||||
label: "Projekt",
|
label: "Projekt",
|
||||||
@@ -101,16 +109,14 @@ const columns = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const runningTimeInfo = ref({})
|
|
||||||
const showConfigTimeModal = ref(false)
|
|
||||||
const configTimeMode = ref("create")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const startTime = async () => {
|
const startTime = async () => {
|
||||||
console.log("started")
|
console.log("started")
|
||||||
timeInfo.value.profile = profileStore.activeProfile.id
|
timeInfo.value.profile = profileStore.activeProfile.id
|
||||||
timeInfo.value.start = new Date().toISOString()
|
timeInfo.value.startDate = dayjs()
|
||||||
timeInfo.value.tenant = profileStore.currentTenant
|
timeInfo.value.tenant = profileStore.currentTenant
|
||||||
|
|
||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
@@ -120,45 +126,34 @@ const startTime = async () => {
|
|||||||
|
|
||||||
if(error) {
|
if(error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
|
toast.add({title: "Fehler beim starten der Zeit",color:"rose"})
|
||||||
} else if(data) {
|
} else if(data) {
|
||||||
//timeInfo.value = data[0]
|
toast.add({title: "Zeit erfolgreich gestartet"})
|
||||||
await dataStore.fetchTimes()
|
runningTimeInfo.value = data[0]
|
||||||
runningTimeInfo.value = dataStore.times.find(time => time.profile === profileStore.activeProfile.id && !time.end)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const stopStartedTime = async () => {
|
const stopStartedTime = async () => {
|
||||||
console.log(runningTimeInfo.value)
|
runningTimeInfo.value.endDate = dayjs()
|
||||||
|
runningTimeInfo.value.state = "Im Web gestoppt"
|
||||||
|
|
||||||
runningTimeInfo.value.end = new Date().toISOString()
|
|
||||||
|
|
||||||
const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
|
|
||||||
((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
|
|
||||||
|
|
||||||
runningTimeInfo.value.duration = Math.round(mapNumRange(Math.abs(new Date(runningTimeInfo.value.end) - new Date(runningTimeInfo.value.start))/1000/60,0,60,0,1)*100)/100
|
|
||||||
|
|
||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
.from("times")
|
.from("times")
|
||||||
.update(runningTimeInfo.value)
|
.update(runningTimeInfo.value)
|
||||||
.eq('id',runningTimeInfo.value.id)
|
.eq('id',runningTimeInfo.value.id)
|
||||||
.select()
|
.select()
|
||||||
console.log(data)
|
|
||||||
|
|
||||||
if(error) {
|
if(error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
} else {
|
} else {
|
||||||
toast.add({title: "Zeit erfolgreich gestoppt"})
|
toast.add({title: "Zeit erfolgreich gestoppt"})
|
||||||
runningTimeInfo.value = {}
|
runningTimeInfo.value = null
|
||||||
dataStore.fetchTimes()
|
setup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(times.value.find(time => time.profile == profileStore.activeProfile.id && !time.end)) {
|
|
||||||
runningTimeInfo.value = times.value.find(time => time.profile == profileStore.activeProfile.id && !time.end)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const createTime = async () => {
|
const createTime = async () => {
|
||||||
const {data,error} = await supabase
|
const {data,error} = await supabase
|
||||||
.from("times")
|
.from("times")
|
||||||
@@ -224,13 +219,13 @@ const setState = async (newState) => {
|
|||||||
<template #left>
|
<template #left>
|
||||||
<UButton
|
<UButton
|
||||||
@click="startTime"
|
@click="startTime"
|
||||||
:disabled="runningTimeInfo.id "
|
:disabled="runningTimeInfo "
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
@click="stopStartedTime"
|
@click="stopStartedTime"
|
||||||
:disabled="!runningTimeInfo.id"
|
:disabled="!runningTimeInfo"
|
||||||
>
|
>
|
||||||
Stop
|
Stop
|
||||||
</UButton>
|
</UButton>
|
||||||
@@ -251,9 +246,9 @@ const setState = async (newState) => {
|
|||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</template>
|
</template>
|
||||||
</UDashboardToolbar>
|
</UDashboardToolbar>
|
||||||
<div v-if="runningTimeInfo.id" class="m-3">
|
<div v-if="runningTimeInfo" class="m-3">
|
||||||
|
|
||||||
Start: {{dayjs(runningTimeInfo.start).format("DD.MM.YY HH:mm")}}
|
Start: {{dayjs(runningTimeInfo.startDate).format("DD.MM.YY HH:mm")}}
|
||||||
|
|
||||||
<UFormGroup
|
<UFormGroup
|
||||||
label="Notizen:"
|
label="Notizen:"
|
||||||
@@ -270,10 +265,10 @@ const setState = async (newState) => {
|
|||||||
:options="dataStore.projects"
|
:options="dataStore.projects"
|
||||||
option-attribute="name"
|
option-attribute="name"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
v-model="runningTimeInfo.projectId"
|
v-model="runningTimeInfo.project"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{ dataStore.projects.find(project => project.id === runningTimeInfo.projectId) ? dataStore.projects.find(project => project.id === runningTimeInfo.projectId).name : "Projekt auswählen" }}
|
{{ dataStore.projects.find(project => project.id === runningTimeInfo.project) ? dataStore.projects.find(project => project.id === runningTimeInfo.project).name : "Projekt auswählen" }}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -305,34 +300,32 @@ const setState = async (newState) => {
|
|||||||
<UFormGroup
|
<UFormGroup
|
||||||
label="Start:"
|
label="Start:"
|
||||||
>
|
>
|
||||||
<VueDatePicker
|
<UPopover :popper="{ placement: 'bottom-start' }">
|
||||||
v-model="itemInfo.start"
|
<UButton
|
||||||
locale="de"
|
icon="i-heroicons-calendar-days-20-solid"
|
||||||
cancel-text="Abbrechen"
|
:label="itemInfo.startDate ? dayjs(itemInfo.startDate).format('DD.MM.YYYY') : 'Datum auswählen'"
|
||||||
select-text="Auswählen"
|
variant="outline"
|
||||||
now-button-label="Jetzt"
|
/>
|
||||||
text-input="MM.dd.yyyy HH:mm"
|
|
||||||
:dark="useColorMode().value !== 'light'"
|
<template #panel="{ close }">
|
||||||
:format="format"
|
<LazyDatePicker v-model="itemInfo.startDate" @close="close" mode="dateTime" />
|
||||||
:preview-format="format"
|
</template>
|
||||||
:disabled="configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf'"
|
</UPopover>
|
||||||
/>
|
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
<UFormGroup
|
<UFormGroup
|
||||||
label="Ende:"
|
label="Ende:"
|
||||||
>
|
>
|
||||||
<VueDatePicker
|
<UPopover :popper="{ placement: 'bottom-start' }">
|
||||||
v-model="itemInfo.end"
|
<UButton
|
||||||
locale="de"
|
icon="i-heroicons-calendar-days-20-solid"
|
||||||
cancel-text="Abbrechen"
|
:label="itemInfo.endDate ? dayjs(itemInfo.endDate).format('DD.MM.YYYY') : 'Datum auswählen'"
|
||||||
select-text="Auswählen"
|
variant="outline"
|
||||||
now-button-label="Jetzt"
|
/>
|
||||||
text-input="MM.dd.yyyy HH:mm"
|
|
||||||
:dark="useColorMode().value !== 'light'"
|
<template #panel="{ close }">
|
||||||
:format="format"
|
<LazyDatePicker v-model="itemInfo.endDate" @close="close" mode="dateTime" />
|
||||||
:preview-format="format"
|
</template>
|
||||||
:disabled="configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf'"
|
</UPopover>
|
||||||
/>
|
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
<UFormGroup
|
<UFormGroup
|
||||||
label="Benutzer:"
|
label="Benutzer:"
|
||||||
@@ -342,7 +335,7 @@ const setState = async (newState) => {
|
|||||||
v-model="itemInfo.user"
|
v-model="itemInfo.user"
|
||||||
option-attribute="fullName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
:disabled="(configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf') || (!dataStore.hasRight('createTime') || !dataStore.hasRight('createOwnTime'))"
|
:disabled="(configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf') || (!dataStore.hasRight('createTime') || !useRole().hasRight('createOwnTime'))"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{profileStore.profiles.find(profile => profile.id === itemInfo.user) ? profileStore.profiles.find(profile => profile.id === itemInfo.user).fullName : "Benutzer auswählen"}}
|
{{profileStore.profiles.find(profile => profile.id === itemInfo.user) ? profileStore.profiles.find(profile => profile.id === itemInfo.user).fullName : "Benutzer auswählen"}}
|
||||||
@@ -354,7 +347,7 @@ const setState = async (newState) => {
|
|||||||
>
|
>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:options="dataStore.projects"
|
:options="dataStore.projects"
|
||||||
v-model="itemInfo.projectId"
|
v-model="itemInfo.project"
|
||||||
option-attribute="name"
|
option-attribute="name"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
searchable
|
searchable
|
||||||
@@ -363,7 +356,7 @@ const setState = async (newState) => {
|
|||||||
:disabled="configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf'"
|
:disabled="configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf'"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{dataStore.projects.find(project => project.id === itemInfo.projectId) ? dataStore.projects.find(project => project.id === itemInfo.projectId).name : "Projekt auswählen"}}
|
{{dataStore.projects.find(project => project.id === itemInfo.project) ? dataStore.projects.find(project => project.id === itemInfo.project).name : "Projekt auswählen"}}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
@@ -443,20 +436,17 @@ const setState = async (newState) => {
|
|||||||
>{{row.state}}</span>
|
>{{row.state}}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #user-data="{row}">
|
<template #user-data="{row}">
|
||||||
{{profileStore.profiles.find(profile => profile.id === row.user) ? profileStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
|
{{row.profile ? row.profile.fullName : "" }}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #start-data="{row}">
|
<template #startDate-data="{row}">
|
||||||
{{dayjs(row.start).format("DD.MM.YY HH:mm")}}
|
{{dayjs(row.startDate).format("DD.MM.YY HH:mm")}}
|
||||||
</template>
|
</template>
|
||||||
<template #end-data="{row}">
|
<template #endDate-data="{row}">
|
||||||
{{dayjs(row.end).format("DD.MM.YY HH:mm")}}
|
{{dayjs(row.endDate).format("DD.MM.YY HH:mm")}}
|
||||||
</template>
|
</template>
|
||||||
<template #duration-data="{row}">
|
<template #project-data="{row}">
|
||||||
{{getDuration(row).composed}}
|
{{row.project ? row.project.name : "" }}
|
||||||
</template>
|
|
||||||
<template #projectId-data="{row}">
|
|
||||||
{{dataStore.projects.find(project => project.id === row.projectId) ? dataStore.projects.find(project => project.id === row.projectId).name : ""}}
|
|
||||||
</template>
|
</template>
|
||||||
</UTable>
|
</UTable>
|
||||||
</template>
|
</template>
|
||||||
@@ -978,7 +978,7 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
redirect:true,
|
redirect:true,
|
||||||
historyItemHolder: "project",
|
historyItemHolder: "project",
|
||||||
numberRangeHolder: "projectNumber",
|
numberRangeHolder: "projectNumber",
|
||||||
supabaseSelectWithInformation: "*, customer(id,name), plant(id,name), projecttype(name, id), tasks(*, project(id,name), customer(id,name), plant(id,name)), files(*), createddocuments(*, statementallocations(*)), events(*)",
|
supabaseSelectWithInformation: "*, customer(id,name), plant(id,name), projecttype(name, id), tasks(*, project(id,name), customer(id,name), plant(id,name)), files(*), createddocuments(*, statementallocations(*)), events(*), times(*, profile(id, fullName))",
|
||||||
supabaseSortColumn: "projectNumber",
|
supabaseSortColumn: "projectNumber",
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
@@ -1086,6 +1086,8 @@ export const useDataStore = defineStore('data', () => {
|
|||||||
},{
|
},{
|
||||||
key: "files",
|
key: "files",
|
||||||
label: "Dateien"
|
label: "Dateien"
|
||||||
|
},{
|
||||||
|
label: "Zeiten"
|
||||||
},{
|
},{
|
||||||
label: "Ausgangsbelege"
|
label: "Ausgangsbelege"
|
||||||
},{
|
},{
|
||||||
|
|||||||
Reference in New Issue
Block a user