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>
<div>
<v-toolbar>
<v-toolbar-title>
Dienstübersicht
</v-toolbar-title>
<v-toolbar-title>Dienstübersicht</v-toolbar-title>
<v-spacer />
<v-toolbar-items>
<v-btn text icon @click="changeMonth(-1)">
<v-icon>{{ keyboard_arrow_left }}</v-icon>
</v-btn>
<v-list-item>
<v-list-item-title class="title"
>{{ monthArray[date.getMonth()] }}
<v-list-item-title class="title">
{{ monthArray[date.getMonth()] }}
{{ date.getFullYear() }}
</v-list-item-title>
</v-list-item>
@ -85,6 +83,18 @@ export default {
}
this.createMonth(this.date)
this.getAllUsers()
this.getUsers({
from_date: {
year: this.startDate.getFullYear(),
month: this.startDate.getMonth() + 1,
day: this.startDate.getDate()
},
to_date: {
year: this.endDate.getFullYear(),
month: this.endDate.getMonth() + 1,
day: this.endDate.getDate()
}
})
this.getTransactJobs({
year: this.date.getFullYear(),
month: this.date.getMonth() + 1,
@ -95,7 +105,8 @@ export default {
...mapActions({
getTransactJobs: 'requestJobs/getTransactJobs',
createMonth: 'jobs/createMonth',
getAllUsers: 'jobs/getAllUsers'
getAllUsers: 'jobs/getAllUsers',
getUsers: 'jobs/getUsers'
}),
changeMonth(value) {
if (value === -1) {
@ -104,11 +115,25 @@ export default {
this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 1)
}
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: {
...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)">
<v-chip
style="margin: 3px;"
:close="user(worker) && !day.locked || canDelete && user(worker)"
:close="
(user(worker) && !day.locked) || (canDelete && user(worker))
"
@click:close="
deleteJob({
year: day.date.getFullYear(),
@ -25,8 +27,7 @@
day: day.date.getDate()
})
"
>{{ worker.firstname }} {{ worker.lastname }}
</v-chip>
>{{ worker.firstname }} {{ worker.lastname }}</v-chip>
</div>
</div>
</v-expand-transition>
@ -49,9 +50,7 @@
</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-title>{{ data.item.firstname }} {{ data.item.lastname }}</v-list-item-title>
</v-list-item-content>
</template>
</v-autocomplete>
@ -75,10 +74,12 @@
<v-spacer />
<v-btn
text
v-if="!day.locked &&
v-if="
!day.locked &&
!day.loading &&
day.worker.length < 2 &&
!userInWorker"
!userInWorker
"
@click="
addJob({
year: day.date.getFullYear(),
@ -86,8 +87,7 @@
day: day.date.getDate()
})
"
>Eintragen
</v-btn>
>Eintragen</v-btn>
</v-card-actions>
</v-card>
</div>
@ -110,17 +110,9 @@ export default {
},
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({
getUser: 'jobs/getUser',
setLoading: 'jobs/setDayLoading',
setNotLoading: 'jobs/setDayNotLoading',
addJob: 'jobs/addJob',
@ -190,15 +182,6 @@ export default {
}
},
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() {
return this.day.worker
}

View File

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

View File

@ -39,14 +39,13 @@
close
@click="data.select"
@click:close="remove(data.item)"
>
{{ data.item.firstname }} {{ data.item.lastname }}
</v-chip>
>{{ 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 }}
{{ data.item.firstname }}
{{ data.item.lastname }}
</v-list-item-title>
</v-list-item-content>
</template>
@ -57,7 +56,7 @@
<v-card-actions v-if="!day.loading">
<v-chip class="text-uppercase" :color="lockedColor">{{ lockedText }}</v-chip>
<v-spacer />
<v-btn text @click="lock">{{lockedTextBtn}}</v-btn>
<v-btn text @click="lock">{{ lockedTextBtn }}</v-btn>
</v-card-actions>
</v-card>
</div>
@ -80,13 +79,13 @@ export default {
},
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()
})
//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({
@ -129,7 +128,12 @@ export default {
}
},
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: {
@ -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>

View File

@ -31,6 +31,7 @@ const url = {
addUser: main + 'sm/addUser',
deleteUser: main + 'sm/deleteUser',
getUser: main + 'sm/getUser',
getUsers: main + 'sm/getUsers',
lockDay: main + 'sm/lockDay',
searchUser: main + 'sm/searchWithExtern'
},
@ -45,6 +46,7 @@ const url = {
user: {
config: main + 'user/saveConfig',
job: main + 'user/job',
jobs: main + 'user/jobs',
addJob: main + 'user/addJob',
deleteJob: main + 'user/deleteJob',
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 }) => {
let day = getters.getDay(date)
day.loading = true
@ -228,6 +235,38 @@ const actions = {
setDayNotLoading({ commit, getters }, date) {
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) {
commit('setDayLoading', { date: data.startdatetime, getters })
try {
@ -322,6 +361,12 @@ const getters = {
},
allUsers: state => {
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
console.log(month)
},
setStartEndDate: week => {
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 }) => {
let day = getters.getDay(date)
day.loading = true
@ -227,6 +235,39 @@ const actions = {
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) {
commit('setDayLoading', { date: data.startdatetime, getters })
try {
@ -312,6 +353,12 @@ const getters = {
},
disabled: state => {
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'),
// cert: fs.readFileSync('./cert/server.crt')
// }
},
configureWebpack: {
devtool: 'source-map'
}
}