2020-01-17 00:01:10 +00:00
|
|
|
<template>
|
2020-02-27 14:52:58 +00:00
|
|
|
<v-container>
|
|
|
|
<v-dialog v-model="dialog" max-width="290">
|
|
|
|
<v-card>
|
|
|
|
<v-card-title class="headline"
|
|
|
|
>Transaktion ist länger als 5 Minuten her!</v-card-title
|
|
|
|
>
|
|
|
|
<v-card-text>
|
|
|
|
Da die Transaktion länger als 5 Minutern her ist, kann eine
|
|
|
|
Stornierung nicht durchgeführt werden. Wende dich bitte an den
|
|
|
|
Finanzer.
|
|
|
|
</v-card-text>
|
|
|
|
<v-card-actions>
|
|
|
|
<v-spacer />
|
|
|
|
<v-btn text @click="dialog = false">
|
|
|
|
Verstanden
|
|
|
|
</v-btn>
|
|
|
|
</v-card-actions>
|
|
|
|
</v-card>
|
|
|
|
</v-dialog>
|
2020-01-23 22:25:21 +00:00
|
|
|
<AddAmountSkeleton v-if="loading" />
|
2020-02-27 14:52:58 +00:00
|
|
|
<v-navigation-drawer v-model="menu" right app clipped>
|
|
|
|
<v-list-item-group :key="componentRenderer">
|
|
|
|
<v-list-item inactive>
|
|
|
|
<v-list-item-title class="headline">
|
|
|
|
Verlauf
|
|
|
|
</v-list-item-title>
|
|
|
|
</v-list-item>
|
|
|
|
<v-divider />
|
|
|
|
<div
|
|
|
|
v-for="message in messages"
|
|
|
|
three-line
|
|
|
|
:key="messages.indexOf(message)"
|
2020-01-17 00:01:10 +00:00
|
|
|
>
|
2020-02-27 14:52:58 +00:00
|
|
|
<v-list-item three-line inactive @click="storno(message)">
|
|
|
|
<v-list-item-content>
|
|
|
|
<v-progress-linear indeterminate v-if="message.loading" />
|
|
|
|
<v-list-item-title>{{ now(message.date) }}</v-list-item-title>
|
|
|
|
<v-list-item-subtitle>{{ message.message }}</v-list-item-subtitle>
|
|
|
|
<v-list-item-subtitle class="red--text" v-if="message.storno"
|
|
|
|
>STORNIERT!!!</v-list-item-subtitle
|
|
|
|
>
|
|
|
|
<v-list-item-action-text
|
|
|
|
>Klicken um zu Stornieren
|
|
|
|
</v-list-item-action-text>
|
|
|
|
</v-list-item-content>
|
|
|
|
</v-list-item>
|
|
|
|
</div>
|
|
|
|
</v-list-item-group>
|
|
|
|
</v-navigation-drawer>
|
|
|
|
<v-card v-if="!loading" :loading="addLoading">
|
|
|
|
<v-card-title>
|
|
|
|
{{ user.firstname }} {{ user.lastname }}
|
|
|
|
<v-spacer />
|
2020-02-27 14:59:10 +00:00
|
|
|
<v-btn @click="menu = !menu" icon>
|
|
|
|
<v-icon>{{ menuIcon }}</v-icon>
|
|
|
|
</v-btn>
|
2020-02-27 14:52:58 +00:00
|
|
|
</v-card-title>
|
2020-01-17 00:01:10 +00:00
|
|
|
<v-card-text>
|
|
|
|
<v-row>
|
|
|
|
<v-col cols="10">
|
|
|
|
<v-row>
|
|
|
|
<v-col>
|
|
|
|
<v-btn
|
|
|
|
class="creditBtn"
|
|
|
|
block
|
|
|
|
@click="addAmount(200)"
|
|
|
|
:color="color"
|
|
|
|
:disabled="user.locked"
|
|
|
|
>2 €</v-btn
|
|
|
|
>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
|
|
|
<v-btn
|
|
|
|
class="creditBtn"
|
|
|
|
block
|
|
|
|
@click="addAmount(100)"
|
|
|
|
:color="color"
|
|
|
|
:disabled="user.locked"
|
|
|
|
>1 €</v-btn
|
|
|
|
>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
|
|
|
<v-btn
|
|
|
|
class="creditBtn"
|
|
|
|
block
|
|
|
|
@click="addAmount(50)"
|
|
|
|
:color="color"
|
|
|
|
:disabled="user.locked"
|
|
|
|
>0,50 €</v-btn
|
|
|
|
>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
<v-row>
|
|
|
|
<v-col>
|
|
|
|
<v-btn
|
|
|
|
class="creditBtn"
|
|
|
|
block
|
|
|
|
@click="addAmount(40)"
|
|
|
|
:color="color"
|
|
|
|
:disabled="user.locked"
|
|
|
|
>0,40 €</v-btn
|
|
|
|
>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
|
|
|
<v-btn
|
|
|
|
class="creditBtn"
|
|
|
|
block
|
|
|
|
@click="addAmount(20)"
|
|
|
|
:color="color"
|
|
|
|
:disabled="user.locked"
|
|
|
|
>0,20 €</v-btn
|
|
|
|
>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
|
|
|
<v-btn
|
|
|
|
class="creditBtn"
|
|
|
|
block
|
|
|
|
@click="addAmount(10)"
|
|
|
|
:color="color"
|
|
|
|
:disabled="user.locked"
|
|
|
|
>0,10 €</v-btn
|
|
|
|
>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-col>
|
|
|
|
<v-col align-self="center">
|
|
|
|
<v-row>
|
|
|
|
<v-list-item>
|
|
|
|
<v-list-item-action-text :class="getColor(getAllSum())"
|
|
|
|
>{{
|
|
|
|
(getAllSum() / 100).toFixed(2)
|
|
|
|
}}
|
|
|
|
€</v-list-item-action-text
|
|
|
|
>
|
|
|
|
</v-list-item>
|
|
|
|
</v-row>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
<v-alert v-if="user.locked" type="error"
|
|
|
|
>{{ user.firstname }} darf nicht mehr anschreiben.
|
|
|
|
{{ user.firstname }} sollte sich lieber mal beim Finanzer
|
|
|
|
melden.</v-alert
|
|
|
|
>
|
|
|
|
</v-card-text>
|
|
|
|
</v-card>
|
2020-02-27 14:52:58 +00:00
|
|
|
<v-snackbar
|
|
|
|
v-for="message in messages"
|
|
|
|
:key="messages.indexOf(message)"
|
|
|
|
:color="message.error ? 'error' : 'success'"
|
|
|
|
bottom
|
|
|
|
:timeout="3000"
|
|
|
|
:multi-line="true"
|
|
|
|
v-model="message.visible"
|
|
|
|
>
|
|
|
|
{{ message.message }}
|
|
|
|
</v-snackbar>
|
2020-01-17 00:01:10 +00:00
|
|
|
</v-container>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-02-27 14:52:58 +00:00
|
|
|
import { mapGetters, mapActions } from 'vuex'
|
2020-02-27 14:59:10 +00:00
|
|
|
import { mdiMenu } from '@mdi/js'
|
2020-02-27 14:52:58 +00:00
|
|
|
import AddAmountSkeleton from './Skeleton/AddAmountSkeleton'
|
2020-01-17 00:01:10 +00:00
|
|
|
export default {
|
|
|
|
name: 'AddAmount',
|
2020-01-23 22:25:21 +00:00
|
|
|
components: { AddAmountSkeleton },
|
2020-01-17 00:01:10 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2020-02-27 14:52:58 +00:00
|
|
|
color: 'green accent-4',
|
|
|
|
menu: false,
|
|
|
|
dialog: false,
|
|
|
|
componentRenderer: 0,
|
2020-02-27 14:59:10 +00:00
|
|
|
timer: '',
|
|
|
|
menuIcon: mdiMenu
|
2020-01-17 00:01:10 +00:00
|
|
|
}
|
|
|
|
},
|
2020-02-27 14:52:58 +00:00
|
|
|
created() {
|
|
|
|
this.timer = setInterval(this.forceRender, 1000)
|
|
|
|
},
|
2020-01-17 00:01:10 +00:00
|
|
|
methods: {
|
|
|
|
...mapActions({
|
2020-02-27 14:52:58 +00:00
|
|
|
addAmount: 'user/addAmount',
|
|
|
|
commitStorno: 'user/storno'
|
2020-01-17 00:01:10 +00:00
|
|
|
}),
|
2020-02-27 14:52:58 +00:00
|
|
|
forceRender() {
|
|
|
|
this.componentRenderer += 1
|
|
|
|
},
|
2020-01-17 00:01:10 +00:00
|
|
|
getColor(value) {
|
|
|
|
return value >= 0 ? 'title green--text' : 'title red--text'
|
|
|
|
},
|
|
|
|
getAllSum() {
|
2020-02-27 14:52:58 +00:00
|
|
|
console.log('getAllSum', this.user)
|
2020-01-17 00:01:10 +00:00
|
|
|
if (this.user)
|
2020-02-27 14:52:58 +00:00
|
|
|
return (
|
|
|
|
this.user.creditList[this.year][2].sum +
|
|
|
|
this.user.creditList[this.year][1].last
|
|
|
|
)
|
2020-01-17 00:01:10 +00:00
|
|
|
return 0
|
2020-02-27 14:52:58 +00:00
|
|
|
},
|
|
|
|
storno(message) {
|
|
|
|
console.log('storno')
|
|
|
|
if (!message.error) {
|
|
|
|
if (!this.under5minutes(message.date)) this.dialog = true
|
|
|
|
else {
|
|
|
|
this.commitStorno({
|
|
|
|
amount: message.amount,
|
|
|
|
date: message.date
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-01-17 00:01:10 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
user: 'user/user',
|
2020-01-23 22:25:21 +00:00
|
|
|
year: 'user/year',
|
2020-01-26 22:55:59 +00:00
|
|
|
loading: 'user/loading',
|
2020-02-27 14:52:58 +00:00
|
|
|
addLoading: 'user/addLoading',
|
|
|
|
messages: 'user/messages'
|
2020-01-17 00:01:10 +00:00
|
|
|
}),
|
2020-02-27 14:52:58 +00:00
|
|
|
under5minutes() {
|
|
|
|
return now => {
|
|
|
|
var actual = new Date()
|
|
|
|
var zero = new Date(0)
|
|
|
|
var date = new Date(actual - now)
|
|
|
|
if (
|
|
|
|
date.getFullYear() === zero.getFullYear() &&
|
|
|
|
date.getMonth() === zero.getMonth() &&
|
|
|
|
date.getDate() === zero.getDate()
|
|
|
|
) {
|
|
|
|
if (date.getMinutes() < 6) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
now() {
|
|
|
|
return now => {
|
|
|
|
var actual = new Date()
|
|
|
|
var zero = new Date(0)
|
|
|
|
var date = new Date(actual - now)
|
|
|
|
if (date.getFullYear() === zero.getFullYear()) {
|
|
|
|
if (date.getMonth() === zero.getMonth()) {
|
|
|
|
if (date.getDate() === zero.getDate()) {
|
|
|
|
if (date.getHours() === zero.getDate()) {
|
|
|
|
if (date.getMinutes() < 1) {
|
|
|
|
return 'vor ' + date.getSeconds() + ' Sekunden'
|
|
|
|
} else if (date.getMinutes() < 10) {
|
|
|
|
return 'vor ' + date.getMinutes() + ' Minuten'
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
(now.getHours() < 10 ? '0' : '') +
|
|
|
|
now.getHours() +
|
|
|
|
':' +
|
|
|
|
(now.getMinutes() < 10 ? '0' : '') +
|
|
|
|
now.getMinutes()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
(now.getHours() < 10 ? '0' : '') +
|
|
|
|
now.getHours() +
|
|
|
|
':' +
|
|
|
|
(now.getMinutes() < 10 ? '0' : '') +
|
|
|
|
now.getMinutes()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
now.getDate() +
|
|
|
|
'.' +
|
|
|
|
now.getMonth() +
|
|
|
|
'.' +
|
|
|
|
now.getFullYear() +
|
|
|
|
' ' +
|
|
|
|
(now.getHours() < 10 ? '0' : '') +
|
|
|
|
now.getHours() +
|
|
|
|
':' +
|
|
|
|
(now.getMinutes() < 10 ? '0' : '') +
|
|
|
|
now.getMinutes()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
clearInterval(this.timer)
|
2020-01-17 00:01:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|