2019-12-26 09:31:36 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<v-toolbar tile>
|
2020-01-14 17:20:05 +00:00
|
|
|
<v-toolbar-title>{{activeUser.lastname}}, {{activeUser.firstname}}</v-toolbar-title>
|
2020-01-05 13:17:06 +00:00
|
|
|
<v-spacer/>
|
|
|
|
<v-toolbar-items>
|
2020-01-14 17:20:05 +00:00
|
|
|
<v-btn @click="sendMail({username: activeUser.username})" text>Email senden</v-btn>
|
2020-01-05 13:17:06 +00:00
|
|
|
</v-toolbar-items>
|
2019-12-26 09:31:36 +00:00
|
|
|
</v-toolbar>
|
2020-01-05 13:17:06 +00:00
|
|
|
<v-expand-transition>
|
2020-01-14 17:20:05 +00:00
|
|
|
<v-card style="margin-top: 3px" v-show="errorMail">
|
|
|
|
<v-alert dense :type="computeError(errorMail)">
|
|
|
|
{{errorMessage(errorMail)}}
|
2020-01-05 13:17:06 +00:00
|
|
|
</v-alert>
|
|
|
|
</v-card>
|
|
|
|
</v-expand-transition>
|
2019-12-29 11:37:46 +00:00
|
|
|
<v-card style="margin-top: 3px;">
|
|
|
|
<v-card-title>Konfiguration</v-card-title>
|
|
|
|
<v-card-text>
|
|
|
|
<v-form style="margin-left: 15px; margin-right: 15px">
|
|
|
|
<v-row>
|
|
|
|
<v-col>
|
|
|
|
<v-label>Status: </v-label>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
2020-01-14 17:20:05 +00:00
|
|
|
<v-chip outlined :text-color="getLockedColor(activeUser.locked)">{{activeUser.locked ? 'Gesperrt': 'nicht Gesperrt'}}</v-chip>
|
2019-12-29 11:37:46 +00:00
|
|
|
</v-col>
|
|
|
|
<v-col>
|
2020-01-14 17:20:05 +00:00
|
|
|
<v-btn @click="doLock({user: activeUser, locked: !activeUser.locked})">{{activeUser.locked ? 'Entperren' : 'Sperren'}}</v-btn>
|
2019-12-29 11:37:46 +00:00
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
<v-divider style="margin-bottom: 15px;"/>
|
|
|
|
<v-row>
|
|
|
|
<v-col>
|
|
|
|
<v-text-field :rules="[isNumber]" label="Betrag des Sperrlimits in € (EURO)" v-model="limit"></v-text-field>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
|
|
|
<v-select return-object v-model="autoLock" label="Automatische Sperre" :items="[{value: true, text: 'Aktiviert'}, {value: false, text: 'Deaktiviert'}]"
|
|
|
|
item-text="text" item-value="value"/>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
<v-row>
|
2020-01-14 17:20:05 +00:00
|
|
|
<v-btn block @click="saveConfig({user: activeUser, limit: limit, autoLock: autoLock.value})">Speichern</v-btn>
|
2019-12-29 11:37:46 +00:00
|
|
|
</v-row>
|
|
|
|
</v-form>
|
|
|
|
</v-card-text>
|
|
|
|
</v-card>
|
2019-12-29 20:35:32 +00:00
|
|
|
<v-card style="margin-top: 3px;">
|
|
|
|
<v-card-title>Geld transferieren</v-card-title>
|
|
|
|
<v-card-text>
|
|
|
|
<v-form style="margin-left: 15px; margin-right: 15px">
|
|
|
|
<v-row>
|
|
|
|
<v-col>
|
|
|
|
<v-text-field :rules="[isNumber]" label="Betrag"
|
|
|
|
v-model="amount"></v-text-field>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
|
|
|
<v-select return-object v-model="type" label="Typ"
|
|
|
|
:items="[{value: 'amount', text: 'Schulden'}, {value: 'credit', text: 'Guthaben'}]"
|
|
|
|
item-text="text" item-value="value"></v-select>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
<v-row>
|
|
|
|
<v-col>
|
|
|
|
<v-select return-object v-model="selectedYear" label="Jahr"
|
|
|
|
:items="selectYears" item-text="text"
|
|
|
|
item-value="value"></v-select>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
|
|
|
<v-select return-object v-model="selectedMonth" label="Monat"
|
|
|
|
:items="months" item-text="text"
|
|
|
|
item-value="value"></v-select>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-form>
|
|
|
|
<v-btn block @click="add">Hinzufügen</v-btn>
|
|
|
|
</v-card-text>
|
|
|
|
</v-card>
|
2019-12-26 09:31:36 +00:00
|
|
|
<div v-for="year in years" :key="years.indexOf(year)">
|
|
|
|
<v-card style="margin-top: 3px;">
|
|
|
|
<v-card-title>{{year}}</v-card-title>
|
2020-01-14 17:20:05 +00:00
|
|
|
<Table v-bind:user="activeUser" v-bind:year="year"/>
|
2019-12-26 09:31:36 +00:00
|
|
|
<v-container fluid>
|
|
|
|
<v-col>
|
|
|
|
<v-row>
|
|
|
|
<v-col>
|
|
|
|
<v-label>Vorjahr:</v-label>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
2020-01-14 17:20:05 +00:00
|
|
|
<v-chip outlined :text-color="getLastColor(activeUser.creditList[year][1].last)">
|
|
|
|
{{(activeUser.creditList[year][1].last / 100).toFixed(2)}}
|
2019-12-26 09:31:36 +00:00
|
|
|
</v-chip>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
|
|
|
<v-label>Gesamt:</v-label>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
|
|
|
<v-chip outlined x-large
|
2020-01-14 17:20:05 +00:00
|
|
|
:text-color="getLastColor(getAllSum(activeUser.creditList[year][2].sum ,activeUser.creditList[year][1].last))">
|
|
|
|
{{(getAllSum(activeUser.creditList[year][2].sum ,activeUser.creditList[year][1].last) /
|
2019-12-26 09:31:36 +00:00
|
|
|
100).toFixed(2)}}
|
|
|
|
</v-chip>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-col>
|
|
|
|
</v-container>
|
|
|
|
</v-card>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Table from "./Table";
|
2020-01-14 17:20:05 +00:00
|
|
|
import {mapGetters, mapActions} from 'vuex';
|
2019-12-26 09:31:36 +00:00
|
|
|
export default {
|
|
|
|
name: "User",
|
|
|
|
components: {Table},
|
|
|
|
data () {
|
|
|
|
return {
|
2019-12-29 11:37:46 +00:00
|
|
|
isNumber: value => !isNaN(value) || 'Betrag muss eine Zahl sein.',
|
|
|
|
limit: null,
|
|
|
|
autoLock: null,
|
2019-12-29 20:35:32 +00:00
|
|
|
amount: null,
|
|
|
|
type: {value: 'credit', text: 'Guthaben'},
|
|
|
|
selectedYear: {value: new Date().getFullYear(), text: new Date().getFullYear()},
|
|
|
|
selectedMonth: {value: new Date().getMonth() + 1, text: ["Januar", "Februar", "März", "April", "Mai", "Juni",
|
|
|
|
"Juli", "August", "September", "Oktober", "November", "Dezember"
|
|
|
|
][new Date().getMonth()]}
|
2019-12-29 11:37:46 +00:00
|
|
|
|
2019-12-26 09:31:36 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
2020-01-14 17:20:05 +00:00
|
|
|
this.limit = (this.activeUser.limit / 100).toFixed(2)
|
|
|
|
this.autoLock = {value: this.activeUser.autoLock, text: this.activeUser.autoLock? "Aktiviert" : "Deaktiviert"}
|
2019-12-26 09:31:36 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2020-01-14 17:20:05 +00:00
|
|
|
...mapActions(['finanzerUsers/addAmount', 'finanzerUsers/addCredit', 'finanzerUsers/sendMail', 'finanzerUsers/doLock', 'finanzerUsers/saveConfig']),
|
2019-12-26 09:31:36 +00:00
|
|
|
getLastColor (value) {
|
|
|
|
return value < 0 ? 'red' : 'green'
|
|
|
|
},
|
|
|
|
getAllSum(sum, lastYear) {
|
|
|
|
return lastYear + sum
|
|
|
|
},
|
2019-12-29 11:37:46 +00:00
|
|
|
getLockedColor (value) {
|
|
|
|
return value ? 'red' : 'green'
|
|
|
|
},
|
2019-12-29 20:35:32 +00:00
|
|
|
add() {
|
|
|
|
if (this.type.value === 'amount') {
|
2020-01-14 17:20:05 +00:00
|
|
|
this.addAmount( {user: this.activeUser, amount: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
2019-12-29 20:35:32 +00:00
|
|
|
}
|
|
|
|
if (this.type.value === 'credit') {
|
2020-01-14 17:20:05 +00:00
|
|
|
this.addCredit({user: this.activeUser, credit: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
2019-12-29 20:35:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.createDefault()
|
|
|
|
|
|
|
|
},
|
|
|
|
createDefault() {
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
let year = new Date().getFullYear()
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
let month = new Date().getMonth()
|
|
|
|
this.amount = null
|
|
|
|
this.type = {value: 'credit', text: 'Guthaben'}
|
|
|
|
this.selectedYear = {value: new Date().getFullYear(), text: new Date().getFullYear()}
|
|
|
|
this.selectedMonth = {value: new Date().getMonth() + 1, text: ["Januar", "Februar", "März", "April", "Mai", "Juni",
|
|
|
|
"Juli", "August", "September", "Oktober", "November", "Dezember"
|
|
|
|
][new Date().getMonth()]}
|
2020-01-05 13:17:06 +00:00
|
|
|
},
|
|
|
|
computeError(error) {
|
|
|
|
if (error) {
|
|
|
|
if (error.error) return 'error'
|
|
|
|
else return 'success'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
errorMessage(error) {
|
|
|
|
if (error) {
|
|
|
|
if (error.error) return 'Konnte Email an ' + error.user.firstname + ' ' + error.user.lastname + ' nicht senden!'
|
|
|
|
else return 'Email wurde an ' + error.user.firstname + ' ' + error.user.lastname + ' versandt.'
|
|
|
|
}
|
2019-12-29 11:37:46 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
years() {
|
|
|
|
let years = []
|
2020-01-14 17:20:05 +00:00
|
|
|
for (let year in this.activeUser.creditList) {
|
2019-12-29 11:37:46 +00:00
|
|
|
years.unshift(parseInt(year))
|
|
|
|
}
|
|
|
|
return years
|
2020-01-14 17:20:05 +00:00
|
|
|
},
|
|
|
|
...mapGetters({activeUser: 'finanzerUsers/activeUser',
|
|
|
|
errorMail: 'finanzerUsers/errorMail',
|
|
|
|
months: 'finanzerUsers/months',
|
|
|
|
selectYears: 'finanzerUsers/selectYears'})
|
2019-12-29 11:37:46 +00:00
|
|
|
},
|
|
|
|
watch: {
|
2020-01-14 17:20:05 +00:00
|
|
|
activeUser(newVal) {
|
2019-12-29 11:37:46 +00:00
|
|
|
this.limit = (newVal.limit / 100).toFixed(2)
|
|
|
|
this.autoLock = {value: newVal.autoLock, text: newVal.autoLock? "Aktiviert" : "Deaktiviert"}
|
|
|
|
}
|
2019-12-26 09:31:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
</style>
|