updated functions for ##222

This commit is contained in:
Tim Gröger 2020-03-13 19:07:57 +02:00
parent f845c0d686
commit 0b545c1c8e
8 changed files with 203 additions and 68 deletions

View File

@ -1,17 +1,15 @@
<template> <template>
<div> <div>
<v-toolbar> <v-toolbar>
<v-toolbar-title> <v-toolbar-title>Dienstübersicht</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 @click="changeMonth(-1)">
<v-icon>{{ keyboard_arrow_left }}</v-icon> <v-icon>{{ keyboard_arrow_left }}</v-icon>
</v-btn> </v-btn>
<v-list-item> <v-list-item>
<v-list-item-title class="title" <v-list-item-title class="title">
>{{ monthArray[date.getMonth()] }} {{ monthArray[date.getMonth()] }}
{{ date.getFullYear() }} {{ date.getFullYear() }}
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
@ -85,6 +83,18 @@ export default {
} }
this.createMonth(this.date) this.createMonth(this.date)
this.getAllUsers() this.getAllUsers()
this.getUsers({
from_date: {
year: this.startDate.getFullYear(),
month: this.startDate.getMonth() + 1,
day: this.startDate.getDate()
},
to_date: {
year: this.endDate.getFullYear(),
month: this.endDate.getMonth() + 1,
day: this.endDate.getDate()
}
})
this.getTransactJobs({ this.getTransactJobs({
year: this.date.getFullYear(), year: this.date.getFullYear(),
month: this.date.getMonth() + 1, month: this.date.getMonth() + 1,
@ -95,7 +105,8 @@ export default {
...mapActions({ ...mapActions({
getTransactJobs: 'requestJobs/getTransactJobs', getTransactJobs: 'requestJobs/getTransactJobs',
createMonth: 'jobs/createMonth', createMonth: 'jobs/createMonth',
getAllUsers: 'jobs/getAllUsers' getAllUsers: 'jobs/getAllUsers',
getUsers: 'jobs/getUsers'
}), }),
changeMonth(value) { changeMonth(value) {
if (value === -1) { if (value === -1) {
@ -104,11 +115,25 @@ export default {
this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 1) this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 1)
} }
this.createMonth(this.date) this.createMonth(this.date)
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()
}
})
} }
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
month: 'jobs/month' month: 'jobs/month',
startDate: 'jobs/getStartDate',
endDate: 'jobs/getEndDate'
}) })
} }
} }

View File

@ -17,7 +17,9 @@
<div v-for="worker in day.worker" :key="day.worker.indexOf(worker)"> <div v-for="worker in day.worker" :key="day.worker.indexOf(worker)">
<v-chip <v-chip
style="margin: 3px;" style="margin: 3px;"
:close="user(worker) && !day.locked || canDelete && user(worker)" :close="
(user(worker) && !day.locked) || (canDelete && user(worker))
"
@click:close=" @click:close="
deleteJob({ deleteJob({
year: day.date.getFullYear(), year: day.date.getFullYear(),
@ -25,8 +27,7 @@
day: day.date.getDate() day: day.date.getDate()
}) })
" "
>{{ worker.firstname }} {{ worker.lastname }} >{{ worker.firstname }} {{ worker.lastname }}</v-chip>
</v-chip>
</div> </div>
</div> </div>
</v-expand-transition> </v-expand-transition>
@ -49,9 +50,7 @@
</template> </template>
<template v-slot:item="data"> <template v-slot:item="data">
<v-list-item-content> <v-list-item-content>
<v-list-item-title> <v-list-item-title>{{ data.item.firstname }} {{ data.item.lastname }}</v-list-item-title>
{{ data.item.firstname }} {{ data.item.lastname }}
</v-list-item-title>
</v-list-item-content> </v-list-item-content>
</template> </template>
</v-autocomplete> </v-autocomplete>
@ -75,10 +74,12 @@
<v-spacer /> <v-spacer />
<v-btn <v-btn
text text
v-if="!day.locked && v-if="
!day.locked &&
!day.loading && !day.loading &&
day.worker.length < 2 && day.worker.length < 2 &&
!userInWorker" !userInWorker
"
@click=" @click="
addJob({ addJob({
year: day.date.getFullYear(), year: day.date.getFullYear(),
@ -86,8 +87,7 @@
day: day.date.getDate() day: day.date.getDate()
}) })
" "
>Eintragen >Eintragen</v-btn>
</v-btn>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</div> </div>
@ -110,17 +110,9 @@ export default {
}, },
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({
getUser: 'jobs/getUser',
setLoading: 'jobs/setDayLoading', setLoading: 'jobs/setDayLoading',
setNotLoading: 'jobs/setDayNotLoading', setNotLoading: 'jobs/setDayNotLoading',
addJob: 'jobs/addJob', addJob: 'jobs/addJob',
@ -190,15 +182,6 @@ export default {
} }
}, },
watch: { watch: {
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()
})
},
worker() { worker() {
return this.day.worker return this.day.worker
} }

View File

@ -1,9 +1,7 @@
<template> <template>
<div> <div>
<v-toolbar> <v-toolbar>
<v-toolbar-title> <v-toolbar-title>Dienstverwaltung</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 @click="changeMonth(-1)">
@ -11,7 +9,8 @@
</v-btn> </v-btn>
<v-list-item> <v-list-item>
<v-list-item-title class="title"> <v-list-item-title class="title">
{{ monthArray[date.getMonth()] }} {{ date.getFullYear() }} {{ monthArray[date.getMonth()] }}
{{ 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 @click="changeMonth(1)">
@ -90,11 +89,24 @@ export default {
this.createMonth(this.date) this.createMonth(this.date)
this.getAllUsers() this.getAllUsers()
this.getUsers({
from_date: {
year: this.startDate.getFullYear(),
month: this.startDate.getMonth() + 1,
day: this.startDate.getDate()
},
to_date: {
year: this.endDate.getFullYear(),
month: this.endDate.getMonth() + 1,
day: this.endDate.getDate()
}
})
}, },
methods: { methods: {
...mapActions({ ...mapActions({
createMonth: 'sm/createMonth', createMonth: 'sm/createMonth',
getAllUsers: 'sm/getAllUsers', getAllUsers: 'sm/getAllUsers',
getUsers: 'sm/getUsers',
lockDay: 'sm/lockDay' lockDay: 'sm/lockDay'
}), }),
changeMonth(value) { changeMonth(value) {
@ -104,6 +116,18 @@ export default {
this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 1) this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 1)
} }
this.createMonth(this.date) this.createMonth(this.date)
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()
}
})
}, },
lockDays(value) { lockDays(value) {
for (var week in this.month) { for (var week in this.month) {
@ -121,7 +145,9 @@ export default {
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
month: 'sm/month' month: 'sm/month',
startDate: 'sm/getStartDate',
endDate: 'sm/getEndDate'
}) })
} }
} }

View File

@ -39,14 +39,13 @@
close close
@click="data.select" @click="data.select"
@click:close="remove(data.item)" @click:close="remove(data.item)"
> >{{ data.item.firstname }} {{ data.item.lastname }}</v-chip>
{{ data.item.firstname }} {{ data.item.lastname }}
</v-chip>
</template> </template>
<template v-slot:item="data"> <template v-slot:item="data">
<v-list-item-content> <v-list-item-content>
<v-list-item-title> <v-list-item-title>
{{ data.item.firstname }} {{ data.item.lastname }} {{ data.item.firstname }}
{{ data.item.lastname }}
</v-list-item-title> </v-list-item-title>
</v-list-item-content> </v-list-item-content>
</template> </template>
@ -80,13 +79,13 @@ export default {
}, },
created() { created() {
this.setLoading(this.day.date) this.setLoading(this.day.date)
this.getUser({ //this.getUser({
date: this.day.date.getTime() / 1000, // date: this.day.date.getTime() / 1000,
startdatetime: this.day.date, // startdatetime: this.day.date,
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()
}) //})
}, },
methods: { methods: {
...mapActions({ ...mapActions({
@ -129,7 +128,12 @@ export default {
} }
}, },
lock() { lock() {
this.lockDay({year: this.day.date.getFullYear(), month: this.day.date.getMonth() + 1, day: this.day.date.getDate(), locked: !this.day.locked}) this.lockDay({
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate(),
locked: !this.day.locked
})
} }
}, },
computed: { computed: {
@ -181,16 +185,16 @@ export default {
} }
} }
} }
},
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()
})
} }
//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

@ -31,6 +31,7 @@ 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',
lockDay: main + 'sm/lockDay', lockDay: main + 'sm/lockDay',
searchUser: main + 'sm/searchWithExtern' searchUser: main + 'sm/searchWithExtern'
}, },
@ -45,6 +46,7 @@ const url = {
user: { user: {
config: main + 'user/saveConfig', config: main + 'user/saveConfig',
job: main + 'user/job', job: main + 'user/job',
jobs: main + 'user/jobs',
addJob: main + 'user/addJob', addJob: main + 'user/addJob',
deleteJob: main + 'user/deleteJob', deleteJob: main + 'user/deleteJob',
transactJob: main + 'user/transactJob', transactJob: main + 'user/transactJob',

View File

@ -155,6 +155,13 @@ const mutations = {
} }
} }
}, },
setAllDayLoading: state => {
for (let week = 0; week < state.month.length; week++) {
for (let day in state.month[week].days) {
state.month[week].days[day].loading = true
}
}
},
setDayLoading: (state, { date, getters }) => { setDayLoading: (state, { date, getters }) => {
let day = getters.getDay(date) let day = getters.getDay(date)
day.loading = true day.loading = true
@ -228,6 +235,38 @@ const actions = {
setDayNotLoading({ commit, getters }, date) { setDayNotLoading({ commit, getters }, date) {
commit('setDayNotLoading', { date, getters }) commit('setDayNotLoading', { date, getters })
}, },
async getUsers({ commit, rootState, dispatch, getters }, data) {
commit('setAllDayLoading')
try {
const response = await axios.post(
url.user.jobs,
{ ...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
})
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 })
}
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async getUser({ commit, rootState, dispatch, getters }, data) { async getUser({ commit, rootState, dispatch, getters }, data) {
commit('setDayLoading', { date: data.startdatetime, getters }) commit('setDayLoading', { date: data.startdatetime, getters })
try { try {
@ -322,6 +361,12 @@ const getters = {
}, },
allUsers: state => { allUsers: state => {
return state.allUsers return state.allUsers
},
getStartDate: state => {
return state.month[0].startDate
},
getEndDate: state => {
return state.month[state.month.length - 1].endDate
} }
} }

View File

@ -120,6 +120,7 @@ const mutations = {
} }
} }
state.month = month state.month = month
console.log(month)
}, },
setStartEndDate: week => { setStartEndDate: week => {
if (week.days.monday) { if (week.days.monday) {
@ -180,6 +181,13 @@ const mutations = {
} }
} }
}, },
setAllDayLoading: state => {
for (let week = 0; week < state.month.length; week++) {
for (let day in state.month[week].days) {
state.month[week].days[day].loading = true
}
}
},
setDayLoading: (state, { date, getters }) => { setDayLoading: (state, { date, getters }) => {
let day = getters.getDay(date) let day = getters.getDay(date)
day.loading = true day.loading = true
@ -227,6 +235,39 @@ const actions = {
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
}, },
// eslint-disable-next-line no-unused-vars
async getUsers({ commit, rootState, dispatch, getters }, data) {
commit('setAllDayLoading')
try {
const response = await axios.post(
url.vorstand.sm.getUsers,
{ ...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
})
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 })
}
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async getUser({ commit, rootState, dispatch, getters }, data) { async getUser({ commit, rootState, dispatch, getters }, data) {
commit('setDayLoading', { date: data.startdatetime, getters }) commit('setDayLoading', { date: data.startdatetime, getters })
try { try {
@ -312,6 +353,12 @@ const getters = {
}, },
disabled: state => { disabled: state => {
return state.disabled return state.disabled
},
getStartDate: state => {
return state.month[0].startDate
},
getEndDate: state => {
return state.month[state.month.length - 1].endDate
} }
} }

View File

@ -8,5 +8,8 @@ module.exports = {
// key: fs.readFileSync('./cert/server.key'), // key: fs.readFileSync('./cert/server.key'),
// cert: fs.readFileSync('./cert/server.crt') // cert: fs.readFileSync('./cert/server.crt')
// } // }
},
configureWebpack: {
devtool: 'source-map'
} }
} }