diff --git a/src/components/user/Jobs.vue b/src/components/user/Jobs.vue index 0f9f119..02fd66b 100644 --- a/src/components/user/Jobs.vue +++ b/src/components/user/Jobs.vue @@ -1,17 +1,15 @@ @@ -74,11 +73,13 @@ Eintragen - + >Eintragen @@ -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 } diff --git a/src/components/vorstand/ServiceManagement.vue b/src/components/vorstand/ServiceManagement.vue index bd4de19..6a43295 100644 --- a/src/components/vorstand/ServiceManagement.vue +++ b/src/components/vorstand/ServiceManagement.vue @@ -1,9 +1,7 @@ @@ -57,7 +56,7 @@ {{ lockedText }} - {{lockedTextBtn}} + {{ lockedTextBtn }} @@ -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() + // }) + //} } } diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 547b80f..822bba7 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -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', diff --git a/src/store/modules/jobs.js b/src/store/modules/jobs.js index db6c20e..2fd0ca2 100644 --- a/src/store/modules/jobs.js +++ b/src/store/modules/jobs.js @@ -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 } } diff --git a/src/store/modules/serviceManagement.js b/src/store/modules/serviceManagement.js index 9910bf6..a195db8 100644 --- a/src/store/modules/serviceManagement.js +++ b/src/store/modules/serviceManagement.js @@ -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 } } diff --git a/vue.config.js b/vue.config.js index 2bb43cb..573f9db 100644 --- a/vue.config.js +++ b/vue.config.js @@ -8,5 +8,8 @@ module.exports = { // key: fs.readFileSync('./cert/server.key'), // cert: fs.readFileSync('./cert/server.crt') // } + }, + configureWebpack: { + devtool: 'source-map' } }