vorstand can set job_kinds for day with max persons
workers willsort to job_kinds
This commit is contained in:
parent
9bd854209e
commit
bc2289173f
|
@ -86,9 +86,10 @@ export default {
|
|||
if (this.date.getDate() < intDate)
|
||||
this.date = new Date(this.date.getFullYear(), this.date.getMonth(), 0)
|
||||
}
|
||||
|
||||
this.getAllJobKinds()
|
||||
this.createMonth(this.date)
|
||||
this.getAllUsers()
|
||||
this.getDBUsers()
|
||||
this.getUsers({
|
||||
from_date: {
|
||||
year: this.startDate.getFullYear(),
|
||||
|
@ -107,7 +108,9 @@ export default {
|
|||
createMonth: 'sm/createMonth',
|
||||
getAllUsers: 'sm/getAllUsers',
|
||||
getUsers: 'sm/getUsers',
|
||||
lockDay: 'sm/lockDay'
|
||||
lockDay: 'sm/lockDay',
|
||||
getDBUsers: 'usermanager/getUsers',
|
||||
getAllJobKinds: 'jkm/getAllJobKinds',
|
||||
}),
|
||||
changeMonth(value) {
|
||||
if (value === -1) {
|
||||
|
|
|
@ -2,9 +2,13 @@
|
|||
<div v-if="day">
|
||||
<v-card :color="color(day)" max-width="250px" min-width="250px">
|
||||
<v-card-title v-if="day.date" class="subtitle-1 font-weight-bold">
|
||||
{{ day.name }} den {{ day.date.getDate() }}.{{
|
||||
day.date.getMonth() + 1
|
||||
}}.{{ day.date.getFullYear() }}
|
||||
{{ day.name }} {{ day.date.getDate() }}.{{ day.date.getMonth() + 1 }}.{{
|
||||
day.date.getFullYear()
|
||||
}}
|
||||
<v-spacer />
|
||||
<v-btn icon small @click="dialog = true">
|
||||
<v-icon>{{ menuIcon }}</v-icon>
|
||||
</v-btn>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-expand-transition>
|
||||
|
@ -12,22 +16,32 @@
|
|||
<v-progress-circular indeterminate color="grey" />
|
||||
</v-row>
|
||||
</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>
|
||||
<div v-show="!day.loading">
|
||||
<v-autocomplete
|
||||
chips
|
||||
return-object
|
||||
multiple
|
||||
v-model="day.worker"
|
||||
:items="allUsers"
|
||||
item-text="fullName"
|
||||
label="Dienste"
|
||||
:counter="jobkinddateitem.maxpersons"
|
||||
v-model="jobkinddateitem.worker"
|
||||
:items="filterUser(jobkinddateitem.job_kind)"
|
||||
:item-text="item => item.firstname + ' ' + item.lastname"
|
||||
:label="jobkinddateitem.job_kind.name"
|
||||
filled
|
||||
color="green"
|
||||
@input="searchInput = null"
|
||||
:search-input.sync="searchInput"
|
||||
@blur="focused = false"
|
||||
@focus="focused = true"
|
||||
:key="update"
|
||||
@change="forceRenderer(jobkinddateitem)"
|
||||
>
|
||||
<template v-slot:prepend-inner>
|
||||
<v-icon>{{ account_add }}</v-icon>
|
||||
|
@ -38,33 +52,160 @@
|
|||
:input-value="data.selected"
|
||||
close
|
||||
@click="data.select"
|
||||
@click:close="remove(data.item)"
|
||||
>{{ 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>
|
||||
@click:close="remove(jobkinddateitem, data.item)"
|
||||
>{{ data.item.firstname }} {{ data.item.lastname }}
|
||||
</v-chip>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
</div>
|
||||
</v-expand-transition>
|
||||
</div>
|
||||
</div>
|
||||
</v-card-text>
|
||||
<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-btn text @click="lock">{{ lockedTextBtn }}</v-btn>
|
||||
</v-card-actions>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters, mapActions } from 'vuex'
|
||||
import { mdiAccountPlus } from '@mdi/js'
|
||||
import { mdiAccountPlus, mdiDotsVertical, mdiPlus, mdiMinus } from '@mdi/js'
|
||||
export default {
|
||||
name: 'Day',
|
||||
props: {
|
||||
|
@ -73,19 +214,37 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
account_add: mdiAccountPlus,
|
||||
menuIcon: mdiDotsVertical,
|
||||
plusIcon: mdiPlus,
|
||||
minusIcon: mdiMinus,
|
||||
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() {
|
||||
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: {
|
||||
...mapActions({
|
||||
|
@ -94,15 +253,32 @@ export default {
|
|||
deleteUser: 'sm/deleteUser',
|
||||
setLoading: 'sm/setDayLoading',
|
||||
setNotLoading: 'sm/setDayNotLoading',
|
||||
lockDay: 'sm/lockDay'
|
||||
lockDay: 'sm/lockDay',
|
||||
updateJobKindDate: 'sm/updateJobKindDate'
|
||||
}),
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
remove(deletedUser) {
|
||||
const obj = this.day.worker.find(a => {
|
||||
return a.username === deletedUser.username
|
||||
forceRenderer(jobkind) {
|
||||
console.log(jobkind)
|
||||
this.update += 1
|
||||
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({
|
||||
startdatetime: this.day.date,
|
||||
date: this.day.date.getTime() / 1000,
|
||||
|
@ -111,17 +287,35 @@ export default {
|
|||
month: this.day.date.getMonth() + 1,
|
||||
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.date.getDay() === 0 || day.date.getDay() === 1) {
|
||||
return 'grey lighten-4'
|
||||
} else {
|
||||
if (day.worker.length < 2) {
|
||||
var retVal = 'yellow'
|
||||
retVal = 'light-green'
|
||||
for (var jobkind in day.jobkinddate) {
|
||||
if (day.jobkinddate[jobkind].worker.length >= day.jobkinddate[jobkind].maxpersons)
|
||||
retVal = 'light-green'
|
||||
else
|
||||
return 'yellow'
|
||||
} else {
|
||||
return 'light-green'
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
} else {
|
||||
return 'grey lighten-4'
|
||||
|
@ -134,16 +328,122 @@ export default {
|
|||
day: this.day.date.getDate(),
|
||||
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) {
|
||||
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
|
||||
})
|
||||
})
|
||||
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
|
||||
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: {
|
||||
...mapGetters({
|
||||
allUsers: 'sm/allUsers',
|
||||
disabled: 'sm/disabled'
|
||||
dbUsers: 'usermanager/users',
|
||||
disabled: 'sm/disabled',
|
||||
jobkinds: 'jkm/jobkinds'
|
||||
}),
|
||||
worker() {
|
||||
return this.day.worker
|
||||
},
|
||||
tada() {
|
||||
return this.day.jobkinddate
|
||||
},
|
||||
lockedColor() {
|
||||
return this.day.locked ? 'red' : 'green'
|
||||
},
|
||||
|
@ -152,6 +452,27 @@ export default {
|
|||
},
|
||||
lockedTextBtn() {
|
||||
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: {
|
||||
|
@ -185,16 +506,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>
|
||||
|
|
|
@ -31,13 +31,15 @@ const url = {
|
|||
addUser: main + 'sm/addUser',
|
||||
deleteUser: main + 'sm/deleteUser',
|
||||
getUser: main + 'sm/getUser',
|
||||
getUsers: main + 'sm/getUsers',
|
||||
getUsers: main + 'user/jobs',
|
||||
lockDay: main + 'sm/lockDay',
|
||||
searchUser: main + 'sm/searchWithExtern',
|
||||
jobkind: main + 'sm/JobKind',
|
||||
getAllJobKindsbKinds: main + 'sm/getAllJobKinds',
|
||||
getJobKind: main + 'sm/getJobKind',
|
||||
deleteJobKind: main + 'sm/deleteJobKind'
|
||||
deleteJobKind: main + 'sm/deleteJobKind',
|
||||
updateJobKindDates: main + 'jk/JobKindDate',
|
||||
getJobKindDates: main + 'jk/JobKindDate'
|
||||
},
|
||||
um: {
|
||||
setStatus: main + 'um/setStatus',
|
||||
|
|
|
@ -48,7 +48,8 @@ const mutations = {
|
|||
name: 'Montag',
|
||||
worker: [],
|
||||
loading: false,
|
||||
locked: false
|
||||
locked: false,
|
||||
jobkinddate: []
|
||||
}
|
||||
break
|
||||
case 2:
|
||||
|
@ -58,7 +59,8 @@ const mutations = {
|
|||
name: 'Dienstag',
|
||||
worker: [],
|
||||
loading: false,
|
||||
locked: false
|
||||
locked: false,
|
||||
jobkinddate: []
|
||||
}
|
||||
break
|
||||
case 3:
|
||||
|
@ -73,7 +75,8 @@ const mutations = {
|
|||
name: 'Mittwoch',
|
||||
worker: [],
|
||||
loading: false,
|
||||
locked: false
|
||||
locked: false,
|
||||
jobkinddate: []
|
||||
}
|
||||
}
|
||||
break
|
||||
|
@ -84,7 +87,8 @@ const mutations = {
|
|||
name: 'Donnerstag',
|
||||
worker: [],
|
||||
loading: false,
|
||||
locked: false
|
||||
locked: false,
|
||||
jobkinddate: []
|
||||
}
|
||||
break
|
||||
case 5:
|
||||
|
@ -94,7 +98,8 @@ const mutations = {
|
|||
name: 'Freitag',
|
||||
worker: [],
|
||||
loading: false,
|
||||
locked: false
|
||||
locked: false,
|
||||
jobkinddate: []
|
||||
}
|
||||
break
|
||||
case 6:
|
||||
|
@ -104,7 +109,8 @@ const mutations = {
|
|||
name: 'Samstag',
|
||||
worker: [],
|
||||
loading: false,
|
||||
locked: false
|
||||
locked: false,
|
||||
jobkinddate: []
|
||||
}
|
||||
break
|
||||
case 0:
|
||||
|
@ -114,7 +120,8 @@ const mutations = {
|
|||
name: 'Sontag',
|
||||
worker: [],
|
||||
loading: false,
|
||||
locked: false
|
||||
locked: false,
|
||||
jobkinddate: []
|
||||
}
|
||||
break
|
||||
}
|
||||
|
@ -155,31 +162,71 @@ const mutations = {
|
|||
week.endDate = week.days.monday.date
|
||||
}
|
||||
},
|
||||
updateMonth: (state, data) => {
|
||||
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
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
updateMonthWorker: (state, { workers, date, getters }) => {
|
||||
var day = getters.getDay(date)
|
||||
for (var worker in workers) {
|
||||
var jobkind = day.jobkinddate.find(jobkind => {
|
||||
return (
|
||||
jobkind.job_kind.id ===
|
||||
(workers[worker].job_kind ? workers[worker].job_kind.id : 1)
|
||||
)
|
||||
})
|
||||
if (!worker && data.com === 'add') {
|
||||
state.month[week].days[day].worker.push({
|
||||
firstname: user.firstname,
|
||||
lastname: user.lastname,
|
||||
username: user.username,
|
||||
fullName: user.firstname + ' ' + user.lastname
|
||||
if (jobkind) {
|
||||
jobkind.worker.push(workers[worker].user)
|
||||
jobkind.backupWorker.push(workers[worker].user)
|
||||
}
|
||||
}
|
||||
},
|
||||
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) {
|
||||
state.month[week].days[day].locked = data.day.locked
|
||||
}
|
||||
}
|
||||
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 => {
|
||||
for (let week = 0; week < state.month.length; week++) {
|
||||
|
@ -221,6 +268,7 @@ const actions = {
|
|||
// eslint-disable-next-line no-unused-vars
|
||||
async addUser({ commit, rootState, dispatch }, data) {
|
||||
try {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const response = await axios.post(
|
||||
url.vorstand.sm.addUser,
|
||||
{ ...data },
|
||||
|
@ -228,7 +276,7 @@ const actions = {
|
|||
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 })
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
|
@ -244,24 +292,29 @@ const actions = {
|
|||
{ ...data },
|
||||
{ headers: { Token: rootState.login.user.accessToken } }
|
||||
)
|
||||
for (let 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
|
||||
})
|
||||
console.log(response.data)
|
||||
for (var day in response.data) {
|
||||
var date = new Date(
|
||||
response.data[day].day.date.year,
|
||||
response.data[day].day.date.month - 1,
|
||||
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) {
|
||||
if (e.response)
|
||||
|
@ -303,7 +356,7 @@ const actions = {
|
|||
{ ...data },
|
||||
{ headers: { Token: rootState.login.user.accessToken } }
|
||||
)
|
||||
commit('updateMonth', { ...data, com: 'delete' })
|
||||
//commit('updateMonth', { ...data, com: 'delete' })
|
||||
dispatch('getLifeTime', null, { root: true })
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
|
@ -324,6 +377,25 @@ const actions = {
|
|||
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) {
|
||||
commit('setDayLoading', { date, getters })
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue