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

View File

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