2019-12-21 07:20:25 +00:00
|
|
|
<template>
|
2020-01-17 21:11:19 +00:00
|
|
|
<v-content>
|
2020-01-14 21:01:24 +00:00
|
|
|
<v-toolbar tile>
|
|
|
|
<v-toolbar-title>Gesamtübersicht</v-toolbar-title>
|
|
|
|
<v-spacer />
|
|
|
|
<v-toolbar-items>
|
|
|
|
<v-btn text icon @click="countYear(false)">
|
2020-01-26 22:55:59 +00:00
|
|
|
<v-icon>{{keyboard_arrow_left}}</v-icon>
|
2020-01-14 21:01:24 +00:00
|
|
|
</v-btn>
|
|
|
|
<v-list-item>
|
2020-01-14 22:10:09 +00:00
|
|
|
<v-list-item-title class="title">{{ year }}</v-list-item-title>
|
2020-01-14 21:01:24 +00:00
|
|
|
</v-list-item>
|
|
|
|
<v-btn text icon @click="countYear(true)" :disabled="isActualYear">
|
2020-01-26 22:55:59 +00:00
|
|
|
<v-icon>{{keyboard_arrow_right}}</v-icon>
|
2020-01-14 21:01:24 +00:00
|
|
|
</v-btn>
|
|
|
|
</v-toolbar-items>
|
|
|
|
<v-spacer />
|
|
|
|
<v-toolbar-items>
|
|
|
|
<v-btn text @click="sendMails">Emails senden</v-btn>
|
2020-01-17 21:11:19 +00:00
|
|
|
<v-autocomplete
|
2020-01-14 22:10:09 +00:00
|
|
|
outlined
|
2020-01-17 21:11:19 +00:00
|
|
|
return-object
|
|
|
|
v-model="user"
|
|
|
|
style="margin-top: 3px"
|
|
|
|
placeholder="Suche Person"
|
|
|
|
:items="allUsers"
|
|
|
|
item-text="fullName"
|
|
|
|
full-width
|
2020-01-23 22:25:21 +00:00
|
|
|
:loading="allUsersLoading"
|
2020-01-17 21:11:19 +00:00
|
|
|
:search-input.sync="filter"
|
2020-01-26 22:55:59 +00:00
|
|
|
>
|
|
|
|
<template v-slot:prepend-inner>
|
|
|
|
<v-icon>{{search_person}}</v-icon>
|
|
|
|
</template>
|
|
|
|
</v-autocomplete>
|
2020-01-17 21:11:19 +00:00
|
|
|
<v-btn
|
|
|
|
text
|
|
|
|
@click="addToUser(user)"
|
|
|
|
>Hinzufügen</v-btn
|
|
|
|
>
|
2020-01-14 21:01:24 +00:00
|
|
|
</v-toolbar-items>
|
|
|
|
</v-toolbar>
|
|
|
|
<v-expand-transition>
|
|
|
|
<v-card style="margin-top: 3px" v-show="errorMails">
|
|
|
|
<v-row>
|
|
|
|
<v-spacer />
|
|
|
|
<v-btn
|
|
|
|
text
|
|
|
|
icon
|
|
|
|
style="margin-right: 5px"
|
2020-01-14 22:10:09 +00:00
|
|
|
@click="errorExpand ? (errorExpand = false) : (errorExpand = true)"
|
2020-01-14 21:01:24 +00:00
|
|
|
>
|
|
|
|
<v-icon :class="isExpand(errorExpand)" dense>$expand</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
</v-row>
|
2020-01-05 13:17:06 +00:00
|
|
|
<v-expand-transition>
|
2020-01-14 21:01:24 +00:00
|
|
|
<div v-show="errorExpand">
|
|
|
|
<v-alert
|
|
|
|
v-for="error in errorMails"
|
|
|
|
:key="errorMails.indexOf(error)"
|
|
|
|
dense
|
|
|
|
:type="computeError(error.error)"
|
2020-01-14 22:10:09 +00:00
|
|
|
>{{ errorMessage(error) }}</v-alert
|
|
|
|
>
|
2020-01-14 21:01:24 +00:00
|
|
|
</div>
|
2020-01-05 13:17:06 +00:00
|
|
|
</v-expand-transition>
|
2020-01-14 21:01:24 +00:00
|
|
|
</v-card>
|
|
|
|
</v-expand-transition>
|
2020-01-26 11:55:39 +00:00
|
|
|
<v-progress-linear v-if="loading && users.length !== 0" indeterminate />
|
|
|
|
<TableSkeleton v-if="loading && users.length === 0" />
|
2020-01-14 21:01:24 +00:00
|
|
|
<div v-for="user in users" :key="users.indexOf(user)">
|
2020-01-14 22:10:09 +00:00
|
|
|
<v-card
|
|
|
|
v-if="user.creditList[year] && isFiltered(user)"
|
|
|
|
style="margin-top: 3px"
|
2020-01-23 22:25:21 +00:00
|
|
|
:loading="user.loading"
|
2020-01-14 22:10:09 +00:00
|
|
|
>
|
|
|
|
<v-card-title>{{ user.lastname }}, {{ user.firstname }}</v-card-title>
|
2020-01-14 21:01:24 +00:00
|
|
|
<Table v-bind:user="user" v-bind:year="year" />
|
|
|
|
<v-container fluid>
|
|
|
|
<v-row align="start" align-content="start">
|
|
|
|
<v-col>
|
|
|
|
<v-row>
|
|
|
|
<v-col>
|
|
|
|
<v-label>Vorjahr:</v-label>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
|
|
|
<v-chip
|
|
|
|
outlined
|
|
|
|
:text-color="getLastColor(user.creditList[year][1].last)"
|
2020-01-14 22:10:09 +00:00
|
|
|
>{{
|
|
|
|
(user.creditList[year][1].last / 100).toFixed(2)
|
|
|
|
}}</v-chip
|
|
|
|
>
|
2020-01-14 21:01:24 +00:00
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
<v-row>
|
|
|
|
<v-col>
|
|
|
|
<v-label>Gesamt:</v-label>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
|
|
|
<v-chip
|
|
|
|
outlined
|
|
|
|
x-large
|
2020-01-14 22:10:09 +00:00
|
|
|
:text-color="
|
|
|
|
getLastColor(
|
|
|
|
getAllSum(
|
|
|
|
user.creditList[year][2].sum,
|
|
|
|
user.creditList[year][1].last
|
|
|
|
)
|
|
|
|
)
|
|
|
|
"
|
2020-01-14 21:01:24 +00:00
|
|
|
>
|
2020-01-14 22:10:09 +00:00
|
|
|
{{
|
|
|
|
(
|
|
|
|
getAllSum(
|
|
|
|
user.creditList[year][2].sum,
|
|
|
|
user.creditList[year][1].last
|
|
|
|
) / 100
|
|
|
|
).toFixed(2)
|
|
|
|
}}
|
2020-01-14 21:01:24 +00:00
|
|
|
</v-chip>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-col>
|
|
|
|
<v-col align-self="center">
|
|
|
|
<v-row>
|
|
|
|
<v-col>
|
|
|
|
<v-label>Status:</v-label>
|
|
|
|
</v-col>
|
|
|
|
<v-col>
|
2020-01-14 22:10:09 +00:00
|
|
|
<v-chip outlined :text-color="getLockedColor(user.locked)">{{
|
|
|
|
user.locked ? 'Gesperrt' : 'nicht Gesperrt'
|
|
|
|
}}</v-chip>
|
2020-01-14 21:01:24 +00:00
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
<v-card outlined>
|
|
|
|
<v-row>
|
2020-01-14 22:10:09 +00:00
|
|
|
<v-card-title class="subtitle-2"
|
|
|
|
>Geld transferieren</v-card-title
|
|
|
|
>
|
2020-01-14 21:01:24 +00:00
|
|
|
<v-spacer />
|
2020-01-14 22:10:09 +00:00
|
|
|
<v-btn
|
|
|
|
text
|
|
|
|
icon
|
|
|
|
style="margin-right: 5px"
|
|
|
|
@click="setExpand(user)"
|
|
|
|
>
|
|
|
|
<v-icon :class="isExpand(user.expand)" dense
|
|
|
|
>$expand</v-icon
|
|
|
|
>
|
2020-01-14 21:01:24 +00:00
|
|
|
</v-btn>
|
|
|
|
</v-row>
|
|
|
|
<v-expand-transition>
|
|
|
|
<v-card-text v-show="user.expand">
|
|
|
|
<v-form style="margin-left: 15px; margin-right: 15px">
|
|
|
|
<v-row>
|
2019-12-26 09:31:36 +00:00
|
|
|
<v-col>
|
2020-01-14 22:10:09 +00:00
|
|
|
<v-text-field
|
|
|
|
:rules="[isNumber]"
|
|
|
|
label="Betrag"
|
|
|
|
v-model="amount"
|
|
|
|
></v-text-field>
|
2019-12-26 09:31:36 +00:00
|
|
|
</v-col>
|
2020-01-14 21:01:24 +00:00
|
|
|
<v-col>
|
|
|
|
<v-select
|
|
|
|
return-object
|
|
|
|
v-model="type"
|
|
|
|
label="Typ"
|
2020-01-14 22:10:09 +00:00
|
|
|
:items="[
|
|
|
|
{ value: 'amount', text: 'Schulden' },
|
|
|
|
{ value: 'credit', text: 'Guthaben' }
|
|
|
|
]"
|
2020-01-14 21:01:24 +00:00
|
|
|
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="years"
|
|
|
|
item-text="text"
|
|
|
|
item-value="value"
|
|
|
|
></v-select>
|
2019-12-26 09:31:36 +00:00
|
|
|
</v-col>
|
2020-01-14 21:01:24 +00:00
|
|
|
<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(user)">Hinzufügen</v-btn>
|
|
|
|
</v-card-text>
|
|
|
|
</v-expand-transition>
|
|
|
|
</v-card>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-container>
|
|
|
|
</v-card>
|
2019-12-26 09:31:36 +00:00
|
|
|
</div>
|
2020-01-17 21:11:19 +00:00
|
|
|
</v-content>
|
2019-12-21 07:20:25 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-01-14 21:01:24 +00:00
|
|
|
import Table from './Table'
|
|
|
|
import { mapGetters, mapActions } from 'vuex'
|
2020-01-23 22:25:21 +00:00
|
|
|
import TableSkeleton from './Skeleton/TableSkeleton'
|
2020-01-26 22:55:59 +00:00
|
|
|
import {mdiChevronLeft, mdiChevronRight, mdiAccountSearch} from '@mdi/js'
|
2020-01-14 21:01:24 +00:00
|
|
|
export default {
|
|
|
|
name: 'Overview',
|
2020-01-23 22:25:21 +00:00
|
|
|
components: { TableSkeleton, Table },
|
2020-01-14 21:01:24 +00:00
|
|
|
props: {},
|
|
|
|
data() {
|
|
|
|
return {
|
2020-01-26 22:55:59 +00:00
|
|
|
keyboard_arrow_left: mdiChevronLeft,
|
|
|
|
keyboard_arrow_right: mdiChevronRight,
|
|
|
|
search_person: mdiAccountSearch,
|
2020-01-14 21:01:24 +00:00
|
|
|
errorExpand: false,
|
2020-01-05 13:17:06 +00:00
|
|
|
|
2020-01-14 21:01:24 +00:00
|
|
|
filter: '',
|
2020-01-17 21:11:19 +00:00
|
|
|
user: null,
|
2019-12-26 09:31:36 +00:00
|
|
|
|
2020-01-14 21:01:24 +00:00
|
|
|
amount: null,
|
|
|
|
isNumber: value => !isNaN(value) || 'Betrag muss eine Zahl sein.',
|
|
|
|
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()]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2020-01-14 22:10:09 +00:00
|
|
|
created() {},
|
2020-01-14 21:01:24 +00:00
|
|
|
methods: {
|
|
|
|
...mapActions({
|
|
|
|
createYears: 'finanzerUsers/createYears',
|
|
|
|
addAmount: 'finanzerUsers/addAmount',
|
|
|
|
addCredit: 'finanzerUsers/addCredit',
|
|
|
|
countYear: 'finanzerUsers/countYear',
|
2020-01-17 21:11:19 +00:00
|
|
|
sendMails: 'finanzerUsers/sendMails',
|
|
|
|
addUser: 'finanzerUsers/addUser'
|
2020-01-14 21:01:24 +00:00
|
|
|
}),
|
|
|
|
async getData(promise) {
|
|
|
|
return await promise
|
|
|
|
},
|
|
|
|
getLastColor(value) {
|
|
|
|
return value < 0 ? 'red' : 'green'
|
|
|
|
},
|
|
|
|
getAllSum(sum, lastYear) {
|
|
|
|
return lastYear + sum
|
|
|
|
},
|
|
|
|
getLockedColor(value) {
|
|
|
|
return value ? 'red' : 'green'
|
|
|
|
},
|
|
|
|
computeError(error) {
|
|
|
|
if (error) return 'error'
|
|
|
|
else return 'success'
|
|
|
|
},
|
|
|
|
errorMessage(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.'
|
|
|
|
)
|
|
|
|
},
|
|
|
|
setExpand(user) {
|
|
|
|
user.expand ? (user.expand = false) : (user.expand = true)
|
|
|
|
},
|
|
|
|
isExpand(value) {
|
|
|
|
return value ? 'rotate' : ''
|
|
|
|
},
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
add(user) {
|
|
|
|
if (this.type.value === 'amount') {
|
|
|
|
this.addAmount({
|
|
|
|
user: user,
|
|
|
|
amount: this.amount,
|
|
|
|
year: this.selectedYear.value,
|
|
|
|
month: this.selectedMonth.value
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (this.type.value === 'credit') {
|
|
|
|
this.addCredit({
|
|
|
|
user: user,
|
|
|
|
credit: this.amount,
|
|
|
|
year: this.selectedYear.value,
|
|
|
|
month: this.selectedMonth.value
|
|
|
|
})
|
|
|
|
}
|
2019-12-26 09:31:36 +00:00
|
|
|
|
2020-01-14 21:01:24 +00:00
|
|
|
this.createDefault(
|
|
|
|
this.amount,
|
|
|
|
this.type,
|
|
|
|
this.selectedYear,
|
|
|
|
this.selectedMonth
|
|
|
|
)
|
|
|
|
},
|
|
|
|
isFiltered(user) {
|
2020-01-17 21:11:19 +00:00
|
|
|
try {
|
|
|
|
return (
|
|
|
|
user.firstname.toLowerCase().includes(this.filter.toLowerCase()) ||
|
|
|
|
user.lastname.toLowerCase().includes(this.filter.toLowerCase())
|
|
|
|
)
|
|
|
|
} catch (e) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
addToUser(user) {
|
|
|
|
this.addUser(user)
|
|
|
|
this.$router.push({name: 'activeUser', params: {id: user.username}})
|
2020-01-14 21:01:24 +00:00
|
|
|
},
|
|
|
|
createDefault() {
|
|
|
|
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()]
|
|
|
|
}
|
2019-12-21 07:20:25 +00:00
|
|
|
}
|
2020-01-14 21:01:24 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isActualYear() {
|
|
|
|
return this.year === new Date().getFullYear()
|
|
|
|
},
|
|
|
|
...mapGetters({
|
|
|
|
users: 'finanzerUsers/users',
|
2020-01-17 21:11:19 +00:00
|
|
|
allUsers: 'finanzerUsers/allUsers',
|
2020-01-14 21:01:24 +00:00
|
|
|
errorMails: 'finanzerUsers/errorMails',
|
|
|
|
year: 'finanzerUsers/year',
|
|
|
|
years: 'finanzerUsers/years',
|
2020-01-23 22:25:21 +00:00
|
|
|
months: 'finanzerUsers/months',
|
|
|
|
loading: 'finanzerUsers/usersLoading',
|
|
|
|
allUsersLoading: 'finanzerUsers/allUsersLoading'
|
2020-01-14 21:01:24 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2019-12-21 07:20:25 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2020-01-14 21:01:24 +00:00
|
|
|
.rotate {
|
|
|
|
transform: rotate(180deg);
|
|
|
|
}
|
2019-12-21 07:20:25 +00:00
|
|
|
</style>
|