finished serviceManagement
This commit is contained in:
		
							parent
							
								
									b724f83e84
								
							
						
					
					
						commit
						af542bb2e5
					
				|  | @ -11,7 +11,10 @@ | ||||||
|             <v-icon>keyboard_arrow_left</v-icon> |             <v-icon>keyboard_arrow_left</v-icon> | ||||||
|           </v-btn> |           </v-btn> | ||||||
|           <v-list-item> |           <v-list-item> | ||||||
|             <v-list-item-title class="title">{{monthArray[date.getMonth()]}} {{date.getFullYear()}}</v-list-item-title> |             <v-list-item-title class="title" | ||||||
|  |               >{{ monthArray[date.getMonth()] }} | ||||||
|  |               {{ date.getFullYear() }}</v-list-item-title | ||||||
|  |             > | ||||||
|           </v-list-item> |           </v-list-item> | ||||||
|           <v-btn text icon @click="changeMonth(1)"> |           <v-btn text icon @click="changeMonth(1)"> | ||||||
|             <v-icon>keyboard_arrow_right</v-icon> |             <v-icon>keyboard_arrow_right</v-icon> | ||||||
|  | @ -20,17 +23,22 @@ | ||||||
|         <v-spacer /> |         <v-spacer /> | ||||||
|       </v-toolbar> |       </v-toolbar> | ||||||
|       <v-card v-for="week in month" :key="month.indexOf(week)"> |       <v-card v-for="week in month" :key="month.indexOf(week)"> | ||||||
|         <v-card-title> |         <v-card-title class="subtitle-1 font-weight-bold"> | ||||||
|           Woche vom {{ week.startDate.getDate() }}.{{ |           Woche vom {{ week.startDate.getDate() }}.{{ | ||||||
|             week.startDate.getMonth()+1 |             week.startDate.getMonth() + 1 | ||||||
|           }}.{{week.startDate.getFullYear()}} bis {{ week.endDate.getDate() }}.{{ |           }}.{{ week.startDate.getFullYear() }} bis | ||||||
|           week.endDate.getMonth()+1 |           {{ week.endDate.getDate() }}.{{ week.endDate.getMonth() + 1 }}.{{ | ||||||
|           }}.{{week.endDate.getFullYear()}} |             week.endDate.getFullYear() | ||||||
|  |           }} | ||||||
|         </v-card-title> |         </v-card-title> | ||||||
|         <v-card-text> |         <v-card-text> | ||||||
|           <div v-for="day in week.days" :key="day.id"> |           <v-row justify="start" align="start"> | ||||||
|             <Day v-bind:day="day" /> |             <div v-for="day in week.days" :key="day.id"> | ||||||
|           </div> |               <v-col> | ||||||
|  |                 <Day v-bind:day="day"/> | ||||||
|  |               </v-col> | ||||||
|  |             </div> | ||||||
|  |           </v-row> | ||||||
|         </v-card-text> |         </v-card-text> | ||||||
|       </v-card> |       </v-card> | ||||||
|     </v-content> |     </v-content> | ||||||
|  | @ -48,18 +56,18 @@ export default { | ||||||
|       id: 0, |       id: 0, | ||||||
|       date: new Date(), |       date: new Date(), | ||||||
|       monthArray: [ |       monthArray: [ | ||||||
|               'Januar', |         'Januar', | ||||||
|               'Februar', |         'Februar', | ||||||
|               'März', |         'März', | ||||||
|               'April', |         'April', | ||||||
|               'Mai', |         'Mai', | ||||||
|               'Juni', |         'Juni', | ||||||
|               'Juli', |         'Juli', | ||||||
|               'August', |         'August', | ||||||
|               'September', |         'September', | ||||||
|               'Oktober', |         'Oktober', | ||||||
|               'November', |         'November', | ||||||
|               'Dezember' |         'Dezember' | ||||||
|       ] |       ] | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|  | @ -74,9 +82,9 @@ export default { | ||||||
|     }), |     }), | ||||||
|     changeMonth(value) { |     changeMonth(value) { | ||||||
|       if (value === -1) { |       if (value === -1) { | ||||||
|         this.date = new Date(this.date.getFullYear(), this.date.getMonth(), 0, 1) |         this.date = new Date(this.date.getFullYear(), this.date.getMonth() - 1) | ||||||
|       } else { |       } else { | ||||||
|         this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 2, 0, 1) |         this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 1) | ||||||
|       } |       } | ||||||
|       this.createMonth(this.date) |       this.createMonth(this.date) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -1,28 +1,46 @@ | ||||||
| <template> | <template> | ||||||
|   <v-card v-if="day"> |   <div v-if="day"> | ||||||
|     <v-card-title v-if="day.date"> |     <v-card :color="color(day)" max-width="300px" min-width="300px"> | ||||||
|       {{ day.name }} den {{ day.date.getDate() }}.{{ |       <v-card-title v-if="day.date" class="subtitle-1 font-weight-bold"> | ||||||
|         day.date.getMonth() + 1 |         {{ day.name }} den {{ day.date.getDate() }}.{{ | ||||||
|       }}.{{ day.date.getFullYear() }} |           day.date.getMonth() + 1 | ||||||
|     </v-card-title> |         }}.{{ day.date.getFullYear() }} | ||||||
|     <v-card-text> |       </v-card-title> | ||||||
|       <v-chip v-for="worker in day.worker" :key="day.worker.indexOf(worker)"> |       <v-card-text> | ||||||
|         {{ worker.firstname }} {{ worker.lastname }} |         <v-autocomplete | ||||||
|       </v-chip> |           chips | ||||||
|       <v-autocomplete |           return-object | ||||||
|         chips |           multiple | ||||||
|         outlined |           v-model="day.worker" | ||||||
|         return-object |           :items="allUsers" | ||||||
|         v-model="user" |           item-text="fullName" | ||||||
|         placeholder="Suche Person" |           label="Dienste" | ||||||
|         :items="allUsers" |           prepend-inner-icon="group_add" | ||||||
|         item-text="fullName" |           filled | ||||||
|         prepend-inner-icon="search" |           color="green" | ||||||
|         full-width |         > | ||||||
|       /> |           <template v-slot:selection="data"> | ||||||
|       <v-btn @click="test({ worker: user, day: day })">Hinzufügen</v-btn> |             <v-chip | ||||||
|     </v-card-text> |               v-bind="data.attrs" | ||||||
|   </v-card> |               :input-value="data.selected" | ||||||
|  |               close | ||||||
|  |               @click="data.select" | ||||||
|  |               @click:close="remove(data.item)" | ||||||
|  |             > | ||||||
|  |               {{ 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-card-text> | ||||||
|  |     </v-card> | ||||||
|  |   </div> | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
| <script> | <script> | ||||||
|  | @ -33,24 +51,69 @@ export default { | ||||||
|     day: Object |     day: Object | ||||||
|   }, |   }, | ||||||
|   data() { |   data() { | ||||||
|     return { |     return {} | ||||||
|       user: null |   }, | ||||||
|     } |   created() { | ||||||
|  |     this.getUser({date: this.day.date.getTime()/1000}) | ||||||
|   }, |   }, | ||||||
|   created() {}, |  | ||||||
|   methods: { |   methods: { | ||||||
|     ...mapActions({ |     ...mapActions({ | ||||||
|       setWorker: 'sm/setWorker' |       addUser: 'sm/addUser', | ||||||
|  |       getUser: 'sm/getUser', | ||||||
|  |       deleteUser: 'sm/deleteUser' | ||||||
|     }), |     }), | ||||||
|     test(data) { |     // eslint-disable-next-line no-unused-vars | ||||||
|       this.setWorker(data) |     remove(deletedUser) { | ||||||
|       console.log('user', this.day) |       const obj = this.day.worker.find(a => { | ||||||
|  |         return a.username === deletedUser.username | ||||||
|  |       }) | ||||||
|  |       const index = this.day.worker.indexOf(obj) | ||||||
|  |       if (index >= 0) this.day.worker.splice(index, 1) | ||||||
|  |       this.deleteUser({startdatetime: this.day.date, date: this.day.date.getTime()/1000, user: deletedUser}) | ||||||
|  |     }, | ||||||
|  |     color: day => { | ||||||
|  |       if (day) { | ||||||
|  |         if (day.date.getDay() === 0 || day.date.getDay() === 1) { | ||||||
|  |           return 'grey lighten-4' | ||||||
|  |         } else { | ||||||
|  |           if (day.worker.length < 2) { | ||||||
|  |             return 'yellow' | ||||||
|  |           } else { | ||||||
|  |             return 'light-green' | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |       } else { | ||||||
|  |         return 'grey lighten-4' | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   computed: { |   computed: { | ||||||
|     ...mapGetters({ |     ...mapGetters({ | ||||||
|       allUsers: 'sm/allUsers' |       allUsers: 'sm/allUsers' | ||||||
|     }) |     }), | ||||||
|  |     worker() { | ||||||
|  |       return this.day.worker | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   watch: { | ||||||
|  |     worker(newValue, oldValue) { | ||||||
|  |       if (oldValue !== newValue) { | ||||||
|  |         let addedUser = null | ||||||
|  |         for (let user in newValue) { | ||||||
|  |           if (!oldValue.includes(newValue[user])) { | ||||||
|  |             addedUser = newValue[user] | ||||||
|  |             this.addUser({date: this.day.date.getTime()/1000, user: addedUser}) | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |         let deletedUser = null | ||||||
|  |         for (let user in oldValue) { | ||||||
|  |           if (!newValue.includes(oldValue[user])) { | ||||||
|  |             deletedUser = oldValue[user] | ||||||
|  |             this.deleteUser({startdatetime: this.day.date, date: this.day.date.getTime()/1000, user: deletedUser}) | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
|  | @ -18,7 +18,14 @@ const url = { | ||||||
|   finanzerSendAllMail: main + 'finanzerSendAllMail', |   finanzerSendAllMail: main + 'finanzerSendAllMail', | ||||||
|   finanzerSendOneMail: main + 'finanzerSendOneMail', |   finanzerSendOneMail: main + 'finanzerSendOneMail', | ||||||
|   userMain: main + 'user/main', |   userMain: main + 'user/main', | ||||||
|   userAddAmount: main + 'user/addAmount' |   userAddAmount: main + 'user/addAmount', | ||||||
|  |   vorstand: { | ||||||
|  |     sm: { | ||||||
|  |       addUser: main + 'sm/addUser', | ||||||
|  |       deleteUser: main + 'sm/deleteUser', | ||||||
|  |       getUser: main + 'sm/getUser' | ||||||
|  |     } | ||||||
|  |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export default url | export default url | ||||||
|  |  | ||||||
|  | @ -20,8 +20,7 @@ const mutations = { | ||||||
|     let id = 0 |     let id = 0 | ||||||
|     const year = date.getFullYear() |     const year = date.getFullYear() | ||||||
|     const mon = date.getMonth() |     const mon = date.getMonth() | ||||||
|     let a = new Date(year, mon, 0, 13, 1) |     let a = new Date(year, mon + 1, 0) | ||||||
|     console.log('createMonth', a) |  | ||||||
|     let days = a.getDate() |     let days = a.getDate() | ||||||
|     let startDate = 1 |     let startDate = 1 | ||||||
|     for (let intDay = 1; intDay <= days; intDay++) { |     for (let intDay = 1; intDay <= days; intDay++) { | ||||||
|  | @ -30,45 +29,15 @@ const mutations = { | ||||||
|         break |         break | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |     let end = false | ||||||
|     let week = { id: id, days: {} } |     let week = { id: id, days: {} } | ||||||
|     for (let intDay = startDate; intDay <= days; intDay++) { |     for (let intDay = startDate; intDay <= days + 7; intDay++) { | ||||||
|       let currentDate = new Date(year, mon, intDay, 13, 1) |       if (end) break | ||||||
|       console.log('currentDate', currentDate) |       let currentDate = new Date(year, mon, intDay, 12) | ||||||
| 
 | 
 | ||||||
|       switch (currentDate.getDay()) { |       switch (currentDate.getDay()) { | ||||||
|         case 1: |         case 1: | ||||||
|           if (week.days.monday) { |           mutations.setStartEndDate(week) | ||||||
|             week.startDate = week.days.monday.date |  | ||||||
|           } else if (week.days.tuesday) { |  | ||||||
|             week.startDate = week.days.tuesday.date |  | ||||||
|           } else if (week.days.wednesday) { |  | ||||||
|             week.startDate = week.days.wednesday.date |  | ||||||
|           } else if (week.days.thursday) { |  | ||||||
|             week.startDate = week.days.thursday.date |  | ||||||
|           } else if (week.days.friday) { |  | ||||||
|             week.startDate = week.days.friday.date |  | ||||||
|           } else if (week.days.satturday) { |  | ||||||
|             week.startDate = week.days.satturday.date |  | ||||||
|           } else if (week.days.sunday) { |  | ||||||
|             week.startDate = week.days.sunday.date |  | ||||||
|           } |  | ||||||
| 
 |  | ||||||
|           if (week.days.sunday) { |  | ||||||
|             week.endDate = week.days.sunday.date |  | ||||||
|           } else if (week.days.satturday) { |  | ||||||
|             week.endDate = week.days.satturday.date |  | ||||||
|           } else if (week.days.friday) { |  | ||||||
|             week.endDate = week.days.friday.date |  | ||||||
|           } else if (week.days.thursday) { |  | ||||||
|             week.endDate = week.days.thursday.date |  | ||||||
|           } else if (week.days.wednesday) { |  | ||||||
|             week.endDate = week.days.wednesday.date |  | ||||||
|           } else if (week.days.tuesday) { |  | ||||||
|             week.endDate = week.days.tuesday.date |  | ||||||
|           } else if (week.days.monday) { |  | ||||||
|             week.endDate = week.days.monday.date |  | ||||||
|           } |  | ||||||
| 
 |  | ||||||
|           month.push(week) |           month.push(week) | ||||||
|           id++ |           id++ | ||||||
|           week = { id: id, days: {} } |           week = { id: id, days: {} } | ||||||
|  | @ -88,11 +57,17 @@ const mutations = { | ||||||
|           } |           } | ||||||
|           break |           break | ||||||
|         case 3: |         case 3: | ||||||
|           week.days.wednesday = { |           if (currentDate.getMonth() === mon + 1) { | ||||||
|             id: currentDate.getDay(), |             end = true | ||||||
|             date: currentDate, |             mutations.setStartEndDate(week) | ||||||
|             name: 'Mittwoch', |             month.push(week) | ||||||
|             worker: [] |           } else { | ||||||
|  |             week.days.wednesday = { | ||||||
|  |               id: currentDate.getDay(), | ||||||
|  |               date: currentDate, | ||||||
|  |               name: 'Mittwoch', | ||||||
|  |               worker: [] | ||||||
|  |             } | ||||||
|           } |           } | ||||||
|           break |           break | ||||||
|         case 4: |         case 4: | ||||||
|  | @ -129,6 +104,9 @@ const mutations = { | ||||||
|           break |           break | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |     state.month = month | ||||||
|  |   }, | ||||||
|  |   setStartEndDate: week => { | ||||||
|     if (week.days.monday) { |     if (week.days.monday) { | ||||||
|       week.startDate = week.days.monday.date |       week.startDate = week.days.monday.date | ||||||
|     } else if (week.days.tuesday) { |     } else if (week.days.tuesday) { | ||||||
|  | @ -160,20 +138,24 @@ const mutations = { | ||||||
|     } else if (week.days.monday) { |     } else if (week.days.monday) { | ||||||
|       week.endDate = week.days.monday.date |       week.endDate = week.days.monday.date | ||||||
|     } |     } | ||||||
|     month.push(week) |  | ||||||
|     state.month = month |  | ||||||
|     console.log(state.month) |  | ||||||
|   }, |   }, | ||||||
|   setWorker: (state, data) => { |   updateMonth: (state, data) => { | ||||||
|     console.log('hier ist die mutation', data) |     const date = new Date(data.startdatetime) | ||||||
|     for (let week in state.month) { |     const user = data.user | ||||||
|       console.log('week', 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) { | ||||||
|         console.log(state.month[week].days[day], data.day) |         if (state.month[week].days[day].date - date === 0) { | ||||||
|         if (state.month[week].days[day].date - data.day.date === 0) { |           let worker = state.month[week].days[day].worker.find(a => { | ||||||
|           state.month[week].days[day].worker.push(data.worker) |              return a.username === user.username | ||||||
|           console.log('sm', state.month) |           }) | ||||||
|           return |           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 | ||||||
|  |             }) | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  | @ -196,9 +178,52 @@ const actions = { | ||||||
|         if (e.response.data === 401) dispatch('logout', null, { root: true }) |         if (e.response.data === 401) dispatch('logout', null, { root: true }) | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   setWorker({ commit }, data) { |   // eslint-disable-next-line no-unused-vars
 | ||||||
|     console.log('hier bin ich', data) |   async addUser({ commit, rootState, dispatch }, data) { | ||||||
|     commit('setWorker', data) |     try { | ||||||
|  |       const response = await axios.post( | ||||||
|  |         url.vorstand.sm.addUser, | ||||||
|  |         { ...data }, | ||||||
|  |         { | ||||||
|  |           headers: { Token: rootState.login.user.accessToken } | ||||||
|  |         } | ||||||
|  |       ) | ||||||
|  |       console.log(response.data) | ||||||
|  |       commit('updateMonth', {...response.data[0], com: 'add'}) | ||||||
|  |     } catch (e) { | ||||||
|  |       if (e.response) | ||||||
|  |         if (e.response.status === 401) dispatch('logout', null, { root: true }) | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   async getUser({ commit, rootState, dispatch }, data) { | ||||||
|  |     try { | ||||||
|  |       const response = await axios.post( | ||||||
|  |         url.vorstand.sm.getUser, | ||||||
|  |         { ...data }, | ||||||
|  |         { headers: { Token: rootState.login.user.accessToken } } | ||||||
|  |       ) | ||||||
|  |       for (let item = 0; item < response.data.length; item++) { | ||||||
|  |         commit('updateMonth', { ...response.data[item], com: 'add' }) | ||||||
|  |       } | ||||||
|  |     } catch (e) { | ||||||
|  |       if (e.response) | ||||||
|  |         if (e.response.status === 401) dispatch('logout', null, { root: true }) | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   // eslint-disable-next-line no-unused-vars
 | ||||||
|  |   async deleteUser({ commit, rootState, dispatch }, data) { | ||||||
|  |     try { | ||||||
|  |       // eslint-disable-next-line no-unused-vars
 | ||||||
|  |       const response = await axios.post( | ||||||
|  |         url.vorstand.sm.deleteUser, | ||||||
|  |         { ...data }, | ||||||
|  |         { headers: { Token: rootState.login.user.accessToken } } | ||||||
|  |       ) | ||||||
|  |       commit('updateMonth', {...data, com: 'delete'}) | ||||||
|  |     } catch (e) { | ||||||
|  |       if (e.response) | ||||||
|  |         if (e.response.status === 401) dispatch('logout', null, { root: true }) | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| const getters = { | const getters = { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue