user kann eine dienstübertragung annehmen
bugfixes, sodass bei Einladungen oder dienstübertragungen der tag neu geladen wird. Ladezeichen hinzugefügt.
This commit is contained in:
parent
758f03aa40
commit
33028050fc
|
@ -18,23 +18,27 @@
|
|||
{{ jobInvite.from_user.lastname }}
|
||||
</div>
|
||||
<v-row
|
||||
class="text-right"
|
||||
style="margin-right: 5px"
|
||||
v-show="userInWorker(jobInvite)"
|
||||
>
|
||||
<v-spacer />
|
||||
<v-icon color="green">
|
||||
{{ check }}
|
||||
</v-icon>
|
||||
<v-col>
|
||||
<v-icon color="green">
|
||||
{{ check }}
|
||||
</v-icon>
|
||||
<v-progress-circular indeterminate v-if="jobInvitesLoading"></v-progress-circular>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-expansion-panel-header>
|
||||
<v-expansion-panel-content :eager="true">
|
||||
<v-row>
|
||||
<v-spacer />
|
||||
<v-btn text @click="updatingJobInvite(jobInvite)">
|
||||
<v-icon>
|
||||
{{ jobInvite.watched ? seen : notSeen }}
|
||||
</v-icon>
|
||||
</v-btn>
|
||||
<v-row class="text-right">
|
||||
<v-col>
|
||||
<v-btn icon @click="updatingJobInvite(jobInvite)">
|
||||
<v-icon>
|
||||
{{ jobInvite.watched ? seen : notSeen }}
|
||||
</v-icon>
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<Day
|
||||
:day="jobInvite.day"
|
||||
|
|
|
@ -1,17 +1,127 @@
|
|||
<template>
|
||||
<div>
|
||||
<h1>
|
||||
Transfer
|
||||
</h1>
|
||||
<div>
|
||||
<v-card tile>
|
||||
<v-card-title>
|
||||
Eingehende Anfragen
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-expansion-panels>
|
||||
<v-expansion-panel
|
||||
v-for="(jobrequest, index) in jobRequestsToMe"
|
||||
:key="index"
|
||||
>
|
||||
<v-expansion-panel-header @click.once="seenJobRequest(jobrequest)">
|
||||
{{ jobrequest.on_date.getDate() }}.{{
|
||||
jobrequest.on_date.getMonth() + 1
|
||||
}}.{{ jobrequest.on_date.getFullYear() }} von
|
||||
{{ jobrequest.from_user.firstname }}
|
||||
{{ jobrequest.from_user.lastname }}
|
||||
<v-row class="text-right">
|
||||
<v-col>
|
||||
<v-progress-circular
|
||||
indeterminate
|
||||
v-if="jobRequestsLoading"
|
||||
></v-progress-circular>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-expansion-panel-header>
|
||||
<v-expansion-panel-content>
|
||||
<v-row class="text-right">
|
||||
<v-col>
|
||||
<v-btn icon @click="updatingSeenJobRequest(jobrequest)">
|
||||
<v-icon>
|
||||
{{ jobrequest.watched ? seen : notSeen }}
|
||||
</v-icon>
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<Day :day="jobrequest.day" :long="true" />
|
||||
<v-row class="text-right">
|
||||
<v-col>
|
||||
<v-btn
|
||||
v-show="!jobrequest.accepted"
|
||||
text
|
||||
@click="updatingAcceptedJobRequest(jobrequest)"
|
||||
>Annehmen</v-btn
|
||||
>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-expansion-panel-content>
|
||||
</v-expansion-panel>
|
||||
</v-expansion-panels>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<h1>
|
||||
fromme
|
||||
</h1>
|
||||
<div v-for="(jobrequest, index) in jobRequestsFromMe" :key="index">
|
||||
{{ jobrequest }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "JobTransfer"
|
||||
import { mapGetters, mapActions } from 'vuex'
|
||||
import { mdiEyeOff, mdiEyeCheck } from '@mdi/js'
|
||||
import Day from '@/components/user/Jobs/Day'
|
||||
export default {
|
||||
name: 'JobTransfer',
|
||||
components: { Day },
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
notSeen: mdiEyeOff,
|
||||
seen: mdiEyeCheck
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions({
|
||||
getJobRequests: 'jobRequests/getJobRequests',
|
||||
updateJobRequestToMe: 'jobRequests/updateJobRequestToMe'
|
||||
}),
|
||||
updatingAcceptedJobRequest(jobRequest) {
|
||||
jobRequest.accepted = true
|
||||
jobRequest.answered = true
|
||||
this.updateJobRequestToMe({ ...jobRequest })
|
||||
setTimeout(() => {
|
||||
this.getJobRequests(), 200
|
||||
})
|
||||
},
|
||||
updatingSeenJobRequest(jobRequest) {
|
||||
jobRequest.watched = !jobRequest.watched
|
||||
this.updateJobRequestToMe({...jobRequest})
|
||||
},
|
||||
seenJobRequest(jobRequest) {
|
||||
if (!jobRequest.watched) {
|
||||
jobRequest.watched = true
|
||||
this.updateJobRequestToMe(jobRequest)
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
jobRequestsToMe: 'jobRequests/jobRequestsToMe',
|
||||
jobRequestsFromMe: 'jobRequests/jobRequestsFromMe',
|
||||
jobRequestsLoading: 'jobRequests/jobRequestsLoading',
|
||||
loading: 'user/loading'
|
||||
})
|
||||
},
|
||||
created() {
|
||||
if (!this.loading) {
|
||||
this.getJobRequests()
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
loading(newValue) {
|
||||
if (!newValue) {
|
||||
this.getJobRequests()
|
||||
}
|
||||
},
|
||||
jobRequestsLoading(newValue, oldValue) {
|
||||
console.log(newValue, oldValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
<div>
|
||||
<v-bottom-navigation v-model="bottom_nav">
|
||||
<v-btn :to="{ name: 'jobRequests', params: { kind: 'jobInvites' } }">
|
||||
<v-badge color="red" :content="news" :value="news !== 0">Diensteinladungen</v-badge>
|
||||
<v-badge color="red" :content="newsInvite" :value="newsInvite !== 0">
|
||||
Diensteinladungen
|
||||
</v-badge>
|
||||
</v-btn>
|
||||
<v-btn :to="{ name: 'jobRequests', params: { kind: 'jobTransfer' } }">
|
||||
<v-badge color="red" :content="newsRequest" :value="newsRequest !== 0">Dienstübertragung</v-badge>
|
||||
</v-btn>
|
||||
<v-btn :to="{ name: 'jobRequests', params: { kind: 'jobTransfer' } }"
|
||||
>Dienstübertragung</v-btn
|
||||
>
|
||||
</v-bottom-navigation>
|
||||
<JobInvites v-if="kind === 'jobInvites'"></JobInvites>
|
||||
<JobTransfer v-if="kind === 'jobTransfer'"></JobTransfer>
|
||||
|
@ -33,7 +35,8 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
news: 'jobInvites/news'
|
||||
newsInvite: 'jobInvites/news',
|
||||
newsRequest: 'jobRequests/news'
|
||||
})
|
||||
},
|
||||
created() {
|
||||
|
|
|
@ -77,20 +77,31 @@ export default {
|
|||
methods: {
|
||||
...mapActions({
|
||||
getJobInvites: 'jobInvites/getJobInvites',
|
||||
getJobRequests: 'jobRequests/getJobRequests',
|
||||
getUser: 'user/getUser'
|
||||
})
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
news: 'jobInvites/news'
|
||||
})
|
||||
newsInvite: 'jobInvites/news',
|
||||
newsRequest: 'jobRequests/news',
|
||||
loading: 'user/loading'
|
||||
}),
|
||||
news() {
|
||||
return this.newsInvite + this.newsRequest
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getUser()
|
||||
setTimeout(() => {
|
||||
this.getJobInvites()
|
||||
}, 500)
|
||||
|
||||
},
|
||||
watch: {
|
||||
loading(newValue) {
|
||||
if (!newValue) {
|
||||
this.getJobInvites()
|
||||
this.getJobRequests()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -309,10 +309,12 @@ export default {
|
|||
var retVal = 'yellow'
|
||||
retVal = 'light-green'
|
||||
for (var jobkind in day.jobkinddate) {
|
||||
if (day.jobkinddate[jobkind].worker.length >= day.jobkinddate[jobkind].maxpersons)
|
||||
if (
|
||||
day.jobkinddate[jobkind].worker.length >=
|
||||
day.jobkinddate[jobkind].maxpersons
|
||||
)
|
||||
retVal = 'light-green'
|
||||
else
|
||||
return 'yellow'
|
||||
else return 'yellow'
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
@ -384,9 +386,41 @@ export default {
|
|||
this.dialog = false
|
||||
},
|
||||
filterWorker() {},
|
||||
// filterUser(jobkind) {
|
||||
// console.log(jobkind, this.day.jobkinddate)
|
||||
// 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
|
||||
// })
|
||||
// })
|
||||
// console.log('test', test)
|
||||
// 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
|
||||
filterUser(jobkind) {
|
||||
console.log(jobkind, this.day.jobkinddate)
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var filtered = this.dbUsers.filter(user => {
|
||||
var test = this.day.jobkinddate.find(item => {
|
||||
var userInOther = this.day.jobkinddate.find(item => {
|
||||
if (item.job_kind === null) {
|
||||
return false
|
||||
}
|
||||
|
@ -397,17 +431,21 @@ export default {
|
|||
return work.id === user.id
|
||||
})
|
||||
})
|
||||
if (test) {
|
||||
if (userInOther) {
|
||||
return false
|
||||
}
|
||||
if (jobkind.workgroup === null) {
|
||||
if (jobkind.id === 1 || !jobkind.workgroup) {
|
||||
return true
|
||||
} else {
|
||||
if (user.workgroups ? user.workgroups.length > 0 : false) {
|
||||
return user.workgroups.find(wg => {
|
||||
console.log(wg, jobkind.workgroup)
|
||||
return wg.id === jobkind.workgroup.id
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return user.workgroups.find(workgroup => {
|
||||
if (jobkind.workgroup && workgroup) {
|
||||
return jobkind.workgroup.id === workgroup.id
|
||||
} else return true
|
||||
})
|
||||
})
|
||||
return filtered
|
||||
},
|
||||
|
|
|
@ -66,6 +66,9 @@ const url = {
|
|||
getJobInvites: main + 'user/getJobInvites',
|
||||
setJobInvites: main + 'user/JobInvites',
|
||||
deletJobInvite: main + 'user/deleteJobInvite',
|
||||
getJobRequests: main + 'user/getJobRequests',
|
||||
setJobRequests: main + 'user/JobRequests',
|
||||
deletJobRequest: main + 'user/deleteJobRequest',
|
||||
storno: main + 'user/storno',
|
||||
getAllStatus: main + 'getAllStatus',
|
||||
getStatus: main + 'getStatus',
|
||||
|
|
|
@ -11,6 +11,7 @@ import usermanager from '@/store/modules/userManager'
|
|||
import wm from '@/store/modules/workgroupManagement'
|
||||
import jkm from '@/store/modules/jobkindManager'
|
||||
import jobInvites from "@/store/modules/jobInvites";
|
||||
import jobRequests from "@/store/modules/jobRequests";
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
|
@ -26,6 +27,7 @@ export default new Vuex.Store({
|
|||
usermanager,
|
||||
wm,
|
||||
jkm,
|
||||
jobInvites
|
||||
jobInvites,
|
||||
jobRequests
|
||||
}
|
||||
})
|
||||
|
|
|
@ -175,6 +175,7 @@ const mutations = {
|
|||
const actions = {
|
||||
async getJobInvites({ commit, dispatch, rootState, getters }) {
|
||||
try {
|
||||
commit('setJobInvitesLoading', true)
|
||||
const date = new Date()
|
||||
const from_me = await axios.post(
|
||||
url.user.getJobInvites,
|
||||
|
@ -232,6 +233,7 @@ const actions = {
|
|||
commit('updateMonthWorker', { workers: item.worker, date, getters, from_me: false })
|
||||
commit('updateMonthLocked', { locked: item.day.locked, date, getters, from_me: false })
|
||||
})
|
||||
commit('setJobInvitesLoading', false)
|
||||
dispatch('getLifeTime', null, { root: true })
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
|
@ -256,6 +258,7 @@ const actions = {
|
|||
var date = new Date(data.year, data.month - 1, data.day)
|
||||
commit('setDayLoading', { date, getters, value: true })
|
||||
try {
|
||||
commit('setJobInvitesLoading', true)
|
||||
const response = await axios.post(
|
||||
url.user.addJob,
|
||||
{ ...data },
|
||||
|
@ -270,6 +273,7 @@ const actions = {
|
|||
})
|
||||
commit('setDayLoading', { date, getters, value: false })
|
||||
dispatch('getLifeTime', null, { root: true })
|
||||
commit('setJobInvitesLoading', false)
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||
|
@ -278,6 +282,7 @@ const actions = {
|
|||
async deleteJob({ commit, rootState, dispatch, getters }, data) {
|
||||
var date = new Date(data.year, data.month - 1, data.day)
|
||||
commit('setDayLoading', {date, getters, value: true})
|
||||
commit('setJobInvitesLoading', true)
|
||||
try {
|
||||
const response = await axios.post(
|
||||
url.user.deleteJob,
|
||||
|
@ -294,6 +299,7 @@ const actions = {
|
|||
})
|
||||
commit('setDayLoading', {date, getters, value: false})
|
||||
dispatch('getLifeTime', null, { root: true })
|
||||
commit('setJobInvitesLoading', false)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
if (e.response)
|
||||
|
@ -302,11 +308,13 @@ const actions = {
|
|||
},
|
||||
async updateJobInviteToMe({ commit, rootState, dispatch }, data) {
|
||||
try {
|
||||
commit('setJobInvitesLoading', true)
|
||||
const response = await axios.post(url.user.setJobInvites, data, {
|
||||
headers: { Token: rootState.login.user.accessToken }
|
||||
})
|
||||
commit('updateJobInviteToMe', response.data)
|
||||
dispatch('getLifeTime', null, { root: true })
|
||||
commit('setJobInvitesLoading', false)
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||
|
@ -314,8 +322,10 @@ const actions = {
|
|||
},
|
||||
async deleteJobInviteFromMe({ commit, rootState, dispatch}, data) {
|
||||
try {
|
||||
commit('setJobInvitesLoading', true)
|
||||
await axios.post(url.user.deletJobInvite, data, {headers: {Token: rootState.login.user.accessToken}})
|
||||
commit('deleteJobInviteFromMe', data)
|
||||
commit('setJobInvitesLoading', false)
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||
|
|
|
@ -0,0 +1,371 @@
|
|||
import axios from 'axios'
|
||||
import url from '@/plugins/routes'
|
||||
|
||||
const state = {
|
||||
jobRequestsFromMe: [],
|
||||
jobRequestsToMe: [],
|
||||
jobRequestsLoading: false
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
setJobRequestsFromMe: (state, jobRequests) => {
|
||||
state.jobRequestsFromMe = jobRequests
|
||||
state.jobRequestsFromMe.forEach(item => {
|
||||
item.on_date = new Date(
|
||||
item.on_date.year,
|
||||
item.on_date.month - 1,
|
||||
item.on_date.day
|
||||
)
|
||||
item.day = {
|
||||
date: new Date(),
|
||||
worker: [],
|
||||
loading: false,
|
||||
locked: false,
|
||||
jobkinddate: []
|
||||
}
|
||||
})
|
||||
},
|
||||
setJobRequestsToMe: (state, jobRequests) => {
|
||||
state.jobRequestsToMe = jobRequests
|
||||
state.jobRequestsToMe.forEach(item => {
|
||||
item.on_date = new Date(
|
||||
item.on_date.year,
|
||||
item.on_date.month - 1,
|
||||
item.on_date.day
|
||||
)
|
||||
item.day = {
|
||||
date: new Date(),
|
||||
worker: [],
|
||||
loading: false,
|
||||
locked: false,
|
||||
jobkinddate: []
|
||||
}
|
||||
})
|
||||
},
|
||||
setJobRequestsLoading: (state, value) => {
|
||||
state.jobRequestsLoading = value
|
||||
},
|
||||
updateJobRequestToMe: (state, jobRequest) => {
|
||||
state.jobRequestsToMe.forEach(item => {
|
||||
if (item.id === jobRequest.id) {
|
||||
item.watched = jobRequest.watched
|
||||
item.accepted = jobRequest.accepted
|
||||
}
|
||||
})
|
||||
},
|
||||
updateMonthWorker: (state, { workers, date, getters, from_me }) => {
|
||||
let mop
|
||||
if (from_me) {
|
||||
mop = getters.getDayFromMe(date)
|
||||
} else {
|
||||
mop = getters.getDayToMe(date)
|
||||
}
|
||||
mop.forEach(a => {
|
||||
let day = a.day
|
||||
day.jobkinddate.forEach(item => {
|
||||
var filtered = workers.filter(worker => {
|
||||
return item.job_kind.id === (worker.job_kind ? worker.job_kind.id : 1)
|
||||
})
|
||||
var filteredWorkers = []
|
||||
filtered.forEach(item => {
|
||||
filteredWorkers.push(item.user)
|
||||
})
|
||||
filteredWorkers.forEach(worker => {
|
||||
if (
|
||||
!item.worker.find(a => {
|
||||
return a.id === worker.id
|
||||
})
|
||||
) {
|
||||
item.worker.push(worker)
|
||||
}
|
||||
})
|
||||
item.worker.forEach(worker => {
|
||||
if (
|
||||
!filteredWorkers.find(a => {
|
||||
return a.id === worker.id
|
||||
})
|
||||
) {
|
||||
item.worker.splice(item.worker.indexOf(worker), 1)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
updateMonthLocked: (state, { locked, date, getters, from_me }) => {
|
||||
let mop
|
||||
if (from_me) {
|
||||
mop = getters.getDayFromMe(date)
|
||||
} else {
|
||||
mop = getters.getDayToMe(date)
|
||||
}
|
||||
mop.forEach(a => {
|
||||
let day = a.day
|
||||
day.locked = !!locked
|
||||
})
|
||||
},
|
||||
updateMonthJobkind: (state, { data, date, getters, from_me }) => {
|
||||
let mop
|
||||
if (from_me) {
|
||||
mop = getters.getDayFromMe(date)
|
||||
} else {
|
||||
mop = getters.getDayToMe(date)
|
||||
}
|
||||
mop.forEach(a => {
|
||||
let day = a.day
|
||||
day.date = 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: []
|
||||
})
|
||||
}
|
||||
}
|
||||
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
|
||||
: []
|
||||
}
|
||||
})
|
||||
console.log(mop)
|
||||
},
|
||||
setDayLoading: (state, { getters, date, value }) => {
|
||||
let day = getters.getDayToMe(date)
|
||||
day.forEach(a => {
|
||||
a.day.loading = value
|
||||
console.log('day', value ? 'loading' : 'not loading', day, a.day.loading)
|
||||
})
|
||||
},
|
||||
deleteJobRequestFromMe: (state, jobrequest) => {
|
||||
var item = state.jobRequestsFromMe.find(item => {
|
||||
return item.id === jobrequest.id
|
||||
})
|
||||
state.jobRequestsFromMe.splice(item, 1)
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
async getJobRequests({ commit, dispatch, rootState, getters }) {
|
||||
try {
|
||||
commit('setJobRequestsLoading', true)
|
||||
const date = new Date()
|
||||
const from_me = await axios.post(
|
||||
url.user.getJobRequests,
|
||||
{
|
||||
from_user: rootState.user.user,
|
||||
date: {
|
||||
year: date.getFullYear(),
|
||||
month: date.getMonth() + 1,
|
||||
day: date.getDate()
|
||||
}
|
||||
},
|
||||
{ headers: { Token: rootState.login.user.accessToken } }
|
||||
)
|
||||
const workers_from_me = await axios.post(
|
||||
url.user.getJobOnDates,
|
||||
from_me.data,
|
||||
{ headers: { Token: rootState.login.user.accessToken } }
|
||||
)
|
||||
commit('setJobRequestsFromMe', from_me.data)
|
||||
workers_from_me.data.forEach(item => {
|
||||
var date = new Date(
|
||||
item.day.date.year,
|
||||
item.day.date.month - 1,
|
||||
item.day.date.day
|
||||
)
|
||||
commit('updateMonthJobkind', {
|
||||
data: item.jobkinddate,
|
||||
date,
|
||||
getters,
|
||||
from_me: true
|
||||
})
|
||||
commit('updateMonthWorker', {
|
||||
workers: item.worker,
|
||||
date,
|
||||
getters,
|
||||
from_me: true
|
||||
})
|
||||
commit('updateMonthLocked', {
|
||||
locked: item.day.locked,
|
||||
date,
|
||||
getters,
|
||||
from_me: true
|
||||
})
|
||||
})
|
||||
const to_me = await axios.post(
|
||||
url.user.getJobRequests,
|
||||
{
|
||||
to_user: rootState.user.user,
|
||||
date: {
|
||||
year: date.getFullYear(),
|
||||
month: date.getMonth() + 1,
|
||||
day: date.getDate()
|
||||
}
|
||||
},
|
||||
{ headers: { Token: rootState.login.user.accessToken } }
|
||||
)
|
||||
const workers_to_me = await axios.post(
|
||||
url.user.getJobOnDates,
|
||||
to_me.data,
|
||||
{ headers: { Token: rootState.login.user.accessToken } }
|
||||
)
|
||||
console.log(to_me.data)
|
||||
commit('setJobRequestsToMe', to_me.data)
|
||||
workers_to_me.data.forEach(item => {
|
||||
var date = new Date(
|
||||
item.day.date.year,
|
||||
item.day.date.month - 1,
|
||||
item.day.date.day
|
||||
)
|
||||
commit('updateMonthJobkind', {
|
||||
data: item.jobkinddate,
|
||||
date,
|
||||
getters,
|
||||
from_me: false
|
||||
})
|
||||
commit('updateMonthWorker', {
|
||||
workers: item.worker,
|
||||
date,
|
||||
getters,
|
||||
from_me: false
|
||||
})
|
||||
commit('updateMonthLocked', {
|
||||
locked: item.day.locked,
|
||||
date,
|
||||
getters,
|
||||
from_me: false
|
||||
})
|
||||
})
|
||||
commit('setJobRequestsLoading', false)
|
||||
dispatch('getLifeTime', null, { root: true })
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||
}
|
||||
},
|
||||
async setJobRequests({ commit, dispatch, rootState }, data) {
|
||||
try {
|
||||
commit('setJobRequestsLoading', true)
|
||||
const response = await axios.put(url.user.setJobRequests, data, {
|
||||
headers: { Token: rootState.login.user.accessToken }
|
||||
})
|
||||
commit('setJobRequestsFromMe', response.data)
|
||||
commit('setJobRequestsLoading', false)
|
||||
dispatch('getLifeTime', null, { root: true })
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||
}
|
||||
},
|
||||
async updateJobRequestToMe({ commit, rootState, dispatch }, data) {
|
||||
try {
|
||||
commit('setJobRequestsLoading', true)
|
||||
data.on_date = {
|
||||
year: data.on_date.getFullYear(),
|
||||
month: data.on_date.getMonth() + 1,
|
||||
day: data.on_date.getDate()
|
||||
}
|
||||
const response = await axios.post(url.user.setJobRequests, data, {
|
||||
headers: { Token: rootState.login.user.accessToken }
|
||||
})
|
||||
response.data.on_date = new Date(response.data.on_date.year, response.data.on_date.month - 1, response.data.on_date.day)
|
||||
commit('updateJobRequestToMe', response.data)
|
||||
commit('setJobRequestsLoading', false)
|
||||
dispatch('getLifeTime', null, { root: true })
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||
}
|
||||
},
|
||||
async deleteJobRequestFromMe({ commit, rootState, dispatch }, data) {
|
||||
try {
|
||||
commit('setJobRequestsLoading', true)
|
||||
await axios.post(url.user.deletJobRequest, data, {
|
||||
headers: { Token: rootState.login.user.accessToken }
|
||||
})
|
||||
commit('deleteJobRequestFromMe', data)
|
||||
commit('setJobRequestsLoading', false)
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getters = {
|
||||
jobRequestsFromMe: state => {
|
||||
return state.jobRequestsFromMe
|
||||
},
|
||||
jobRequestsToMe: state => {
|
||||
return state.jobRequestsToMe
|
||||
},
|
||||
jobRequestsLoading: state => {
|
||||
return state.jobRequestsLoading
|
||||
},
|
||||
getDayToMe: state => {
|
||||
return date => {
|
||||
return state.jobRequestsToMe.filter(item => {
|
||||
return item.on_date - date === 0
|
||||
})
|
||||
}
|
||||
},
|
||||
getDayFromMe: state => {
|
||||
return date => {
|
||||
return state.jobRequestsFromMe.filter(item => {
|
||||
return item.on_date - date === 0
|
||||
})
|
||||
}
|
||||
},
|
||||
getDayWorkerFromMe: state => {
|
||||
return date => {
|
||||
return state.jobRequestsFromMe.filter(jobRequest => {
|
||||
return jobRequest.on_date - date === 0
|
||||
})
|
||||
}
|
||||
},
|
||||
news: state => {
|
||||
var test = state.jobRequestsToMe.filter(item => {
|
||||
return !item.watched
|
||||
})
|
||||
return test.length
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions,
|
||||
getters
|
||||
}
|
|
@ -164,18 +164,26 @@ const mutations = {
|
|||
// 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)
|
||||
)
|
||||
day.jobkinddate.forEach(item => {
|
||||
var filtered = workers.filter(worker => {
|
||||
return item.job_kind.id === (worker.job_kind ? worker.job_kind.id : 1)
|
||||
})
|
||||
if (jobkind) {
|
||||
jobkind.worker.push(workers[worker].user)
|
||||
jobkind.backupWorker.push(workers[worker].user)
|
||||
}
|
||||
}
|
||||
var filteredWorkers = []
|
||||
filtered.forEach(item => {
|
||||
filteredWorkers.push(item.user)
|
||||
})
|
||||
filteredWorkers.forEach(worker => {
|
||||
if (!item.worker.find(a => {return a.id === worker.id})) {
|
||||
item.worker.push(worker)
|
||||
item.backupWorker.push(worker)
|
||||
}
|
||||
})
|
||||
item.worker.forEach(worker => {
|
||||
if (!filteredWorkers.find(a => {return a.id === worker.id})) {
|
||||
item.worker.splice(item.worker.indexOf(worker), 1)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
updateMonthLocked: (state, { locked, date, getters }) => {
|
||||
var day = getters.getDay(date)
|
||||
|
|
Loading…
Reference in New Issue