diff --git a/src/components/TitleBar.vue b/src/components/TitleBar.vue index 78e580d..3876b0c 100644 --- a/src/components/TitleBar.vue +++ b/src/components/TitleBar.vue @@ -1,25 +1,31 @@ + + diff --git a/src/components/pricelist/PriceList.vue b/src/components/pricelist/PriceList.vue new file mode 100644 index 0000000..25ec347 --- /dev/null +++ b/src/components/pricelist/PriceList.vue @@ -0,0 +1,492 @@ + + + + + diff --git a/src/components/vorstand/ManagementNavigation.vue b/src/components/vorstand/ManagementNavigation.vue new file mode 100644 index 0000000..8db8cf6 --- /dev/null +++ b/src/components/vorstand/ManagementNavigation.vue @@ -0,0 +1,26 @@ + + + + + diff --git a/src/components/vorstand/ServiceManagement.vue b/src/components/vorstand/ServiceManagement.vue index d951ba3..1e4d562 100644 --- a/src/components/vorstand/ServiceManagement.vue +++ b/src/components/vorstand/ServiceManagement.vue @@ -1,51 +1,49 @@ @@ -100,7 +98,12 @@ export default { for (var week in this.month) { for (var dayint in this.month[week].days) { var day = this.month[week].days[dayint] - this.lockDay({year: day.date.getFullYear(), month: day.date.getMonth() + 1, day: day.date.getDate(), locked: value}) + this.lockDay({ + year: day.date.getFullYear(), + month: day.date.getMonth() + 1, + day: day.date.getDate(), + locked: value + }) } } } diff --git a/src/plugins/routes.js b/src/plugins/routes.js index a9dd05f..86df7f1 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -1,10 +1,12 @@ //const main = 'https://192.168.5.128:5000/' -const main = 'http://localhost:5000/' -//const main = 'http://192.168.5.118:5000/' +//const main = 'http://localhost:5000/' +const main = 'http://192.168.5.118:5000/' //const main = 'https://groeger-clan.duckdns.org:5000/' const url = { login: main + 'login', + pricelist: main + 'pricelist', + getTypes: main + 'drinkTypes', getFinanzerMain: main + 'getFinanzerMain', bar: main + 'bar', barGetUser: main + 'barGetUser', @@ -42,6 +44,14 @@ const url = { }, barU: { storno: main + 'bar/storno' + }, + gastro: { + setDrink: main + 'gastro/setDrink', + updateDrink: main + 'gastro/updateDrink', + deleteDrink: main + 'gastro/deleteDrink', + setType: main + 'gastro/setDrinkType', + updateType: main + 'gastro/updateDrinkType', + deleteType: main + 'gastro/deleteDrinkType' } } diff --git a/src/router/index.js b/src/router/index.js index 8f46419..2a9774f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -18,10 +18,19 @@ import ServiceManagement from '../components/vorstand/ServiceManagement' import Config from '@/components/user/Config' import Jobs from '@/components/user/Jobs' import JobRequests from '@/components/user/JobRequests' +import PriceList from '@/components/pricelist/PriceList' +import ManagementNavigation from "@/components/vorstand/ManagementNavigation"; +import GastroNavigation from "@/components/gastro/GastroNavigation"; +import PriceListView from "@/views/contents/PriceListView"; Vue.use(VueRouter) const routes = [ + { + path: '/pricelist', + name: 'priceListNoLogin', + component: PriceListView + }, { path: '/login', name: 'login', @@ -32,10 +41,21 @@ const routes = [ name: 'main', component: MainView, children: [ + { + path: 'management', + name: 'management', + components: { nav: ManagementNavigation, default: BarView}, + children: [ + { + path: 'servicemanagement', + component: ServiceManagement + } + ] + }, { path: 'user', name: 'user', - components: { userNav: UserNavigation, default: UserView }, + components: { nav: UserNavigation, default: UserView }, children: [ { path: 'add', @@ -67,7 +87,7 @@ const routes = [ { path: 'bar', name: 'bar', - components: { userNav: BarNavigation, default: BarView }, + components: { nav: BarNavigation, default: BarView }, children: [ { path: 'geruecht', @@ -79,7 +99,7 @@ const routes = [ { path: 'finanzer', name: 'finanzer', - components: { default: FinanzerView, finanzerNav: FinanzerNavigation }, + components: { default: FinanzerView, nav: FinanzerNavigation }, children: [ { path: 'overview', @@ -90,10 +110,18 @@ const routes = [ name: 'activeUser', props: true, component: User - }, + } + ] + }, + { + path: 'gastro', + name: 'gastro', + components: { nav: GastroNavigation, default: BarView}, + children: [ { - path: 'servicemanagement', - component: ServiceManagement + path: 'pricelist', + name: 'gastroPricelist', + component: PriceList } ] } @@ -138,7 +166,7 @@ router.beforeEach((to, from, next) => { if (to.fullPath === '/login') { if (store.state.login.user.accessToken) { if (store.state.login.user.group.includes('moneymaster')) { - next('/main/finanzer') + next('/main/finanzer/overview') } else if (store.state.login.user.group.includes('bar')) { next('/main/bar/geruecht') } else if (store.state.login.user.group.includes('user')) { diff --git a/src/store/index.js b/src/store/index.js index 2890a75..0398961 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -7,6 +7,7 @@ import user from '@/store/modules/user' import sm from '@/store/modules/serviceManagement' import jobs from '@/store/modules/jobs' import requestJobs from '@/store/modules/jobRequests' +import priceList from '@/store/modules/pricelist' Vue.use(Vuex) @@ -18,6 +19,7 @@ export default new Vuex.Store({ user, sm, jobs, - requestJobs + requestJobs, + priceList } }) diff --git a/src/store/modules/login.js b/src/store/modules/login.js index 4f778a9..2575952 100644 --- a/src/store/modules/login.js +++ b/src/store/modules/login.js @@ -115,27 +115,41 @@ const getters = { }, isBar: state => { try { - return state.user.group.includes('bar') ? true : false + return state.user.group.includes('bar') } catch (e) { return false } }, isFinanzer: state => { try { - return state.user.group.includes('moneymaster') ? true : false + return state.user.group.includes('moneymaster') } catch (e) { return false } }, isUser: state => { try { - return state.user.group.includes('user') ? true : false + return state.user.group.includes('user') + } catch (e) { + return false + } + }, + isGastro: state => { + try { + return state.user.group.includes('gastro') + } catch (e) { + return false + } + }, + isManagement: state => { + try { + return state.user.group.includes('management') || state.user.group.includes('gastro') || state.user.group.includes('moneymaster') } catch (e) { return false } }, isLoggedIn: state => { - return state.user.accessToken ? true : false + return state.user.accessToken }, user: state => { return state.user diff --git a/src/store/modules/pricelist.js b/src/store/modules/pricelist.js new file mode 100644 index 0000000..79df600 --- /dev/null +++ b/src/store/modules/pricelist.js @@ -0,0 +1,202 @@ +import url from '@/plugins/routes' +import axios from 'axios' + +const state = { + priceList: [], + types: [] +} + +const mutations = { + setPriceList: (state, priceList) => { + state.priceList = priceList + }, + setTypes: (state, types) => { + state.types = types + state.types.sort((a, b) => { + const low = b.name.toLowerCase() + const high = a.name.toLowerCase() + if (high < low) return -1 + if (high > low) return 1 + return 0 + }) + }, + updatePriceList: (state, drink) => { + var a = state.priceList.find(b => { + return b.id === drink.id + }) + if (a) { + a.name = drink.name + a.type = drink.type + a.price = drink.price + a.price_big = drink.price_big + a.price_club = drink.price_club + a.price_club_big = drink.price_club_big + a.premium = drink.premium + a.premium_club = drink.premium_club + a.price_extern_club = drink.price_extern_club + } else { + state.priceList.push({ + id: drink.id, + name: drink.name, + type: drink.type, + price: drink.price, + price_big: drink.price_big, + price_club: drink.price_club, + price_club_big: drink.price_club_big, + premium: drink.premium, + premium_club: drink.premium_club, + price_extern_club: drink.price_extern_club + }) + } + }, + deleteDrinkPrice: (state, data) => { + var index = state.priceList.indexOf( + state.priceList.find(a => { + return a.id === data.id + }) + ) + state.priceList.splice(index, 1) + }, + updateDrinkType: (state, type) => { + var a = state.types.find(b => { + return b.id === type.id + }) + if (a) { + a.name = type.name + } else { + state.types.push({ + ...type + }) + } + state.types.sort((a, b) => { + const low = b.name.toLowerCase() + const high = a.name.toLowerCase() + if (high < low) return -1 + if (high > low) return 1 + return 0 + }) + }, + deleteDrinkType: (state, type) => { + var index = state.types.indexOf( + state.types.find(a => { + return a.id === type.id + }) + ) + state.types.splice(index, 1) + } +} + +const actions = { + async getPriceList({ commit }) { + try { + const response = await axios.get(url.pricelist) + commit('setPriceList', response.data) + } catch (e) { + console.log(e) + } + }, + async getTypes({ commit, dispatch }) { + try { + const response = await axios.get(url.getTypes) + commit('setTypes', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async setDrink({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.gastro.setDrink, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updatePriceList', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async updateDrink({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.gastro.updateDrink, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updatePriceList', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async deleteDrink({ commit, rootState, dispatch }, data) { + try { + await axios.post( + url.gastro.deleteDrink, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('deleteDrinkPrice', data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async setDrinkType({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.gastro.setType, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateDrinkType', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async updateDrinkType({ commit, rootState, dispatch }, data) { + try { + const response = await axios.post( + url.gastro.updateType, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateDrinkType', response.data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async deleteDrinkType({ commit, rootState, dispatch }, data) { + try { + await axios.post( + url.gastro.deleteType, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('deleteDrinkType', data) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + } +} + +const getters = { + priceList: state => { + return state.priceList + }, + types: state => { + return state.types + } +} + +export default { + namespaced: true, + state, + mutations, + actions, + getters +} diff --git a/src/views/MainView.vue b/src/views/MainView.vue index 85b04f8..482c4ed 100644 --- a/src/views/MainView.vue +++ b/src/views/MainView.vue @@ -24,6 +24,22 @@ Bar + + + {{king}} + + + Vorstand + + + + + {{gastro}} + + + Gastro + + {{attach_money}} @@ -32,9 +48,7 @@ - - - +