add customfield for baruser to addAmount of a custom value

This commit is contained in:
Tim Gröger 2020-03-03 23:28:05 +01:00
parent 11b8df2251
commit 4316e1b791
2 changed files with 56 additions and 25 deletions

View File

@ -64,7 +64,7 @@
<v-row>
<v-col cols="10">
<v-row>
<v-col>
<v-col cols="6" xs="5" sm="4">
<v-btn
class="creditBtn"
block
@ -77,10 +77,10 @@
"
:color="color"
:disabled="user.locked"
>2 </v-btn
>
>2
</v-btn>
</v-col>
<v-col>
<v-col cols="6" xs="5" sm="4">
<v-btn
class="creditBtn"
block
@ -93,10 +93,10 @@
"
:color="color"
:disabled="user.locked"
>1 </v-btn
>
>1
</v-btn>
</v-col>
<v-col>
<v-col cols="6" xs="5" sm="4">
<v-btn
class="creditBtn"
block
@ -109,12 +109,10 @@
"
:color="color"
:disabled="user.locked"
>0,50 </v-btn
>
>0,50
</v-btn>
</v-col>
</v-row>
<v-row>
<v-col>
<v-col cols="6" xs="5" sm="4">
<v-btn
class="creditBtn"
block
@ -127,10 +125,10 @@
"
:color="color"
:disabled="user.locked"
>0,40 </v-btn
>
>0,40
</v-btn>
</v-col>
<v-col>
<v-col cols="6" xs="5" sm="4">
<v-btn
class="creditBtn"
block
@ -143,10 +141,10 @@
"
:color="color"
:disabled="user.locked"
>0,20 </v-btn
>
>0,20
</v-btn>
</v-col>
<v-col>
<v-col cols="6" xs="5" sm="4">
<v-btn
class="creditBtn"
block
@ -159,8 +157,16 @@
"
:color="color"
:disabled="user.locked"
>0,10 </v-btn
>
>0,10
</v-btn>
</v-col>
<v-col cols="8">
<v-text-field outlined type="number" v-model="user.value" label="Benutzerdefinierter Betrag"></v-text-field>
</v-col>
<v-col cols="4">
<v-btn fab :color="color" @click="addAmountMore(user)">
<v-icon>{{plus}}</v-icon>
</v-btn>
</v-col>
</v-row>
</v-col>
@ -203,6 +209,7 @@
<script>
import { mapGetters, mapActions } from 'vuex'
import {mdiPlus} from '@mdi/js'
import AddAmountSkeleton from '../user/Skeleton/AddAmountSkeleton'
export default {
@ -211,6 +218,8 @@ export default {
props: {},
data() {
return {
plus: mdiPlus,
value: null,
color: 'green accent-4',
menu: true,
dialog: false,
@ -246,6 +255,12 @@ export default {
return true
}
},
addAmountMore(user) {
this.addAmount({username: user.username, amount: user.value * 100, user: user})
setTimeout(() => {
user.value = null
}, 300)
},
storno(message) {
console.log('storno')
if (!message.error) {
@ -343,7 +358,7 @@ export default {
this.menu = this.menu_from_store
}
},
beforeDestroy () {
beforeDestroy() {
clearInterval(this.timer)
}
}

View File

@ -136,7 +136,11 @@ const actions = {
commit('setUsersLoading', false)
},
async addAmount({ commit, rootState, dispatch }, data) {
commit('updateUser', { username: data.username, loading: true })
try {
commit('updateUser', {username: data.username, loading: true})
} catch (e) {
console.log(e)
}
try {
const response = await axios.post(
url.barAddAmount,
@ -158,10 +162,18 @@ const actions = {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
commit('updateUser', { username: data.username, loading: false })
try {
commit('updateUser', {username: data.username, loading: false})
} catch (e) {
console.log(e)
}
},
async addCreditList({ commit, rootState, dispatch }, data) {
commit('updateUser', { username: data.username, loading: true })
try {
commit('updateUser', {username: data.username, loading: true})
} catch (e) {
console.log(e)
}
try {
const response = await axios.post(
url.barGetUser,
@ -173,7 +185,11 @@ const actions = {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
commit('updateUser', { username: data.username, loading: false })
try {
commit('updateUser', {username: data.username, loading: false})
} catch (e) {
console.log(e)
}
},
async getAllUsers({ commit, rootState, dispatch }) {
commit('setAllUsersLoading', true)