finished ##184
This commit is contained in:
parent
dadb31f376
commit
b6dfc45c46
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
|
|
@ -23,6 +23,20 @@
|
|||
</div>
|
||||
</v-expand-transition>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<v-btn
|
||||
v-if="!day.locked && !day.loading && day.worker.length < 2"
|
||||
@click="
|
||||
addJob({
|
||||
year: day.date.getFullYear(),
|
||||
month: day.date.getMonth() + 1,
|
||||
day: day.date.getDate()
|
||||
})
|
||||
"
|
||||
>Eintragen</v-btn
|
||||
>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -55,7 +69,8 @@ export default {
|
|||
...mapActions({
|
||||
getUser: 'jobs/getUser',
|
||||
setLoading: 'jobs/setDayLoading',
|
||||
setNotLoading: 'jobs/setDayNotLoading'
|
||||
setNotLoading: 'jobs/setDayNotLoading',
|
||||
addJob: 'jobs/addJob'
|
||||
}),
|
||||
test(event) {
|
||||
console.log('blur', event)
|
||||
|
|
|
@ -29,7 +29,8 @@ const url = {
|
|||
},
|
||||
user: {
|
||||
config: main + 'user/saveConfig',
|
||||
job: main + 'user/job'
|
||||
job: main + 'user/job',
|
||||
addJob: main + 'user/addJob'
|
||||
},
|
||||
barU: {
|
||||
storno: main + 'bar/storno'
|
||||
|
|
|
@ -38,7 +38,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Montag',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
break
|
||||
case 2:
|
||||
|
@ -47,7 +48,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Dienstag',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
break
|
||||
case 3:
|
||||
|
@ -61,7 +63,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Mittwoch',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
}
|
||||
break
|
||||
|
@ -71,7 +74,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Donnerstag',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
break
|
||||
case 5:
|
||||
|
@ -80,7 +84,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Freitag',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
break
|
||||
case 6:
|
||||
|
@ -89,7 +94,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Samstag',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
break
|
||||
case 0:
|
||||
|
@ -98,7 +104,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Sontag',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
break
|
||||
}
|
||||
|
@ -114,13 +121,18 @@ const mutations = {
|
|||
let worker = state.month[week].days[day].worker.find(a => {
|
||||
return a.username === user.username
|
||||
})
|
||||
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 (user) {
|
||||
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 (data.day) {
|
||||
state.month[week].days[day].locked = data.day.locked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -192,14 +204,38 @@ const actions = {
|
|||
{ ...data },
|
||||
{ headers: { Token: rootState.login.user.accessToken } }
|
||||
)
|
||||
for (let item = 0; item < response.data.length; item++) {
|
||||
commit('updateMonth', { ...response.data[item], com: 'add' })
|
||||
for (let item = 0; item < response.data.worker.length; item++) {
|
||||
commit('updateMonth', {
|
||||
...response.data.worker[item],
|
||||
com: 'add',
|
||||
day: response.data.day
|
||||
})
|
||||
}
|
||||
if (response.data.worker.length === 0)
|
||||
commit('updateMonth', {
|
||||
start: response.data.day.date,
|
||||
day: response.data.day
|
||||
})
|
||||
commit('setDayNotLoading', { date: data.startdatetime, getters })
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||
}
|
||||
},
|
||||
async addJob({ commit, rootState, dispatch }, data) {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
url.user.addJob,
|
||||
{ ...data },
|
||||
{
|
||||
headers: { Token: rootState.login.user.accessToken }
|
||||
}
|
||||
)
|
||||
commit('updateMonth', { ...response.data[0], com: 'add' })
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -156,13 +156,18 @@ const mutations = {
|
|||
let worker = state.month[week].days[day].worker.find(a => {
|
||||
return a.username === user.username
|
||||
})
|
||||
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 (user) {
|
||||
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 (data.day) {
|
||||
state.month[week].days[day].locked = data.day.locked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -224,9 +229,11 @@ const actions = {
|
|||
{ headers: { Token: rootState.login.user.accessToken } }
|
||||
)
|
||||
console.log(response.data)
|
||||
for (let item = 0; item < response.data.length; item++) {
|
||||
commit('updateMonth', { ...response.data[item], com: 'add' })
|
||||
for (let item = 0; item < response.data.worker.length; item++) {
|
||||
commit('updateMonth', { ...response.data.worker[item], com: 'add', day: response.data.day })
|
||||
}
|
||||
if (response.data.worker.length === 0)
|
||||
commit('updateMonth', { start: response.data.day.date, day:response.data.day})
|
||||
commit('setDayNotLoading', { date: data.startdatetime, getters })
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
|
|
Loading…
Reference in New Issue