diff --git a/src/components/vorstand/JobKindManager.vue b/src/components/vorstand/JobKindManager.vue new file mode 100644 index 0000000..036674f --- /dev/null +++ b/src/components/vorstand/JobKindManager.vue @@ -0,0 +1,119 @@ + + + + + diff --git a/src/components/vorstand/ManagementNavigation.vue b/src/components/vorstand/ManagementNavigation.vue index f2ec3ac..46ffe61 100644 --- a/src/components/vorstand/ManagementNavigation.vue +++ b/src/components/vorstand/ManagementNavigation.vue @@ -24,6 +24,14 @@ Arbeitsgruppen + + + ??? + + + Dienstarten + + diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 118a35e..66b4282 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -33,7 +33,11 @@ const url = { getUser: main + 'sm/getUser', getUsers: main + 'sm/getUsers', lockDay: main + 'sm/lockDay', - searchUser: main + 'sm/searchWithExtern' + searchUser: main + 'sm/searchWithExtern', + jobkind: main + 'sm/JobKind', + getAllJobKindsbKinds: main + 'sm/getAllJobKinds', + getJobKind: main + 'sm/getJobKind', + deleteJobKind: main + 'sm/deleteJobKind' }, um: { setStatus: main + 'um/setStatus', diff --git a/src/router/index.js b/src/router/index.js index fecd282..c7a8f16 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -24,6 +24,7 @@ import GastroNavigation from '@/components/gastro/GastroNavigation' import PriceListView from '@/views/contents/PriceListView' import UserManager from '@/components/vorstand/UserManager' import WorkgroupManagement from "@/components/vorstand/WorkgroupManagement"; +import JobKindManager from "@/components/vorstand/JobKindManager"; Vue.use(VueRouter) @@ -63,6 +64,10 @@ const routes = [ { path: 'workgroupmanagement', component: WorkgroupManagement + }, + { + path: 'jobkindmanagement', + component: JobKindManager } ] }, diff --git a/src/store/index.js b/src/store/index.js index 5fc6616..eb63086 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -10,6 +10,7 @@ import requestJobs from '@/store/modules/jobRequests' import priceList from '@/store/modules/pricelist' import usermanager from '@/store/modules/userManager' import wm from '@/store/modules/workgroupManagement' +import jkm from '@/store/modules/jobkindManager' Vue.use(Vuex) @@ -24,6 +25,7 @@ export default new Vuex.Store({ requestJobs, priceList, usermanager, - wm + wm, + jkm } }) diff --git a/src/store/modules/jobkindManager.js b/src/store/modules/jobkindManager.js new file mode 100644 index 0000000..09b36a9 --- /dev/null +++ b/src/store/modules/jobkindManager.js @@ -0,0 +1,118 @@ +import url from '@/plugins/routes' +import axios from 'axios' + +const state = { + jobkinds: [], + jobkindLoading: false +} + +const mutations = { + setJobkinds: (state, jobkinds) => { + state.jobkinds = jobkinds + }, + updateJobKind: (state, jobkind) => { + console.log(jobkind) + const exists = state.jobkinds.find(a => { + return a.id === jobkind.id + }) + console.log(exists) + if (exists) { + exists.name = jobkind.name + } else { + state.jobkinds.push(jobkind) + } + }, + deleteJobKind: (state, jobkind) => { + const exists = state.jobkinds.indexOf( + state.jobkinds.find(a => { + return a.id === jobkind.id + }) + ) + state.jobkinds.splice(exists, 1) + }, + setJobkindsLoading: (state, value) => { + state.jobkindLoading = value + } +} + +const actions = { + async getAllJobKinds({ commit, rootState, dispatch }) { + try { + commit('setJobkindsLoading', true) + const response = await axios.get(url.vorstand.sm.getAllJobKindsbKinds, { + headers: { Token: rootState.login.user.accessToken } + }) + commit('setJobkinds', response.data) + commit('setJobkindsLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async addJobKind({ commit, rootState, dispatch }, data) { + try { + commit('setJobkindsLoading', true) + const response = await axios.put( + url.vorstand.sm.jobkind, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateJobKind', response.data) + commit('setJobkindsLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async updateJobKind({ commit, rootState, dispatch }, data) { + try { + commit('setJobkindsLoading', true) + const response = await axios.post( + url.vorstand.sm.jobkind, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateJobKind', response.data) + commit('setJobkindsLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async deleteJobKind({ commit, rootState, dispatch }, data) { + try { + commit('setJobkindsLoading', true) + await axios.post( + url.vorstand.sm.deleteJobKind, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('deleteJobKind', data) + commit('setJobkindsLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + } +} + +const getters = { + jobkinds: state => { + return state.jobkinds + }, + jobkindsLoading: state => { + return state.jobkindLoading + } +} + +export default { + namespaced: true, + state, + mutations, + actions, + getters +}