fixed, dass wenn die dienstübersicht neu geladen wird, man bei dem gleichen Monat bleibt

This commit is contained in:
Tim Gröger 2020-05-24 23:24:58 +02:00
parent b4f5735947
commit 6dd5f75d2e
7 changed files with 111 additions and 72 deletions

View File

@ -4,7 +4,7 @@
<v-toolbar-title>Dienstübersicht</v-toolbar-title>
<v-spacer />
<v-toolbar-items>
<v-btn text icon @click="changeMonth(-1)">
<v-btn text icon :to="{name: 'userJobs', params: {year: date.getFullYear(), month: date.getMonth()}}">
<v-icon>{{ keyboard_arrow_left }}</v-icon>
</v-btn>
<v-list-item>
@ -13,7 +13,7 @@
{{ date.getFullYear() }}
</v-list-item-title>
</v-list-item>
<v-btn text icon @click="changeMonth(1)">
<v-btn text icon :to="{name: 'userJobs', params: {year: date.getFullYear(), month: date.getMonth() +2}}">
<v-icon>{{ keyboard_arrow_right }}</v-icon>
</v-btn>
</v-toolbar-items>
@ -52,7 +52,7 @@ export default {
return {
keyboard_arrow_left: mdiChevronLeft,
keyboard_arrow_right: mdiChevronRight,
date: new Date(),
date: new Date(this.$route.params.year, this.$route.params.month -1, 1),
monthArray: [
'Januar',
'Februar',
@ -71,17 +71,6 @@ export default {
},
created() {
this.getActiveUser()
for (let intDate = 1; intDate < 7; intDate++) {
if (
new Date(
this.date.getFullYear(),
this.date.getMonth(),
intDate
).getDay() === 3
)
if (this.date.getDate() < intDate)
this.date = new Date(this.date.getFullYear(), this.date.getMonth(), 0)
}
this.getAllJobKinds()
this.createMonth(this.date)
this.getAllUsers()
@ -140,6 +129,34 @@ export default {
startDate: 'jobs/getStartDate',
endDate: 'jobs/getEndDate'
})
},
watch: {
$route() {
this.getActiveUser()
console.log(this.$route.params)
console.log(this.date)
this.date = new Date(this.$route.params.year, this.$route.params.month - 1, 1)
this.getAllJobKinds()
this.createMonth(this.date)
this.getAllUsers()
this.getUsers({
from_date: {
year: this.startDate.getFullYear(),
month: this.startDate.getMonth() + 1,
day: this.startDate.getDate()
},
to_date: {
year: this.endDate.getFullYear(),
month: this.endDate.getMonth() + 1,
day: this.endDate.getDate()
}
})
this.getTransactJobs({
year: this.date.getFullYear(),
month: this.date.getMonth() + 1,
day: 1
})
}
}
}
</script>

View File

@ -73,42 +73,47 @@
<v-btn text block @click="send">senden</v-btn>
</v-card-actions>
</div>
<v-card-actions
class="text--secondary"
v-if="!day.loading"
v-show="filterAddJob.length > 0 && !userInWorker()"
>
<div>
<v-card-actions class="text--secondary" v-if="!day.loading">
<div v-show="filterAddJob.length > 0 && !userInWorker()">
<div>Hier kannst du dich zum Bardienst eintragen.</div>
<v-spacer />
<v-menu
v-model="menu"
open-on-hover
close-on-click
close-on-content-click
offset-y
>
<template v-slot:activator="{ on }">
<v-btn
text
v-on="on"
v-show="filterAddJob.length > 0 && !userInWorker()"
>
Eintragen
</v-btn>
</template>
<v-list>
<v-list-item
v-for="(jobkinddateitem, index) in filterAddJob"
:key="index"
@click="addingJob(jobkinddateitem)"
>
<v-list-item-title>
{{ jobkinddateitem.job_kind.name }}
</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<div class="text-right">
<v-menu
v-model="menu"
open-on-hover
close-on-click
close-on-content-click
offset-y
>
<template v-slot:activator="{ on }">
<v-spacer/>
<v-btn
text
v-on="on"
v-show="filterAddJob.length > 0 && !userInWorker()"
>
Eintragen
</v-btn>
</template>
<v-list>
<v-list-item
v-for="(jobkinddateitem, index) in filterAddJob"
:key="index"
@click="addingJob(jobkinddateitem)"
>
<v-list-item-title>
{{ jobkinddateitem.job_kind.name }}
</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</div>
</div>
<v-spacer/>
<div v-show="userInWorker()">
<v-btn v-show="jobkindWithSpace.length !== 0" text>Einladen</v-btn>
<v-btn v-show="day.locked" text>Abgeben</v-btn>
</div>
</v-card-actions>
</v-card>
@ -188,7 +193,6 @@ export default {
setTimeout(() => {
this.update += 1
}, 200)
console.log('after adding Job', this.day.jobkinddate)
},
userInWorker() {
var jobkinddate = this.day.jobkinddate.find(item => {
@ -196,7 +200,6 @@ export default {
return workeritem.id === this.activeUser.id
})
})
console.log('userin', !!jobkinddate, !jobkinddate)
return !!jobkinddate
}
},
@ -227,6 +230,16 @@ export default {
})
return test
},
jobkindWithSpace() {
var retVal = this.day.jobkinddate.filter(item => {
if (item.maxpersons <= item.worker.length)
return false
else
return true
})
return retVal
}
,
filterAddJob() {
var retVal = this.day.jobkinddate.filter(item => {
if (item.maxpersons <= item.worker.length) {
@ -242,7 +255,6 @@ export default {
}
}
})
console.log('filterAddJob', retVal, retVal.length > 0, this.user.workgroups)
return retVal
}
}

View File

@ -14,7 +14,7 @@
</v-list-item-icon>
<v-list-item-title>Finanzübersicht</v-list-item-title>
</v-list-item>
<v-list-item link to="/main/user/jobs">
<v-list-item link :to="{name: 'userJobs', params: {year: new Date().getFullYear(), month: new Date().getMonth() + 1}}">
<v-list-item-icon>
<v-icon>
{{ briefcase }}

View File

@ -1,7 +1,6 @@
<template>
<v-list>
<v-list-item link to="/main/management/servicemanagement">
<v-list-item-icon>
<v-list-item link :to="{name: 'serviceManagement', params: {year: new Date().getFullYear(), month: new Date().getMonth() + 1}}"> <v-list-item-icon>
<v-icon>{{ work }}</v-icon>
</v-list-item-icon>
<v-list-item-title>

View File

@ -4,7 +4,7 @@
<v-toolbar-title>Dienstverwaltung</v-toolbar-title>
<v-spacer />
<v-toolbar-items>
<v-btn text icon @click="changeMonth(-1)">
<v-btn text icon :to="{name: 'serviceManagement', params: {year: date.getFullYear(), month: date.getMonth()}}">
<v-icon>{{ keyboard_arrow_left }}</v-icon>
</v-btn>
<v-list-item>
@ -13,7 +13,7 @@
{{ date.getFullYear() }}
</v-list-item-title>
</v-list-item>
<v-btn text icon @click="changeMonth(1)">
<v-btn text icon :to="{name: 'serviceManagement', params: {year: date.getFullYear(), month: date.getMonth() + 2}}">
<v-icon>{{ keyboard_arrow_right }}</v-icon>
</v-btn>
</v-toolbar-items>
@ -57,7 +57,7 @@ export default {
keyboard_arrow_left: mdiChevronLeft,
keyboard_arrow_right: mdiChevronRight,
id: 0,
date: new Date(),
date: new Date(this.$route.params.year, this.$route.params.month -1, 1),
monthArray: [
'Januar',
'Februar',
@ -75,17 +75,6 @@ export default {
}
},
created() {
for (let intDate = 1; intDate < 7; intDate++) {
if (
new Date(
this.date.getFullYear(),
this.date.getMonth(),
intDate
).getDay() === 3
)
if (this.date.getDate() < intDate)
this.date = new Date(this.date.getFullYear(), this.date.getMonth(), 0)
}
this.getAllJobKinds()
this.createMonth(this.date)
this.getAllUsers()
@ -152,6 +141,27 @@ export default {
startDate: 'sm/getStartDate',
endDate: 'sm/getEndDate'
})
},
watch: {
$route() {
this.date = new Date(this.$route.params.year, this.$route.params.month - 1, 1)
this.getAllJobKinds()
this.createMonth(this.date)
this.getAllUsers()
this.getDBUsers()
this.getUsers({
from_date: {
year: this.startDate.getFullYear(),
month: this.startDate.getMonth() + 1,
day: this.startDate.getDate()
},
to_date: {
year: this.endDate.getFullYear(),
month: this.endDate.getMonth() + 1,
day: this.endDate.getDate()
}
})
}
}
}
</script>

View File

@ -1,7 +1,7 @@
//const main = 'https://192.168.5.128:5000/'
//const main = 'http://localhost:5000/'
const main = 'http://192.168.5.118:5000/'
//const main = 'https://groeger-clan.duckdns.org:5000/'
//const main = 'http://192.168.5.118:5000/'
const main = 'https://groeger-clan.duckdns.org:5000/'
const url = {
login: main + 'login',

View File

@ -54,7 +54,8 @@ const routes = [
components: { nav: ManagementNavigation, default: BarView },
children: [
{
path: 'servicemanagement',
name: 'serviceManagement',
path: 'servicemanagement/:year/:month',
component: ServiceManagement
},
{
@ -92,7 +93,7 @@ const routes = [
component: Config
},
{
path: 'jobs',
path: 'jobs/:year/:month',
name: 'userJobs',
component: Jobs
},