diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index ea1eee9..73ef19c 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -35,6 +35,40 @@ + + + Warnung + + {{ overLimitUser.firstname }} {{ overLimitUser.lastname }} übersteigt + das Anschreibelimit von + {{ (overLimitUser.limit / 100).toFixed(2) }} €. Danach kann dieses + Mitglied nichts mehr anschreiben. Will er das wirklich? + + + + Abbrechen + Anschreiben + + + + + + Anschreiben nicht möglich + + {{ overOverLimit.firstname }} + {{ overOverLimit.lastname }} überschreitet das Anschreibelimit zuviel. + Das Anschreiben wurde daher gestoppt und zurückgesetzt. + + + Verstanden + + + @@ -173,13 +207,11 @@ {{ - (user.amount / 100).toFixed(2) - }} + >{{ (user.amount / 100).toFixed(2) }} € - - {{(user.toSetAmount / 100).toFixed(2)}} + - {{ (user.toSetAmount / 100).toFixed(2) }} @@ -189,23 +221,19 @@ {{ user.firstname }} darf nicht mehr anschreiben. + >{{ user.firstname }} darf nicht mehr anschreiben. {{ user.firstname }} sollte sich lieber mal beim Finanzer melden. - + {{ - (user.amount / 100).toFixed(2) - }} + >{{ (user.amount / 100).toFixed(2) }} € - + @@ -221,16 +249,18 @@ :value="messages.length > 0 ? messages[0].visible : test" vertical > - - - - {{ createMessage(message) }} - - - + + + + {{ createMessage(message) }} + + + @@ -258,7 +288,9 @@ export default { timer: '', stornoMessage: null, checkValidate: false, - test: null + test: null, + overLimitUser: null, + overOverLimit: null } }, created() { @@ -273,17 +305,75 @@ export default { deactivate: 'barUsers/deactivateMenu', commitStorno: 'barUsers/storno' }), + continueAdd(user) { + this.overLimitUser = null + user.checkedOverLimit = true + if (user.value) { + this.addAmount({ + username: user.username, + amount: Math.round(Math.abs(user.value * 100)), + user: user + }) + setTimeout(() => { + user.value = null + user.toSetAmount = null + }, 300) + } else { + user.timeout = setTimeout(() => { + this.addAmount({ + username: user.username, + amount: user.toSetAmount, + user: user + }) + setTimeout(() => { + user.toSetAmount = null + }, 300) + }, 2000) + } + }, + cancel() { + this.overLimitUser.toSetAmount = null + this.overLimitUser.value = null + this.overLimitUser = null + }, + checkOverLimitIsValid(user) { + if (user.toSetAmount) { + if (Math.abs(user.amount - Number.parseInt(user.toSetAmount)) > user.limit + 500) { + this.overOverLimit = user + user.toSetAmount = null + user.value = null + return false + } + } + return true + }, + checkOverLimit(user) { + if (user.toSetAmount) { + if (Math.abs( user.amount - user.toSetAmount) > user.limit) { + return user.checkedOverLimit ? false : true + } + } + return false + }, addingAmount(user, amount) { clearTimeout(user.timeout) user.toSetAmount = user.toSetAmount ? user.toSetAmount + amount : amount - user.timeout = setTimeout(() => { - this.addAmount({username: user.username, - amount: user.toSetAmount, - user: user}) - setTimeout(() => { - user.toSetAmount = null - }, 300) - }, 2000) + if (this.checkOverLimitIsValid(user)) { + if (this.checkOverLimit(user)) { + this.overLimitUser = user + } else { + user.timeout = setTimeout(() => { + this.addAmount({ + username: user.username, + amount: user.toSetAmount, + user: user + }) + setTimeout(() => { + user.toSetAmount = null + }, 300) + }, 2000) + } + } }, forceRender() { this.componentRenderer += 1 @@ -315,14 +405,25 @@ export default { } }, addAmountMore(user) { - this.addAmount({ - username: user.username, - amount: Math.round(Math.abs(user.value * 100)), - user: user - }) - setTimeout(() => { - user.value = null - }, 300) + user.toSetAmount = user.toSetAmount + ? user.toSetAmount + Math.round(Math.abs(user.value * 100)) + : Math.round(Math.abs(user.value * 100)) + if (this.checkOverLimitIsValid(user)) { + if (this.checkOverLimit(user)) { + this.overLimitUser = user + } + else { + this.addAmount({ + username: user.username, + amount: Math.round(Math.abs(user.value * 100)), + user: user + }) + setTimeout(() => { + user.value = null + user.toSetAmount = null + }, 300) + } + } }, storno(message) { if (!message.error) { @@ -373,7 +474,7 @@ export default { calcLastSeen(user) { if (user.last_seen) { let date = new Date() - if (((date - user.last_seen)/1000/60/60) < 72) { + if ((date - user.last_seen) / 1000 / 60 / 60 < 72) { return true } } diff --git a/src/components/user/AddAmount.vue b/src/components/user/AddAmount.vue index c9804e3..6a09240 100644 --- a/src/components/user/AddAmount.vue +++ b/src/components/user/AddAmount.vue @@ -6,11 +6,13 @@ Willst du wirklich?? - Willst du wirklich den Betrag {{(stornoMessage.amount/100).toFixed(2)}}€ von {{stornoMessage.user.firstname}} - {{stornoMessage.user.lastname}} stornieren? + Willst du wirklich den Betrag + {{ (stornoMessage.amount / 100).toFixed(2) }}€ von + {{ stornoMessage.user.firstname }} + {{ stornoMessage.user.lastname }} stornieren? - + Abbrechen Stornieren @@ -34,6 +36,40 @@ + + + Warnung + + {{ overLimitUser.firstname }} {{ overLimitUser.lastname }} übersteigt + das Anschreibelimit von + {{ (overLimitUser.limit / 100).toFixed(2) }} €. Danach kann dieses + Mitglied nichts mehr anschreiben. Will er das wirklich? + + + + Abbrechen + Anschreiben + + + + + + Anschreiben nicht möglich + + {{ overOverLimit.firstname }} + {{ overOverLimit.lastname }} überschreitet das Anschreibelimit zuviel. + Das Anschreiben wurde daher gestoppt und zurückgesetzt. + + + Verstanden + + + @@ -54,7 +90,7 @@ {{ now(message.date) }} - {{createSum(message)}} {{ createMessage(message) }} + {{ createSum(message) }} {{ createMessage(message) }} STORNIERT!!! @@ -76,6 +112,10 @@ {{ menuIcon }} + + Nur noch {{ ((user.limit + getAllSum()) / 100).toFixed(2) }} € + übrig!! + @@ -166,14 +206,11 @@ {{ - (getAllSum() / 100).toFixed(2) - }} + >{{ (getAllSum() / 100).toFixed(2) }} € - + - - {{(toSetAmount / 100).toFixed(2)}} + - {{ (toSetAmount / 100).toFixed(2) }} @@ -188,7 +225,6 @@
-

{{createSum(message)}}

{{ createMessage(message) }} +

{{ createSum(message) }}

+ {{ createMessage(message) }}
- {{now(message.date)}} + {{ now(message.date) }}
- {{close}} + {{ close }}
@@ -235,7 +272,9 @@ export default { checkValidate: false, stornoMessage: null, timeout: null, - toSetAmount: null + toSetAmount: null, + overLimitUser: null, + overOverLimit: null, } }, created() { @@ -246,15 +285,63 @@ export default { addAmount: 'user/addAmount', commitStorno: 'user/storno' }), + continueAdd(user) { + this.overLimitUser = null + user.checkedOverLimit = true + if (this.value) { + this.addAmount(Math.round(Math.abs(this.value * 100))) + setTimeout(() => { + this.value = null + this.toSetAmount = null + }, 300) + } else { + user.timeout = setTimeout(() => { + this.addAmount(this.toSetAmount) + setTimeout(() => { + this.toSetAmount = null + }, 300) + }, 2000) + } + }, + cancel() { + this.toSetAmount = null + this.value = null + this.overLimitUser = null + }, + checkOverLimitIsValid(user) { + if (this.toSetAmount) { + if (Math.abs(this.getAllSum() - Number.parseInt(this.toSetAmount)) > user.limit + 500) { + this.overOverLimit = user + this.toSetAmount = null + this.value = null + return false + } + } + return true + }, + checkOverLimit(user) { + if (this.toSetAmount) { + if (Math.abs( this.getAllSum() - this.toSetAmount) > user.limit) { + return user.checkedOverLimit ? false : true + } + } + return false + }, addingAmount(amount) { clearTimeout(this.timeout) this.toSetAmount = this.toSetAmount ? this.toSetAmount + amount : amount - this.timeout = setTimeout(() => { - this.addAmount(this.toSetAmount) - setTimeout(() => { - this.toSetAmount = null - }, 300) - }, 2000) + if (this.checkOverLimitIsValid(this.user)) { + if (this.checkOverLimit(this.user)) { + this.overLimitUser = this.user + } else { + this.timeout = setTimeout(() => { + this.addAmount(this.toSetAmount) + setTimeout(() => { + this.toSetAmount = null + }, 300) + }, 2000) + } + } }, forceRender() { this.componentRenderer += 1 @@ -279,29 +366,37 @@ export default { } } }, - acceptStorno() { - this.commitStorno({ - amount: this.stornoMessage.amount, - date: this.stornoMessage.date - }) - setTimeout(() => { - this.cancelStorno() - }, 300) - }, - cancelStorno() { - this.stornoMessage = null - this.checkValidate = null - }, - addAmountMore() { - this.addAmount(Math.abs(this.value * 100)) + acceptStorno() { + this.commitStorno({ + amount: this.stornoMessage.amount, + date: this.stornoMessage.date + }) setTimeout(() => { - this.value = null + this.cancelStorno() }, 300) }, + cancelStorno() { + this.stornoMessage = null + this.checkValidate = null + }, + addAmountMore() { + this.toSetAmount = this.toSetAmount + ? this.toSetAmount + Math.round(Math.abs(this.value * 100)) + : Math.round(Math.abs(this.value * 100)) + if (this.checkOverLimitIsValid(this.user)) { + if (this.checkOverLimit(this.user)) { + this.overLimitUser = this.user + } + else { + this.addAmount(Math.abs(this.value * 100)) + setTimeout(() => { + this.value = null + }, 300) + } + } + }, createSum(message) { - var text = '' + - (message.amount / 100).toFixed(2) + - '€' + var text = '' + (message.amount / 100).toFixed(2) + '€' return text }, createMessage(message) { @@ -335,7 +430,7 @@ export default { under5minutes() { return now => { var actual = new Date() - return actual - now < 15000 + return actual - now < 15000 } }, now() { diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index 7130ca8..3a8a906 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -242,6 +242,7 @@ const actions = { }, { headers: { Token: rootState.login.user.accessToken } } ) + console.log(response.data) commit('setUsers', { [response.data.username]: response.data }) commit('updateMessage', { date: data.date, storno: true }) dispatch('getLifeTime', null, { root: true })