Merge branch 'feature/jobkind' into develop

This commit is contained in:
Tim Gröger 2020-06-04 13:20:39 +02:00
commit 3d9ab23a20
28 changed files with 5397 additions and 3026 deletions

4722
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,33 +8,33 @@
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"@mdi/font": "^4.8.95", "@mdi/font": "^4.9.95",
"@mdi/js": "^4.8.95", "@mdi/js": "^4.9.95",
"core-js": "^3.4.3", "core-js": "^3.6.5",
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-router": "^3.1.3", "vue-router": "^3.2.0",
"vuetify": "^2.1.0", "vuetify": "^2.2.29",
"vuex": "^3.1.2" "vuex": "^3.4.0"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^4.1.0", "@vue/cli-plugin-babel": "^4.3.1",
"@vue/cli-plugin-eslint": "^4.1.0", "@vue/cli-plugin-eslint": "^4.3.1",
"@vue/cli-plugin-router": "^4.1.1", "@vue/cli-plugin-router": "^4.3.1",
"@vue/cli-plugin-vuex": "^4.1.1", "@vue/cli-plugin-vuex": "^4.3.1",
"@vue/cli-service": "^4.1.0", "@vue/cli-service": "^4.3.1",
"@vue/eslint-config-prettier": "^6.0.0", "@vue/eslint-config-prettier": "^6.0.0",
"axios": "^0.19.0", "axios": "^0.19.2",
"babel-eslint": "^10.0.3", "babel-eslint": "^10.1.0",
"eslint": "^5.16.0", "eslint": "^5.16.0",
"eslint-plugin-prettier": "^3.1.2", "eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^5.0.0", "eslint-plugin-vue": "^5.0.0",
"material-design-icons-iconfont": "^5.0.1", "material-design-icons-iconfont": "^5.0.1",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"sass": "^1.19.0", "sass": "^1.26.5",
"sass-loader": "^8.0.0", "sass-loader": "^8.0.2",
"vue-cli-plugin-vuetify": "^2.0.2", "vue-cli-plugin-vuetify": "^2.0.5",
"vue-template-compiler": "^2.6.10", "vue-template-compiler": "^2.6.10",
"vuetify-loader": "^1.3.0" "vuetify-loader": "^1.4.4"
}, },
"eslintConfig": { "eslintConfig": {
"root": true, "root": true,

View File

@ -17,7 +17,7 @@
<v-btn icon v-if="isUser" disabled> <v-btn icon v-if="isUser" disabled>
<v-icon>{{person}}</v-icon> <v-icon>{{person}}</v-icon>
</v-btn> </v-btn>
<v-btn icon to="/pricelist"> <v-btn icon :to="{name: 'priceListNoLogin'}">
<v-icon>{{list}}</v-icon> <v-icon>{{list}}</v-icon>
</v-btn> </v-btn>
</v-app-bar> </v-app-bar>

View File

@ -1,6 +1,6 @@
<template> <template>
<v-list> <v-list>
<v-list-item link to="/main/bar/geruecht"> <v-list-item link :to="{name: 'geruecht'}">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{ glass_mug_variant }}</v-icon> <v-icon>{{ glass_mug_variant }}</v-icon>
</v-list-item-icon> </v-list-item-icon>

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<v-list> <v-list>
<v-list-item class="title" link to="/main/finanzer/overview"> <v-list-item class="title" link :to="{name: 'overview'}">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{home}}</v-icon> <v-icon>{{home}}</v-icon>
</v-list-item-icon> </v-list-item-icon>

View File

@ -1,6 +1,6 @@
<template> <template>
<v-list> <v-list>
<v-list-item class="title" link to="/main/gastro/pricelist"> <v-list-item class="title" link :to="{name: 'gastroPricelist'}">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{list}}</v-icon> <v-icon>{{list}}</v-icon>
</v-list-item-icon> </v-list-item-icon>

View File

@ -1,250 +0,0 @@
<template>
<div>
<v-toolbar>
<v-toolbar-title>
Dienstanfragen
</v-toolbar-title>
</v-toolbar>
<v-card tile flat>
<v-card-title>
Gesendete Anfragen
</v-card-title>
<v-progress-circular indeterminate v-if="transactJobsLoading" />
<div v-for="job in transactJobs" :key="transactJobs.indexOf(job)">
<v-expand-transition>
<v-card tile style="margin-top: 3px">
<v-card-text>
<v-row>
<v-col>
<v-combobox
outlined
label="An"
:value="job.to_user.firstname + ' ' + job.to_user.lastname"
readonly
append-icon
>
<template v-slot:selection="data">
<v-chip>
{{ data.item }}
</v-chip>
</template>
</v-combobox>
</v-col>
<v-col>
<v-combobox
outlined
label="Datum"
:value="
job.date.getDate() +
'.' +
(job.date.getMonth() + 1) +
'.' +
job.date.getFullYear()
"
readonly
append-icon
>
<template v-slot:selection="data">
<v-chip>
{{ data.item }}
</v-chip>
</template>
</v-combobox>
</v-col>
<v-col>
<v-combobox
outlined
label="Status"
:value="acceptedStatus(job)"
readonly
append-icon
>
<template v-slot:selection="data">
<v-chip :color="statusColor(job)">
{{ data.item }}
</v-chip>
</template>
</v-combobox>
</v-col>
</v-row>
</v-card-text>
<v-card-actions v-if="!job.answerd">
<v-spacer/>
<v-btn
@click="
deleteTransactJob({
username: job.to_user.username,
year: job.date.getFullYear(),
month: job.date.getMonth() + 1,
day: job.date.getDate()
})
"
>Stornieren
</v-btn
>
</v-card-actions>
</v-card>
</v-expand-transition>
</div>
</v-card>
<v-divider />
<v-card tile flat>
<v-card-title>
Eingehende Anfragen
</v-card-title>
<v-progress-circular indeterminate v-if="requestJobsLoading" />
<div v-for="job in requestJobs" :key="requestJobs.indexOf(job)">
<v-card tile style="margin-top: 3px">
<v-card-text>
<v-row>
<v-col>
<v-combobox
outlined
label="Von"
:value="
job.from_user.firstname + ' ' + job.from_user.lastname
"
readonly
append-icon
>
<template v-slot:selection="data">
<v-chip>
{{ data.item }}
</v-chip>
</template>
</v-combobox>
</v-col>
<v-col>
<v-combobox
outlined
label="Datum"
:value="
job.date.getDate() +
'.' +
(job.date.getMonth() + 1) +
'.' +
job.date.getFullYear()
"
readonly
append-icon
>
<template v-slot:selection="data">
<v-chip>
{{ data.item }}
</v-chip>
</template>
</v-combobox>
</v-col>
<v-col>
<v-combobox
outlined
label="Status"
:value="acceptedStatus(job)"
readonly
append-icon
>
<template v-slot:selection="data">
<v-chip :color="statusColor(job)">
{{ data.item }}
</v-chip>
</template>
</v-combobox>
</v-col>
</v-row>
</v-card-text>
<v-expand-transition>
<v-card-actions v-if="!job.answerd">
<v-spacer />
<v-btn
color="red"
@click="
answerJob({
username: job.from_user.username,
year: job.date.getFullYear(),
month: job.date.getMonth() + 1,
day: job.date.getDate(),
answer: false
})
"
>Ablehnen
</v-btn>
<v-btn
color="green"
@click="
answerJob({
username: job.from_user.username,
year: job.date.getFullYear(),
month: job.date.getMonth() + 1,
day: job.date.getDate(),
answer: true
})
"
>Annehmen
</v-btn>
</v-card-actions>
</v-expand-transition>
</v-card>
</div>
</v-card>
</div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
export default {
name: 'JobRequests',
methods: {
...mapActions({
getTransactJobs: 'requestJobs/getTransactJobs',
getRequestJobs: 'requestJobs/getRequestJobs',
answerJob: 'requestJobs/answerTransactJob',
deleteTransactJob: 'requestJobs/deleteTransactJob'
})
},
computed: {
...mapGetters({
transactJobs: 'requestJobs/transactJobs',
transactJobsLoading: 'requestJobs/transactJobsLoading',
requestJobs: 'requestJobs/requestJobs',
requestJobsLoading: 'requestJobs/requestJobsLoading'
}),
acceptedStatus() {
return job => {
if (!job.answerd) {
return 'gesendet'
}
if (job.answerd && job.accepted) {
return 'angenommen'
}
return 'abgelehnt'
}
},
statusColor() {
return job => {
if (!job.answerd) {
return
}
if (job.answerd && job.accepted) {
return 'green'
}
return 'red'
}
}
},
created() {
var now = new Date()
this.getTransactJobs({
year: now.getFullYear(),
month: now.getMonth() + 1,
day: now.getDate()
})
this.getRequestJobs({
year: now.getFullYear(),
month: now.getMonth() + 1,
day: now.getDate()
})
}
}
</script>
<style scoped></style>

View File

@ -0,0 +1,208 @@
<template>
<div>
<v-card tile :loading="jobInvitesLoading">
<v-card-title>
Eingehende Einladungen
</v-card-title>
<v-card-text>
<v-expansion-panels>
<v-expansion-panel
v-for="jobInvite in jobInvitesToMe"
:key="jobInvite.id"
@click.once="seenJobIvnite(jobInvite)"
>
<v-expansion-panel-header>
<div>
{{ jobInvite.on_date.getDate() }}.{{
jobInvite.on_date.getMonth() + 1
}}.{{ jobInvite.on_date.getFullYear() }} von
<v-badge dot :value="!jobInvite.watched" color="red">
{{ jobInvite.from_user.firstname }}
{{ jobInvite.from_user.lastname }}
</v-badge>
</div>
<v-row class="text-right" style="margin-right: 5px">
<v-col>
<v-progress-circular
indeterminate
v-if="jobInvitesLoading"
></v-progress-circular>
</v-col>
<v-col>
<v-icon color="green" v-show="userInWorker(jobInvite)">
{{ check }}
</v-icon>
</v-col>
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content :eager="true">
<v-row class="text-right">
<v-col>
<v-btn icon @click="updatingJobInvite(jobInvite)">
<v-icon>
{{ jobInvite.watched ? seen : notSeen }}
</v-icon>
</v-btn>
</v-col>
</v-row>
<Day
:day="jobInvite.day"
:long="true"
:loading="jobInvite.day.loading"
@addingJob="addingJob(jobInvite, $event)"
@deletingJob="deletingJob(jobInvite, $event)"
@sendInvites="setJobInvites"
@sendRequests="setJobRequests"
@deleteJobInvite="deleteInvite"
@deleteJobRequest="deleteRequest"
/>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
</v-card-text>
</v-card>
<v-card tile :loading="jobInvitesLoading">
<v-card-title>
Versendete Einladungen
</v-card-title>
<v-card-text>
<v-expansion-panels>
<v-expansion-panel
v-for="jobInvite in jobInvitesFromMe"
:key="jobInvite.id"
@click.once="seenJobIvnite(jobInvite)"
>
<v-expansion-panel-header>
<div>
{{ jobInvite.on_date.getDate() }}.{{
jobInvite.on_date.getMonth() + 1
}}.{{ jobInvite.on_date.getFullYear() }} an
<v-badge :value="jobInvite.watched" icon="mdi-eye" color="grey" inline>
{{ jobInvite.to_user.firstname }}
{{ jobInvite.to_user.lastname }}
</v-badge>
</div>
<v-row class="text-right" style="margin-right: 5px">
<v-col>
<v-progress-circular
indeterminate
v-if="jobInvitesLoading"
></v-progress-circular>
</v-col>
<v-col>
<v-icon color="green" v-show="userInWorker(jobInvite)">
{{ check }}
</v-icon>
</v-col>
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content :eager="true">
<v-row class="text-right">
<v-col>
<v-btn icon @click="deleteInvite(jobInvite)">
<v-icon>
{{trashCan}}
</v-icon>
</v-btn>
</v-col>
</v-row>
<Day
:day="jobInvite.day"
:long="true"
:loading="jobInvite.day.loading"
@addingJob="addingJob(jobInvite, $event)"
@deletingJob="deletingJob(jobInvite, $event)"
@sendInvites="setJobInvites"
@sendRequests="setJobRequests"
@deleteJobInvite="deleteInvite"
@deleteJobRequest="deleteRequest"
/>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
</v-card-text>
</v-card>
</div>
</template>
<script>
import { mapActions, mapGetters } from 'vuex'
import { mdiEyeOff, mdiEyeCheck, mdiCheck, mdiTrashCan } from '@mdi/js'
import Day from '@/components/user/Jobs/Day'
export default {
name: 'JobInvites',
components: { Day },
data() {
return {
notSeen: mdiEyeOff,
seen: mdiEyeCheck,
check: mdiCheck,
trashCan: mdiTrashCan,
showNotSeen: false,
showSeen: false,
update: 0
}
},
methods: {
...mapActions({
getJobInvites: 'jobInvites/getJobInvites',
addJob: 'jobInvites/addJob',
setJobInvites: 'jobInvites/setJobInvites',
updateJobInviteToMe: 'jobInvites/updateJobInviteToMe',
deleteJob: 'jobInvites/deleteJob',
setJobRequests: 'jobRequests/setJobRequests',
deleteInvite: 'jobInvites/deleteJobInviteFromMe',
deleteRequest: 'jobRequests/deleteJobRequestFromMe'
}),
forceRender() {
setTimeout(() => {
this.update += 0
}, 500)
},
updatingJobInvite(jobInvite) {
jobInvite.watched = !jobInvite.watched
this.updateJobInviteToMe(jobInvite)
},
seenJobIvnite(jobInvite) {
if (!jobInvite.watched) {
jobInvite.watched = true
this.updateJobInviteToMe(jobInvite)
}
},
addingJob(jobInvite, event) {
this.seenJobIvnite(jobInvite)
this.addJob(event)
this.forceRender()
},
deletingJob(jobInvite, event) {
this.seenJobIvnite(jobInvite)
this.deleteJob(event)
this.forceRender()
},
userInWorker(jobinvite) {
var jobkinddate = jobinvite.day.jobkinddate.find(item => {
return item.worker.find(workeritem => {
return workeritem.id === jobinvite.to_user.id
})
})
return !!jobkinddate
}
},
computed: {
...mapGetters({
jobInvitesFromMe: 'jobInvites/jobInvitesFromMe',
jobInvitesToMe: 'jobInvites/jobInvitesToMe',
jobInvitesLoading: 'jobInvites/jobInvitesLoading',
activeUser: 'user/user'
})
},
created() {
setTimeout(() => {
this.getJobInvites(new Date())
}, 200)
}
}
</script>
<style scoped></style>

View File

@ -0,0 +1,224 @@
<template>
<div>
<v-card tile :loading="jobRequestsLoading">
<v-card-title>
Eingehende Anfragen
</v-card-title>
<v-card-text>
<v-expansion-panels>
<v-expansion-panel
v-for="(jobrequest, index) in jobRequestsToMe"
:key="index"
>
<v-expansion-panel-header @click.once="seenJobRequest(jobrequest)">
<div>
{{ jobrequest.on_date.getDate() }}.{{
jobrequest.on_date.getMonth() + 1
}}.{{ jobrequest.on_date.getFullYear() }} von
<v-badge dot :value="!jobrequest.watched" color="red">
{{ jobrequest.from_user.firstname }}
{{ jobrequest.from_user.lastname }}
</v-badge>
</div>
<v-row class="text-right" style="margin-right: 5px">
<v-col>
<v-progress-circular
indeterminate
v-if="jobRequestsLoading"
></v-progress-circular>
</v-col>
<v-col>
<v-icon color="green" v-show="userInWorker(jobrequest)">
{{ check }}
</v-icon>
</v-col>
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<v-row class="text-right">
<v-col>
<v-btn icon @click="updatingSeenJobRequest(jobrequest)">
<v-icon>
{{ jobrequest.watched ? seen : notSeen }}
</v-icon>
</v-btn>
</v-col>
</v-row>
<Day
:day="jobrequest.day"
:long="true"
@sendRequests="sendingJobRequests(jobrequest, $event)"
@addingJob="addJob"
@deletingJob="deleteJob"
@sendInvites="setJobInvites"
@deleteJobInvite="deleteInvite"
@deleteJobRequest="deleteJobRequestFromMe"
/>
<v-row class="text-right">
<v-col>
<v-btn
v-show="!jobrequest.answered"
text
@click="updatingAcceptedJobRequest(jobrequest)"
>Annehmen</v-btn
>
<div v-show="jobrequest.answered && !jobrequest.accepted">
Dieser Dienst wurde schon übertragen.
</div>
</v-col>
</v-row>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
</v-card-text>
</v-card>
<v-card tile :loading="jobRequestsLoading">
<v-card-title>
Ausgehende Anfragen
</v-card-title>
<v-card-text>
<v-expansion-panels>
<v-expansion-panel
v-for="(jobrequest, index) in jobRequestsFromMe"
:key="index"
>
<v-expansion-panel-header>
<div>
{{ jobrequest.on_date.getDate() }}.{{
jobrequest.on_date.getMonth() + 1
}}.{{ jobrequest.on_date.getFullYear() }} an
<v-badge :value="jobrequest.watched" icon="mdi-eye" color="grey" inline>
{{ jobrequest.to_user.firstname }}
{{ jobrequest.to_user.lastname }}
</v-badge>
</div>
<v-row class="text-right" style="margin-right: 5px">
<v-col>
<v-progress-circular
indeterminate
v-if="jobRequestsLoading"
></v-progress-circular>
</v-col>
<v-col>
<v-icon color="green" v-show="jobrequest.accepted">
{{ check }}
</v-icon>
</v-col>
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<v-row class="text-right">
<v-col>
<v-btn icon @click="deleteJobRequestFromMe(jobrequest)">
<v-icon>
{{trashCan}}
</v-icon>
</v-btn>
</v-col>
</v-row>
<Day
:day="jobrequest.day"
:long="true"
@sendRequests="sendingJobRequests(jobrequest, $event)"
@addingJob="addJob"
@deletingJob="deleteJob"
@sendInvites="setJobInvites"
@deleteJobInvite="deleteInvite"
@deleteJobRequest="deleteJobRequestFromMe"
/>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
</v-card-text>
</v-card>
</div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
import { mdiEyeOff, mdiEyeCheck, mdiCheck, mdiTrashCan } from '@mdi/js'
import Day from '@/components/user/Jobs/Day'
export default {
name: 'JobTransfer',
components: { Day },
props: {},
data() {
return {
notSeen: mdiEyeOff,
seen: mdiEyeCheck,
check: mdiCheck,
trashCan: mdiTrashCan,
}
},
methods: {
...mapActions({
getJobRequests: 'jobRequests/getJobRequests',
updateJobRequestToMe: 'jobRequests/updateJobRequestToMe',
setJobRequests: 'jobRequests/setJobRequests',
deleteJobRequestFromMe: 'jobRequests/deleteJobRequestFromMe',
deleteInvite: 'jobInvites/deleteJobInviteFromMe',
getJobInvites: 'jobInvites/getJobInvites',
addJob: 'jobInvites/addJob',
setJobInvites: 'jobInvites/setJobInvites',
updateJobInviteToMe: 'jobInvites/updateJobInviteToMe',
deleteJob: 'jobInvites/deleteJob',
}),
updatingAcceptedJobRequest(jobRequest) {
jobRequest.accepted = true
jobRequest.answered = true
this.updateJobRequestToMe({ ...jobRequest })
setTimeout(() => {
this.getJobRequests(), 200
})
},
updatingSeenJobRequest(jobRequest) {
jobRequest.watched = !jobRequest.watched
this.updateJobRequestToMe({ ...jobRequest })
},
seenJobRequest(jobRequest) {
if (!jobRequest.watched) {
jobRequest.watched = true
this.updateJobRequestToMe(jobRequest)
}
},
userInWorker(jobrequest) {
var jobkinddate = jobrequest.day.jobkinddate.find(item => {
return item.worker.find(workeritem => {
return workeritem.id === this.activeUser.id
})
})
return !!jobkinddate
},
sendingJobRequests(jobrequest, event) {
this.seenJobRequest(jobrequest)
this.setJobRequests(event)
}
},
computed: {
...mapGetters({
jobRequestsToMe: 'jobRequests/jobRequestsToMe',
jobRequestsFromMe: 'jobRequests/jobRequestsFromMe',
jobRequestsLoading: 'jobRequests/jobRequestsLoading',
loading: 'user/loading',
activeUser: 'user/user'
})
},
created() {
if (!this.loading) {
this.getJobRequests()
}
},
watch: {
loading(newValue) {
if (!newValue) {
this.getJobRequests()
}
},
jobRequestsLoading(newValue, oldValue) {
console.log(newValue, oldValue)
}
}
}
</script>
<style scoped></style>

View File

@ -4,7 +4,14 @@
<v-toolbar-title>Dienstübersicht</v-toolbar-title> <v-toolbar-title>Dienstübersicht</v-toolbar-title>
<v-spacer /> <v-spacer />
<v-toolbar-items> <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-icon>{{ keyboard_arrow_left }}</v-icon>
</v-btn> </v-btn>
<v-list-item> <v-list-item>
@ -13,7 +20,14 @@
{{ date.getFullYear() }} {{ date.getFullYear() }}
</v-list-item-title> </v-list-item-title>
</v-list-item> </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-icon>{{ keyboard_arrow_right }}</v-icon>
</v-btn> </v-btn>
</v-toolbar-items> </v-toolbar-items>
@ -31,8 +45,17 @@
<v-card-text> <v-card-text>
<v-row justify="start" align="start"> <v-row justify="start" align="start">
<div v-for="day in week.days" :key="day.id"> <div v-for="day in week.days" :key="day.id">
<v-col> <v-col cols="12">
<Day v-bind:day="day" /> <Day
:day="day"
:long="false"
@addingJob="addJob"
@sendInvites="setJobInvites"
@deletingJob="deleteJob"
@sendRequests="setJobRequests"
@deleteJobInvite="deleteInvite"
@deleteJobRequest="deleteRequest"
/>
</v-col> </v-col>
</div> </div>
</v-row> </v-row>
@ -52,7 +75,7 @@ export default {
return { return {
keyboard_arrow_left: mdiChevronLeft, keyboard_arrow_left: mdiChevronLeft,
keyboard_arrow_right: mdiChevronRight, keyboard_arrow_right: mdiChevronRight,
date: new Date(), date: new Date(this.$route.params.year, this.$route.params.month - 1, 1),
monthArray: [ monthArray: [
'Januar', 'Januar',
'Februar', 'Februar',
@ -70,19 +93,10 @@ export default {
} }
}, },
created() { created() {
for (let intDate = 1; intDate < 7; intDate++) { this.getActiveUser()
if ( this.getAllJobKinds()
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.createMonth(this.date) this.createMonth(this.date)
this.getAllUsers() this.getDBUsers()
this.getUsers({ this.getUsers({
from_date: { from_date: {
year: this.startDate.getFullYear(), year: this.startDate.getFullYear(),
@ -95,18 +109,22 @@ export default {
day: this.endDate.getDate() day: this.endDate.getDate()
} }
}) })
this.getTransactJobs({
year: this.date.getFullYear(),
month: this.date.getMonth() + 1,
day: 1
})
}, },
methods: { methods: {
...mapActions({ ...mapActions({
getTransactJobs: 'requestJobs/getTransactJobs', getActiveUser: 'user/getUser',
createMonth: 'jobs/createMonth', createMonth: 'jobs/createMonth',
getAllUsers: 'jobs/getAllUsers', getUsers: 'jobs/getUsers',
getUsers: 'jobs/getUsers' getDBUsers: 'usermanager/getUsers',
getAllJobKinds: 'jkm/getAllJobKinds',
addJob: 'jobs/addJob',
deleteJob: 'jobs/deleteJob',
setJobInvites: 'jobInvites/setJobInvites',
getJobInvites: 'jobInvites/getJobInvites',
getJobRequests: 'jobRequests/getJobRequests',
setJobRequests: 'jobRequests/setJobRequests',
deleteInvite: 'jobInvites/deleteJobInviteFromMe',
deleteRequest: 'jobRequests/deleteJobRequestFromMe'
}), }),
changeMonth(value) { changeMonth(value) {
if (value === -1) { if (value === -1) {
@ -133,8 +151,40 @@ export default {
...mapGetters({ ...mapGetters({
month: 'jobs/month', month: 'jobs/month',
startDate: 'jobs/getStartDate', startDate: 'jobs/getStartDate',
endDate: 'jobs/getEndDate' endDate: 'jobs/getEndDate',
loading: 'user/loading'
}) })
},
watch: {
$route() {
this.getActiveUser()
this.date = new Date(
this.$route.params.year,
this.$route.params.month - 1,
1
)
this.getAllJobKinds()
this.createMonth(this.date)
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()
}
})
},
loading(newValue) {
if (!newValue) {
this.getJobInvites()
this.getJobRequests()
}
}
} }
} }
</script> </script>

View File

@ -1,144 +1,280 @@
<template> <template>
<div v-if="day"> <div v-if="day">
<v-card :color="color(day)" max-width="250px" min-width="250px"> <v-card :color="color(day)" :max-width="long ? '' : '20em'">
<v-card-title v-if="day.date" class="subtitle-1 font-weight-bold"> <v-card-title v-if="day.date" class="subtitle-1 font-weight-bold">
{{ day.name }} den {{ day.date.getDate() }}.{{ {{ name }} den {{ day.date.getDate() }}.{{ day.date.getMonth() + 1 }}.{{
day.date.getMonth() + 1 day.date.getFullYear()
}}.{{ day.date.getFullYear() }} }}
</v-card-title> </v-card-title>
<v-card-text> <v-card-text>
<v-expand-transition> <v-expand-transition>
<v-row align="center" justify="center" v-if="day.loading"> <v-row align="center" justify="center" v-if="dayLoading">
<v-progress-circular indeterminate color="grey" /> <v-progress-circular indeterminate color="grey" />
</v-row> </v-row>
</v-expand-transition> </v-expand-transition>
<v-expand-transition> <v-expand-transition>
<div v-show="!day.loading"> <div v-show="!dayLoading">
<div v-for="worker in day.worker" :key="day.worker.indexOf(worker)"> <div
v-for="(jobkinddateitem, index) in day.jobkinddate"
:key="index"
>
<div class="title black--text text-sm-center">
{{ jobkinddateitem.job_kind.name }}
</div>
<v-combobox
multiple
filled
disabled
readonly
:counter="jobkinddateitem.maxpersons"
v-model="jobkinddateitem.worker"
:item-text="item => item.firstname + ' ' + item.lastname"
item-value="username"
chips
append-icon=""
>
<template v-slot:selection="data">
<v-chip <v-chip
style="margin: 3px;" >{{ data.item.firstname }} {{ data.item.lastname }}</v-chip
:close=" >
(user(worker) && !day.locked) || (canDelete && user(worker)) </template>
" </v-combobox>
@click:close="
deleteJob({
year: day.date.getFullYear(),
month: day.date.getMonth() + 1,
day: day.date.getDate()
})
"
>{{ worker.firstname }} {{ worker.lastname }}</v-chip>
</div> </div>
</div> </div>
</v-expand-transition> </v-expand-transition>
</v-card-text> </v-card-text>
<div v-if="userInWorker && day.locked"> <v-card-actions class="text--secondary" v-if="!dayLoading" :key="update">
<v-card-actions class="text--secondary"> <v-spacer />
<v-autocomplete <v-menu
return-object v-model="menu"
v-model="requestUser" open-on-hover
:items="specifiedUsers" close-on-click
item-text="fullName" close-on-content-click
label="Dienstanfrage" offset-y
filled
color="green"
@input="searchInput = null"
:search-input.sync="searchInput"
> >
<template v-slot:prepend-inner> <template v-slot:activator="{ on }">
<v-icon>{{ account_add }}</v-icon> <v-btn
text
v-on="on"
v-show="filterAddJob.length > 0 && !userInWorker() && !day.locked"
>
Eintragen
</v-btn>
</template> </template>
<template v-slot:item="data"> <v-list>
<v-list-item-content> <v-list-item
<v-list-item-title>{{ data.item.firstname }} {{ data.item.lastname }}</v-list-item-title> v-for="(jobkinddateitem, index) in filterAddJob"
</v-list-item-content> :key="index"
@click="addingJob(jobkinddateitem)"
>
<v-list-item-title>
{{ jobkinddateitem.job_kind.name }}
</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<v-menu v-model="menu_invite" :close-on-content-click="false" offset-y>
<template v-slot:activator="{ on }">
<v-btn
v-show="
jobkindWithSpace.length !== 0 && !day.locked && userInWorker()
"
text
v-on="on"
>Einladen</v-btn
>
</template> </template>
<v-card :loading="jobInvitesLoading">
<v-card-title>
Einladungen
</v-card-title>
<v-card-text>
<v-div
bottom
v-for="(invite, index) in getInvites(day.date)"
:key="index"
>
<v-chip v-on="on" style="margin: 5px">
{{ invite.to_user.firstname }}
{{ invite.to_user.lastname }}
</v-chip>
</v-div>
<v-divider style="margin-bottom: 5px" />
<v-autocomplete
v-model="job_invites"
label="Einladungen senden an"
return-object
multiple
filled
:item-text="item => item.firstname + ' ' + item.lastname"
item-value="id"
chips
deletable-chips
:items="filteredDBUsers()"
>
</v-autocomplete> </v-autocomplete>
</v-card-actions> </v-card-text>
<v-card-actions> <v-card-actions>
<v-btn text block @click="send">senden</v-btn>
</v-card-actions>
</div>
<v-card-actions class="text--secondary">
<div v-if="!userInWorker">
<div v-if="day.locked">
Du kannst dich nicht zum Bardienst eintragen, da der Tag gesperrt
ist.
</div>
<div v-else-if="day.worker.length >= 2">
Du kannst dich nicht Bardienst eintragen, da mehr als 2 Personen
schon eingetragen sind.
</div>
<div v-else>Hier kannst du dich zum Bardienst eintragen.</div>
</div>
<v-spacer /> <v-spacer />
<v-btn <v-btn
text text
v-if=" :disabled="job_invites.length === 0"
!day.locked && @click="sendInvites()"
!day.loading && >
day.worker.length < 2 && {{ job_invites.length >= 1 ? 'Einladungen' : 'Einladung' }}
!userInWorker senden
" </v-btn>
@click=" </v-card-actions>
addJob({ </v-card>
year: day.date.getFullYear(), </v-menu>
month: day.date.getMonth() + 1, <v-menu
day: day.date.getDate() v-model="menu_request"
}) :close-on-content-click="false"
" offset-y
>Eintragen</v-btn> v-if="day.locked && userInWorker()"
>
<template v-slot:activator="{ on }">
<v-btn v-show="day.locked && userInWorker()" text v-on="on">
Abgeben
</v-btn>
</template>
<v-card :loading="jobRequestsLoading">
<v-card-title>
Dienstabgabenanfrage
</v-card-title>
<v-card-text>
<div v-if="jobRequestsLoading">
<v-progress-circular indeterminate />
</div>
<div v-if="!jobRequestsLoading">
<v-div
bottom
v-for="(request, index) in getRequests(day.date)"
:key="index"
>
<v-chip v-on="on" style="margin: 5px">
{{ request.to_user.firstname }}
{{ request.to_user.lastname }}
</v-chip>
</v-div>
</div>
<v-divider style="margin-bottom: 5px" />
<v-autocomplete
v-model="job_requests"
label="Anfragen senden an"
return-object
multiple
filled
:item-text="item => item.firstname + ' ' + item.lastname"
item-value="id"
chips
deletable-chips
:items="filteredDBUsersWithJobKind()"
>
</v-autocomplete>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn text @click="sendRequests()">
Anfragen
</v-btn>
</v-card-actions>
</v-card>
</v-menu>
<v-btn
v-show="!day.locked && userInWorker()"
text
@click="deletingJob()"
>Austragen</v-btn
>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</div> </div>
</template> </template>
<script> <script>
import { mapActions, mapGetters } from 'vuex' import { mapGetters, mapActions } from 'vuex'
import { mdiAccountPlus } from '@mdi/js' import { mdiAccountPlus } from '@mdi/js'
export default { export default {
name: 'Day', name: 'Day',
props: { props: {
day: Object day: Object,
long: Boolean,
loading: Boolean
}, },
data() { data() {
return { return {
account_add: mdiAccountPlus, account_add: mdiAccountPlus,
searchInput: null, searchInput: null,
requestUser: null requestUser: null,
menu: false,
menu_invite: false,
menu_request: false,
update: 0,
job_invites: [],
job_requests: []
} }
}, },
created() { created() {
this.setLoading(this.day.date) //setInterval(() => {console.log(this.day.loading)},100)
}, },
methods: { methods: {
...mapActions({ ...mapActions({}),
setLoading: 'jobs/setDayLoading', sendInvites() {
setNotLoading: 'jobs/setDayNotLoading', var sendData = []
addJob: 'jobs/addJob', this.job_invites.forEach(item => {
deleteJob: 'jobs/deleteJob', sendData.push({
transactJob: 'jobs/transactJob' from_user: this.activeUser,
}), to_user: item,
send() { date: {
this.transactJob({
user: this.requestUser.username,
year: this.day.date.getFullYear(), year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1, month: this.day.date.getMonth() + 1,
day: this.day.date.getDate() day: this.day.date.getDate()
}
}) })
this.requestUser = null })
this.searchInput = null this.$emit('sendInvites', sendData)
setTimeout(() => {
this.job_invites = []
}, 200)
this.menu_invite = false
},
sendRequests() {
var sendData = []
this.job_requests.forEach(item => {
sendData.push({
from_user: this.activeUser,
to_user: item,
date: {
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
},
job_kind: this.getJob_Kind()
})
})
this.$emit('sendRequests', sendData)
setTimeout(() => {
this.job_requests = []
}, 200)
this.menu_request = false
}, },
color: day => { color: day => {
if (day) { if (day) {
if (day.date.getDay() === 0 || day.date.getDay() === 1) { if (day.date.getDay() === 0 || day.date.getDay() === 1) {
return 'grey lighten-4' return 'grey lighten-4'
} else { } else {
if (day.worker.length < 2) { var retVal = 'yellow'
return 'yellow' retVal = 'light-green'
} else { for (var jobkind in day.jobkinddate) {
return 'light-green' if (
day.jobkinddate[jobkind].worker.length >=
day.jobkinddate[jobkind].maxpersons
)
retVal = 'light-green'
else return 'yellow'
} }
return retVal
} }
} else { } else {
return 'grey lighten-4' return 'grey lighten-4'
@ -146,44 +282,155 @@ export default {
}, },
user(worker) { user(worker) {
return worker.username === this.activeUser.username return worker.username === this.activeUser.username
},
addingJob(jobkinddateitem) {
this.$emit('addingJob', {
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate(),
job_kind: jobkinddateitem.job_kind
})
this.menu = false
setTimeout(() => {
this.update += 1
}, 200)
},
deletingJob() {
this.$emit('deletingJob', {
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
})
setTimeout(() => {
this.update += 1
})
},
userInWorker() {
var jobkinddate = this.day.jobkinddate.find(item => {
return item.worker.find(workeritem => {
return workeritem.id === this.activeUser.id
})
})
return !!jobkinddate
},
deletingInvite(jobInvite) {
let sendData = { ...jobInvite }
sendData.on_date = {
year: sendData.on_date.getFullYear(),
month: sendData.on_date.getMonth() + 1,
day: sendData.on_date.getDate()
}
this.$emit('deleteJobInvite', sendData)
},
deletingRequest(jobRequest) {
let sendData = { ...jobRequest }
sendData.on_date = {
year: sendData.on_date.getFullYear(),
month: sendData.on_date.getMonth() + 1,
day: sendData.on_date.getDate()
}
this.$emit('deleteJobRequest', sendData)
this.menu_request = false
setTimeout(() => {
this.menu_request = true
}, 200)
},
getJob_Kind() {
var jobkinddate = this.day.jobkinddate.find(item => {
return item.worker.find(user => {
return this.activeUser.id === user.id
})
})
return jobkinddate.job_kind
},
filteredDBUsersWithJobKind() {
console.log(this.day.jobkinddate)
var retVal = this.filteredDBUsers()
var job_kind = this.getJob_Kind()
retVal = retVal.filter(user => {
if (job_kind.workgroup ? job_kind.workgroup.if === null : true) {
return true
} else {
if (user.workgroups ? user.workgroups.length > 0 : false) {
return user.workgroups.find(wg => {
return wg.id === job_kind.workgroup.id
})
}
}
return false
})
return retVal
},
filteredDBUsers() {
var retVal = this.allUsers.filter(user => {
var test = this.day.jobkinddate.find(item => {
return item.worker.find(workeritem => {
return workeritem.id === user.id
})
})
return !test
})
retVal = retVal.filter(user => {
let getedDay = this.getDay(this.day.date)
let test = getedDay
? getedDay.find(day => {
return day.to_user.id === user.id
})
: false
return !test
})
return retVal
} }
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
disabled: 'jobs/disabled', activeUser: 'user/user',
activeUser: 'user', allUsers: 'usermanager/users',
allUsers: 'jobs/allUsers', getDay: 'jobInvites/getDayFromMe',
transactJobs: 'requestJobs/transactJobs' getInvites: 'jobInvites/getDayWorkerFromMe',
getRequests: 'jobRequests/getDayWorkerFromMe',
jobInvitesLoading: 'jobInvites/jobInvitesLoading',
jobRequestsLoading: 'jobRequests/jobRequestsLoading'
}), }),
userInWorker() { jobkindWithSpace() {
return this.day.worker.find(a => { var retVal = this.day.jobkinddate.filter(item => {
return a.username === this.activeUser.username if (item.maxpersons <= item.worker.length) return false
else return true
}) })
return retVal
}, },
specifiedUsers() { filterAddJob() {
var users = [...this.allUsers] var retVal = this.day.jobkinddate.filter(item => {
for (var i in this.day.worker) { if (item.maxpersons <= item.worker.length) {
var worker = users.find(a => { return false
return a.username === this.day.worker[i].username
})
var index = users.indexOf(worker)
if (worker) users.splice(index, 1)
} }
return users if (!item.job_kind.workgroup) {
}, return true
canDelete() { } else {
var transactJob = this.transactJobs.filter(a => { if (this.activeUser.workgroups) {
return a.date - this.day.date === 0 return this.activeUser.workgroups.find(workgroup => {
return workgroup.id === item.job_kind.workgroup.id
}) })
var test = transactJob.find(a => {
return a.accepted && a.answerd
})
return test
} }
}
})
return retVal
}, },
watch: {
worker() { name() {
return this.day.worker const name = this.day.date.getDay()
if (name === 0) return 'Sonntag'
else if (name === 1) return 'Montag'
else if (name === 2) return 'Dienstag'
else if (name === 3) return 'Mittwoche'
else if (name == 4) return 'Donnerstag'
else if (name === 5) return 'Freitag'
else return 'Samstag'
},
dayLoading() {
return this.loading
} }
} }
} }

View File

@ -0,0 +1,55 @@
<template>
<div>
<v-bottom-navigation v-model="bottom_nav">
<v-btn :to="{ name: 'jobRequests', params: { kind: 'jobInvites' } }">
<v-badge color="red" :content="newsInvite" :value="newsInvite !== 0">
Diensteinladungen
</v-badge>
</v-btn>
<v-btn :to="{ name: 'jobRequests', params: { kind: 'jobTransfer' } }">
<v-badge color="red" :content="newsRequest" :value="newsRequest !== 0">Dienstübertragung</v-badge>
</v-btn>
</v-bottom-navigation>
<JobInvites v-if="kind === 'jobInvites'"></JobInvites>
<JobTransfer v-if="kind === 'jobTransfer'"></JobTransfer>
</div>
</template>
<script>
import JobInvites from '@/components/user/JobRequests/JobInvites'
import JobTransfer from '@/components/user/JobRequests/JobTransfer'
import { mapActions, mapGetters } from 'vuex'
export default {
name: 'JobsRequest',
components: { JobTransfer, JobInvites },
data() {
return {
bottom_nav: true,
kind: this.$route.params.kind
}
},
methods: {
...mapActions({
getUser: 'user/getUser',
getDBUsers: 'usermanager/getUsers',
})
},
computed: {
...mapGetters({
newsInvite: 'jobInvites/news',
newsRequest: 'jobRequests/news'
})
},
created() {
this.getUser()
this.getDBUsers()
},
watch: {
$route() {
this.kind = this.$route.params.kind
}
}
}
</script>
<style scoped></style>

View File

@ -8,13 +8,22 @@
Home Home
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item link to="/main/user/overview"> <v-list-item link :to="{ name: 'userOverview' }">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{ bank }}</v-icon> <v-icon>{{ bank }}</v-icon>
</v-list-item-icon> </v-list-item-icon>
<v-list-item-title>Finanzübersicht</v-list-item-title> <v-list-item-title>Finanzübersicht</v-list-item-title>
</v-list-item> </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-list-item-icon>
<v-icon> <v-icon>
{{ briefcase }} {{ briefcase }}
@ -22,15 +31,20 @@
</v-list-item-icon> </v-list-item-icon>
<v-list-item-title>Dienstübersicht</v-list-item-title> <v-list-item-title>Dienstübersicht</v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item link to="/main/user/jobRequests"> <v-list-item
link
:to="{ name: 'jobRequests', params: { kind: 'jobInvites' } }"
>
<v-list-item-icon> <v-list-item-icon>
<v-badge overlap color="red" :content="news" :value="news !== 0">
<v-icon> <v-icon>
{{ switchAccount }} {{ switchAccount }}
</v-icon> </v-icon>
</v-badge>
</v-list-item-icon> </v-list-item-icon>
<v-list-item-title>Dienstanfragen</v-list-item-title> <v-list-item-title>Dienstanfragen</v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item link to="/main/user/config"> <v-list-item link :to="{ name: 'userConfig' }">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{ account_card_details }}</v-icon> <v-icon>{{ account_card_details }}</v-icon>
</v-list-item-icon> </v-list-item-icon>
@ -47,6 +61,8 @@ import {
mdiBriefcase, mdiBriefcase,
mdiAccountSwitch mdiAccountSwitch
} from '@mdi/js' } from '@mdi/js'
import { mapGetters, mapActions } from 'vuex'
export default { export default {
name: 'UserNavigation', name: 'UserNavigation',
data() { data() {
@ -57,6 +73,35 @@ export default {
briefcase: mdiBriefcase, briefcase: mdiBriefcase,
switchAccount: mdiAccountSwitch switchAccount: mdiAccountSwitch
} }
},
methods: {
...mapActions({
getJobInvites: 'jobInvites/getJobInvites',
getJobRequests: 'jobRequests/getJobRequests',
getUser: 'user/getUser'
})
},
computed: {
...mapGetters({
newsInvite: 'jobInvites/news',
newsRequest: 'jobRequests/news',
loading: 'user/loading'
}),
news() {
return this.newsInvite + this.newsRequest
}
},
created() {
this.getUser()
},
watch: {
loading(newValue) {
if (!newValue) {
this.getJobInvites()
this.getJobRequests()
}
}
} }
} }
</script> </script>

View File

@ -0,0 +1,171 @@
<template>
<div>
<v-data-table
:items="jobkinds"
:headers="header"
:loading="jobkindsLoading || workgroupsLoading"
:search="search"
>
<template v-slot:top>
<v-toolbar flat color="white">
<v-toolbar-title>
Dienstarten
</v-toolbar-title>
<v-spacer />
<v-text-field
v-model="search"
label="Suche Dienstart"
single-line
hide-details
>
<template v-slot:append>
<v-icon>{{ searchIcon }}</v-icon>
</template>
</v-text-field>
<v-btn fab small color="primary" @click="add()">
<v-icon>{{ plusIcon }}</v-icon>
</v-btn>
</v-toolbar>
</template>
<template v-slot:item.workgroup="{ item }">
{{ item.workgroup === null ? 'Alle' : item.workgroup.name }}
</template>
<template v-slot:item.actions="{item}">
<v-icon x-small @click="editJobKind(item)">{{editIcon}}</v-icon>
<v-icon x-small @click="deleteJobKind(item)">{{deleteIcon}}</v-icon>
</template>
</v-data-table>
<v-dialog v-model="dialog">
<v-card>
<v-card-title>
{{ title }}
</v-card-title>
<v-card-text>
<v-row>
<v-col>
<v-text-field outlined label="Name" v-model="editedItem.name" />
</v-col>
<v-col>
<v-autocomplete
outlined
return-object
label="Arbeitsgruppe"
v-model="editedItem.workgroup"
item-text="name"
item-value="id"
:items="[...workgroups, { id: -1, name: 'Alle' }]"
/>
</v-col>
</v-row>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn text color="primary" @click="close()">Abbrechen</v-btn>
<v-btn text color="primary" @click="save()">Speichern</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
import { mdiPencil, mdiDelete, mdiPlus, mdiMagnify } from '@mdi/js'
export default {
name: 'JobKindManager',
data() {
return {
search: null,
editIcon: mdiPencil,
deleteIcon: mdiDelete,
plusIcon: mdiPlus,
searchIcon: mdiMagnify,
dialog: false,
header: [
{ text: 'Name', value: 'name' },
{ text: 'Zugewiesene Arbeitsgruppe', value: 'workgroup' },
{
text: 'Aktionen',
value: 'actions',
filterable: false,
sortable: false
}
],
editedItem: {
id: -1,
name: null,
workgroup: {
id: -1,
name: null
}
},
defaultItem: {
id: -1,
name: null,
workgroup: {
id: -1,
name: null
}
}
}
},
methods: {
...mapActions({
getAllJobKinds: 'jkm/getAllJobKinds',
addingJobKind: 'jkm/addJobKind',
updateJobKind: 'jkm/updateJobKind',
deletingJobKind: 'jkm/deleteJobKind',
getAllWorkgroups: 'wm/getAllWorkgroups'
}),
add() {
this.dialog = true
},
editJobKind(jobkind) {
this.dialog = true
this.editedItem = Object.assign({}, jobkind)
if (this.editedItem.workgroup === null) {
this.editedItem.workgroup = Object.assign({}, this.defaultItem.workgroup)
}
},
deleteJobKind(jobkind) {
confirm('Willst du diese Dienstart wirklich löschen') &&
this.deletingJobKind(jobkind)
this.close()
},
close() {
setTimeout(() => {
this.editedItem = Object.assign({}, this.defaultItem)
this.dialog = false
}, 200)
},
save() {
if (this.editedItem.workgroup.id === -1)
this.editedItem.workgroup = null
this.editedItem.id === -1
? this.addingJobKind(this.editedItem)
: this.updateJobKind(this.editedItem)
this.close()
}
},
computed: {
...mapGetters({
jobkinds: 'jkm/jobkinds',
jobkindsLoading: 'jkm/jobkindsLoading',
workgroups: 'wm/workgroups',
workgroupsLoading: 'wm/workgroupLoading'
}),
title() {
return this.editedItem.id === -1
? 'Neue Dienstart erstellen'
: 'Dienstart bearbeiten'
}
},
created() {
this.getAllJobKinds()
this.getAllWorkgroups()
console.log(this.jobkinds)
}
}
</script>
<style scoped></style>

View File

@ -1,14 +1,13 @@
<template> <template>
<v-list> <v-list>
<v-list-item link to="/main/management/servicemanagement"> <v-list-item link :to="{name: 'serviceManagement', params: {year: new Date().getFullYear(), month: new Date().getMonth() + 1}}"> <v-list-item-icon>
<v-list-item-icon>
<v-icon>{{ work }}</v-icon> <v-icon>{{ work }}</v-icon>
</v-list-item-icon> </v-list-item-icon>
<v-list-item-title> <v-list-item-title>
Dienstverwaltung Dienstverwaltung
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item link to="/main/management/usermanager"> <v-list-item link :to="{name: 'userManager'}">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{list}}</v-icon> <v-icon>{{list}}</v-icon>
</v-list-item-icon> </v-list-item-icon>
@ -16,7 +15,7 @@
Benutzerliste Benutzerliste
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item link to="/main/management/workgroupmanagement"> <v-list-item link :to="{name: 'workgroupManagement'}">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{group}}</v-icon> <v-icon>{{group}}</v-icon>
</v-list-item-icon> </v-list-item-icon>
@ -24,6 +23,14 @@
Arbeitsgruppen Arbeitsgruppen
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item link :to="{name: 'jobkindManagement'}">
<v-list-item-icon>
<v-icon>???</v-icon>
</v-list-item-icon>
<v-list-item-title>
Dienstarten
</v-list-item-title>
</v-list-item>
</v-list> </v-list>
</template> </template>

View File

@ -4,7 +4,7 @@
<v-toolbar-title>Dienstverwaltung</v-toolbar-title> <v-toolbar-title>Dienstverwaltung</v-toolbar-title>
<v-spacer /> <v-spacer />
<v-toolbar-items> <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-icon>{{ keyboard_arrow_left }}</v-icon>
</v-btn> </v-btn>
<v-list-item> <v-list-item>
@ -13,7 +13,7 @@
{{ date.getFullYear() }} {{ date.getFullYear() }}
</v-list-item-title> </v-list-item-title>
</v-list-item> </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-icon>{{ keyboard_arrow_right }}</v-icon>
</v-btn> </v-btn>
</v-toolbar-items> </v-toolbar-items>
@ -57,7 +57,7 @@ export default {
keyboard_arrow_left: mdiChevronLeft, keyboard_arrow_left: mdiChevronLeft,
keyboard_arrow_right: mdiChevronRight, keyboard_arrow_right: mdiChevronRight,
id: 0, id: 0,
date: new Date(), date: new Date(this.$route.params.year, this.$route.params.month -1, 1),
monthArray: [ monthArray: [
'Januar', 'Januar',
'Februar', 'Februar',
@ -75,20 +75,10 @@ export default {
} }
}, },
created() { created() {
for (let intDate = 1; intDate < 7; intDate++) { this.getAllJobKinds()
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.createMonth(this.date) this.createMonth(this.date)
this.getAllUsers() this.getAllUsers()
this.getDBUsers()
this.getUsers({ this.getUsers({
from_date: { from_date: {
year: this.startDate.getFullYear(), year: this.startDate.getFullYear(),
@ -107,7 +97,9 @@ export default {
createMonth: 'sm/createMonth', createMonth: 'sm/createMonth',
getAllUsers: 'sm/getAllUsers', getAllUsers: 'sm/getAllUsers',
getUsers: 'sm/getUsers', getUsers: 'sm/getUsers',
lockDay: 'sm/lockDay' lockDay: 'sm/lockDay',
getDBUsers: 'usermanager/getUsersWithExtern',
getAllJobKinds: 'jkm/getAllJobKinds',
}), }),
changeMonth(value) { changeMonth(value) {
if (value === -1) { if (value === -1) {
@ -149,6 +141,27 @@ export default {
startDate: 'sm/getStartDate', startDate: 'sm/getStartDate',
endDate: 'sm/getEndDate' 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> </script>

View File

@ -1,10 +1,14 @@
<template> <template>
<div v-if="day"> <div v-if="day">
<v-card :color="color(day)" max-width="250px" min-width="250px"> <v-card :color="color(day)" max-width="20em">
<v-card-title v-if="day.date" class="subtitle-1 font-weight-bold"> <v-card-title v-if="day.date" class="subtitle-1 font-weight-bold">
{{ day.name }} den {{ day.date.getDate() }}.{{ {{ day.name }} {{ day.date.getDate() }}.{{ day.date.getMonth() + 1 }}.{{
day.date.getMonth() + 1 day.date.getFullYear()
}}.{{ day.date.getFullYear() }} }}
<v-spacer />
<v-btn icon small @click="dialog = true">
<v-icon>{{ menuIcon }}</v-icon>
</v-btn>
</v-card-title> </v-card-title>
<v-card-text> <v-card-text>
<v-expand-transition> <v-expand-transition>
@ -12,22 +16,32 @@
<v-progress-circular indeterminate color="grey" /> <v-progress-circular indeterminate color="grey" />
</v-row> </v-row>
</v-expand-transition> </v-expand-transition>
<div v-for="(jobkinddateitem, index) in day.jobkinddate" :key="index">
<div
v-if="
jobkinddateitem.job_kind
? jobkinddateitem.job_kind.id !== 0
: false
"
>
<v-expand-transition> <v-expand-transition>
<div v-show="!day.loading"> <div v-show="!day.loading">
<v-autocomplete <v-autocomplete
chips chips
return-object return-object
multiple multiple
v-model="day.worker" :counter="jobkinddateitem.maxpersons"
:items="allUsers" v-model="jobkinddateitem.worker"
item-text="fullName" :items="filterUser(jobkinddateitem.job_kind)"
label="Dienste" :item-text="item => item.firstname + ' ' + item.lastname"
:label="jobkinddateitem.job_kind.name"
filled filled
color="green" color="green"
@input="searchInput = null"
:search-input.sync="searchInput"
@blur="focused = false" @blur="focused = false"
@focus="focused = true" @focus="focused = true"
:key="update"
@change="forceRenderer(jobkinddateitem)"
> >
<template v-slot:prepend-inner> <template v-slot:prepend-inner>
<v-icon>{{ account_add }}</v-icon> <v-icon>{{ account_add }}</v-icon>
@ -38,33 +52,160 @@
:input-value="data.selected" :input-value="data.selected"
close close
@click="data.select" @click="data.select"
@click:close="remove(data.item)" @click:close="remove(jobkinddateitem, data.item)"
>{{ data.item.firstname }} {{ data.item.lastname }}</v-chip> >{{ data.item.firstname }} {{ data.item.lastname }}
</template> </v-chip>
<template v-slot:item="data">
<v-list-item-content>
<v-list-item-title>
{{ data.item.firstname }}
{{ data.item.lastname }}
</v-list-item-title>
</v-list-item-content>
</template> </template>
</v-autocomplete> </v-autocomplete>
</div> </div>
</v-expand-transition> </v-expand-transition>
</div>
</div>
</v-card-text> </v-card-text>
<v-card-actions v-if="!day.loading"> <v-card-actions v-if="!day.loading">
<v-chip class="text-uppercase" :color="lockedColor">{{ lockedText }}</v-chip> <v-chip class="text-uppercase" :color="lockedColor">{{
lockedText
}}</v-chip>
<v-spacer /> <v-spacer />
<v-btn text @click="lock">{{ lockedTextBtn }}</v-btn> <v-btn text @click="lock">{{ lockedTextBtn }}</v-btn>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
<v-dialog v-model="dialog">
<v-card>
<v-card-title>
Bearbeite Tag
</v-card-title>
<v-card-text>
<div>
<v-row v-if="!isBarDienstIn">
<v-col cols="8">
<v-text-field readonly outlined value="Bardienst" />
</v-col>
<v-col cols="2">
<v-text-field
outlined
label="Maximale Personen"
type="number"
v-model="maxpersons"
@change="createBarJobKindDate(maxpersons)"
/>
</v-col>
<v-col cols="2"> </v-col>
</v-row>
<v-row
v-for="(jobkinddateitem, index) in day.jobkinddate"
:key="index"
>
<v-col cols="8">
<v-text-field
v-if="!jobkinddateitem.new"
readonly
outlined
:value="jobkinddateitem.job_kind.name"
/>
<v-autocomplete
v-else
outlined
:items="filterJobKinds(jobkinddateitem, index)"
:rules="rules"
item-text="name"
item-value="id"
v-model="jobkinddateitem.job_kind"
return-object
></v-autocomplete>
</v-col>
<v-col cols="2">
<v-text-field
outlined
label="Maximale Personen"
type="number"
v-model="jobkinddateitem.maxpersons"
/>
</v-col>
<v-col cols="2">
<div v-if="jobkinddateitem.job_kind !== null">
<div v-if="jobkinddateitem.job_kind.id !== 1">
<v-btn
v-if="jobkinddateitem.id === 0"
fab
x-small
color="green"
@click="undoDelteJobKindDate(index)"
>
<v-icon>{{ plusIcon }}</v-icon>
</v-btn>
<v-btn
v-else
fab
x-small
color="red"
@click="deleteJobKindDate(index)"
>
<v-icon>{{ minusIcon }}</v-icon>
</v-btn>
</div>
</div>
<div v-else>
<v-btn
v-if="jobkinddateitem.id === 0"
fab
x-small
color="green"
@click="undoDelteJobKindDate(index)"
>
<v-icon>{{ plusIcon }}</v-icon>
</v-btn>
<v-btn
v-else
fab
x-small
color="red"
@click="deleteJobKindDate(index)"
>
<v-icon>{{ minusIcon }}</v-icon>
</v-btn>
</div>
</v-col>
<v-row v-if="jobkinddateitem.id === 0">
<v-col>
<v-alert dense type="info"
>{{ jobkinddateitem.job_kind.name }} wird beim Speichern
gelöscht.</v-alert
>
</v-col>
</v-row>
</v-row>
</div>
<v-row>
<v-spacer />
<v-btn
fab
small
color="green darken-1"
@click="addJobKindDate()"
:disabled="disableAddBtn"
>
<v-icon>{{ plusIcon }}</v-icon>
</v-btn>
</v-row>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn text color="primary" @click="dialog = false">
Abbrechen
</v-btn>
<v-btn text color="primary" @click="saveJobKind()">
Speichern
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div> </div>
</template> </template>
<script> <script>
import { mapGetters, mapActions } from 'vuex' import { mapGetters, mapActions } from 'vuex'
import { mdiAccountPlus } from '@mdi/js' import { mdiAccountPlus, mdiDotsVertical, mdiPlus, mdiMinus } from '@mdi/js'
export default { export default {
name: 'Day', name: 'Day',
props: { props: {
@ -73,36 +214,70 @@ export default {
data() { data() {
return { return {
account_add: mdiAccountPlus, account_add: mdiAccountPlus,
menuIcon: mdiDotsVertical,
plusIcon: mdiPlus,
minusIcon: mdiMinus,
searchInput: null, searchInput: null,
focused: false focused: false,
dialog: false,
update: 0,
maxpersons: 2,
rules: [
data => {
if (data === null) return false
var list = this.day.jobkinddate.filter(a => {
if (a.job_kind === null) return false
else {
return a.job_kind.id === data.id
}
})
return list.length > 1 ? data.name + 'ist schon vorhanden' : false
}
],
workerRules: [
(data, test) => {
console.log(data, test)
return false
}
],
backup: null
} }
}, },
created() { created() {
this.setLoading(this.day.date) this.setLoading(this.day.date)
//this.getUser({
// date: this.day.date.getTime() / 1000,
// startdatetime: this.day.date,
// year: this.day.date.getFullYear(),
// month: this.day.date.getMonth() + 1,
// day: this.day.date.getDate()
//})
}, },
methods: { methods: {
...mapActions({ ...mapActions({
addUser: 'sm/addUser', addUser: 'sm/addUser',
getUser: 'sm/getUser',
deleteUser: 'sm/deleteUser', deleteUser: 'sm/deleteUser',
setLoading: 'sm/setDayLoading', setLoading: 'sm/setDayLoading',
setNotLoading: 'sm/setDayNotLoading', setNotLoading: 'sm/setDayNotLoading',
lockDay: 'sm/lockDay' lockDay: 'sm/lockDay',
updateJobKindDate: 'sm/updateJobKindDate'
}), }),
// eslint-disable-next-line no-unused-vars forceRenderer(jobkind) {
remove(deletedUser) { console.log(jobkind)
const obj = this.day.worker.find(a => { this.update += 1
return a.username === deletedUser.username console.log('before', jobkind.worker, jobkind.backupWorker)
if (jobkind.backupWorker !== jobkind.worker && this.focused) {
let addedUser = null
for (let user in jobkind.worker) {
if (!jobkind.backupWorker.includes(jobkind.worker[user])) {
addedUser = jobkind.worker[user]
this.addUser({
date: this.day.date.getTime() / 1000,
user: addedUser,
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate(),
job_kind: jobkind.job_kind
}) })
const index = this.day.worker.indexOf(obj) }
if (index >= 0) this.day.worker.splice(index, 1) }
let deletedUser = null
for (let user in jobkind.backupWorker) {
if (!jobkind.worker.includes(jobkind.backupWorker[user])) {
deletedUser = jobkind.backupWorker[user]
this.deleteUser({ this.deleteUser({
startdatetime: this.day.date, startdatetime: this.day.date,
date: this.day.date.getTime() / 1000, date: this.day.date.getTime() / 1000,
@ -111,17 +286,37 @@ export default {
month: this.day.date.getMonth() + 1, month: this.day.date.getMonth() + 1,
day: this.day.date.getDate() day: this.day.date.getDate()
}) })
}
}
}
jobkind.backupWorker = [...jobkind.worker]
}, },
color: day => { // eslint-disable-next-line no-unused-vars
remove(jobkind, deletedUser) {
jobkind.worker.indexOf()
const obj = jobkind.worker.find(a => {
return a.username === deletedUser.username
})
const index = jobkind.worker.indexOf(obj)
if (index >= 0) jobkind.worker.splice(index, 1)
this.forceRenderer(jobkind)
},
color(day) {
if (day) { if (day) {
if (day.date.getDay() === 0 || day.date.getDay() === 1) { if (day.date.getDay() === 0 || day.date.getDay() === 1) {
return 'grey lighten-4' return 'grey lighten-4'
} else { } else {
if (day.worker.length < 2) { var retVal = 'yellow'
return 'yellow' retVal = 'light-green'
} else { for (var jobkind in day.jobkinddate) {
return 'light-green' if (
day.jobkinddate[jobkind].worker.length >=
day.jobkinddate[jobkind].maxpersons
)
retVal = 'light-green'
else return 'yellow'
} }
return retVal
} }
} else { } else {
return 'grey lighten-4' return 'grey lighten-4'
@ -134,16 +329,158 @@ export default {
day: this.day.date.getDate(), day: this.day.date.getDate(),
locked: !this.day.locked locked: !this.day.locked
}) })
},
createBarJobKindDate(maxpersons) {
this.day.jobkinddate.push({
id: -1,
job_kind: Object.assign(
{},
this.jobkinds.find(a => {
return a.id === 1
})
),
maxpersons: maxpersons,
daydate: {
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
},
worker: [],
backupWorker: []
})
},
addJobKindDate() {
this.day.jobkinddate.push({
id: -1,
job_kind: null,
maxpersons: 2,
new: true,
daydate: {
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
},
worker: [],
backupWorker: []
})
},
mop(jobkind) {
console.log(jobkind.worker)
},
deleteJobKindDate(index) {
if (this.day.jobkinddate[index].id === -1) {
this.day.jobkinddate.splice(index, 1)
} else {
this.day.jobkinddate[index].backupid = this.day.jobkinddate[index].id
this.day.jobkinddate[index].id = 0
}
},
undoDelteJobKindDate(index) {
this.day.jobkinddate[index].id = this.day.jobkinddate[index].backupid
},
saveJobKind() {
this.updateJobKindDate({
data: this.day.jobkinddate,
date: this.day.date
})
this.dialog = false
},
filterWorker() {},
// filterUser(jobkind) {
// console.log(jobkind, this.day.jobkinddate)
// var filtered = this.dbUsers.filter(user => {
// var test = this.day.jobkinddate.find(item => {
// if (item.job_kind === null) {
// return false
// }
// if (item.job_kind.id === jobkind.id) {
// return false
// }
// return item.worker.find(work => {
// return work.id === user.id
// })
// })
// console.log('test', test)
// if (test) {
// return false
// }
// if (jobkind.workgroup === null) {
// return true
// }
// return user.workgroups.find(workgroup => {
// if (jobkind.workgroup && workgroup) {
// return jobkind.workgroup.id === workgroup.id
// } else return true
// })
// })
// return filtered
// },
// eslint-disable-next-line no-unused-vars
filterUser(jobkind) {
console.log(jobkind, this.day.jobkinddate)
// eslint-disable-next-line no-unused-vars
var filtered = this.dbUsers.filter(user => {
var userInOther = this.day.jobkinddate.find(item => {
if (item.job_kind === null) {
return false
}
if (item.job_kind.id === jobkind.id) {
return false
}
return item.worker.find(work => {
return work.id === user.id
})
})
if (userInOther) {
return false
}
if (jobkind.id === 1 || !jobkind.workgroup) {
return true
} else {
if (user.workgroups ? user.workgroups.length > 0 : false) {
return user.workgroups.find(wg => {
console.log(wg, jobkind.workgroup)
return wg.id === jobkind.workgroup.id
})
} else {
return false
}
}
})
return filtered
},
// eslint-disable-next-line no-unused-vars
filterJobKinds(jobkinddateitem, index) {
var retVal = this.jobkinds.filter(jobkind => {
return jobkind.id !== 1
})
retVal = retVal.filter(jobkind => {
return !this.day.jobkinddate.find(item => {
if (item.job_kind === jobkinddateitem.job_kind) {
return false
} else {
if (item.job_kind !== null && jobkind !== null)
if (item.job_kind.id === jobkind.id) return true
}
return false
})
})
return retVal
} }
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
allUsers: 'sm/allUsers', allUsers: 'sm/allUsers',
disabled: 'sm/disabled' dbUsers: 'usermanager/users',
disabled: 'sm/disabled',
jobkinds: 'jkm/jobkinds'
}), }),
worker() { worker() {
return this.day.worker return this.day.worker
}, },
tada() {
return this.day.jobkinddate
},
lockedColor() { lockedColor() {
return this.day.locked ? 'red' : 'green' return this.day.locked ? 'red' : 'green'
}, },
@ -152,6 +489,27 @@ export default {
}, },
lockedTextBtn() { lockedTextBtn() {
return this.day.locked ? 'freigeben' : 'sperren' return this.day.locked ? 'freigeben' : 'sperren'
},
isBarDienstIn() {
for (var jobkinddate in this.day.jobkinddate) {
if (!(this.day.jobkinddate[jobkinddate].job_kind === null))
if (this.day.jobkinddate[jobkinddate].job_kind.id === 1) return true
}
return false
},
existJobKinds() {
var retVal = [...this.jobkinds]
retVal.splice(
retVal.findIndex(a => {
return a.id === 1
}),
1
)
return retVal
},
disableAddBtn() {
var barset = this.isBarDienstIn ? 0 : 1
return this.day.jobkinddate.length === this.jobkinds.length - barset
} }
}, },
watch: { watch: {
@ -185,16 +543,15 @@ export default {
} }
} }
} }
},
dialog(newValue) {
if (newValue) {
this.backup = [...this.day.jobkinddate]
} else {
this.day.jobkinddate = [...this.backup]
this.backup = []
}
} }
//day() {
// this.getUser({
// date: this.day.date.getTime() / 1000,
// startdatetime: this.day.date,
// year: this.day.date.getFullYear(),
// month: this.day.date.getMonth() + 1,
// day: this.day.date.getDate()
// })
//}
} }
} }
</script> </script>

View File

@ -53,7 +53,8 @@
:items="workgroups" :items="workgroups"
item-value="id" item-value="id"
item-text="name" item-text="name"
return-object></v-autocomplete> return-object
></v-autocomplete>
</v-col> </v-col>
</v-row> </v-row>
</v-container> </v-container>
@ -65,7 +66,12 @@
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-dialog> </v-dialog>
<v-data-table :headers="header" :items="users" :search="search" :loading="usersLoading || statusLoading"> <v-data-table
:headers="header"
:items="users"
:search="search"
:loading="usersLoading || statusLoading"
>
<template v-slot:top> <template v-slot:top>
<v-toolbar flat color="white"> <v-toolbar flat color="white">
<v-toolbar-title>Mitgliederliste</v-toolbar-title> <v-toolbar-title>Mitgliederliste</v-toolbar-title>
@ -138,7 +144,7 @@
</template> </template>
<script> <script>
import { mdiPencil, mdiMagnify, } from '@mdi/js' import { mdiPencil, mdiMagnify } from '@mdi/js'
import { mapActions, mapGetters } from 'vuex' import { mapActions, mapGetters } from 'vuex'
export default { export default {
name: 'UserManager', name: 'UserManager',
@ -153,7 +159,7 @@ export default {
header: [ header: [
{ text: 'Nachname', value: 'lastname' }, { text: 'Nachname', value: 'lastname' },
{ text: 'Vorname(n)', value: 'firstname' }, { text: 'Vorname(n)', value: 'firstname' },
{ text: 'AG\'s', value: 'workgroups'}, { text: "AG's", value: 'workgroups' },
{ text: 'Status', value: 'statusgroup' }, { text: 'Status', value: 'statusgroup' },
{ text: 'Stimmrecht', value: 'voting' }, { text: 'Stimmrecht', value: 'voting' },
{ {
@ -196,9 +202,8 @@ export default {
mounted() { mounted() {
this.$nextTick(function() { this.$nextTick(function() {
window.addEventListener('resize', this.getWindowWidth); window.addEventListener('resize', this.getWindowWidth)
this.getWindowWidth() this.getWindowWidth()
}) })
}, },
@ -212,7 +217,7 @@ export default {
getAllWorkgroups: 'wm/getAllWorkgroups' getAllWorkgroups: 'wm/getAllWorkgroups'
}), }),
getWindowWidth() { getWindowWidth() {
this.isFulllineText = document.documentElement.clientWidth <= 750; this.isFulllineText = document.documentElement.clientWidth <= 750
}, },
close() { close() {
this.editUser = false this.editUser = false
@ -226,8 +231,12 @@ export default {
{}, {},
this.status.find(a => a.id == item.statusgroup) this.status.find(a => a.id == item.statusgroup)
) )
this.editedItem.voting = Object.assign({}, this.editedItem.voting = Object.assign(
item.voting ? {value: true, text: 'ja'} : {value: false, text: 'nein'}) {},
item.voting
? { value: true, text: 'ja' }
: { value: false, text: 'nein' }
)
this.clickItem(this.editedItem.statusgroup) this.clickItem(this.editedItem.statusgroup)
this.editUser = true this.editUser = true
}, },
@ -255,8 +264,14 @@ export default {
} }
}, },
save() { save() {
this.updateStatusUser({username: this.editedItem.username, status: this.editedItem.statusgroup}) this.updateStatusUser({
this.updateVoting({username: this.editedItem.username, voting: this.editedItem.voting.value}) username: this.editedItem.username,
status: this.editedItem.statusgroup
})
this.updateVoting({
username: this.editedItem.username,
voting: this.editedItem.voting.value
})
this.updateWorkgroups(this.editedItem) this.updateWorkgroups(this.editedItem)
this.close() this.close()
} }

View File

@ -1,6 +1,6 @@
//const main = 'https://192.168.5.128:5000/' //const main = 'https://192.168.5.128:5000/'
const main = 'http://localhost:5000/' //const main = 'http://localhost:5000/'
//const main = 'http://192.168.5.118:5000/' const main = 'http://192.168.5.118:5000/'
//const main = 'https://groeger-clan.duckdns.org:5000/' //const main = 'https://groeger-clan.duckdns.org:5000/'
const url = { const url = {
@ -31,9 +31,15 @@ const url = {
addUser: main + 'sm/addUser', addUser: main + 'sm/addUser',
deleteUser: main + 'sm/deleteUser', deleteUser: main + 'sm/deleteUser',
getUser: main + 'sm/getUser', getUser: main + 'sm/getUser',
getUsers: main + 'sm/getUsers', getUsers: main + 'user/jobs',
lockDay: main + 'sm/lockDay', lockDay: main + 'sm/lockDay',
searchUser: main + 'sm/searchWithExtern' searchUser: main + 'sm/searchWithExtern',
jobkind: main + 'sm/JobKind',
getAllJobKindsbKinds: main + 'sm/getAllJobKinds',
getJobKind: main + 'sm/getJobKind',
deleteJobKind: main + 'sm/deleteJobKind',
updateJobKindDates: main + 'jk/JobKindDate',
getJobKindDates: main + 'jk/JobKindDate'
}, },
um: { um: {
setStatus: main + 'um/setStatus', setStatus: main + 'um/setStatus',
@ -55,12 +61,14 @@ const url = {
job: main + 'user/job', job: main + 'user/job',
jobs: main + 'user/jobs', jobs: main + 'user/jobs',
addJob: main + 'user/addJob', addJob: main + 'user/addJob',
getJobOnDates: main + 'user/jobsOnDates',
deleteJob: main + 'user/deleteJob', deleteJob: main + 'user/deleteJob',
transactJob: main + 'user/transactJob', getJobInvites: main + 'user/getJobInvites',
answerTransactJob: main + 'user/answerTransactJob', setJobInvites: main + 'user/JobInvites',
jobRequests: main + 'user/jobRequests', deletJobInvite: main + 'user/deleteJobInvite',
getTransactJobs: main + 'user/getTransactJobs', getJobRequests: main + 'user/getJobRequests',
deleteTransactJobs: main + 'user/deleteTransactJob', setJobRequests: main + 'user/JobRequests',
deletJobRequest: main + 'user/deleteJobRequest',
storno: main + 'user/storno', storno: main + 'user/storno',
getAllStatus: main + 'getAllStatus', getAllStatus: main + 'getAllStatus',
getStatus: main + 'getStatus', getStatus: main + 'getStatus',

View File

@ -17,33 +17,36 @@ import User from '../components/finanzer/User'
import ServiceManagement from '../components/vorstand/ServiceManagement' import ServiceManagement from '../components/vorstand/ServiceManagement'
import Config from '@/components/user/Config' import Config from '@/components/user/Config'
import Jobs from '@/components/user/Jobs' import Jobs from '@/components/user/Jobs'
import JobRequests from '@/components/user/JobRequests'
import PriceList from '@/components/pricelist/PriceList' import PriceList from '@/components/pricelist/PriceList'
import ManagementNavigation from '@/components/vorstand/ManagementNavigation' import ManagementNavigation from '@/components/vorstand/ManagementNavigation'
import GastroNavigation from '@/components/gastro/GastroNavigation' import GastroNavigation from '@/components/gastro/GastroNavigation'
import PriceListView from '@/views/contents/PriceListView' import PriceListView from '@/views/contents/PriceListView'
import UserManager from '@/components/vorstand/UserManager' import UserManager from '@/components/vorstand/UserManager'
import WorkgroupManagement from "@/components/vorstand/WorkgroupManagement"; import WorkgroupManagement from "@/components/vorstand/WorkgroupManagement";
import JobKindManager from "@/components/vorstand/JobKindManager";
import JobsRequest from "@/components/user/JobsRequest";
Vue.use(VueRouter) Vue.use(VueRouter)
const rootPath = ''
const routes = [ const routes = [
{ {
path: '/cookies', path: rootPath + '/cookies',
name: 'cookies' name: 'cookies'
}, },
{ {
path: '/pricelist', path: rootPath + '/pricelist',
name: 'priceListNoLogin', name: 'priceListNoLogin',
component: PriceListView component: PriceListView
}, },
{ {
path: '/login', path: rootPath + '/login',
name: 'login', name: 'login',
component: Login component: Login
}, },
{ {
path: '/main', path: rootPath + '/main',
name: 'main', name: 'main',
component: MainView, component: MainView,
children: [ children: [
@ -53,16 +56,24 @@ const routes = [
components: { nav: ManagementNavigation, default: BarView }, components: { nav: ManagementNavigation, default: BarView },
children: [ children: [
{ {
path: 'servicemanagement', name: 'serviceManagement',
path: 'servicemanagement/:year/:month',
component: ServiceManagement component: ServiceManagement
}, },
{ {
path: 'usermanager', path: 'usermanager',
name: 'userManager',
component: UserManager component: UserManager
}, },
{ {
path: 'workgroupmanagement', path: 'workgroupmanagement',
name: 'workgroupManagement',
component: WorkgroupManagement component: WorkgroupManagement
},
{
path: 'jobkindmanagement',
name: 'jobkindManagement',
component: JobKindManager
} }
] ]
}, },
@ -87,14 +98,14 @@ const routes = [
component: Config component: Config
}, },
{ {
path: 'jobs', path: 'jobs/:year/:month',
name: 'userJobs', name: 'userJobs',
component: Jobs component: Jobs
}, },
{ {
path: 'jobRequests', path: 'jobRequests/:kind',
name: 'jobRequests', name: 'jobRequests',
component: JobRequests component: JobsRequest
} }
] ]
}, },
@ -117,6 +128,7 @@ const routes = [
children: [ children: [
{ {
path: 'overview', path: 'overview',
name: 'overview',
component: Overview component: Overview
}, },
{ {

View File

@ -6,10 +6,12 @@ import barUsers from '@/store/modules/barUsers'
import user from '@/store/modules/user' import user from '@/store/modules/user'
import sm from '@/store/modules/serviceManagement' import sm from '@/store/modules/serviceManagement'
import jobs from '@/store/modules/jobs' import jobs from '@/store/modules/jobs'
import requestJobs from '@/store/modules/jobRequests'
import priceList from '@/store/modules/pricelist' import priceList from '@/store/modules/pricelist'
import usermanager from '@/store/modules/userManager' import usermanager from '@/store/modules/userManager'
import wm from '@/store/modules/workgroupManagement' import wm from '@/store/modules/workgroupManagement'
import jkm from '@/store/modules/jobkindManager'
import jobInvites from "@/store/modules/jobInvites";
import jobRequests from "@/store/modules/jobRequests";
Vue.use(Vuex) Vue.use(Vuex)
@ -21,9 +23,11 @@ export default new Vuex.Store({
user, user,
sm, sm,
jobs, jobs,
requestJobs,
priceList, priceList,
usermanager, usermanager,
wm wm,
jkm,
jobInvites,
jobRequests
} }
}) })

View File

@ -0,0 +1,381 @@
import axios from 'axios'
import url from '@/plugins/routes'
const state = {
jobInvitesFromMe: [],
jobInvitesToMe: [],
jobInvitesLoading: false
}
const mutations = {
setJobInvitesFromMe: (state, jobInvites) => {
state.jobInvitesFromMe = jobInvites
state.jobInvitesFromMe.forEach(item => {
item.on_date = new Date(
item.on_date.year,
item.on_date.month - 1,
item.on_date.day
)
item.day = {
date: new Date(),
worker: [],
loading: false,
locked: false,
jobkinddate: []
}
})
},
setJobInvitesToMe: (state, jobInvites) => {
state.jobInvitesToMe = jobInvites
state.jobInvitesToMe.forEach(item => {
item.on_date = new Date(
item.on_date.year,
item.on_date.month - 1,
item.on_date.day
)
item.day = {
date: new Date(),
worker: [],
loading: false,
locked: false,
jobkinddate: []
}
})
},
setJobInvitesLoading: (state, value) => {
state.jobInvitesLoading = value
},
updateJobInviteToMe: (state, jobInvite) => {
state.jobInvitesToMe.forEach(item => {
if (item.id === jobInvite.id) {
item.watched = jobInvite.watched
}
})
},
updateMonthWorker: (state, { workers, date, getters, from_me }) => {
let mop
if (from_me) {
mop = getters.getDayFromMe(date)
} else {
mop = getters.getDayToMe(date)
}
mop.forEach(a => {
let day = a.day
day.jobkinddate.forEach(item => {
var filtered = workers.filter(worker => {
return item.job_kind.id === (worker.job_kind ? worker.job_kind.id : 1)
})
var filteredWorkers = []
filtered.forEach(item => {
filteredWorkers.push(item.user)
})
filteredWorkers.forEach(worker => {
if (
!item.worker.find(a => {
return a.id === worker.id
})
) {
item.worker.push(worker)
}
})
item.worker.forEach(worker => {
if (
!filteredWorkers.find(a => {
return a.id === worker.id
})
) {
item.worker.splice(item.worker.indexOf(worker), 1)
}
})
})})
},
updateMonthLocked: (state, { locked, date, getters, from_me }) => {
let mop
if (from_me) {
mop = getters.getDayFromMe(date)
} else {
mop = getters.getDayToMe(date)
}
mop.forEach(a => {
let day = a.day
day.locked = !!locked
})
},
updateMonthJobkind: (state, { data, date, getters, from_me }) => {
let mop
if (from_me) {
mop = getters.getDayFromMe(date)
} else {
mop = getters.getDayToMe(date)
}
mop.forEach(a => {
let day = a.day
day.date = date
var backup = []
for (let jobkind in day.jobkinddate) {
if (day.jobkinddate[jobkind].worker !== undefined) {
backup.push({
id: day.jobkinddate[jobkind].job_kind.id,
worker: day.jobkinddate[jobkind].worker,
backupWorker: day.jobkinddate[jobkind].backupWorker
})
} else {
backup.push({
id: day.jobkinddate[jobkind].job_kind.id,
worker: [],
backupWorker: []
})
}
}
day.jobkinddate = [...data]
var test = day.jobkinddate.find(jobkind => {
return jobkind.job_kind.id === 1
})
if (!test) {
day.jobkinddate.push({
id: -1,
job_kind: { id: 1, name: 'Bardienst' },
maxpersons: 2,
daydate: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()
},
worker: [],
backupWorker: []
})
}
for (var jobkind in day.jobkinddate) {
var worker = backup.find(item => {
return item.id === day.jobkinddate[jobkind].job_kind.id
})
day.jobkinddate[jobkind].worker = worker ? worker.worker : []
day.jobkinddate[jobkind].backupWorker = worker ? worker.backupWorker : []
}
})
},
setDayLoading: (state, { getters, date, value }) => {
let day = getters.getDayToMe(date)
day.forEach(a => {
a.day.loading = value
console.log('day', value ? 'loading' : 'not loading', day, a.day.loading)
})
},
deleteJobInviteFromMe: (state, jobinvite) => {
var item = state.jobInvitesFromMe.find(item => {
return item.id === jobinvite.id
})
state.jobInvitesFromMe.splice(item, 1)
}
}
const actions = {
async getJobInvites({ commit, dispatch, rootState, getters }) {
try {
commit('setJobInvitesLoading', true)
const date = new Date()
const from_me = await axios.post(
url.user.getJobInvites,
{
from_user: rootState.user.user,
date: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()
}
},
{ headers: { Token: rootState.login.user.accessToken } }
)
const workers_from_me = await axios.post(
url.user.getJobOnDates,
from_me.data,
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setJobInvitesFromMe', from_me.data)
workers_from_me.data.forEach(item => {
var date = new Date(
item.day.date.year,
item.day.date.month - 1,
item.day.date.day
)
commit('updateMonthJobkind', { data: item.jobkinddate, date, getters, from_me: true })
commit('updateMonthWorker', { workers: item.worker, date, getters, from_me: true })
commit('updateMonthLocked', { locked: item.day.locked, date, getters, from_me: true })
})
const to_me = await axios.post(
url.user.getJobInvites,
{
to_user: rootState.user.user,
date: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()
}
},
{ headers: { Token: rootState.login.user.accessToken } }
)
const workers_to_me = await axios.post(
url.user.getJobOnDates,
to_me.data,
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setJobInvitesToMe', to_me.data)
workers_to_me.data.forEach(item => {
var date = new Date(
item.day.date.year,
item.day.date.month - 1,
item.day.date.day
)
commit('updateMonthJobkind', { data: item.jobkinddate, date, getters, from_me: false })
commit('updateMonthWorker', { workers: item.worker, date, getters, from_me: false })
commit('updateMonthLocked', { locked: item.day.locked, date, getters, from_me: false })
})
commit('setJobInvitesLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async setJobInvites({ commit, dispatch, rootState }, data) {
try {
commit('setJobInvitesLoading', true)
const response = await axios.put(url.user.setJobInvites, data, {
headers: { Token: rootState.login.user.accessToken }
})
commit('setJobInvitesFromMe', response.data)
commit('setJobInvitesLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async addJob({ commit, rootState, dispatch, getters }, data) {
var date = new Date(data.year, data.month - 1, data.day)
commit('setDayLoading', { date, getters, value: true })
try {
commit('setJobInvitesLoading', true)
const response = await axios.post(
url.user.addJob,
{ ...data },
{
headers: { Token: rootState.login.user.accessToken }
}
)
commit('updateMonthWorker', {
workers: [...response.data],
date: new Date(data.year, data.month - 1, data.day),
getters, from_me: false
})
commit('setDayLoading', { date, getters, value: false })
dispatch('getLifeTime', null, { root: true })
commit('setJobInvitesLoading', false)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async deleteJob({ commit, rootState, dispatch, getters }, data) {
var date = new Date(data.year, data.month - 1, data.day)
commit('setDayLoading', {date, getters, value: true})
commit('setJobInvitesLoading', true)
try {
const response = await axios.post(
url.user.deleteJob,
{ ...data },
{
headers: { Token: rootState.login.user.accessToken }
}
)
console.log(response.data)
commit('updateMonthWorker', {
workers: [...response.data],
date: new Date(data.year, data.month - 1, data.day),
getters
})
commit('setDayLoading', {date, getters, value: false})
dispatch('getLifeTime', null, { root: true })
commit('setJobInvitesLoading', false)
} catch (e) {
console.log(e)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async updateJobInviteToMe({ commit, rootState, dispatch }, data) {
try {
commit('setJobInvitesLoading', true)
const response = await axios.post(url.user.setJobInvites, data, {
headers: { Token: rootState.login.user.accessToken }
})
commit('updateJobInviteToMe', response.data)
dispatch('getLifeTime', null, { root: true })
commit('setJobInvitesLoading', false)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async deleteJobInviteFromMe({ commit, rootState, dispatch}, data) {
try {
commit('setJobInvitesLoading', true)
await axios.post(url.user.deletJobInvite, data, {headers: {Token: rootState.login.user.accessToken}})
commit('deleteJobInviteFromMe', data)
commit('setJobInvitesLoading', false)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
}
}
const getters = {
jobInvitesFromMe: state => {
return state.jobInvitesFromMe
},
jobInvitesToMe: state => {
return state.jobInvitesToMe
},
jobInvitesLoading: state => {
return state.jobInvitesLoading
},
getDayToMe: state => {
return date => {
return state.jobInvitesToMe.filter(item => {
return item.on_date - date === 0
})
}
},
getDayFromMe: state => {
return date => {
return state.jobInvitesFromMe.filter(item => {
return item.on_date - date === 0
})
}
},
getDayWorkerFromMe: state => {
return date => {
return state.jobInvitesFromMe.filter(jobInvite => {
return jobInvite.on_date - date === 0
})
}
},
news: state => {
var test = state.jobInvitesToMe.filter(item => {
return !item.watched
})
return test.length
}
}
export default {
namespaced: true,
state,
mutations,
actions,
getters
}

View File

@ -2,153 +2,363 @@ import axios from 'axios'
import url from '@/plugins/routes' import url from '@/plugins/routes'
const state = { const state = {
transactJobs: [], jobRequestsFromMe: [],
transactJobsLoading: false, jobRequestsToMe: [],
requestJobs: [], jobRequestsLoading: false
requestJobsLoading: false
} }
const mutations = { const mutations = {
setTransactJobs: (state, data) => { setJobRequestsFromMe: (state, jobRequests) => {
var list = [] state.jobRequestsFromMe = jobRequests
for (var i in data) { state.jobRequestsFromMe.forEach(item => {
list.push({ item.on_date = new Date(
date: new Date( item.on_date.year,
data[i].date.year, item.on_date.month - 1,
data[i].date.month - 1, item.on_date.day
data[i].date.day )
), item.day = {
from_user: data[i].from_user, date: new Date(),
to_user: data[i].to_user, worker: [],
accepted: data[i].accepted, loading: false,
answerd: data[i].answerd locked: false,
}) jobkinddate: []
} }
state.transactJobs = list
},
setRequestJobs: (state, data) => {
var list = []
for (var i in data) {
list.push({
date: new Date(
data[i].date.year,
data[i].date.month - 1,
data[i].date.day
),
from_user: data[i].from_user,
to_user: data[i].to_user,
accepted: data[i].accepted,
answerd: data[i].answerd
}) })
},
setJobRequestsToMe: (state, jobRequests) => {
state.jobRequestsToMe = jobRequests
state.jobRequestsToMe.forEach(item => {
item.on_date = new Date(
item.on_date.year,
item.on_date.month - 1,
item.on_date.day
)
item.day = {
date: new Date(),
worker: [],
loading: false,
locked: false,
jobkinddate: []
} }
state.requestJobs = list })
}, },
setTransactJobsLoading: (state, value) => { setJobRequestsLoading: (state, value) => {
state.transactJobsLoading = value state.jobRequestsLoading = value
}, },
setRequestJobsLoading: (state, value) => { updateJobRequestToMe: (state, jobRequest) => {
state.requestJobsLoading = value state.jobRequestsToMe.forEach(item => {
if (item.id === jobRequest.id) {
item.watched = jobRequest.watched
item.accepted = jobRequest.accepted
}
})
}, },
updateRequestJob: (state, data) => { updateMonthWorker: (state, { workers, date, getters, from_me }) => {
const date = new Date(data.date.year, data.date.month - 1, data.date.day) let mop
for (var i in state.requestJobs) { if (from_me) {
mop = getters.getDayFromMe(date)
} else {
mop = getters.getDayToMe(date)
}
mop.forEach(a => {
let day = a.day
day.jobkinddate.forEach(item => {
var filtered = workers.filter(worker => {
return item.job_kind.id === (worker.job_kind ? worker.job_kind.id : 1)
})
var filteredWorkers = []
filtered.forEach(item => {
filteredWorkers.push(item.user)
})
filteredWorkers.forEach(worker => {
if ( if (
state.requestJobs[i].date - date === 0 && !item.worker.find(a => {
state.requestJobs[i].from_user.username === data.from_user.username return a.id === worker.id
) {
state.requestJobs[i].accepted = data.accepted
state.requestJobs[i].answerd = data.answerd
break
}
}
},
deleteTransactJobactJob: (state, data) => {
const date = new Date(data.year, data.month - 1, data.day)
var job = state.transactJobs.find(a => {
return a.date - date === 0 && a.to_user.username === data.username
}) })
var index = state.transactJobs.indexOf(job) ) {
if (job) state.transactJobs.splice(index, 1) item.worker.push(worker)
}
})
item.worker.forEach(worker => {
if (
!filteredWorkers.find(a => {
return a.id === worker.id
})
) {
item.worker.splice(item.worker.indexOf(worker), 1)
}
})
})
})
},
updateMonthLocked: (state, { locked, date, getters, from_me }) => {
let mop
if (from_me) {
mop = getters.getDayFromMe(date)
} else {
mop = getters.getDayToMe(date)
}
mop.forEach(a => {
let day = a.day
day.locked = !!locked
})
},
updateMonthJobkind: (state, { data, date, getters, from_me }) => {
let mop
if (from_me) {
mop = getters.getDayFromMe(date)
} else {
mop = getters.getDayToMe(date)
}
mop.forEach(a => {
let day = a.day
day.date = date
var backup = []
for (let jobkind in day.jobkinddate) {
if (day.jobkinddate[jobkind].worker !== undefined) {
backup.push({
id: day.jobkinddate[jobkind].job_kind.id,
worker: day.jobkinddate[jobkind].worker,
backupWorker: day.jobkinddate[jobkind].backupWorker
})
} else {
backup.push({
id: day.jobkinddate[jobkind].job_kind.id,
worker: [],
backupWorker: []
})
}
}
day.jobkinddate = [...data]
var test = day.jobkinddate.find(jobkind => {
return jobkind.job_kind.id === 1
})
if (!test) {
day.jobkinddate.push({
id: -1,
job_kind: { id: 1, name: 'Bardienst' },
maxpersons: 2,
daydate: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()
},
worker: [],
backupWorker: []
})
}
for (var jobkind in day.jobkinddate) {
var worker = backup.find(item => {
return item.id === day.jobkinddate[jobkind].job_kind.id
})
day.jobkinddate[jobkind].worker = worker ? worker.worker : []
day.jobkinddate[jobkind].backupWorker = worker
? worker.backupWorker
: []
}
})
console.log(mop)
},
setDayLoading: (state, { getters, date, value }) => {
let day = getters.getDayToMe(date)
day.forEach(a => {
a.day.loading = value
console.log('day', value ? 'loading' : 'not loading', day, a.day.loading)
})
},
deleteJobRequestFromMe: (state, jobrequest) => {
var item = state.jobRequestsFromMe.find(item => {
return item.id === jobrequest.id
})
state.jobRequestsFromMe.splice(item, 1)
} }
} }
const actions = { const actions = {
async getTransactJobs({ commit, rootState, dispatch }, data) { async getJobRequests({ commit, dispatch, rootState, getters }) {
commit('setTransactJobsLoading', true)
try { try {
const response = await axios.post( commit('setJobRequestsLoading', true)
url.user.getTransactJobs, const date = new Date()
{ ...data }, const from_me = await axios.post(
{ headers: { Token: rootState.login.user.accessToken } } url.user.getJobRequests,
) {
commit('setTransactJobs', response.data) from_user: rootState.user.user,
dispatch('getLifeTime', null, { root: true }) date: {
} catch (e) { year: date.getFullYear(),
if (e.response) month: date.getMonth() + 1,
if (e.response.data === 401) dispatch('logout', null, { root: true }) day: date.getDate()
commit('setTransactJobsLoading', false)
}
commit('setTransactJobsLoading', false)
},
async getRequestJobs({ commit, rootState, dispatch }, data) {
commit('setRequestJobsLoading', true)
try {
const response = await axios.post(
url.user.jobRequests,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setRequestJobs', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })
commit('setRequestJobsLoading', false)
}
commit('setRequestJobsLoading', false)
},
async answerTransactJob({ commit, rootState, dispatch }, data) {
try {
const response = await axios.post(
url.user.answerTransactJob,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateRequestJob', response.data)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })
} }
}, },
async deleteTransactJob({ commit, rootState, dispatch }, data) {
try {
await axios.post(
url.user.deleteTransactJobs,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
commit('deleteTransactJobactJob', data) const workers_from_me = await axios.post(
url.user.getJobOnDates,
from_me.data,
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setJobRequestsFromMe', from_me.data)
workers_from_me.data.forEach(item => {
var date = new Date(
item.day.date.year,
item.day.date.month - 1,
item.day.date.day
)
commit('updateMonthJobkind', {
data: item.jobkinddate,
date,
getters,
from_me: true
})
commit('updateMonthWorker', {
workers: item.worker,
date,
getters,
from_me: true
})
commit('updateMonthLocked', {
locked: item.day.locked,
date,
getters,
from_me: true
})
})
const to_me = await axios.post(
url.user.getJobRequests,
{
to_user: rootState.user.user,
date: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()
}
},
{ headers: { Token: rootState.login.user.accessToken } }
)
const workers_to_me = await axios.post(
url.user.getJobOnDates,
to_me.data,
{ headers: { Token: rootState.login.user.accessToken } }
)
console.log(to_me.data)
commit('setJobRequestsToMe', to_me.data)
workers_to_me.data.forEach(item => {
var date = new Date(
item.day.date.year,
item.day.date.month - 1,
item.day.date.day
)
commit('updateMonthJobkind', {
data: item.jobkinddate,
date,
getters,
from_me: false
})
commit('updateMonthWorker', {
workers: item.worker,
date,
getters,
from_me: false
})
commit('updateMonthLocked', {
locked: item.day.locked,
date,
getters,
from_me: false
})
})
commit('setJobRequestsLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.response) if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async setJobRequests({ commit, dispatch, rootState }, data) {
try {
commit('setJobRequestsLoading', true)
const response = await axios.put(url.user.setJobRequests, data, {
headers: { Token: rootState.login.user.accessToken }
})
commit('setJobRequestsFromMe', response.data)
commit('setJobRequestsLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async updateJobRequestToMe({ commit, rootState, dispatch }, data) {
try {
commit('setJobRequestsLoading', true)
data.on_date = {
year: data.on_date.getFullYear(),
month: data.on_date.getMonth() + 1,
day: data.on_date.getDate()
}
const response = await axios.post(url.user.setJobRequests, data, {
headers: { Token: rootState.login.user.accessToken }
})
response.data.on_date = new Date(response.data.on_date.year, response.data.on_date.month - 1, response.data.on_date.day)
commit('updateJobRequestToMe', response.data)
commit('setJobRequestsLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async deleteJobRequestFromMe({ commit, rootState, dispatch }, data) {
try {
commit('setJobRequestsLoading', true)
await axios.post(url.user.deletJobRequest, data, {
headers: { Token: rootState.login.user.accessToken }
})
commit('deleteJobRequestFromMe', data)
commit('setJobRequestsLoading', false)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
} }
} }
const getters = { const getters = {
transactJobs: state => { jobRequestsFromMe: state => {
return state.transactJobs return state.jobRequestsFromMe
}, },
transactJobsLoading: state => { jobRequestsToMe: state => {
return state.transactJobsLoading return state.jobRequestsToMe
}, },
requestJobs: state => { jobRequestsLoading: state => {
return state.requestJobs return state.jobRequestsLoading
}, },
requestJobsLoading: state => { getDayToMe: state => {
return state.requestJobsLoading return date => {
return state.jobRequestsToMe.filter(item => {
return item.on_date - date === 0
})
}
},
getDayFromMe: state => {
return date => {
return state.jobRequestsFromMe.filter(item => {
return item.on_date - date === 0
})
}
},
getDayWorkerFromMe: state => {
return date => {
return state.jobRequestsFromMe.filter(jobRequest => {
return jobRequest.on_date - date === 0
})
}
},
news: state => {
var test = state.jobRequestsToMe.filter(item => {
return !item.watched
})
return test.length
} }
} }

View File

@ -0,0 +1,119 @@
import url from '@/plugins/routes'
import axios from 'axios'
const state = {
jobkinds: [],
jobkindLoading: false
}
const mutations = {
setJobkinds: (state, jobkinds) => {
state.jobkinds = jobkinds
},
updateJobKind: (state, jobkind) => {
console.log(jobkind)
const exists = state.jobkinds.find(a => {
return a.id === jobkind.id
})
console.log(exists)
if (exists) {
exists.name = jobkind.name
exists.workgroup = jobkind.workgroup
} else {
state.jobkinds.push(jobkind)
}
},
deleteJobKind: (state, jobkind) => {
const exists = state.jobkinds.indexOf(
state.jobkinds.find(a => {
return a.id === jobkind.id
})
)
state.jobkinds.splice(exists, 1)
},
setJobkindsLoading: (state, value) => {
state.jobkindLoading = value
}
}
const actions = {
async getAllJobKinds({ commit, rootState, dispatch }) {
try {
commit('setJobkindsLoading', true)
const response = await axios.get(url.vorstand.sm.getAllJobKindsbKinds, {
headers: { Token: rootState.login.user.accessToken }
})
commit('setJobkinds', response.data)
commit('setJobkindsLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async addJobKind({ commit, rootState, dispatch }, data) {
try {
commit('setJobkindsLoading', true)
const response = await axios.put(
url.vorstand.sm.jobkind,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateJobKind', response.data)
commit('setJobkindsLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async updateJobKind({ commit, rootState, dispatch }, data) {
try {
commit('setJobkindsLoading', true)
const response = await axios.post(
url.vorstand.sm.jobkind,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateJobKind', response.data)
commit('setJobkindsLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async deleteJobKind({ commit, rootState, dispatch }, data) {
try {
commit('setJobkindsLoading', true)
await axios.post(
url.vorstand.sm.deleteJobKind,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('deleteJobKind', data)
commit('setJobkindsLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
}
}
const getters = {
jobkinds: state => {
return state.jobkinds
},
jobkindsLoading: state => {
return state.jobkindLoading
}
}
export default {
namespaced: true,
state,
mutations,
actions,
getters
}

View File

@ -52,7 +52,8 @@ const mutations = {
name: 'Montag', name: 'Montag',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
break break
case 2: case 2:
@ -62,7 +63,8 @@ const mutations = {
name: 'Dienstag', name: 'Dienstag',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
break break
case 3: case 3:
@ -77,7 +79,8 @@ const mutations = {
name: 'Mittwoch', name: 'Mittwoch',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
} }
break break
@ -88,7 +91,8 @@ const mutations = {
name: 'Donnerstag', name: 'Donnerstag',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
break break
case 5: case 5:
@ -98,7 +102,8 @@ const mutations = {
name: 'Freitag', name: 'Freitag',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
break break
case 6: case 6:
@ -108,7 +113,8 @@ const mutations = {
name: 'Samstag', name: 'Samstag',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
break break
case 0: case 0:
@ -118,7 +124,8 @@ const mutations = {
name: 'Sontag', name: 'Sontag',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
break break
} }
@ -155,6 +162,78 @@ const mutations = {
} }
} }
}, },
// eslint-disable-next-line no-unused-vars
updateMonthWorker: (state, { workers, date, getters }) => {
var day = getters.getDay(date)
day.jobkinddate.forEach(item => {
var filtered = workers.filter(worker => {
return item.job_kind.id === (worker.job_kind ? worker.job_kind.id : 1)
})
var filteredWorkers = []
filtered.forEach(item => {
filteredWorkers.push(item.user)
})
filteredWorkers.forEach(worker => {
if (!item.worker.find(a => {return a.id === worker.id})) {
item.worker.push(worker)
}
})
item.worker.forEach(worker => {
if (!filteredWorkers.find(a => {return a.id === worker.id})) {
item.worker.splice(item.worker.indexOf(worker), 1)
}
})
})
},
updateMonthLocked: (state, { locked, date, getters }) => {
var day = getters.getDay(date)
day.locked = !!locked
},
updateMonthJobkind: (state, { data, date, getters }) => {
let day = getters.getDay(date)
var backup = []
for (let jobkind in day.jobkinddate) {
if (day.jobkinddate[jobkind].worker !== undefined) {
backup.push({
id: day.jobkinddate[jobkind].job_kind.id,
worker: day.jobkinddate[jobkind].worker,
backupWorker: day.jobkinddate[jobkind].backupWorker
})
} else {
backup.push({
id: day.jobkinddate[jobkind].job_kind.id,
worker: [],
backupWorker: []
})
}
}
day.jobkinddate = [...data]
var test = day.jobkinddate.find(jobkind => {
return jobkind.job_kind.id === 1
})
if (!test) {
day.jobkinddate.push({
id: -1,
job_kind: { id: 1, name: 'Bardienst' },
maxpersons: 2,
daydate: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()
},
worker: [],
backupWorker: []
})
}
for (var jobkind in day.jobkinddate) {
var worker = backup.find(item => {
return item.id === day.jobkinddate[jobkind].job_kind.id
})
day.jobkinddate[jobkind].worker = worker ? worker.worker : []
day.jobkinddate[jobkind].backupWorker = worker ? worker.backupWorker : []
}
},
setAllDayLoading: state => { setAllDayLoading: state => {
for (let week = 0; week < state.month.length; week++) { for (let week = 0; week < state.month.length; week++) {
for (let day in state.month[week].days) { for (let day in state.month[week].days) {
@ -239,62 +318,43 @@ const actions = {
commit('setAllDayLoading') commit('setAllDayLoading')
try { try {
const response = await axios.post( const response = await axios.post(
url.user.jobs, url.vorstand.sm.getUsers,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
for (let day in response.data) { for (var day in response.data) {
for (let item = 0; item < response.data[day].worker.length; item++) {
commit('updateMonth', {
...response.data[day].worker[item],
com: 'add',
day: response.data[day].day
})
}
commit('updateMonth', {
start: response.data[day].day.date,
day: response.data[day].day
})
var date = new Date( var date = new Date(
response.data[day].day.date.year, response.data[day].day.date.year,
response.data[day].day.date.month - 1, response.data[day].day.date.month - 1,
response.data[day].day.date.day response.data[day].day.date.day
) )
commit('setDayNotLoading', { date: date, getters }) commit('updateMonthJobkind', {
data: [...response.data[day].jobkinddate],
date,
getters
})
commit('updateMonthWorker', {
workers: [...response.data[day].worker],
date,
getters
})
commit('updateMonthLocked', {
locked: response.data[day].day.locked,
date,
getters
})
commit('setDayNotLoading', { date, getters })
} }
} catch (e) { } catch (e) {
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
async getUser({ commit, rootState, dispatch, getters }, data) { async addJob({ commit, rootState, dispatch, getters }, data) {
commit('setDayLoading', { date: data.startdatetime, getters }) var date = new Date(data.year, data.month - 1, data.day)
try { commit('setDayLoading', {date, getters})
const response = await axios.post(
url.user.job,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
for (let item = 0; item < response.data.worker.length; item++) {
commit('updateMonth', {
...response.data.worker[item],
com: 'add',
day: response.data.day
})
}
commit('updateMonth', {
start: response.data.day.date,
day: response.data.day
})
commit('setDayNotLoading', { date: data.startdatetime, getters })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async addJob({ commit, rootState, dispatch }, data) {
try { try {
const response = await axios.post( const response = await axios.post(
url.user.addJob, url.user.addJob,
{ ...data }, { ...data },
@ -302,7 +362,12 @@ const actions = {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken }
} }
) )
commit('updateMonth', { ...response.data[0], com: 'add' }) commit('updateMonthWorker', {
workers: [...response.data],
date: new Date(data.year, data.month - 1, data.day),
getters
})
commit('setDayNotLoading', {date, getters})
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.response) if (e.response)
@ -310,20 +375,27 @@ const actions = {
} }
}, },
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
async deleteJob({ commit, rootState, dispatch }, data) { async deleteJob({ commit, rootState, dispatch, getters }, data) {
var date = new Date(data.year, data.month - 1, data.day)
commit('setDayLoading', {date, getters})
try { try {
await axios.post( const response = await axios.post(
url.user.deleteJob, url.user.deleteJob,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } {
headers: { Token: rootState.login.user.accessToken }
}
) )
commit('updateMonth', { console.log(response.data)
start: { ...data }, commit('updateMonthWorker', {
user: rootState.login.user, workers: [...response.data],
com: 'delete' date: new Date(data.year, data.month - 1, data.day),
getters
}) })
commit('setDayNotLoading', {date, getters})
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
console.log(e)
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }

View File

@ -48,7 +48,8 @@ const mutations = {
name: 'Montag', name: 'Montag',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
break break
case 2: case 2:
@ -58,7 +59,8 @@ const mutations = {
name: 'Dienstag', name: 'Dienstag',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
break break
case 3: case 3:
@ -73,7 +75,8 @@ const mutations = {
name: 'Mittwoch', name: 'Mittwoch',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
} }
break break
@ -84,7 +87,8 @@ const mutations = {
name: 'Donnerstag', name: 'Donnerstag',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
break break
case 5: case 5:
@ -94,7 +98,8 @@ const mutations = {
name: 'Freitag', name: 'Freitag',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
break break
case 6: case 6:
@ -104,7 +109,8 @@ const mutations = {
name: 'Samstag', name: 'Samstag',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
break break
case 0: case 0:
@ -114,13 +120,13 @@ const mutations = {
name: 'Sontag', name: 'Sontag',
worker: [], worker: [],
loading: false, loading: false,
locked: false locked: false,
jobkinddate: []
} }
break break
} }
} }
state.month = month state.month = month
console.log(month)
}, },
setStartEndDate: week => { setStartEndDate: week => {
if (week.days.monday) { if (week.days.monday) {
@ -155,31 +161,79 @@ const mutations = {
week.endDate = week.days.monday.date week.endDate = week.days.monday.date
} }
}, },
updateMonth: (state, data) => { // eslint-disable-next-line no-unused-vars
const date = new Date(data.start.year, data.start.month - 1, data.start.day) updateMonthWorker: (state, { workers, date, getters }) => {
const user = data.user var day = getters.getDay(date)
for (let week = 0; week < state.month.length; week++) { day.jobkinddate.forEach(item => {
for (let day in state.month[week].days) { var filtered = workers.filter(worker => {
if (state.month[week].days[day].date - date === 0) { return item.job_kind.id === (worker.job_kind ? worker.job_kind.id : 1)
if (user) {
let worker = state.month[week].days[day].worker.find(a => {
return a.username === user.username
}) })
if (!worker && data.com === 'add') { var filteredWorkers = []
state.month[week].days[day].worker.push({ filtered.forEach(item => {
firstname: user.firstname, filteredWorkers.push(item.user)
lastname: user.lastname, })
username: user.username, filteredWorkers.forEach(worker => {
fullName: user.firstname + ' ' + user.lastname if (!item.worker.find(a => {return a.id === worker.id})) {
item.worker.push(worker)
item.backupWorker.push(worker)
}
})
item.worker.forEach(worker => {
if (!filteredWorkers.find(a => {return a.id === worker.id})) {
item.worker.splice(item.worker.indexOf(worker), 1)
}
})
})
},
updateMonthLocked: (state, { locked, date, getters }) => {
var day = getters.getDay(date)
day.locked = !!locked
},
updateMonthJobkind: (state, { data, date, getters }) => {
let day = getters.getDay(date)
var backup = []
for (let jobkind in day.jobkinddate) {
if (day.jobkinddate[jobkind].worker !== undefined) {
backup.push({
id: day.jobkinddate[jobkind].job_kind.id,
worker: day.jobkinddate[jobkind].worker,
backupWorker: day.jobkinddate[jobkind].backupWorker
})
} else {
backup.push({
id: day.jobkinddate[jobkind].job_kind.id,
worker: [],
backupWorker: []
}) })
} }
} }
if (data.day) { day.jobkinddate = [...data]
state.month[week].days[day].locked = data.day.locked var test = day.jobkinddate.find(jobkind => {
} return jobkind.job_kind.id === 1
} })
if (!test) {
day.jobkinddate.push({
id: -1,
job_kind: { id: 1, name: 'Bardienst' },
maxpersons: 2,
daydate: {
year: date.getFullYear(),
month: date.getMonth() + 1,
day: date.getDate()
},
worker: [],
backupWorker: []
})
} }
for (var jobkind in day.jobkinddate) {
var worker = backup.find(item => {
return item.id === day.jobkinddate[jobkind].job_kind.id
})
day.jobkinddate[jobkind].worker = worker ? worker.worker : []
day.jobkinddate[jobkind].backupWorker = worker ? worker.backupWorker : []
} }
}, },
setAllDayLoading: state => { setAllDayLoading: state => {
for (let week = 0; week < state.month.length; week++) { for (let week = 0; week < state.month.length; week++) {
@ -221,6 +275,7 @@ const actions = {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
async addUser({ commit, rootState, dispatch }, data) { async addUser({ commit, rootState, dispatch }, data) {
try { try {
// eslint-disable-next-line no-unused-vars
const response = await axios.post( const response = await axios.post(
url.vorstand.sm.addUser, url.vorstand.sm.addUser,
{ ...data }, { ...data },
@ -228,7 +283,7 @@ const actions = {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken }
} }
) )
commit('updateMonth', { ...response.data[0], com: 'add' }) //commit('updateMonth', { ...response.data[0], com: 'add' })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.response) if (e.response)
@ -244,51 +299,29 @@ const actions = {
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
for (let day in response.data) { for (var day in response.data) {
for (let item = 0; item < response.data[day].worker.length; item++) {
commit('updateMonth', {
...response.data[day].worker[item],
com: 'add',
day: response.data[day].day
})
}
commit('updateMonth', {
start: response.data[day].day.date,
day: response.data[day].day
})
var date = new Date( var date = new Date(
response.data[day].day.date.year, response.data[day].day.date.year,
response.data[day].day.date.month - 1, response.data[day].day.date.month - 1,
response.data[day].day.date.day response.data[day].day.date.day
) )
commit('setDayNotLoading', { date: date, getters }) commit('updateMonthJobkind', {
} data: [...response.data[day].jobkinddate],
} catch (e) { date,
if (e.response) getters
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async getUser({ commit, rootState, dispatch, getters }, data) {
commit('setDayLoading', { date: data.startdatetime, getters })
try {
const response = await axios.post(
url.vorstand.sm.getUser,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
for (let item = 0; item < response.data.worker.length; item++) {
commit('updateMonth', {
...response.data.worker[item],
com: 'add',
day: response.data.day
}) })
} commit('updateMonthWorker', {
commit('updateMonth', { workers: [...response.data[day].worker],
start: response.data.day.date, date,
day: response.data.day getters
}) })
commit('setDayNotLoading', { date: data.startdatetime, getters }) commit('updateMonthLocked', {
dispatch('getLifeTime', null, { root: true }) locked: response.data[day].day.locked,
date,
getters
})
commit('setDayNotLoading', { date, getters })
}
} catch (e) { } catch (e) {
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
@ -303,7 +336,7 @@ const actions = {
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
commit('updateMonth', { ...data, com: 'delete' }) //commit('updateMonth', { ...data, com: 'delete' })
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })
} catch (e) { } catch (e) {
if (e.response) if (e.response)
@ -324,6 +357,25 @@ const actions = {
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
async updateJobKindDate(
{ commit, rootState, dispatch, getters },
{ data, date }
) {
try {
commit('setDayLoading', { date, getters })
const response = await axios.post(
url.vorstand.sm.updateJobKindDates,
[...data],
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateMonthJobkind', { data: response.data, date, getters })
commit('setDayNotLoading', { date, getters })
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
setDayLoading({ commit, getters }, date) { setDayLoading({ commit, getters }, date) {
commit('setDayLoading', { date, getters }) commit('setDayLoading', { date, getters })
}, },

View File

@ -79,6 +79,23 @@ const actions = {
const response = await axios.get(url.getUsers, { const response = await axios.get(url.getUsers, {
headers: { Token: rootState.login.user.accessToken } headers: { Token: rootState.login.user.accessToken }
}) })
console.log(response.data)
commit('setUsers', response.data)
commit('setUsersLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setUsersLoading', false)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async getUsersWithExtern({ commit, rootState, dispatch }) {
try {
commit('setUsersLoading', true)
const response = await axios.get(url.getUsers + '?extern=1', {
headers: { Token: rootState.login.user.accessToken }
})
console.log(response.data)
commit('setUsers', response.data) commit('setUsers', response.data)
commit('setUsersLoading', false) commit('setUsersLoading', false)
dispatch('getLifeTime', null, { root: true }) dispatch('getLifeTime', null, { root: true })

View File

@ -18,13 +18,13 @@
{{user.firstname}} {{user.lastname}} {{user.firstname}} {{user.lastname}}
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item :disabled="lockedBar" v-if="isUser" class="title" link to="/main/user/add"> <v-list-item :disabled="lockedBar" v-if="isUser" class="title" link :to="{name: 'add'}">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{person}}</v-icon> <v-icon>{{person}}</v-icon>
</v-list-item-icon> </v-list-item-icon>
<v-list-item-title>{{user.firstname}} {{user.lastname}}</v-list-item-title> <v-list-item-title>{{user.firstname}} {{user.lastname}}</v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item v-if="isBar" class="title" link to="/main/bar/geruecht"> <v-list-item v-if="isBar" class="title" link :to="{name: 'geruecht'}">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{glass_cocktail}}</v-icon> <v-icon>{{glass_cocktail}}</v-icon>
</v-list-item-icon> </v-list-item-icon>
@ -32,7 +32,7 @@
Bar Bar
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item :disabled="lockedBar" v-if="isManagement" class="title" link to="/main/management/servicemanagement"> <v-list-item :disabled="lockedBar" v-if="isManagement" class="title" link :to="{name: 'serviceManagement', params: {year: new Date().getFullYear(), month: new Date().getMonth() + 1}}">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{king}}</v-icon> <v-icon>{{king}}</v-icon>
</v-list-item-icon> </v-list-item-icon>
@ -40,7 +40,7 @@
Vorstand Vorstand
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item :disabled="lockedBar" v-if="isGastro" class="title" link to="/main/gastro/pricelist"> <v-list-item :disabled="lockedBar" v-if="isGastro" class="title" link :to="{name: 'gastroPricelist'}">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{gastro}}</v-icon> <v-icon>{{gastro}}</v-icon>
</v-list-item-icon> </v-list-item-icon>
@ -48,7 +48,7 @@
Gastro Gastro
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item :disabled="lockedBar" v-if="isFinanzer" class="title" link to="/main/finanzer/overview"> <v-list-item :disabled="lockedBar" v-if="isFinanzer" class="title" link :to="{name: 'overview'}">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{attach_money}}</v-icon> <v-icon>{{attach_money}}</v-icon>
</v-list-item-icon> </v-list-item-icon>