Merge branch 'develop' of 192.168.5.2:newgeruecht-vue into develop
This commit is contained in:
commit
40fdb109a6
|
@ -11,17 +11,17 @@
|
||||||
<v-col cols="10">
|
<v-col cols="10">
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-btn class="creditBtn" block @click="addAmount(user.username, 200)"
|
<v-btn class="creditBtn" block @click="addAmount({username: user.username, amount: 200})"
|
||||||
:color="color" :disabled="user.locked">2 €
|
:color="color" :disabled="user.locked">2 €
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-btn class="creditBtn" block @click="addAmount(user.username, 100)"
|
<v-btn class="creditBtn" block @click="addAmount({username: user.username, amount: 100})"
|
||||||
:color="color" :disabled="user.locked">1 €
|
:color="color" :disabled="user.locked">1 €
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-btn class="creditBtn" block @click="addAmount(user.username, 50)"
|
<v-btn class="creditBtn" block @click="addAmount({username: user.username, amount: 50})"
|
||||||
:color="color" :disabled="user.locked">
|
:color="color" :disabled="user.locked">
|
||||||
0,50 €
|
0,50 €
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
@ -29,19 +29,19 @@
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-btn class="creditBtn" block @click="addAmount(user.username, 40)"
|
<v-btn class="creditBtn" block @click="addAmount({username:user.username, amount: 40})"
|
||||||
:color="color" :disabled="user.locked">
|
:color="color" :disabled="user.locked">
|
||||||
0,40 €
|
0,40 €
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-btn class="creditBtn" block @click="addAmount(user.username, 20)"
|
<v-btn class="creditBtn" block @click="addAmount({username: user.username, amount: 20})"
|
||||||
:color="color" :disabled="user.locked">
|
:color="color" :disabled="user.locked">
|
||||||
0,20 €
|
0,20 €
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-btn class="creditBtn" block @click="addAmount(user.username, 10)"
|
<v-btn class="creditBtn" block @click="addAmount({username: user.username, amount: 10})"
|
||||||
:color="color" :disabled="user.locked">
|
:color="color" :disabled="user.locked">
|
||||||
0,10 €
|
0,10 €
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
@ -67,30 +67,35 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "CreditLists",
|
name: "CreditLists",
|
||||||
props: {
|
props: {
|
||||||
users: Array
|
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
color: 'green accent-4'
|
color: 'green accent-4',
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.getUsers()
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(this.users)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addAmount(username, amount) {
|
...mapActions({
|
||||||
this.$emit("add:amount", username, amount)
|
addAmount: 'barUsers/addAmount',
|
||||||
},
|
getUsers: 'barUsers/getUsers'
|
||||||
|
}),
|
||||||
getColor(type) {
|
getColor(type) {
|
||||||
return type === 'credit' ? 'title green--text' : 'title red--text'
|
return type === 'credit' ? 'title green--text' : 'title red--text'
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapGetters({users: 'barUsers/users'})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import httpClient from "../../plugins/restService";
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "SearchBar",
|
name: "SearchBar",
|
||||||
|
@ -22,37 +22,25 @@
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
hover: false,
|
|
||||||
focus: false,
|
|
||||||
item_size: 32,
|
|
||||||
searchString: '',
|
|
||||||
test: [],
|
|
||||||
allUsers: [],
|
|
||||||
user: null,
|
user: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.hasFocus()
|
this.getAllUsers()
|
||||||
},
|
},
|
||||||
methods : {
|
methods : {
|
||||||
mop () {
|
...mapActions({
|
||||||
},
|
getAllUsers: 'barUsers/getAllUsers',
|
||||||
hasFocus () {
|
addCreditList: 'barUsers/addCreditList'
|
||||||
httpClient.searchUser(this.$store.getters.getToken, {searchString: this.searchString})
|
}),
|
||||||
.then(response => {
|
|
||||||
this.allUsers = response.data
|
|
||||||
|
|
||||||
for (let i = 0; i < this.allUsers.length; i++) {
|
|
||||||
this.allUsers[i].fullName = this.allUsers[i].firstname + " " + this.allUsers[i].lastname
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
addUser() {
|
addUser() {
|
||||||
this.$emit("add:creditList", this.user)
|
this.addCreditList(this.user)
|
||||||
this.user = null
|
this.user = null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapGetters({ allUsers: 'barUsers/allUsers'}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -2,19 +2,40 @@
|
||||||
<div>
|
<div>
|
||||||
<v-toolbar tile>
|
<v-toolbar tile>
|
||||||
<v-toolbar-title>Gesamtübersicht</v-toolbar-title>
|
<v-toolbar-title>Gesamtübersicht</v-toolbar-title>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer/>
|
||||||
<v-toolbar-items>
|
<v-toolbar-items>
|
||||||
<v-btn text icon @click="year--"><v-icon>keyboard_arrow_left</v-icon></v-btn>
|
<v-btn text icon @click="countYear(false)"><v-icon>keyboard_arrow_left</v-icon></v-btn>
|
||||||
<v-list-item><v-list-item-title class="title">{{year}}</v-list-item-title></v-list-item>
|
<v-list-item><v-list-item-title class="title">{{year}}</v-list-item-title></v-list-item>
|
||||||
<v-btn text icon @click="year++" :disabled="isActualYear"><v-icon>keyboard_arrow_right</v-icon></v-btn>
|
<v-btn text icon @click="countYear(true)" :disabled="isActualYear"><v-icon>keyboard_arrow_right</v-icon></v-btn>
|
||||||
</v-toolbar-items>
|
</v-toolbar-items>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer/>
|
||||||
<v-toolbar-items>
|
<v-toolbar-items>
|
||||||
<v-text-field v-model="filter" @input="filterUser" style="margin-top: 3px" append-icon="search" outlined></v-text-field>
|
<v-btn text @click="sendMails">Emails senden</v-btn>
|
||||||
|
<v-text-field v-model="filter" style="margin-top: 3px" append-icon="search" outlined></v-text-field>
|
||||||
</v-toolbar-items>
|
</v-toolbar-items>
|
||||||
</v-toolbar>
|
</v-toolbar>
|
||||||
<div v-for="user in filteredUsers" :key="filteredUsers.indexOf(user)">
|
<v-expand-transition>
|
||||||
<v-card v-if="user.creditList[year]"
|
<v-card style="margin-top: 3px" v-show="errorMails">
|
||||||
|
<v-row>
|
||||||
|
<v-spacer/>
|
||||||
|
<v-btn text icon style="margin-right: 5px"
|
||||||
|
@click="errorExpand ? errorExpand = false : errorExpand = true">
|
||||||
|
<v-icon :class="isExpand(errorExpand)" dense>$expand</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-row>
|
||||||
|
<v-expand-transition>
|
||||||
|
<div v-show="errorExpand">
|
||||||
|
<v-alert v-for="error in errorMails" :key="errorMails.indexOf(error)"
|
||||||
|
dense
|
||||||
|
:type="computeError(error.error)"
|
||||||
|
>{{errorMessage(error)}}
|
||||||
|
</v-alert>
|
||||||
|
</div>
|
||||||
|
</v-expand-transition>
|
||||||
|
</v-card>
|
||||||
|
</v-expand-transition>
|
||||||
|
<div v-for="user in users" :key="users.indexOf(user)">
|
||||||
|
<v-card v-if="user.creditList[year] && isFiltered(user)"
|
||||||
style="margin-top: 3px">
|
style="margin-top: 3px">
|
||||||
<v-card-title>{{user.lastname}}, {{user.firstname}}</v-card-title>
|
<v-card-title>{{user.lastname}}, {{user.firstname}}</v-card-title>
|
||||||
<Table v-bind:user="user" v-bind:year="year"/>
|
<Table v-bind:user="user" v-bind:year="year"/>
|
||||||
|
@ -102,36 +123,21 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Table from "./Table";
|
import Table from "./Table";
|
||||||
|
import { mapGetters, mapActions } from 'vuex'
|
||||||
export default {
|
export default {
|
||||||
name: "Overview",
|
name: "Overview",
|
||||||
components: {Table},
|
components: {Table},
|
||||||
props: {
|
props: {
|
||||||
users: Array,
|
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
year: new Date().getFullYear(),
|
errorExpand: false,
|
||||||
|
|
||||||
filter: "",
|
filter: "",
|
||||||
filteredUsers: [],
|
|
||||||
|
|
||||||
amount: null,
|
amount: null,
|
||||||
isNumber: value => !isNaN(value) || 'Betrag muss eine Zahl sein.',
|
isNumber: value => !isNaN(value) || 'Betrag muss eine Zahl sein.',
|
||||||
years: [],
|
|
||||||
months: [
|
|
||||||
{value: 1, text: 'Januar'},
|
|
||||||
{value: 2, text: 'Februar'},
|
|
||||||
{value: 3, text: 'März'},
|
|
||||||
{value: 4, text:'April'},
|
|
||||||
{value: 5, text: 'Mai'},
|
|
||||||
{value: 6, text: 'Juni'},
|
|
||||||
{value: 7, text: 'Juli'},
|
|
||||||
{value: 8, text: 'August'},
|
|
||||||
{value: 9, text: 'September'},
|
|
||||||
{value: 10, text: 'Oktober'},
|
|
||||||
{value: 11, text: 'November'},
|
|
||||||
{value: 12, text: 'Dezember'}
|
|
||||||
],
|
|
||||||
type: {value: 'credit', text: 'Guthaben'},
|
type: {value: 'credit', text: 'Guthaben'},
|
||||||
selectedYear: {value: new Date().getFullYear(), text: new Date().getFullYear()},
|
selectedYear: {value: new Date().getFullYear(), text: new Date().getFullYear()},
|
||||||
selectedMonth: {value: new Date().getMonth() + 1, text: ["Januar", "Februar", "März", "April", "Mai", "Juni",
|
selectedMonth: {value: new Date().getMonth() + 1, text: ["Januar", "Februar", "März", "April", "Mai", "Juni",
|
||||||
|
@ -140,21 +146,35 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.createYears();
|
// eslint-disable-next-line no-console
|
||||||
this.filteredUsers = this.users
|
console.log(this.getData(this.createYears()))
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapActions({createYears: 'finanzerUsers/createYears',
|
||||||
|
addAmount: 'finanzerUsers/addAmount',
|
||||||
|
addCredit: 'finanzerUsers/addCredit',
|
||||||
|
countYear: 'finanzerUsers/countYear',
|
||||||
|
sendMails: 'finanzerUsers/sendMails'}),
|
||||||
|
async getData(promise) {
|
||||||
|
return await promise
|
||||||
|
},
|
||||||
getLastColor (value) {
|
getLastColor (value) {
|
||||||
return value < 0 ? 'red' : 'green'
|
return value < 0 ? 'red' : 'green'
|
||||||
},
|
},
|
||||||
getAllSum(sum, lastYear) {
|
getAllSum(sum, lastYear) {
|
||||||
return lastYear + sum
|
return lastYear + sum
|
||||||
},
|
},
|
||||||
createYears() {
|
getLockedColor (value) {
|
||||||
for (let year = new Date().getFullYear(); year >= 2000; year--) {
|
return value ? 'red' : 'green'
|
||||||
this.years.push({value: year, text: year})
|
},
|
||||||
}
|
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) {
|
setExpand(user) {
|
||||||
user.expand ? user.expand=false : user.expand=true
|
user.expand ? user.expand=false : user.expand=true
|
||||||
|
@ -165,20 +185,19 @@
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
add(user) {
|
add(user) {
|
||||||
if (this.type.value === 'amount') {
|
if (this.type.value === 'amount') {
|
||||||
this.$emit("add:amount", {user: user, amount: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
this.addAmount({user: user, amount: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
||||||
}
|
}
|
||||||
if (this.type.value === 'credit') {
|
if (this.type.value === 'credit') {
|
||||||
this.$emit("add:credit", {user: user, credit: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
this.addCredit( {user: user, credit: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.createDefault()
|
this.createDefault(this.amount, this.type, this.selectedYear, this.selectedMonth)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
isFiltered(user) {
|
||||||
|
return user.firstname.toLowerCase().includes(this.filter.toLowerCase()) || user.lastname.toLowerCase().includes(this.filter.toLowerCase())
|
||||||
|
},
|
||||||
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.amount = null
|
||||||
this.type = {value: 'credit', text: 'Guthaben'}
|
this.type = {value: 'credit', text: 'Guthaben'}
|
||||||
this.selectedYear = {value: new Date().getFullYear(), text: new Date().getFullYear()}
|
this.selectedYear = {value: new Date().getFullYear(), text: new Date().getFullYear()}
|
||||||
|
@ -186,22 +205,16 @@
|
||||||
"Juli", "August", "September", "Oktober", "November", "Dezember"
|
"Juli", "August", "September", "Oktober", "November", "Dezember"
|
||||||
][new Date().getMonth()]}
|
][new Date().getMonth()]}
|
||||||
},
|
},
|
||||||
filterUser() {
|
|
||||||
if (this.filter === "") {
|
|
||||||
this.filteredUsers = this.users
|
|
||||||
}
|
|
||||||
this.filteredUsers = [...this.filteredUsers.filter(user => {
|
|
||||||
return user.firstname.toLowerCase().includes(this.filter.toLowerCase()) || user.lastname.toLowerCase().includes(this.filter.toLowerCase())
|
|
||||||
})]
|
|
||||||
},
|
|
||||||
getLockedColor (value) {
|
|
||||||
return value ? 'red' : 'green'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isActualYear() {
|
isActualYear() {
|
||||||
return this.year === new Date().getFullYear()
|
return this.year === new Date().getFullYear()
|
||||||
}
|
},
|
||||||
|
...mapGetters({users: 'finanzerUsers/users',
|
||||||
|
errorMails: 'finanzerUsers/errorMails',
|
||||||
|
year: 'finanzerUsers/year',
|
||||||
|
years: 'finanzerUsers/years',
|
||||||
|
months: 'finanzerUsers/months'})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,19 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<v-toolbar tile>
|
<v-toolbar tile>
|
||||||
<v-toolbar-title>{{user.lastname}}, {{user.firstname}}</v-toolbar-title>
|
<v-toolbar-title>{{activeUser.lastname}}, {{activeUser.firstname}}</v-toolbar-title>
|
||||||
|
<v-spacer/>
|
||||||
|
<v-toolbar-items>
|
||||||
|
<v-btn @click="sendMail({username: activeUser.username})" text>Email senden</v-btn>
|
||||||
|
</v-toolbar-items>
|
||||||
</v-toolbar>
|
</v-toolbar>
|
||||||
|
<v-expand-transition>
|
||||||
|
<v-card style="margin-top: 3px" v-show="errorMail">
|
||||||
|
<v-alert dense :type="computeError(errorMail)">
|
||||||
|
{{errorMessage(errorMail)}}
|
||||||
|
</v-alert>
|
||||||
|
</v-card>
|
||||||
|
</v-expand-transition>
|
||||||
<v-card style="margin-top: 3px;">
|
<v-card style="margin-top: 3px;">
|
||||||
<v-card-title>Konfiguration</v-card-title>
|
<v-card-title>Konfiguration</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
|
@ -12,10 +23,10 @@
|
||||||
<v-label>Status: </v-label>
|
<v-label>Status: </v-label>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-chip outlined :text-color="getLockedColor(user.locked)">{{user.locked ? 'Gesperrt': 'nicht Gesperrt'}}</v-chip>
|
<v-chip outlined :text-color="getLockedColor(activeUser.locked)">{{activeUser.locked ? 'Gesperrt': 'nicht Gesperrt'}}</v-chip>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-btn @click="lock">{{user.locked ? 'Entperren' : 'Sperren'}}</v-btn>
|
<v-btn @click="doLock({user: activeUser, locked: !activeUser.locked})">{{activeUser.locked ? 'Entperren' : 'Sperren'}}</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-divider style="margin-bottom: 15px;"/>
|
<v-divider style="margin-bottom: 15px;"/>
|
||||||
|
@ -29,7 +40,7 @@
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-btn block @click="saveConfig">Speichern</v-btn>
|
<v-btn block @click="saveConfig({user: activeUser, limit: limit, autoLock: autoLock.value})">Speichern</v-btn>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-form>
|
</v-form>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
@ -68,7 +79,7 @@
|
||||||
<div v-for="year in years" :key="years.indexOf(year)">
|
<div v-for="year in years" :key="years.indexOf(year)">
|
||||||
<v-card style="margin-top: 3px;">
|
<v-card style="margin-top: 3px;">
|
||||||
<v-card-title>{{year}}</v-card-title>
|
<v-card-title>{{year}}</v-card-title>
|
||||||
<Table v-bind:user="user" v-bind:year="year"/>
|
<Table v-bind:user="activeUser" v-bind:year="year"/>
|
||||||
<v-container fluid>
|
<v-container fluid>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-row>
|
<v-row>
|
||||||
|
@ -76,8 +87,8 @@
|
||||||
<v-label>Vorjahr:</v-label>
|
<v-label>Vorjahr:</v-label>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-chip outlined :text-color="getLastColor(user.creditList[year][1].last)">
|
<v-chip outlined :text-color="getLastColor(activeUser.creditList[year][1].last)">
|
||||||
{{(user.creditList[year][1].last / 100).toFixed(2)}}
|
{{(activeUser.creditList[year][1].last / 100).toFixed(2)}}
|
||||||
</v-chip>
|
</v-chip>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
|
@ -85,8 +96,8 @@
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-chip outlined x-large
|
<v-chip outlined x-large
|
||||||
:text-color="getLastColor(getAllSum(user.creditList[year][2].sum ,user.creditList[year][1].last))">
|
:text-color="getLastColor(getAllSum(activeUser.creditList[year][2].sum ,activeUser.creditList[year][1].last))">
|
||||||
{{(getAllSum(user.creditList[year][2].sum ,user.creditList[year][1].last) /
|
{{(getAllSum(activeUser.creditList[year][2].sum ,activeUser.creditList[year][1].last) /
|
||||||
100).toFixed(2)}}
|
100).toFixed(2)}}
|
||||||
</v-chip>
|
</v-chip>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
@ -100,33 +111,16 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Table from "./Table";
|
import Table from "./Table";
|
||||||
|
import {mapGetters, mapActions} from 'vuex';
|
||||||
export default {
|
export default {
|
||||||
name: "User",
|
name: "User",
|
||||||
components: {Table},
|
components: {Table},
|
||||||
props: {
|
|
||||||
user: Object,
|
|
||||||
},
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
isNumber: value => !isNaN(value) || 'Betrag muss eine Zahl sein.',
|
isNumber: value => !isNaN(value) || 'Betrag muss eine Zahl sein.',
|
||||||
limit: null,
|
limit: null,
|
||||||
autoLock: null,
|
autoLock: null,
|
||||||
amount: null,
|
amount: null,
|
||||||
selectYears: [],
|
|
||||||
months: [
|
|
||||||
{value: 1, text: 'Januar'},
|
|
||||||
{value: 2, text: 'Februar'},
|
|
||||||
{value: 3, text: 'März'},
|
|
||||||
{value: 4, text:'April'},
|
|
||||||
{value: 5, text: 'Mai'},
|
|
||||||
{value: 6, text: 'Juni'},
|
|
||||||
{value: 7, text: 'Juli'},
|
|
||||||
{value: 8, text: 'August'},
|
|
||||||
{value: 9, text: 'September'},
|
|
||||||
{value: 10, text: 'Oktober'},
|
|
||||||
{value: 11, text: 'November'},
|
|
||||||
{value: 12, text: 'Dezember'}
|
|
||||||
],
|
|
||||||
type: {value: 'credit', text: 'Guthaben'},
|
type: {value: 'credit', text: 'Guthaben'},
|
||||||
selectedYear: {value: new Date().getFullYear(), text: new Date().getFullYear()},
|
selectedYear: {value: new Date().getFullYear(), text: new Date().getFullYear()},
|
||||||
selectedMonth: {value: new Date().getMonth() + 1, text: ["Januar", "Februar", "März", "April", "Mai", "Juni",
|
selectedMonth: {value: new Date().getMonth() + 1, text: ["Januar", "Februar", "März", "April", "Mai", "Juni",
|
||||||
|
@ -136,13 +130,16 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.limit = (this.user.limit / 100).toFixed(2)
|
this.limit = (this.activeUser.limit / 100).toFixed(2)
|
||||||
this.autoLock = {value: this.user.autoLock, text: this.user.autoLock? "Aktiviert" : "Deaktiviert"}
|
this.autoLock = {value: this.activeUser.autoLock, text: this.activeUser.autoLock? "Aktiviert" : "Deaktiviert"}
|
||||||
for (let year = new Date().getFullYear(); year >= 2000; year--) {
|
|
||||||
this.selectYears.push({value: year, text: year})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapActions({
|
||||||
|
addAmount: 'finanzerUsers/addAmount',
|
||||||
|
addCredit: 'finanzerUsers/addCredit',
|
||||||
|
sendMail: 'finanzerUsers/sendMail',
|
||||||
|
doLock: 'finanzerUsers/doLock',
|
||||||
|
saveConfig: 'finanzerUsers/saveConfig'}),
|
||||||
getLastColor (value) {
|
getLastColor (value) {
|
||||||
return value < 0 ? 'red' : 'green'
|
return value < 0 ? 'red' : 'green'
|
||||||
},
|
},
|
||||||
|
@ -152,19 +149,12 @@
|
||||||
getLockedColor (value) {
|
getLockedColor (value) {
|
||||||
return value ? 'red' : 'green'
|
return value ? 'red' : 'green'
|
||||||
},
|
},
|
||||||
lock() {
|
|
||||||
this.user.locked = !this.user.locked
|
|
||||||
this.$emit("do:lock", {user: this.user, locked: this.user.locked})
|
|
||||||
},
|
|
||||||
saveConfig() {
|
|
||||||
this.$emit("save:config", {user: this.user, limit: this.limit, autoLock: this.autoLock.value})
|
|
||||||
},
|
|
||||||
add() {
|
add() {
|
||||||
if (this.type.value === 'amount') {
|
if (this.type.value === 'amount') {
|
||||||
this.$emit("add:amount", {user: this.user, amount: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
this.addAmount( {user: this.activeUser, amount: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
||||||
}
|
}
|
||||||
if (this.type.value === 'credit') {
|
if (this.type.value === 'credit') {
|
||||||
this.$emit("add:credit", {user: this.user, credit: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
this.addCredit({user: this.activeUser, credit: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.createDefault()
|
this.createDefault()
|
||||||
|
@ -181,19 +171,35 @@
|
||||||
this.selectedMonth = {value: new Date().getMonth() + 1, text: ["Januar", "Februar", "März", "April", "Mai", "Juni",
|
this.selectedMonth = {value: new Date().getMonth() + 1, text: ["Januar", "Februar", "März", "April", "Mai", "Juni",
|
||||||
"Juli", "August", "September", "Oktober", "November", "Dezember"
|
"Juli", "August", "September", "Oktober", "November", "Dezember"
|
||||||
][new Date().getMonth()]}
|
][new Date().getMonth()]}
|
||||||
|
},
|
||||||
|
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.'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
years() {
|
years() {
|
||||||
let years = []
|
let years = []
|
||||||
for (let year in this.user.creditList) {
|
for (let year in this.activeUser.creditList) {
|
||||||
years.unshift(parseInt(year))
|
years.unshift(parseInt(year))
|
||||||
}
|
}
|
||||||
return years
|
return years
|
||||||
}
|
},
|
||||||
|
...mapGetters({activeUser: 'finanzerUsers/activeUser',
|
||||||
|
errorMail: 'finanzerUsers/errorMail',
|
||||||
|
months: 'finanzerUsers/months',
|
||||||
|
selectYears: 'finanzerUsers/selectYears'})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
user(newVal) {
|
activeUser(newVal) {
|
||||||
this.limit = (newVal.limit / 100).toFixed(2)
|
this.limit = (newVal.limit / 100).toFixed(2)
|
||||||
this.autoLock = {value: newVal.autoLock, text: newVal.autoLock? "Aktiviert" : "Deaktiviert"}
|
this.autoLock = {value: newVal.autoLock, text: newVal.autoLock? "Aktiviert" : "Deaktiviert"}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
class Service {
|
|
||||||
constructor(url) {
|
|
||||||
this.url = url
|
|
||||||
}
|
|
||||||
getFinanzerMain(token) {
|
|
||||||
return axios.get(this.url + "getFinanzerMain", {headers: {Token: token}})
|
|
||||||
|
|
||||||
}
|
|
||||||
login(loginData) {
|
|
||||||
return axios.post(this.url+'login', {...loginData})
|
|
||||||
}
|
|
||||||
getUserBar(token) {
|
|
||||||
return axios.get(this.url+'bar', {headers: {Token: token}})
|
|
||||||
}
|
|
||||||
getOneUserBar(token, data) {
|
|
||||||
return axios.post(this.url+'barGetUser', {...data}, {headers: {Token: token}})
|
|
||||||
}
|
|
||||||
addAmountBar(token, data) {
|
|
||||||
return axios.post(this.url+'baradd', {...data}, {headers: {Token: token}})
|
|
||||||
}
|
|
||||||
addAmountFinanzer(token, data) {
|
|
||||||
return axios.post(this.url+'finanzerAddAmount', {...data}, {headers: {Token: token}})
|
|
||||||
}
|
|
||||||
addCreditFinanzer(token, data) {
|
|
||||||
return axios.post(this.url+'finanzerAddCredit', {...data}, {headers: {Token: token}})
|
|
||||||
}
|
|
||||||
searchUser(token, data) {
|
|
||||||
return axios.post(this.url+'search', {...data}, {headers: {Token: token}})
|
|
||||||
}
|
|
||||||
getAllUser(token) {
|
|
||||||
return axios.get(this.url+'barGetUsers', {headers: {Token: token}})
|
|
||||||
}
|
|
||||||
lockUser(token, data) {
|
|
||||||
return axios.post(this.url+'finanzerLock', {...data}, {headers: {Token: token}})
|
|
||||||
}
|
|
||||||
finanzerSetConfig(token, data) {
|
|
||||||
return axios.post(this.url+'finanzerSetConfig', {...data}, {headers: {Token: token}})
|
|
||||||
}
|
|
||||||
finanzerAddUser(token, data) {
|
|
||||||
return axios.post(this.url+'finanzerAddUser', {...data}, {headers: {Token: token}})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const httpClient = new Service("http://localhost:5000/")
|
|
||||||
//const httpClient = new Service("http://192.168.5.118:5000/")
|
|
||||||
//const httpClient = new Service("http://groeger-clan.duckdns.org:5000/")
|
|
||||||
|
|
||||||
export default httpClient
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
const main = 'http://192.168.5.118:5000/';
|
||||||
|
|
||||||
|
const url = {
|
||||||
|
login: main + 'login',
|
||||||
|
getFinanzerMain: main + 'getFinanzerMain',
|
||||||
|
bar: main + 'bar',
|
||||||
|
barGetUser: main + 'barGetUser',
|
||||||
|
barAddAmount: main + 'baradd',
|
||||||
|
finanzerAddAmount: main + 'finanzerAddAmount',
|
||||||
|
finanzerAddCredit: main + 'finanzerAddCredit',
|
||||||
|
searchUser: main + 'search',
|
||||||
|
getAllUser: main + 'barGetUsers',
|
||||||
|
lockUser: main + 'finanzerLock',
|
||||||
|
finanzerSetConfig: main + 'finanzerSetConfig',
|
||||||
|
finanzerAddUser: main + 'finanzerAddUser',
|
||||||
|
finanzerSendAllMail: main + 'finanzerSendAllMail',
|
||||||
|
finanzerSendOneMail: main + 'finanzerSendOneMail'
|
||||||
|
};
|
||||||
|
|
||||||
|
export default url;
|
|
@ -44,24 +44,24 @@ router.beforeEach((to, from, next) => {
|
||||||
let sites = ['/finanzer', '/bar']
|
let sites = ['/finanzer', '/bar']
|
||||||
if (sites.includes(to.fullPath)) {
|
if (sites.includes(to.fullPath)) {
|
||||||
if (to.fullPath === '/finanzer') {
|
if (to.fullPath === '/finanzer') {
|
||||||
if (!store.state.user.group.includes('moneymaster')) {
|
if (!store.state.login.user.group.includes('moneymaster')) {
|
||||||
next('/login')
|
next('/login')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (to.fullPath === '/bar') {
|
if (to.fullPath === '/bar') {
|
||||||
if (!store.state.user.group.includes('bar')) {
|
if (!store.state.login.user.group.includes('bar')) {
|
||||||
next('/login')
|
next('/login')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!store.state.user.accessToken) {
|
if (!store.state.login.user.accessToken) {
|
||||||
next('/login')
|
next('/login')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (to.fullPath === '/login') {
|
if (to.fullPath === '/login') {
|
||||||
if (store.state.user.accessToken) {
|
if (store.state.login.user.accessToken) {
|
||||||
if (store.state.user.group.includes('moneymaster')) {
|
if (store.state.login.user.group.includes('moneymaster')) {
|
||||||
next('/finanzer')
|
next('/finanzer')
|
||||||
} else if (store.state.user.group.includes('bar')) {
|
} else if (store.state.login.user.group.includes('bar')) {
|
||||||
next('/bar')
|
next('/bar')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,86 +1,15 @@
|
||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex';
|
||||||
import router from "@/router";
|
import login from './modules/login';
|
||||||
import httpClient from "../plugins/restService";
|
import finanzerUsers from './modules/finanzerUsers'
|
||||||
|
import barUsers from "@/store/modules/barUsers";
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
state: {
|
|
||||||
user: {
|
|
||||||
username: null,
|
|
||||||
accessToken: null,
|
|
||||||
group: null
|
|
||||||
},
|
|
||||||
loggingIn: false,
|
|
||||||
loginError: null
|
|
||||||
},
|
|
||||||
mutations: {
|
|
||||||
loginStart: state => state.loggingIn = true,
|
|
||||||
loginStop (state, errorMessage){
|
|
||||||
state.loggingIn = false;
|
|
||||||
state.loginError = errorMessage;
|
|
||||||
},
|
|
||||||
updateAccessToken (state, data) {
|
|
||||||
if (typeof(data) === typeof("")) {
|
|
||||||
data = JSON.parse(data)
|
|
||||||
}
|
|
||||||
if (data === null || data === undefined) {
|
|
||||||
state.user.username = null;
|
|
||||||
state.user.accessToken = null;
|
|
||||||
state.user.group = null;
|
|
||||||
} else {
|
|
||||||
this.state.user.username = data.username;
|
|
||||||
state.user.accessToken = data.accessToken;
|
|
||||||
state.user.group = data.group;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
logout (state) {
|
|
||||||
state.user.accessToken = null;
|
|
||||||
state.user.username = null;
|
|
||||||
state.user.group = null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
doLogin({ commit }, loginData) {
|
|
||||||
commit('loginStart');
|
|
||||||
httpClient.login(loginData)
|
|
||||||
.then(response => {
|
|
||||||
localStorage.setItem('user', JSON.stringify({ username: response.data.username, accessToken: response.data.token, group: response.data.group}));
|
|
||||||
commit('loginStop', null);
|
|
||||||
commit('updateAccessToken', response.data)
|
|
||||||
if (this.state.user.group.includes('moneymaster')) {
|
|
||||||
router.push('/finanzer');
|
|
||||||
}
|
|
||||||
else if (this.state.user.group.includes('bar')) {
|
|
||||||
router.push('/bar')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
commit('loginStop', error.response.data.error)
|
|
||||||
commit('updateAccessToken', {username: null, accessToken: null, group: null})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
fetchAccessToken({ commit }) {
|
|
||||||
commit('updateAccessToken', localStorage.getItem('user'))
|
|
||||||
},
|
|
||||||
logout({ commit }) {
|
|
||||||
localStorage.removeItem('user');
|
|
||||||
commit('logout');
|
|
||||||
router.push('/login');
|
|
||||||
},
|
|
||||||
resetLoginError({ commit }) {
|
|
||||||
commit("loginStop")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modules: {
|
modules: {
|
||||||
},
|
login,
|
||||||
getters: {
|
finanzerUsers,
|
||||||
getGroup: state => {
|
barUsers
|
||||||
return state.user.group
|
|
||||||
},
|
|
||||||
getToken: state => {
|
|
||||||
return state.user.accessToken
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
import axios from 'axios';
|
||||||
|
import url from '@/plugins/routes';
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
users: [],
|
||||||
|
allUsers: []
|
||||||
|
};
|
||||||
|
|
||||||
|
const mutations = {
|
||||||
|
setAllUsers: (state, users) => {
|
||||||
|
state.allUsers = []
|
||||||
|
state.allUsers = users
|
||||||
|
for (let i = 0; i < state.allUsers.length; i++) {
|
||||||
|
state.allUsers[i].fullName = state.allUsers[i].firstname + " " + state.allUsers[i].lastname
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setUsers: (state, users) => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(users)
|
||||||
|
for (let user in users) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(user)
|
||||||
|
let existuser = state.users.find(a => {return user === a.username})
|
||||||
|
|
||||||
|
if (existuser) {
|
||||||
|
existuser.sername = users[user].username
|
||||||
|
existuser.firstname = users[user].firstname
|
||||||
|
existuser.lastname = users[user].lastname
|
||||||
|
existuser.locked = users[user].locked
|
||||||
|
existuser.amount = users[user].amount
|
||||||
|
existuser.type = users[user].type
|
||||||
|
} else {
|
||||||
|
state.users.push({
|
||||||
|
username: users[user].username,
|
||||||
|
firstname: users[user].firstname,
|
||||||
|
lastname: users[user].lastname,
|
||||||
|
locked: users[user].locked,
|
||||||
|
amount: users[user].amount,
|
||||||
|
type: users[user].type
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(state.users)
|
||||||
|
mutations.sortUsers(state)
|
||||||
|
},
|
||||||
|
sortUsers: (state) => {
|
||||||
|
state.users = state.users.sort((a,b) => {
|
||||||
|
if (a.lastname > b.lastname) return 1
|
||||||
|
if (a.lastname < b.lastname) return -1
|
||||||
|
if (a.firstname > b.firstname) return 1
|
||||||
|
if (a.firstname < b.firstname) return -1
|
||||||
|
return 0
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const actions = {
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
async getUsers({commit, rootState, dispatch}) {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(url.bar, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(response.data)
|
||||||
|
commit('setUsers', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async addAmount({commit, rootState, dispatch}, data) {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(url.barAddAmount, {userId: data.username, amount: data.amount}, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
commit('setUsers', {[response.data.username]: response.data})
|
||||||
|
} catch (e) {
|
||||||
|
if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async addCreditList({commit, rootState, dispatch}, data) {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(url.barGetUser, {userId: data.username}, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
commit('setUsers', {[response.data.username]: response.data})
|
||||||
|
} catch (e) {
|
||||||
|
if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getAllUsers({commit, rootState, dispatch}) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('hier bin ich')
|
||||||
|
try {
|
||||||
|
const response = await axios.post(url.searchUser, {searchString: ""}, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(response)
|
||||||
|
commit('setAllUsers', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(e)
|
||||||
|
if (e.response) if (e.response.data === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const getters = {
|
||||||
|
users: (state) => { return state.users },
|
||||||
|
allUsers: (state) => { return state.allUsers }
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
namespaced: true,
|
||||||
|
state,
|
||||||
|
mutations,
|
||||||
|
actions,
|
||||||
|
getters
|
||||||
|
}
|
|
@ -0,0 +1,311 @@
|
||||||
|
import axios from 'axios';
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
import url from '@/plugins/routes'
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
users: [],
|
||||||
|
activeUser: {
|
||||||
|
username: null,
|
||||||
|
},
|
||||||
|
allUsers: [],
|
||||||
|
user: null,
|
||||||
|
errorMails: null,
|
||||||
|
errorMail: null,
|
||||||
|
year: new Date().getFullYear(),
|
||||||
|
years: [],
|
||||||
|
months: [
|
||||||
|
{value: 1, text: 'Januar'},
|
||||||
|
{value: 2, text: 'Februar'},
|
||||||
|
{value: 3, text: 'März'},
|
||||||
|
{value: 4, text:'April'},
|
||||||
|
{value: 5, text: 'Mai'},
|
||||||
|
{value: 6, text: 'Juni'},
|
||||||
|
{value: 7, text: 'Juli'},
|
||||||
|
{value: 8, text: 'August'},
|
||||||
|
{value: 9, text: 'September'},
|
||||||
|
{value: 10, text: 'Oktober'},
|
||||||
|
{value: 11, text: 'November'},
|
||||||
|
{value: 12, text: 'Dezember'}
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const mutations = {
|
||||||
|
setAllUsers: (state, users) => {
|
||||||
|
state.allUsers = []
|
||||||
|
state.allUsers = users
|
||||||
|
for (let i = 0; i < state.allUsers.length; i++) {
|
||||||
|
state.allUsers[i].fullName = state.allUsers[i].firstname + " " + state.allUsers[i].lastname
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setActiveUser: (state, user) => {
|
||||||
|
if (state.activeUser.username === user.username) {
|
||||||
|
state.activeUser = {username: null}
|
||||||
|
} else {
|
||||||
|
state.activeUser = user
|
||||||
|
}
|
||||||
|
state.errorMail = null
|
||||||
|
},
|
||||||
|
setUsers: (state, users) => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('users', users)
|
||||||
|
for (let user in users) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('user', user)
|
||||||
|
let list = {}
|
||||||
|
for (let creditList in users[user]['creditList']) {
|
||||||
|
let amount = mutations.createAmount(users[user]['creditList'][creditList])
|
||||||
|
let credit = mutations.createCredit(users[user]['creditList'][creditList])
|
||||||
|
let sum = mutations.createSum(credit, amount)
|
||||||
|
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
||||||
|
}
|
||||||
|
|
||||||
|
let existUser = state.users.find(a => {return a.username === user})
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(existUser)
|
||||||
|
if (existUser) {
|
||||||
|
existUser.username = users[user].username
|
||||||
|
existUser.firstname = users[user].firstname
|
||||||
|
existUser.lastname = users[user].lastname
|
||||||
|
existUser.limit = users[user].limit
|
||||||
|
existUser.locked = users[user].locked
|
||||||
|
existUser.autoLock = users[user].autoLock
|
||||||
|
existUser.creditList = list
|
||||||
|
} else {
|
||||||
|
state.users.push({
|
||||||
|
username: users[user].username,
|
||||||
|
firstname: users[user].firstname,
|
||||||
|
lastname: users[user].lastname,
|
||||||
|
limit: users[user].limit,
|
||||||
|
locked: users[user].locked,
|
||||||
|
autoLock: users[user].autoLock,
|
||||||
|
creditList: list,
|
||||||
|
expand: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mutations.sortUsers(state)
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(state.users)
|
||||||
|
},
|
||||||
|
createAmount(creditList) {
|
||||||
|
let amount = {
|
||||||
|
type:'Schulden',
|
||||||
|
jan_amount: 0 - creditList.jan.depts,
|
||||||
|
feb_amount: 0 - creditList.feb.depts,
|
||||||
|
maer_amount: 0 - creditList.maer.depts,
|
||||||
|
apr_amount:0 - creditList.apr.depts,
|
||||||
|
mai_amount: 0 - creditList.mai.depts,
|
||||||
|
jun_amount: 0 - creditList.jun.depts,
|
||||||
|
jul_amount: 0 - creditList.jul.depts,
|
||||||
|
aug_amount: 0 - creditList.aug.depts,
|
||||||
|
sep_amount: 0 - creditList.sep.depts,
|
||||||
|
okt_amount: 0 - creditList.okt.depts,
|
||||||
|
nov_amount: 0 - creditList.nov.depts,
|
||||||
|
dez_amount: 0 - creditList.dez.depts,
|
||||||
|
last: 0 - creditList['last']
|
||||||
|
}
|
||||||
|
|
||||||
|
amount.sum = amount.jan_amount + amount.feb_amount + amount.maer_amount + amount.apr_amount + amount.mai_amount + amount.jun_amount + amount.jul_amount + amount.aug_amount + amount.sep_amount + amount.okt_amount + amount.nov_amount + amount.dez_amount
|
||||||
|
return amount
|
||||||
|
},
|
||||||
|
createCredit(creditList) {
|
||||||
|
let credit = {
|
||||||
|
type:'Guthaben',
|
||||||
|
jan_amount: creditList.jan.credit,
|
||||||
|
feb_amount: creditList.feb.credit,
|
||||||
|
maer_amount: creditList.maer.credit,
|
||||||
|
apr_amount: creditList.apr.credit,
|
||||||
|
mai_amount: creditList.mai.credit,
|
||||||
|
jun_amount: creditList.jun.credit,
|
||||||
|
jul_amount: creditList.jul.credit,
|
||||||
|
aug_amount: creditList.aug.credit,
|
||||||
|
sep_amount: creditList.sep.credit,
|
||||||
|
okt_amount: creditList.okt.credit,
|
||||||
|
nov_amount: creditList.nov.credit,
|
||||||
|
dez_amount: creditList.dez.credit
|
||||||
|
}
|
||||||
|
credit.sum = credit.jan_amount + credit.feb_amount + credit.maer_amount + credit.apr_amount + credit.mai_amount + credit.jun_amount + credit.jul_amount + credit.aug_amount + credit.sep_amount + credit.okt_amount + credit.nov_amount + credit.dez_amount
|
||||||
|
return credit
|
||||||
|
},
|
||||||
|
createSum(credit, amount) {
|
||||||
|
let sum = {
|
||||||
|
type:'Summe',
|
||||||
|
jan_amount: credit.jan_amount + amount.jan_amount,
|
||||||
|
feb_amount: credit.feb_amount + amount.feb_amount,
|
||||||
|
maer_amount: credit.maer_amount + amount.maer_amount,
|
||||||
|
apr_amount: credit.apr_amount + amount.apr_amount,
|
||||||
|
mai_amount: credit.mai_amount + amount.mai_amount,
|
||||||
|
jun_amount: credit.jun_amount + amount.jun_amount,
|
||||||
|
jul_amount: credit.jul_amount + amount.jul_amount,
|
||||||
|
aug_amount: credit.aug_amount + amount.aug_amount,
|
||||||
|
sep_amount: credit.sep_amount + amount.sep_amount,
|
||||||
|
okt_amount: credit.okt_amount + amount.okt_amount,
|
||||||
|
nov_amount: credit.nov_amount + amount.nov_amount,
|
||||||
|
dez_amount: credit.dez_amount + amount.dez_amount,
|
||||||
|
}
|
||||||
|
sum.sum = sum.jan_amount + sum.feb_amount + sum.maer_amount + sum.apr_amount + sum.mai_amount + sum.jun_amount + sum.jul_amount + sum.aug_amount + sum.sep_amount + sum.okt_amount + sum.nov_amount + sum.dez_amount
|
||||||
|
return sum
|
||||||
|
},
|
||||||
|
sortUsers: (state) => {
|
||||||
|
state.users = state.users.sort((a,b) => {
|
||||||
|
if (a.lastname > b.lastname) return 1
|
||||||
|
if (a.lastname < b.lastname) return -1
|
||||||
|
if (a.firstname > b.firstname) return 1
|
||||||
|
if (a.firstname < b.firstname) return -1
|
||||||
|
return 0
|
||||||
|
})
|
||||||
|
},
|
||||||
|
updateUsers: (state, data) => {
|
||||||
|
let index = state.users.indexOf(state.users.find(a => {return a.username === data.username}))
|
||||||
|
if (data.creditLists !== undefined) {
|
||||||
|
let list = {}
|
||||||
|
for (let creditList in data.creditLists) {
|
||||||
|
let amount = mutations.createAmount(data.creditLists[creditList])
|
||||||
|
let credit = mutations.createCredit(data.creditLists[creditList])
|
||||||
|
let sum = mutations.createSum(credit, amount)
|
||||||
|
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
||||||
|
}
|
||||||
|
state.users[index].creditList = list
|
||||||
|
}
|
||||||
|
if (data.locked !== undefined) state.users[index].locked = data.locked
|
||||||
|
if (data.limit !== undefined) state.users[index].limit = data.limit
|
||||||
|
if (data.autoLock !== undefined) state.users[index].autoLock = data.autoLock
|
||||||
|
},
|
||||||
|
setMails: (state, data) => {
|
||||||
|
state.errorMails = data
|
||||||
|
},
|
||||||
|
setMail: (state, data) => {
|
||||||
|
state.errorMail = data
|
||||||
|
},
|
||||||
|
setYears: (state) => {
|
||||||
|
for (let year = new Date().getFullYear(); year >= 2000; year--) {
|
||||||
|
state.years.push({value: year, text: year})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setYear: (state, value) => {
|
||||||
|
if(value) state.year++
|
||||||
|
else state.year--
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const actions = {
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
async getAllUsers({commit, rootState, dispatch}) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(rootState)
|
||||||
|
try {
|
||||||
|
const response = await axios.post(url.searchUser, {searchString: ""}, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
commit('setAllUsers', response.data)
|
||||||
|
} catch (err) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
if (err.response) if (err.response.status === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getUsers({commit, rootState, dispatch}) {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(url.getFinanzerMain, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('response', response.data)
|
||||||
|
commit('setUsers', response.data)
|
||||||
|
} catch (err) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(err)
|
||||||
|
if (err.response) if (err.response.status === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setActiveUser({ commit }, user) {
|
||||||
|
commit('setActiveUser', user)
|
||||||
|
},
|
||||||
|
async addAmount({commit, rootState, dispatch}, data) {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(url.finanzerAddAmount, {userId: data.user.username, amount: data.amount * 100, year: data.year, month: data.month}, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
const creditLists = {...response.data}
|
||||||
|
delete creditLists.locked
|
||||||
|
commit('updateUsers', {creditLists: creditLists, locked: response.data.locked, username: data.user.username})
|
||||||
|
} catch (err) {
|
||||||
|
if (err.response) if (err.response.status === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async addCredit({commit, rootState, dispatch}, data) {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(url.finanzerAddCredit, {userId: data.user.username, credit: data.credit * 100, year: data.year, month: data.month}, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
const creditLists = {...response.data}
|
||||||
|
delete creditLists.locked
|
||||||
|
commit('updateUsers', {creditLists: creditLists, locked: response.data.locked, username: data.user.username})
|
||||||
|
} catch (err) {
|
||||||
|
if (err.response) if (err.response.status === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async doLock({commit, rootState, dispatch}, data) {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(url.lockUser, {userId: data.user.username, locked: data.locked}, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
commit('updateUsers', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
if (e.response) if(e.response.status === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async saveConfig({commit, rootState, dispatch}, data) {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(url.finanzerSetConfig, {userId: data.user.username, limit: data.limit * 100, autoLock: data.autoLock}, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
commit('updateUsers', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
if (e.response) if(e.response.status === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async addUser({commit, rootState, dispatch}, data) {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(url.finanzerAddUser, {userId: data.username}, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
commit('setUsers', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async sendMails({commit, rootState, dispatch}) {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(url.finanzerSendAllMail, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
commit('setMails', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async sendMail({commit, rootState, dispatch}, data) {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(url.finanzerSendOneMail, {userId: data.username}, {headers: {Token: rootState.login.user.accessToken}})
|
||||||
|
commit('setMail', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
if (e.response) if (e.response.status === 401) dispatch('logout', null, {root: true})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
createYears({commit}) {
|
||||||
|
commit('setYears')
|
||||||
|
return 'hallo'
|
||||||
|
},
|
||||||
|
countYear({commit}, value) {
|
||||||
|
commit('setYear', value)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getters = {
|
||||||
|
users: state => { return state.users },
|
||||||
|
activeUser: state => { return state.activeUser },
|
||||||
|
allUsers: state => { return state.allUsers },
|
||||||
|
user: state => { return state.user },
|
||||||
|
errorMails: state => { return state.errorMails },
|
||||||
|
errorMail: state => { return state.errorMail },
|
||||||
|
years: state => { return state.years },
|
||||||
|
selectYears: state => {return state.years},
|
||||||
|
year: state => { return state.year },
|
||||||
|
months: state => { return state.months},
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
namespaced: true,
|
||||||
|
state,
|
||||||
|
mutations,
|
||||||
|
actions,
|
||||||
|
getters
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
import axios from 'axios';
|
||||||
|
import router from "@/router";
|
||||||
|
import url from '@/plugins/routes'
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
user: {
|
||||||
|
username: null,
|
||||||
|
accessToken: null,
|
||||||
|
group: null
|
||||||
|
},
|
||||||
|
loggingIn: false,
|
||||||
|
loginError: null
|
||||||
|
};
|
||||||
|
|
||||||
|
const mutations = {
|
||||||
|
loginStart: state => state.loggingIn = true,
|
||||||
|
loginStop (state, errorMessage){
|
||||||
|
state.loggingIn = false;
|
||||||
|
state.loginError = errorMessage;
|
||||||
|
},
|
||||||
|
updateAccessToken (state, data) {
|
||||||
|
if (typeof(data) === typeof("")) {
|
||||||
|
data = JSON.parse(data)
|
||||||
|
}
|
||||||
|
if (data === null || data === undefined) {
|
||||||
|
state.user.username = null;
|
||||||
|
state.user.accessToken = null;
|
||||||
|
state.user.group = null;
|
||||||
|
} else {
|
||||||
|
state.user.username = data.username;
|
||||||
|
state.user.accessToken = data.accessToken;
|
||||||
|
state.user.group = data.group;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
logout (state) {
|
||||||
|
state.user.accessToken = null;
|
||||||
|
state.user.username = null;
|
||||||
|
state.user.group = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const actions = {
|
||||||
|
async doLogin({ commit }, loginData) {
|
||||||
|
commit('loginStart');
|
||||||
|
try {
|
||||||
|
const response = await axios.post(url.login, {...loginData})
|
||||||
|
localStorage.setItem('user', JSON.stringify({ username: response.data.username, accessToken: response.data.token, group: response.data.group}));
|
||||||
|
commit('loginStop', null);
|
||||||
|
commit('updateAccessToken', response.data)
|
||||||
|
if (state.user.group.includes('moneymaster')) {
|
||||||
|
router.push('/finanzer');
|
||||||
|
}
|
||||||
|
else if (state.user.group.includes('bar')) {
|
||||||
|
router.push('/bar')
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
commit('loginStop', err.response.data.error)
|
||||||
|
commit('updateAccessToken', {username: null, accessToken: null, group: null})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fetchAccessToken({ commit }) {
|
||||||
|
commit('updateAccessToken', localStorage.getItem('user'))
|
||||||
|
},
|
||||||
|
logout({ commit }) {
|
||||||
|
localStorage.removeItem('user');
|
||||||
|
commit('logout');
|
||||||
|
router.push('/login');
|
||||||
|
},
|
||||||
|
resetLoginError({ commit }) {
|
||||||
|
commit("loginStop")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getters = {
|
||||||
|
getGroup: state => {
|
||||||
|
return state.user.group
|
||||||
|
},
|
||||||
|
group: state => {
|
||||||
|
return state.user.group
|
||||||
|
},
|
||||||
|
getToken: state => {
|
||||||
|
return state.user.accessToken
|
||||||
|
},
|
||||||
|
token: state => {
|
||||||
|
return state.user.accessToken
|
||||||
|
},
|
||||||
|
loginError: state => {
|
||||||
|
return state.loginError
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
state,
|
||||||
|
mutations,
|
||||||
|
actions,
|
||||||
|
getters
|
||||||
|
};
|
|
@ -2,8 +2,8 @@
|
||||||
<div>
|
<div>
|
||||||
<TitleBar/>
|
<TitleBar/>
|
||||||
<v-content>
|
<v-content>
|
||||||
<SearchBar @add:creditList="addCreditList"/>
|
<SearchBar/>
|
||||||
<CreditLists v-bind:users="users" @add:amount="addAmount"></CreditLists>
|
<CreditLists></CreditLists>
|
||||||
</v-content>
|
</v-content>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -11,7 +11,6 @@
|
||||||
<script>
|
<script>
|
||||||
import TitleBar from "@/components/TitleBar";
|
import TitleBar from "@/components/TitleBar";
|
||||||
import CreditLists from "@/components/baruser/CreditLists";
|
import CreditLists from "@/components/baruser/CreditLists";
|
||||||
import httpClient from "../plugins/restService";
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import SearchBar from "../components/baruser/SearchBar";
|
import SearchBar from "../components/baruser/SearchBar";
|
||||||
|
@ -19,85 +18,13 @@
|
||||||
name: "BarView",
|
name: "BarView",
|
||||||
components: {SearchBar, CreditLists, TitleBar},
|
components: {SearchBar, CreditLists, TitleBar},
|
||||||
created() {
|
created() {
|
||||||
this.getUser()
|
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
users: []
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getUser() {
|
|
||||||
this. users = []
|
|
||||||
httpClient.getUserBar(this.$store.getters.getToken)
|
|
||||||
.then(response => {
|
|
||||||
for (let user in response.data) {
|
|
||||||
const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0
|
|
||||||
this.users.push({
|
|
||||||
id: lastId + 1,
|
|
||||||
username: response.data[user].username,
|
|
||||||
firstname: response.data[user].firstname,
|
|
||||||
lastname: response.data[user].lastname,
|
|
||||||
locked: response.data[user].locked,
|
|
||||||
amount: response.data[user].amount,
|
|
||||||
type: response.data[user].type
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
if (error.response) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
this.$store.dispatch('logout')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.users = []
|
|
||||||
})
|
|
||||||
this.users = this.users.sort((a,b) => {
|
|
||||||
if (a.username > b.username) return 1
|
|
||||||
if (a.username < b.username) return -1
|
|
||||||
return 0
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
addAmount(username, amount) {
|
|
||||||
httpClient.addAmountBar(this.$store.getters.getToken, {userId: username, amount: amount})
|
|
||||||
.then((response) => {
|
|
||||||
let user = this.users.find(user => {
|
|
||||||
return user.username === username ? user : false
|
|
||||||
})
|
|
||||||
user.amount = response.data.amount
|
|
||||||
user.locked = response.data.locked
|
|
||||||
user.type = response.data.type
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
if (error.response) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
this.$store.dispatch('logout')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.users = []
|
|
||||||
})
|
|
||||||
},
|
|
||||||
addCreditList(user) {
|
|
||||||
if (!this.users.find(user1 => {
|
|
||||||
return user1.username === user.username
|
|
||||||
})) {
|
|
||||||
httpClient.getOneUserBar(this.$store.getters.getToken, {userId: user.username})
|
|
||||||
.then(response => {
|
|
||||||
const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0
|
|
||||||
this.users.push({
|
|
||||||
id: lastId + 1,
|
|
||||||
username: response.data.username,
|
|
||||||
firstname: response.data.firstname,
|
|
||||||
lastname: response.data.lastname,
|
|
||||||
locked: response.data.locked,
|
|
||||||
amount: 0,
|
|
||||||
type: null
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<TitleBar/>
|
<TitleBar/>
|
||||||
<v-navigation-drawer mini-variant expand-on-hover app clipped permanent overflow>
|
<v-navigation-drawer mini-variant expand-on-hover app clipped permanent overflow>
|
||||||
<v-list>
|
<v-list>
|
||||||
<v-list-item class="title" link @click="test(activeUser)">
|
<v-list-item class="title" link @click="setActiveUser(activeUser)">
|
||||||
<v-list-item-icon>
|
<v-list-item-icon>
|
||||||
<v-icon>home</v-icon>
|
<v-icon>home</v-icon>
|
||||||
</v-list-item-icon>
|
</v-list-item-icon>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
</v-list>
|
</v-list>
|
||||||
<v-divider/>
|
<v-divider/>
|
||||||
<v-list>
|
<v-list>
|
||||||
<v-list-item v-for="user in users" v-bind:key="users.indexOf(user)" :class="user.username === activeUser.username ? 'v-list-item--highlighted' : ''" link @click="test(user)">
|
<v-list-item v-for="user in users" v-bind:key="users.indexOf(user)" :class="user.username === activeUser.username ? 'v-list-item--highlighted' : ''" link @click="setActiveUser(user)">
|
||||||
<v-list-item-title>{{user.lastname}}, {{user.firstname}}</v-list-item-title>
|
<v-list-item-title>{{user.lastname}}, {{user.firstname}}</v-list-item-title>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
|
@ -32,296 +32,48 @@
|
||||||
<v-list-item>
|
<v-list-item>
|
||||||
<v-list-item-icon><v-icon>person_add</v-icon></v-list-item-icon>
|
<v-list-item-icon><v-icon>person_add</v-icon></v-list-item-icon>
|
||||||
<v-list-item-title>
|
<v-list-item-title>
|
||||||
<v-btn text block @click="addUser">Hinzufügen</v-btn>
|
<v-btn text block @click="addUser(user)">Hinzufügen</v-btn>
|
||||||
</v-list-item-title>
|
</v-list-item-title>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
</template>
|
</template>
|
||||||
</v-navigation-drawer>
|
</v-navigation-drawer>
|
||||||
<v-content v-if="!activeUser.username">
|
<v-content v-if="!activeUser.username">
|
||||||
<Overview v-bind:users="users" @add:amount="addAmount" @add:credit="addCredit"/>
|
<Overview/>
|
||||||
</v-content>
|
</v-content>
|
||||||
<v-content v-else>
|
<v-content v-else>
|
||||||
<User v-bind:user="activeUser"
|
<User/>
|
||||||
@add:amount="addAmount" @add:credit="addCredit"
|
|
||||||
@do:lock="doLock" @save:config="saveConfig"/>
|
|
||||||
</v-content>
|
</v-content>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import TitleBar from "@/components/TitleBar";
|
import TitleBar from "@/components/TitleBar";
|
||||||
import httpClient from "../plugins/restService";
|
|
||||||
import Overview from "../components/finanzer/Overview";
|
import Overview from "../components/finanzer/Overview";
|
||||||
import User from "../components/finanzer/User";
|
import User from "../components/finanzer/User";
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import { mapActions } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "FinanzerView",
|
name: "FinanzerView",
|
||||||
components: {User, Overview, TitleBar},
|
components: {User, Overview, TitleBar},
|
||||||
created() {
|
created() {
|
||||||
this.getUser()
|
this.getAllUsers()
|
||||||
httpClient.searchUser(this.$store.getters.getToken, {searchString: ""})
|
this.getUsers()
|
||||||
.then(response => {
|
|
||||||
this.allUsers = response.data
|
|
||||||
|
|
||||||
for (let i = 0; i < this.allUsers.length; i++) {
|
|
||||||
this.allUsers[i].fullName = this.allUsers[i].firstname + " " + this.allUsers[i].lastname
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
users: [],
|
user: null,
|
||||||
activeUser: {
|
|
||||||
username: null,
|
|
||||||
},
|
|
||||||
allUsers: [],
|
|
||||||
user: null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: mapActions({ getAllUsers: 'finanzerUsers/getAllUsers',
|
||||||
test (e) {
|
setActiveUser: 'finanzerUsers/setActiveUser',
|
||||||
if (this.activeUser.username === e.username) {
|
getUsers: 'finanzerUsers/getUsers',
|
||||||
this.activeUser = {username: null}
|
finanzerUsers: 'finanzerUsers/addUser'}),
|
||||||
} else {
|
computed: mapGetters({users: 'finanzerUsers/users',
|
||||||
this.activeUser = e
|
activeUser: 'finanzerUsers/activeUser',
|
||||||
}
|
allUsers: 'finanzerUsers/allUsers'})
|
||||||
},
|
|
||||||
createAmount(creditList) {
|
|
||||||
let amount = {
|
|
||||||
type:'Schulden',
|
|
||||||
jan_amount: 0 - creditList.jan.depts,
|
|
||||||
feb_amount: 0 - creditList.feb.depts,
|
|
||||||
maer_amount: 0 - creditList.maer.depts,
|
|
||||||
apr_amount:0 - creditList.apr.depts,
|
|
||||||
mai_amount: 0 - creditList.mai.depts,
|
|
||||||
jun_amount: 0 - creditList.jun.depts,
|
|
||||||
jul_amount: 0 - creditList.jul.depts,
|
|
||||||
aug_amount: 0 - creditList.aug.depts,
|
|
||||||
sep_amount: 0 - creditList.sep.depts,
|
|
||||||
okt_amount: 0 - creditList.okt.depts,
|
|
||||||
nov_amount: 0 - creditList.nov.depts,
|
|
||||||
dez_amount: 0 - creditList.dez.depts,
|
|
||||||
last: 0 - creditList['last']
|
|
||||||
}
|
|
||||||
|
|
||||||
amount.sum = amount.jan_amount + amount.feb_amount + amount.maer_amount + amount.apr_amount + amount.mai_amount + amount.jun_amount + amount.jul_amount + amount.aug_amount + amount.sep_amount + amount.okt_amount + amount.nov_amount + amount.dez_amount
|
|
||||||
return amount
|
|
||||||
},
|
|
||||||
createCredit(creditList) {
|
|
||||||
let credit = {
|
|
||||||
type:'Guthaben',
|
|
||||||
jan_amount: creditList.jan.credit,
|
|
||||||
feb_amount: creditList.feb.credit,
|
|
||||||
maer_amount: creditList.maer.credit,
|
|
||||||
apr_amount: creditList.apr.credit,
|
|
||||||
mai_amount: creditList.mai.credit,
|
|
||||||
jun_amount: creditList.jun.credit,
|
|
||||||
jul_amount: creditList.jul.credit,
|
|
||||||
aug_amount: creditList.aug.credit,
|
|
||||||
sep_amount: creditList.sep.credit,
|
|
||||||
okt_amount: creditList.okt.credit,
|
|
||||||
nov_amount: creditList.nov.credit,
|
|
||||||
dez_amount: creditList.dez.credit
|
|
||||||
}
|
|
||||||
credit.sum = credit.jan_amount + credit.feb_amount + credit.maer_amount + credit.apr_amount + credit.mai_amount + credit.jun_amount + credit.jul_amount + credit.aug_amount + credit.sep_amount + credit.okt_amount + credit.nov_amount + credit.dez_amount
|
|
||||||
return credit
|
|
||||||
},
|
|
||||||
createSum(credit, amount) {
|
|
||||||
let sum = {
|
|
||||||
type:'Summe',
|
|
||||||
jan_amount: credit.jan_amount + amount.jan_amount,
|
|
||||||
feb_amount: credit.feb_amount + amount.feb_amount,
|
|
||||||
maer_amount: credit.maer_amount + amount.maer_amount,
|
|
||||||
apr_amount: credit.apr_amount + amount.apr_amount,
|
|
||||||
mai_amount: credit.mai_amount + amount.mai_amount,
|
|
||||||
jun_amount: credit.jun_amount + amount.jun_amount,
|
|
||||||
jul_amount: credit.jul_amount + amount.jul_amount,
|
|
||||||
aug_amount: credit.aug_amount + amount.aug_amount,
|
|
||||||
sep_amount: credit.sep_amount + amount.sep_amount,
|
|
||||||
okt_amount: credit.okt_amount + amount.okt_amount,
|
|
||||||
nov_amount: credit.nov_amount + amount.nov_amount,
|
|
||||||
dez_amount: credit.dez_amount + amount.dez_amount,
|
|
||||||
}
|
|
||||||
sum.sum = sum.jan_amount + sum.feb_amount + sum.maer_amount + sum.apr_amount + sum.mai_amount + sum.jun_amount + sum.jul_amount + sum.aug_amount + sum.sep_amount + sum.okt_amount + sum.nov_amount + sum.dez_amount
|
|
||||||
return sum
|
|
||||||
},
|
|
||||||
getUser() {
|
|
||||||
httpClient.getFinanzerMain(this.$store.getters.getToken)
|
|
||||||
.then(response => {
|
|
||||||
for (let user in response.data) {
|
|
||||||
const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
let list = {}
|
|
||||||
for (let creditList in response.data[user]['creditList']) {
|
|
||||||
|
|
||||||
let amount = this.createAmount(response.data[user]['creditList'][creditList])
|
|
||||||
let credit = this.createCredit(response.data[user]['creditList'][creditList])
|
|
||||||
let sum = this.createSum(credit, amount)
|
|
||||||
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
|
||||||
}
|
|
||||||
this.users.push({
|
|
||||||
id: lastId + 1,
|
|
||||||
username: response.data[user].username,
|
|
||||||
firstname: response.data[user].firstname,
|
|
||||||
lastname: response.data[user].lastname,
|
|
||||||
limit: response.data[user].limit,
|
|
||||||
locked: response.data[user].locked,
|
|
||||||
autoLock: response.data[user].autoLock,
|
|
||||||
creditList: list,
|
|
||||||
expand: false,
|
|
||||||
active: false
|
|
||||||
})
|
|
||||||
}})
|
|
||||||
.catch(error => {
|
|
||||||
if (error.response) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
this.$store.dispatch('logout')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.users = []
|
|
||||||
})
|
|
||||||
|
|
||||||
this.users = this.users.sort((a, b) => {
|
|
||||||
if (a.lastname > b.lastname) return 1
|
|
||||||
if (a.lastname < b.lastname) return -1
|
|
||||||
if (a.firstname > b.firstname) return 1
|
|
||||||
if (a.firstname < b.firstname) return -1
|
|
||||||
return 0
|
|
||||||
})
|
|
||||||
},
|
|
||||||
addAmount(data) {
|
|
||||||
httpClient.addAmountFinanzer(this.$store.getters.getToken, {userId: data.user.username, amount: data.amount * 100, year: data.year, month: data.month})
|
|
||||||
.then(response => {
|
|
||||||
|
|
||||||
let user = this.users.find(user => {return user.username === data.user.username})
|
|
||||||
let index = this.users.indexOf(user)
|
|
||||||
let list = {}
|
|
||||||
for (let creditList in response.data) {
|
|
||||||
if (creditList !== 'locked') {
|
|
||||||
let amount = this.createAmount(response.data[creditList])
|
|
||||||
let credit = this.createCredit(response.data[creditList])
|
|
||||||
let sum = this.createSum(credit, amount)
|
|
||||||
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.users[index].creditList = list
|
|
||||||
this.users[index].locked = response.data.locked
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
if (error.response) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
this.$store.dispatch('logout')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.users = []
|
|
||||||
})
|
|
||||||
this.users.find(a => {return a.username === this.activeUser.username})
|
|
||||||
},
|
|
||||||
addCredit(data) {
|
|
||||||
|
|
||||||
httpClient.addCreditFinanzer(this.$store.getters.getToken, {userId: data.user.username, credit: data.credit * 100, year: data.year, month: data.month})
|
|
||||||
.then(response => {
|
|
||||||
|
|
||||||
let user = this.users.find(user => {return user.username === data.user.username})
|
|
||||||
let index = this.users.indexOf(user)
|
|
||||||
let list = {}
|
|
||||||
for (let creditList in response.data) {
|
|
||||||
if (creditList !== 'locked') {
|
|
||||||
let amount = this.createAmount(response.data[creditList])
|
|
||||||
let credit = this.createCredit(response.data[creditList])
|
|
||||||
let sum = this.createSum(credit, amount)
|
|
||||||
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.users[index].creditList = list
|
|
||||||
this.users[index].locked = response.data.locked
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
if (error.response) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
this.$store.dispatch('logout')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.users = []
|
|
||||||
})
|
|
||||||
this.users.find(a => {return a.username === this.activeUser.username})
|
|
||||||
},
|
|
||||||
deactivateAllUser() {
|
|
||||||
for (let user in this.users) {
|
|
||||||
user.active = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
doLock(data) {
|
|
||||||
httpClient.lockUser(this.$store.getters.getToken, {userId: data.user.username, locked: data.locked})
|
|
||||||
.then(response => {
|
|
||||||
let user = this.users.find(user => {return user.username === data.user.username})
|
|
||||||
let index = this.users.indexOf(user)
|
|
||||||
this.users[index].locked = response.data.locked
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
if (error.response) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
this.$store.dispatch('logout')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
saveConfig(data) {
|
|
||||||
httpClient.finanzerSetConfig(this.$store.getters.getToken, {userId: data.user.username, limit: data.limit * 100, autoLock: data.autoLock})
|
|
||||||
.then(response => {
|
|
||||||
let user = this.users.find(user => {return user.username === data.user.username})
|
|
||||||
let index = this.users.indexOf(user)
|
|
||||||
this.users[index].limit = response.data.limit
|
|
||||||
this.users[index].autoLock = response.data.autoLock
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
if (error.response) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
this.$store.dispatch('logout')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
addUser() {
|
|
||||||
httpClient.finanzerAddUser(this.$store.getters.getToken, {userId: this.user.username})
|
|
||||||
.then(response => {
|
|
||||||
for (let username in response.data) {
|
|
||||||
let existUser = this.users.find(a => {return a.username === username})
|
|
||||||
let list = {}
|
|
||||||
for (let creditList in response.data[username]['creditList']) {
|
|
||||||
let amount = this.createAmount(response.data[username]['creditList'][creditList])
|
|
||||||
let credit = this.createCredit(response.data[username]['creditList'][creditList])
|
|
||||||
let sum = this.createSum(credit, amount)
|
|
||||||
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
|
||||||
}
|
|
||||||
if (existUser) {
|
|
||||||
existUser.firstname = response.data[username].firstname
|
|
||||||
existUser.lastname = response.data[username].lastname
|
|
||||||
existUser.limit = response.data[username].limit
|
|
||||||
existUser.locked = response.data[username].locked
|
|
||||||
existUser.autoLock = response.data[username].autoLock
|
|
||||||
existUser.creditList = list
|
|
||||||
} else {
|
|
||||||
const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0
|
|
||||||
this.users.push({
|
|
||||||
id: lastId + 1,
|
|
||||||
username: response.data[username].username,
|
|
||||||
firstname: response.data[username].firstname,
|
|
||||||
lastname: response.data[username].lastname,
|
|
||||||
limit: response.data[username].limit,
|
|
||||||
locked: response.data[username].locked,
|
|
||||||
autoLock: response.data[username].autoLock,
|
|
||||||
creditList: list,
|
|
||||||
expand: false,
|
|
||||||
active: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
type="text"
|
type="text"
|
||||||
v-model="username"
|
v-model="username"
|
||||||
ref="first"
|
ref="first"
|
||||||
@keyup.enter="login"
|
@keyup.enter="doLogin({username: username, password: password})"
|
||||||
@change="resetError"
|
@input="resetLoginError"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
|
@ -44,15 +44,15 @@
|
||||||
prepend-icon="lock"
|
prepend-icon="lock"
|
||||||
type="password"
|
type="password"
|
||||||
v-model="password"
|
v-model="password"
|
||||||
@keyup.enter="login"
|
@keyup.enter="doLogin({username: username, password: password})"
|
||||||
@change="resetError"
|
@input="resetLoginError"
|
||||||
/>
|
/>
|
||||||
</v-form>
|
</v-form>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-alert v-if="loginFail" dense type="error">{{ loginFail }}</v-alert>
|
<v-alert v-if="loginError" dense type="error">{{ loginError }}</v-alert>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-spacer />
|
<v-spacer />
|
||||||
<v-btn @click="login" @submit.prevent="login" color="primary">Login</v-btn>
|
<v-btn @click="doLogin({username: username, password: password})" @submit.prevent="doLogin({username: username, password: password})" color="primary">Login</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
@ -64,6 +64,9 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import TitleBar from "@/components/TitleBar";
|
import TitleBar from "@/components/TitleBar";
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
import { mapActions } from 'vuex';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
export default {
|
export default {
|
||||||
name: "Login",
|
name: "Login",
|
||||||
components: {TitleBar},
|
components: {TitleBar},
|
||||||
|
@ -73,20 +76,8 @@
|
||||||
password: null
|
password: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: mapActions(['doLogin', 'resetLoginError']),
|
||||||
login() {
|
computed: mapGetters(['loginError'])
|
||||||
let o = {username: this.username, password: this.password}
|
|
||||||
this.$store.dispatch("doLogin", o)
|
|
||||||
},
|
|
||||||
resetError() {
|
|
||||||
this.$store.dispatch("resetLoginError")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
loginFail() {
|
|
||||||
return this.$store.state.loginError
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue