finished ##188

for sm only send year, month, day. But you have to decrement month to send, because month starts with 0.
Also you have to increment month to get.
This commit is contained in:
Tim Gröger 2020-02-23 11:19:53 +01:00
parent 62af175884
commit dadb31f376
4 changed files with 39 additions and 43 deletions

View File

@ -14,38 +14,12 @@
</v-expand-transition> </v-expand-transition>
<v-expand-transition> <v-expand-transition>
<div v-show="!day.loading"> <div v-show="!day.loading">
<!-- <v-autocomplete--> <v-chip
<!-- chips--> style="margin: 3px;"
<!-- return-object--> v-for="worker in day.worker"
<!-- multiple--> :key="day.worker.indexOf(worker)"
<!-- v-model="day.worker"--> >{{ worker.firstname }} {{ worker.lastname }}</v-chip
<!-- item-text="fullName"--> >
<!-- label="Dienste"-->
<!-- filled-->
<!-- color="green"-->
<!-- @input="searchInput = null"-->
<!-- :search-input.sync="searchInput"-->
<!-- @blur="focused = false"-->
<!-- @focus="focused = true"-->
<!-- disabled-->
<!-- >-->
<!-- <template v-slot:prepend-inner>-->
<!-- <v-icon>{{ account_add }}</v-icon>-->
<!-- </template>-->
<!-- <template v-slot:selection="data">-->
<!-- <v-chip v-bind="data.attrs" :input-value="data.selected" close>-->
<!-- {{ 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 }}-->
<!-- </v-list-item-title>-->
<!-- </v-list-item-content>-->
<!-- </template>-->
<!-- </v-autocomplete>-->
<v-chip style="margin: 3px;" v-for="worker in day.worker" :key="day.worker.indexOf(worker)">{{ worker.firstname }} {{ worker.lastname }}</v-chip>
</div> </div>
</v-expand-transition> </v-expand-transition>
</v-card-text> </v-card-text>
@ -71,7 +45,10 @@ export default {
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(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
}) })
}, },
methods: { methods: {
@ -108,7 +85,10 @@ export default {
day() { day() {
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(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
}) })
}, },
worker() { worker() {

View File

@ -78,7 +78,10 @@ export default {
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(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
}) })
}, },
methods: { methods: {
@ -99,7 +102,10 @@ export default {
this.deleteUser({ this.deleteUser({
startdatetime: this.day.date, startdatetime: this.day.date,
date: this.day.date.getTime() / 1000, date: this.day.date.getTime() / 1000,
user: deletedUser user: deletedUser,
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
}) })
}, },
test(event) { test(event) {
@ -139,7 +145,10 @@ export default {
addedUser = newValue[user] addedUser = newValue[user]
this.addUser({ this.addUser({
date: this.day.date.getTime() / 1000, date: this.day.date.getTime() / 1000,
user: addedUser user: addedUser,
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
}) })
} }
} }
@ -151,7 +160,10 @@ export default {
this.deleteUser({ this.deleteUser({
startdatetime: this.day.date, startdatetime: this.day.date,
date: this.day.date.getTime() / 1000, date: this.day.date.getTime() / 1000,
user: deletedUser user: deletedUser,
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
}) })
} }
} }
@ -160,7 +172,10 @@ export default {
day() { day() {
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(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
}) })
}, },
focused(newVal, oldValue) { focused(newVal, oldValue) {

View File

@ -25,7 +25,7 @@ const mutations = {
let week = { id: id, days: {} } let week = { id: id, days: {} }
for (let intDay = startDate; intDay <= days + 7; intDay++) { for (let intDay = startDate; intDay <= days + 7; intDay++) {
if (end) break if (end) break
let currentDate = new Date(year, mon, intDay, 12) let currentDate = new Date(year, mon, intDay)
switch (currentDate.getDay()) { switch (currentDate.getDay()) {
case 1: case 1:
@ -106,7 +106,7 @@ const mutations = {
state.month = month state.month = month
}, },
updateMonth: (state, data) => { updateMonth: (state, data) => {
const date = new Date(data.startdatetime) const date = new Date(data.start.year, data.start.month - 1, data.start.day)
const user = data.user const user = data.user
for (let week = 0; week < state.month.length; week++) { for (let week = 0; week < state.month.length; week++) {
for (let day in state.month[week].days) { for (let day in state.month[week].days) {

View File

@ -34,7 +34,7 @@ const mutations = {
let week = { id: id, days: {} } let week = { id: id, days: {} }
for (let intDay = startDate; intDay <= days + 7; intDay++) { for (let intDay = startDate; intDay <= days + 7; intDay++) {
if (end) break if (end) break
let currentDate = new Date(year, mon, intDay, 12) let currentDate = new Date(year, mon, intDay)
switch (currentDate.getDay()) { switch (currentDate.getDay()) {
case 1: case 1:
@ -148,7 +148,7 @@ const mutations = {
} }
}, },
updateMonth: (state, data) => { updateMonth: (state, data) => {
const date = new Date(data.startdatetime) const date = new Date(data.start.year, data.start.month - 1, data.start.day)
const user = data.user const user = data.user
for (let week = 0; week < state.month.length; week++) { for (let week = 0; week < state.month.length; week++) {
for (let day in state.month[week].days) { for (let day in state.month[week].days) {
@ -223,6 +223,7 @@ const actions = {
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
console.log(response.data)
for (let item = 0; item < response.data.length; item++) { for (let item = 0; item < response.data.length; item++) {
commit('updateMonth', { ...response.data[item], com: 'add' }) commit('updateMonth', { ...response.data[item], com: 'add' })
} }