added feature to lock barview

fixed bug, that you can send negative amount.
This commit is contained in:
Tim Gröger 2020-05-11 23:03:16 +02:00
parent 53676763ea
commit e502e3f334
5 changed files with 96 additions and 12 deletions

View File

@ -275,7 +275,7 @@ export default {
addAmountMore(user) { addAmountMore(user) {
this.addAmount({ this.addAmount({
username: user.username, username: user.username,
amount: user.value * 100, amount: Math.abs(user.value * 100),
user: user user: user
}) })
setTimeout(() => { setTimeout(() => {

View File

@ -20,11 +20,28 @@
</template> </template>
</v-autocomplete> </v-autocomplete>
<v-btn text @click="addUser">Hinzufügen</v-btn> <v-btn text @click="addUser">Hinzufügen</v-btn>
<v-btn v-if="!locked" text @click="lock">Sperren</v-btn>
<v-btn v-else text @click="overlay = true">Entsperren</v-btn>
<v-btn @click="clickMenu" icon> <v-btn @click="clickMenu" icon>
<v-icon>{{ menuIcon }}</v-icon> <v-icon>{{ menuIcon }}</v-icon>
</v-btn> </v-btn>
</v-toolbar-items> </v-toolbar-items>
</v-toolbar> </v-toolbar>
<v-dialog v-model="overlay">
<v-container>
<v-card>
<v-card-title>Entsperre Baransicht</v-card-title>
<v-card-text>
<v-text-field outlined type="password" label="Passwort" v-model="password"></v-text-field>
</v-card-text>
<v-card-actions>
<v-spacer/>
<v-btn @click="overlay = false">Abbrechen</v-btn>
<v-btn @click="doUnlock">Entsperren</v-btn>
</v-card-actions>
</v-card>
</v-container>
</v-dialog>
</div> </div>
</template> </template>
@ -40,11 +57,14 @@ export default {
user: null, user: null,
filter: '', filter: '',
search_person: mdiAccountSearch, search_person: mdiAccountSearch,
menuIcon: mdiMenu menuIcon: mdiMenu,
overlay: false,
password: ''
} }
}, },
created() { created() {
this.getAllUsers() this.getAllUsers()
this.getLocked()
}, },
methods: { methods: {
...mapActions({ ...mapActions({
@ -52,7 +72,10 @@ export default {
addCreditList: 'barUsers/addCreditList', addCreditList: 'barUsers/addCreditList',
setFilter: 'barUsers/setFilter', setFilter: 'barUsers/setFilter',
activateMenu: 'barUsers/activateMenu', activateMenu: 'barUsers/activateMenu',
deactivateMenu: 'barUsers/deactivateMenu' deactivateMenu: 'barUsers/deactivateMenu',
lock: 'barUsers/setLocked',
unlock: 'barUsers/unlock',
getLocked: 'barUsers/getLocked'
}), }),
addUser() { addUser() {
this.addCreditList(this.user) this.addCreditList(this.user)
@ -61,13 +84,19 @@ export default {
clickMenu() { clickMenu() {
if (this.menu) this.deactivateMenu() if (this.menu) this.deactivateMenu()
else this.activateMenu() else this.activateMenu()
},
doUnlock() {
this.unlock(this.password)
this.password = ''
this.overlay = false
} }
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
allUsers: 'barUsers/allUsers', allUsers: 'barUsers/allUsers',
loading: 'barUsers/allUsersLoading', loading: 'barUsers/allUsersLoading',
menu: 'barUsers/menu' menu: 'barUsers/menu',
locked: 'barUsers/locked'
}) })
}, },
watch: { watch: {

View File

@ -54,10 +54,12 @@ const url = {
deleteTransactJobs: main + 'user/deleteTransactJob', deleteTransactJobs: main + 'user/deleteTransactJob',
storno: main + 'user/storno', storno: main + 'user/storno',
getAllStatus: main + 'getAllStatus', getAllStatus: main + 'getAllStatus',
getStatus: main + 'getStatus' getStatus: main + 'getStatus',
valid: main + 'valid'
}, },
barU: { barU: {
storno: main + 'bar/storno' storno: main + 'bar/storno',
lock: main + 'bar/lock'
}, },
gastro: { gastro: {
setDrink: main + 'gastro/setDrink', setDrink: main + 'gastro/setDrink',

View File

@ -8,7 +8,8 @@ const state = {
usersLoading: false, usersLoading: false,
allUsersLoading: false, allUsersLoading: false,
message: [], message: [],
menu: false menu: false,
locked: false
} }
const mutations = { const mutations = {
@ -116,6 +117,9 @@ const mutations = {
}, },
setMenu: (state, value) => { setMenu: (state, value) => {
state.menu = value state.menu = value
},
setLocked: (satet, value) => {
state.locked = value
} }
} }
@ -227,6 +231,51 @@ const actions = {
} }
commit('updateMessage', { date: data.date, loading: false }) commit('updateMessage', { date: data.date, loading: false })
}, },
async getLocked({ commit, rootState, dispatch }) {
try {
const response = await axios.get(url.barU.lock, {
headers: { Token: rootState.login.user.accessToken }
})
console.log(response.data.value)
commit('setLocked', response.data.value)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async setLocked({ commit, rootState, dispatch }) {
try {
const response = await axios.post(
url.barU.lock,
{ value: true },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setLocked', response.data.value)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async unlock({ commit, rootState, dispatch }, password) {
try {
const valid = await axios.post(
url.user.valid,
{ password: password },
{ headers: { Token: rootState.login.user.accessToken } }
)
if (valid.data.ok === 'ok') {
const response = await axios.post(
url.barU.lock,
{ value: false },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setLocked', response.data.value)
}
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
setFilter({ commit }, data) { setFilter({ commit }, data) {
commit('setFilter', data) commit('setFilter', data)
}, },
@ -259,6 +308,9 @@ const getters = {
}, },
menu: state => { menu: state => {
return state.menu return state.menu
},
locked: state => {
return state.locked
} }
} }

View File

@ -18,7 +18,7 @@
{{user.firstname}} {{user.lastname}} {{user.firstname}} {{user.lastname}}
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item v-if="isUser" class="title" link to="/main/user/add"> <v-list-item :disabled="lockedBar" v-if="isUser" class="title" link to="/main/user/add">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{person}}</v-icon> <v-icon>{{person}}</v-icon>
</v-list-item-icon> </v-list-item-icon>
@ -32,7 +32,7 @@
Bar Bar
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item v-if="isManagement" class="title" link to="/main/management/servicemanagement"> <v-list-item :disabled="lockedBar" v-if="isManagement" class="title" link to="/main/management/servicemanagement">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{king}}</v-icon> <v-icon>{{king}}</v-icon>
</v-list-item-icon> </v-list-item-icon>
@ -40,7 +40,7 @@
Vorstand Vorstand
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item v-if="isGastro" class="title" link to="/main/gastro/pricelist"> <v-list-item :disabled="lockedBar" v-if="isGastro" class="title" link to="/main/gastro/pricelist">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{gastro}}</v-icon> <v-icon>{{gastro}}</v-icon>
</v-list-item-icon> </v-list-item-icon>
@ -48,7 +48,7 @@
Gastro Gastro
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item v-if="isFinanzer" class="title" link to="/main/finanzer/overview"> <v-list-item :disabled="lockedBar" v-if="isFinanzer" class="title" link to="/main/finanzer/overview">
<v-list-item-icon> <v-list-item-icon>
<v-icon>{{attach_money}}</v-icon> <v-icon>{{attach_money}}</v-icon>
</v-list-item-icon> </v-list-item-icon>
@ -107,7 +107,8 @@ export default {
isManagement: 'isManagement', isManagement: 'isManagement',
isLoggedIn: 'isLoggedIn', isLoggedIn: 'isLoggedIn',
isExtern: 'isExtern', isExtern: 'isExtern',
user: 'user' user: 'user',
lockedBar: 'barUsers/locked'
}) })
} }
} }