Merge branch 'feature/serviceManegement' into develop

This commit is contained in:
Tim Gröger 2020-02-26 20:12:59 +01:00
commit 578f8923b3
13 changed files with 831 additions and 106 deletions

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="de">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

View File

@ -0,0 +1,250 @@
<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

@ -21,7 +21,7 @@
</v-toolbar-items>
<v-spacer />
</v-toolbar>
<v-card v-for="week in month" :key="month.indexOf(week)">
<v-card v-for="week in month" :key="month.indexOf(week)" flat tile>
<v-card-title class="subtitle-1 font-weight-bold">
Woche vom {{ week.startDate.getDate() }}.{{
week.startDate.getMonth() + 1
@ -73,10 +73,12 @@ export default {
},
created() {
this.createMonth(this.date)
this.getAllUsers()
},
methods: {
...mapActions({
createMonth: 'jobs/createMonth'
createMonth: 'jobs/createMonth',
getAllUsers: 'jobs/getAllUsers'
}),
changeMonth(value) {
if (value === -1) {

View File

@ -14,41 +14,80 @@
</v-expand-transition>
<v-expand-transition>
<div v-show="!day.loading">
<!-- <v-autocomplete-->
<!-- chips-->
<!-- return-object-->
<!-- multiple-->
<!-- v-model="day.worker"-->
<!-- item-text="fullName"-->
<!-- label="Dienste"-->
<!-- filled-->
<!-- color="green"-->
<!-- @input="searchInput = null"-->
<!-- :search-input.sync="searchInput"-->
<!-- @blur="focused = false"-->
<!-- @focus="focused = true"-->
<!-- disabled-->
<!-- >-->
<!-- <template v-slot:prepend-inner>-->
<!-- <v-icon>{{ account_add }}</v-icon>-->
<!-- </template>-->
<!-- <template v-slot:selection="data">-->
<!-- <v-chip v-bind="data.attrs" :input-value="data.selected" close>-->
<!-- {{ data.item.firstname }} {{ data.item.lastname }}-->
<!-- </v-chip>-->
<!-- </template>-->
<!-- <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>-->
<!-- </v-autocomplete>-->
<v-chip style="margin: 3px;" v-for="worker in day.worker" :key="day.worker.indexOf(worker)">{{ worker.firstname }} {{ worker.lastname }}</v-chip>
<div v-for="worker in day.worker" :key="day.worker.indexOf(worker)">
<v-chip
style="margin: 3px;"
:close="user(worker) && !day.locked || canDelete && user(worker)"
@click:close="
deleteJob({
year: day.date.getFullYear(),
month: day.date.getMonth() + 1,
day: day.date.getDate()
})
"
>{{ worker.firstname }} {{ worker.lastname }}
</v-chip>
</div>
</div>
</v-expand-transition>
</v-card-text>
<div v-if="userInWorker">
<v-card-actions class="text--secondary">
<v-autocomplete
return-object
v-model="requestUser"
:items="specifiedUsers"
item-text="fullName"
label="Dienstanfrage"
filled
color="green"
@input="searchInput = null"
:search-input.sync="searchInput"
>
<template v-slot:prepend-inner>
<v-icon>{{ account_add }}</v-icon>
</template>
<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>
</v-autocomplete>
</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-btn
v-if="!day.locked &&
!day.loading &&
day.worker.length < 2 &&
!userInWorker"
@click="
addJob({
year: day.date.getFullYear(),
month: day.date.getMonth() + 1,
day: day.date.getDate()
})
"
>Eintragen
</v-btn>
</v-card-actions>
</v-card>
</div>
</template>
@ -64,25 +103,49 @@ export default {
data() {
return {
account_add: mdiAccountPlus,
searchInput: null
searchInput: null,
requestUser: null
}
},
created() {
this.setLoading(this.day.date)
this.getUser({
date: this.day.date.getTime() / 1000,
startdatetime: this.day.date
startdatetime: this.day.date,
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
})
this.getTransactJobs({})
this.getTransactJobs({
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
})
},
methods: {
...mapActions({
getTransactJobs: 'requestJobs/getTransactJobs',
getUser: 'jobs/getUser',
setLoading: 'jobs/setDayLoading',
setNotLoading: 'jobs/setDayNotLoading'
setNotLoading: 'jobs/setDayNotLoading',
addJob: 'jobs/addJob',
deleteJob: 'jobs/deleteJob',
transactJob: 'jobs/transactJob'
}),
test(event) {
console.log('blur', event)
},
send() {
this.transactJob({
user: this.requestUser.username,
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
})
this.requestUser = null
this.searchInput = null
},
color: day => {
if (day) {
if (day.date.getDay() === 0 || day.date.getDay() === 1) {
@ -97,18 +160,56 @@ export default {
} else {
return 'grey lighten-4'
}
},
user(worker) {
return worker.username === this.activeUser.username
}
},
computed: {
...mapGetters({
disabled: 'jobs/disabled'
disabled: 'jobs/disabled',
activeUser: 'user',
allUsers: 'jobs/allUsers',
transactJobs: 'requestJobs/transactJobs'
}),
userInWorker() {
return this.day.worker.find(a => {
return a.username === this.activeUser.username
})
},
specifiedUsers() {
var users = [...this.allUsers]
for (var i in this.day.worker) {
var worker = users.find(a => {
return a.username === this.day.worker[i].username
})
var index = users.indexOf(worker)
if (worker) users.splice(index, 1)
}
return users
},
canDelete() {
console.log(this.day.date)
console.log(this.transactJobs)
var transactJob = this.transactJobs.filter(a => {
return a.date - this.day.date === 0
})
console.log('filter', transactJob)
var test = transactJob.find(a => {
return a.accepted && a.answerd
})
console.log('find', test)
return test
}
},
watch: {
day() {
this.getUser({
date: this.day.date.getTime() / 1000,
startdatetime: this.day.date
startdatetime: this.day.date,
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
})
},
worker() {

View File

@ -22,6 +22,14 @@
</v-list-item-icon>
<v-list-item-title>Dienstübersicht</v-list-item-title>
</v-list-item>
<v-list-item link to="/main/user/jobRequests">
<v-list-item-icon>
<v-icon>
{{ switchAccount }}
</v-icon>
</v-list-item-icon>
<v-list-item-title>Dienstanfragen</v-list-item-title>
</v-list-item>
<v-list-item link to="/main/user/config">
<v-list-item-icon>
<v-icon>{{ account_card_details }}</v-icon>
@ -32,7 +40,13 @@
</template>
<script>
import {mdiAccountCardDetails, mdiHome, mdiBank, mdiBriefcase } from '@mdi/js'
import {
mdiAccountCardDetails,
mdiHome,
mdiBank,
mdiBriefcase,
mdiAccountSwitch
} from '@mdi/js'
export default {
name: 'UserNavigation',
data() {
@ -40,7 +54,8 @@ export default {
account_card_details: mdiAccountCardDetails,
account: mdiHome,
bank: mdiBank,
briefcase: mdiBriefcase
briefcase: mdiBriefcase,
switchAccount: mdiAccountSwitch
}
}
}

View File

@ -21,8 +21,12 @@
</v-btn>
</v-toolbar-items>
<v-spacer />
<v-toolbar-items>
<v-btn text @click="lockDays(true)">Monat sperren</v-btn>
<v-btn text @click="lockDays(false)">Monat freigeben</v-btn>
</v-toolbar-items>
</v-toolbar>
<v-card v-for="week in month" :key="month.indexOf(week)">
<v-card v-for="week in month" :key="month.indexOf(week)" tile flat>
<v-card-title class="subtitle-1 font-weight-bold">
Woche vom {{ week.startDate.getDate() }}.{{
week.startDate.getMonth() + 1
@ -81,7 +85,8 @@ export default {
methods: {
...mapActions({
createMonth: 'sm/createMonth',
getAllUsers: 'sm/getAllUsers'
getAllUsers: 'sm/getAllUsers',
lockDay: 'sm/lockDay'
}),
changeMonth(value) {
if (value === -1) {
@ -90,6 +95,14 @@ export default {
this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 1)
}
this.createMonth(this.date)
},
lockDays(value) {
for (var week in this.month) {
for (var dayint in this.month[week].days) {
var day = this.month[week].days[dayint]
this.lockDay({year: day.date.getFullYear(), month: day.date.getMonth() + 1, day: day.date.getDate(), locked: value})
}
}
}
},
computed: {

View File

@ -28,7 +28,6 @@
:search-input.sync="searchInput"
@blur="focused = false"
@focus="focused = true"
>
<template v-slot:prepend-inner>
<v-icon>{{ account_add }}</v-icon>
@ -55,6 +54,11 @@
</div>
</v-expand-transition>
</v-card-text>
<v-card-actions v-if="!day.loading">
<v-chip class="text-uppercase" :color="lockedColor">{{ lockedText }}</v-chip>
<v-spacer />
<v-btn @click="lock">{{lockedTextBtn}}</v-btn>
</v-card-actions>
</v-card>
</div>
</template>
@ -78,7 +82,10 @@ export default {
this.setLoading(this.day.date)
this.getUser({
date: this.day.date.getTime() / 1000,
startdatetime: this.day.date
startdatetime: this.day.date,
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
})
},
methods: {
@ -87,7 +94,8 @@ export default {
getUser: 'sm/getUser',
deleteUser: 'sm/deleteUser',
setLoading: 'sm/setDayLoading',
setNotLoading: 'sm/setDayNotLoading'
setNotLoading: 'sm/setDayNotLoading',
lockDay: 'sm/lockDay'
}),
// eslint-disable-next-line no-unused-vars
remove(deletedUser) {
@ -99,7 +107,10 @@ export default {
this.deleteUser({
startdatetime: this.day.date,
date: this.day.date.getTime() / 1000,
user: deletedUser
user: deletedUser,
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
})
},
test(event) {
@ -120,6 +131,9 @@ export default {
return 'grey lighten-4'
}
},
lock() {
this.lockDay({year: this.day.date.getFullYear(), month: this.day.date.getMonth() + 1, day: this.day.date.getDate(), locked: !this.day.locked})
}
},
computed: {
...mapGetters({
@ -128,6 +142,15 @@ export default {
}),
worker() {
return this.day.worker
},
lockedColor() {
return this.day.locked ? 'red' : 'green'
},
lockedText() {
return this.day.locked ? 'gesperrt' : 'frei'
},
lockedTextBtn() {
return this.day.locked ? 'freigeben' : 'sperren'
}
},
watch: {
@ -139,7 +162,10 @@ export default {
addedUser = newValue[user]
this.addUser({
date: this.day.date.getTime() / 1000,
user: addedUser
user: addedUser,
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
})
}
}
@ -147,11 +173,14 @@ export default {
for (let user in oldValue) {
if (!newValue.includes(oldValue[user])) {
deletedUser = oldValue[user]
console.log("deleteUser", deletedUser, this.day.date)
console.log('deleteUser', deletedUser, this.day.date)
this.deleteUser({
startdatetime: this.day.date,
date: this.day.date.getTime() / 1000,
user: deletedUser
user: deletedUser,
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
})
}
}
@ -160,7 +189,10 @@ export default {
day() {
this.getUser({
date: this.day.date.getTime() / 1000,
startdatetime: this.day.date
startdatetime: this.day.date,
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
})
},
focused(newVal, oldValue) {

View File

@ -24,12 +24,20 @@ const url = {
sm: {
addUser: main + 'sm/addUser',
deleteUser: main + 'sm/deleteUser',
getUser: main + 'sm/getUser'
getUser: main + 'sm/getUser',
lockDay: main + 'sm/lockDay'
}
},
user: {
config: main + 'user/saveConfig',
job: main + 'user/job'
job: main + 'user/job',
addJob: main + 'user/addJob',
deleteJob: main + 'user/deleteJob',
transactJob: main + 'user/transactJob',
answerTransactJob: main + 'user/answerTransactJob',
jobRequests: main + 'user/jobRequests',
getTransactJobs: main + 'user/getTransactJobs',
deleteTransactJobs: main + 'user/deleteTransactJob'
},
barU: {
storno: main + 'bar/storno'

View File

@ -17,6 +17,7 @@ import User from '../components/finanzer/User'
import ServiceManagement from '../components/vorstand/ServiceManagement'
import Config from '@/components/user/Config'
import Jobs from '@/components/user/Jobs'
import JobRequests from '@/components/user/JobRequests'
Vue.use(VueRouter)
@ -55,6 +56,11 @@ const routes = [
path: 'jobs',
name: 'userJobs',
component: Jobs
},
{
path: 'jobRequests',
name: 'jobRequests',
component: JobRequests
}
]
},

View File

@ -6,6 +6,7 @@ import barUsers from '@/store/modules/barUsers'
import user from '@/store/modules/user'
import sm from '@/store/modules/serviceManagement'
import jobs from '@/store/modules/jobs'
import requestJobs from '@/store/modules/jobRequests'
Vue.use(Vuex)
@ -16,6 +17,7 @@ export default new Vuex.Store({
barUsers,
user,
sm,
jobs
jobs,
requestJobs
}
})

View File

@ -0,0 +1,161 @@
import axios from 'axios'
import url from '@/plugins/routes'
const state = {
transactJobs: [],
transactJobsLoading: false,
requestJobs: [],
requestJobsLoading: false
}
const mutations = {
setTransactJobs: (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
})
}
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
})
}
state.requestJobs = list
},
setTransactJobsLoading: (state, value) => {
state.transactJobsLoading = value
},
setRequestJobsLoading: (state, value) => {
state.requestJobsLoading = value
},
updateRequestJob: (state, data) => {
const date = new Date(data.date.year, data.date.month - 1, data.date.day)
for (var i in state.requestJobs) {
if (
state.requestJobs[i].date - date === 0 &&
state.requestJobs[i].from_user.username === data.from_user.username
) {
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 => {
console.log(a)
console.log(a.date, date)
return a.date - date === 0 && a.to_user.username === data.username
})
console.log(job)
var index = state.transactJobs.indexOf(job)
if (job)
state.transactJobs.splice(index, 1)
}
}
const actions = {
async getTransactJobs({ commit, rootState, dispatch }, data) {
commit('setTransactJobsLoading', true)
try {
const response = await axios.post(
url.user.getTransactJobs,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setTransactJobs', response.data)
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })
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)
} 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)
} 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 } }
)
commit('deleteTransactJobactJob', data)
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })
}
}
}
const getters = {
transactJobs: state => {
return state.transactJobs
},
transactJobsLoading: state => {
return state.transactJobsLoading
},
requestJobs: state => {
return state.requestJobs
},
requestJobsLoading: state => {
return state.requestJobsLoading
}
}
export default {
namespaced: true,
state,
mutations,
actions,
getters
}

View File

@ -3,10 +3,23 @@ import url from '@/plugins/routes'
const state = {
month: [],
allUsers: [],
disabled: false
}
const mutations = {
setAllUsers: (state, data) => {
state.allUsers = []
state.allUsers = data.users
const index = state.allUsers.indexOf(
state.allUsers.find(a => a.username === data.username)
)
state.allUsers.splice(index, 1)
for (let i = 0; i < state.allUsers.length; i++) {
state.allUsers[i].fullName =
state.allUsers[i].firstname + ' ' + state.allUsers[i].lastname
}
},
createMonth: (state, date) => {
let month = []
let id = 0
@ -25,7 +38,7 @@ const mutations = {
let week = { id: id, days: {} }
for (let intDay = startDate; intDay <= days + 7; intDay++) {
if (end) break
let currentDate = new Date(year, mon, intDay, 12)
let currentDate = new Date(year, mon, intDay)
switch (currentDate.getDay()) {
case 1:
@ -38,7 +51,8 @@ const mutations = {
date: currentDate,
name: 'Montag',
worker: [],
loading: false
loading: false,
locked: false
}
break
case 2:
@ -47,7 +61,8 @@ const mutations = {
date: currentDate,
name: 'Dienstag',
worker: [],
loading: false
loading: false,
locked: false
}
break
case 3:
@ -61,7 +76,8 @@ const mutations = {
date: currentDate,
name: 'Mittwoch',
worker: [],
loading: false
loading: false,
locked: false
}
}
break
@ -71,7 +87,8 @@ const mutations = {
date: currentDate,
name: 'Donnerstag',
worker: [],
loading: false
loading: false,
locked: false
}
break
case 5:
@ -80,7 +97,8 @@ const mutations = {
date: currentDate,
name: 'Freitag',
worker: [],
loading: false
loading: false,
locked: false
}
break
case 6:
@ -89,7 +107,8 @@ const mutations = {
date: currentDate,
name: 'Samstag',
worker: [],
loading: false
loading: false,
locked: false
}
break
case 0:
@ -98,7 +117,8 @@ const mutations = {
date: currentDate,
name: 'Sontag',
worker: [],
loading: false
loading: false,
locked: false
}
break
}
@ -106,11 +126,12 @@ const mutations = {
state.month = month
},
updateMonth: (state, data) => {
const date = new Date(data.startdatetime)
const date = new Date(data.start.year, data.start.month - 1, data.start.day)
const user = data.user
for (let week = 0; week < state.month.length; week++) {
for (let day in state.month[week].days) {
if (state.month[week].days[day].date - date === 0) {
if (user) {
let worker = state.month[week].days[day].worker.find(a => {
return a.username === user.username
})
@ -122,6 +143,14 @@ const mutations = {
fullName: user.firstname + ' ' + user.lastname
})
}
if (worker && data.com === 'delete') {
const index = state.month[week].days[day].worker.indexOf(worker)
state.month[week].days[day].worker.splice(index, 1)
}
}
if (data.day) {
state.month[week].days[day].locked = data.day.locked
}
}
}
}
@ -173,6 +202,22 @@ const mutations = {
}
const actions = {
async getAllUsers({ commit, rootState, dispatch }) {
try {
const response = await axios.post(
url.searchUser,
{ searchString: '' },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setAllUsers', {
users: response.data,
username: rootState.login.user.username
})
} catch (e) {
if (e.response)
if (e.response.data === 401) dispatch('logout', null, { root: true })
}
},
createMonth({ commit }, date) {
commit('setDisabled', true)
commit('createMonth', date)
@ -192,14 +237,68 @@ const actions = {
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
for (let item = 0; item < response.data.length; item++) {
commit('updateMonth', { ...response.data[item], com: 'add' })
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 })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async addJob({ commit, rootState, dispatch }, data) {
try {
const response = await axios.post(
url.user.addJob,
{ ...data },
{
headers: { Token: rootState.login.user.accessToken }
}
)
commit('updateMonth', { ...response.data[0], com: 'add' })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
// eslint-disable-next-line no-unused-vars
async deleteJob({ commit, rootState, dispatch }, data) {
try {
const response = await axios.post(
url.user.deleteJob,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateMonth', {
start: { ...data },
user: rootState.login.user,
com: 'delete'
})
console.log(response)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async transactJob({ rootState, dispatch }, data) {
try {
await axios.post(
url.user.transactJob,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
}
}
@ -218,6 +317,9 @@ const getters = {
},
disabled: state => {
return state.disabled
},
allUsers: state => {
return state.allUsers
}
}

View File

@ -34,7 +34,7 @@ const mutations = {
let week = { id: id, days: {} }
for (let intDay = startDate; intDay <= days + 7; intDay++) {
if (end) break
let currentDate = new Date(year, mon, intDay, 12)
let currentDate = new Date(year, mon, intDay)
switch (currentDate.getDay()) {
case 1:
@ -47,7 +47,8 @@ const mutations = {
date: currentDate,
name: 'Montag',
worker: [],
loading: false
loading: false,
locked: false
}
break
case 2:
@ -56,7 +57,8 @@ const mutations = {
date: currentDate,
name: 'Dienstag',
worker: [],
loading: false
loading: false,
locked: false
}
break
case 3:
@ -70,7 +72,8 @@ const mutations = {
date: currentDate,
name: 'Mittwoch',
worker: [],
loading: false
loading: false,
locked: false
}
}
break
@ -80,7 +83,8 @@ const mutations = {
date: currentDate,
name: 'Donnerstag',
worker: [],
loading: false
loading: false,
locked: false
}
break
case 5:
@ -89,7 +93,8 @@ const mutations = {
date: currentDate,
name: 'Freitag',
worker: [],
loading: false
loading: false,
locked: false
}
break
case 6:
@ -98,7 +103,8 @@ const mutations = {
date: currentDate,
name: 'Samstag',
worker: [],
loading: false
loading: false,
locked: false
}
break
case 0:
@ -107,7 +113,8 @@ const mutations = {
date: currentDate,
name: 'Sontag',
worker: [],
loading: false
loading: false,
locked: false
}
break
}
@ -148,11 +155,12 @@ const mutations = {
}
},
updateMonth: (state, data) => {
const date = new Date(data.startdatetime)
const date = new Date(data.start.year, data.start.month - 1, data.start.day)
const user = data.user
for (let week = 0; week < state.month.length; week++) {
for (let day in state.month[week].days) {
if (state.month[week].days[day].date - date === 0) {
if (user) {
let worker = state.month[week].days[day].worker.find(a => {
return a.username === user.username
})
@ -165,6 +173,10 @@ const mutations = {
})
}
}
if (data.day) {
state.month[week].days[day].locked = data.day.locked
}
}
}
}
},
@ -223,9 +235,17 @@ const actions = {
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
for (let item = 0; item < response.data.length; item++) {
commit('updateMonth', { ...response.data[item], com: 'add' })
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 })
} catch (e) {
if (e.response)
@ -247,6 +267,19 @@ const actions = {
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async lockDay({ commit, rootState, dispatch }, data) {
try {
const response = await axios.post(
url.vorstand.sm.lockDay,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateMonth', { start: response.data.date, day: response.data })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
setDayLoading({ commit, getters }, date) {
commit('setDayLoading', { date, getters })
},