finanzer can add useres to DB
in usercontent for finanzer, he can add amount or credit too bug fixes
This commit is contained in:
parent
da26270a61
commit
88abb2599a
|
@ -79,8 +79,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(this.users)
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addAmount(username, amount) {
|
addAmount(username, amount) {
|
||||||
|
|
|
@ -45,6 +45,14 @@
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col align-self="center">
|
<v-col align-self="center">
|
||||||
|
<v-row>
|
||||||
|
<v-col>
|
||||||
|
<v-label>Status: </v-label>
|
||||||
|
</v-col>
|
||||||
|
<v-col>
|
||||||
|
<v-chip outlined :text-color="getLockedColor(user.locked)">{{user.locked ? 'Gesperrt': 'nicht Gesperrt'}}</v-chip>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
<v-card outlined>
|
<v-card outlined>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-card-title class="subtitle-2">Geld transferieren</v-card-title>
|
<v-card-title class="subtitle-2">Geld transferieren</v-card-title>
|
||||||
|
@ -144,7 +152,7 @@
|
||||||
return lastYear + sum
|
return lastYear + sum
|
||||||
},
|
},
|
||||||
createYears() {
|
createYears() {
|
||||||
for (let year = 2000; year <= new Date().getFullYear(); year++) {
|
for (let year = new Date().getFullYear(); year >= 2000; year--) {
|
||||||
this.years.push({value: year, text: year})
|
this.years.push({value: year, text: year})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -185,6 +193,9 @@
|
||||||
this.filteredUsers = [...this.filteredUsers.filter(user => {
|
this.filteredUsers = [...this.filteredUsers.filter(user => {
|
||||||
return user.firstname.toLowerCase().includes(this.filter.toLowerCase()) || user.lastname.toLowerCase().includes(this.filter.toLowerCase())
|
return user.firstname.toLowerCase().includes(this.filter.toLowerCase()) || user.lastname.toLowerCase().includes(this.filter.toLowerCase())
|
||||||
})]
|
})]
|
||||||
|
},
|
||||||
|
getLockedColor (value) {
|
||||||
|
return value ? 'red' : 'green'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -34,6 +34,37 @@
|
||||||
</v-form>
|
</v-form>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
<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>
|
||||||
<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>
|
||||||
|
@ -80,12 +111,36 @@
|
||||||
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,
|
||||||
|
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'},
|
||||||
|
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()]}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.limit = (this.user.limit / 100).toFixed(2)
|
this.limit = (this.user.limit / 100).toFixed(2)
|
||||||
this.autoLock = {value: this.user.autoLock, text: this.user.autoLock? "Aktiviert" : "Deaktiviert"}
|
this.autoLock = {value: this.user.autoLock, text: this.user.autoLock? "Aktiviert" : "Deaktiviert"}
|
||||||
|
for (let year = new Date().getFullYear(); year >= 2000; year--) {
|
||||||
|
this.selectYears.push({value: year, text: year})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getLastColor (value) {
|
getLastColor (value) {
|
||||||
|
@ -103,6 +158,29 @@
|
||||||
},
|
},
|
||||||
saveConfig() {
|
saveConfig() {
|
||||||
this.$emit("save:config", {user: this.user, limit: this.limit, autoLock: this.autoLock.value})
|
this.$emit("save:config", {user: this.user, limit: this.limit, autoLock: this.autoLock.value})
|
||||||
|
},
|
||||||
|
add() {
|
||||||
|
if (this.type.value === 'amount') {
|
||||||
|
this.$emit("add:amount", {user: this.user, amount: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
||||||
|
}
|
||||||
|
if (this.type.value === 'credit') {
|
||||||
|
this.$emit("add:credit", {user: this.user, credit: this.amount, year: this.selectedYear.value, month: this.selectedMonth.value})
|
||||||
|
}
|
||||||
|
|
||||||
|
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()]}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -38,6 +38,9 @@ class Service {
|
||||||
finanzerSetConfig(token, data) {
|
finanzerSetConfig(token, data) {
|
||||||
return axios.post(this.url+'finanzerSetConfig', {...data}, {headers: {Token: token}})
|
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://localhost:5000/")
|
||||||
|
|
|
@ -22,7 +22,6 @@ export default new Vuex.Store({
|
||||||
state.loginError = errorMessage;
|
state.loginError = errorMessage;
|
||||||
},
|
},
|
||||||
updateAccessToken (state, data) {
|
updateAccessToken (state, data) {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
if (typeof(data) === typeof("")) {
|
if (typeof(data) === typeof("")) {
|
||||||
data = JSON.parse(data)
|
data = JSON.parse(data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getUser() {
|
getUser() {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
this. users = []
|
this. users = []
|
||||||
httpClient.getUserBar(this.$store.getters.getToken)
|
httpClient.getUserBar(this.$store.getters.getToken)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
|
|
@ -19,12 +19,32 @@
|
||||||
<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>
|
||||||
|
<template v-slot:append>
|
||||||
|
<v-list>
|
||||||
|
<v-list-item>
|
||||||
|
<v-list-item-icon><v-icon>search</v-icon></v-list-item-icon>
|
||||||
|
<v-list-item-title>
|
||||||
|
<v-autocomplete outlined return-object v-model="user" style="margin-top: 3px"
|
||||||
|
placeholder="Suche Person" :items="allUsers" item-text="fullName"
|
||||||
|
prepend-inner-icon="search" full-width/>
|
||||||
|
</v-list-item-title>
|
||||||
|
</v-list-item>
|
||||||
|
<v-list-item>
|
||||||
|
<v-list-item-icon><v-icon>person_add</v-icon></v-list-item-icon>
|
||||||
|
<v-list-item-title>
|
||||||
|
<v-btn text block @click="addUser">Hinzufügen</v-btn>
|
||||||
|
</v-list-item-title>
|
||||||
|
</v-list-item>
|
||||||
|
</v-list>
|
||||||
|
</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-bind:users="users" @add:amount="addAmount" @add:credit="addCredit"/>
|
||||||
</v-content>
|
</v-content>
|
||||||
<v-content v-else>
|
<v-content v-else>
|
||||||
<User v-bind:user="activeUser" @do:lock="doLock" @save:config="saveConfig"/>
|
<User v-bind:user="activeUser"
|
||||||
|
@add:amount="addAmount" @add:credit="addCredit"
|
||||||
|
@do:lock="doLock" @save:config="saveConfig"/>
|
||||||
</v-content>
|
</v-content>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -40,6 +60,14 @@
|
||||||
components: {User, Overview, TitleBar},
|
components: {User, Overview, TitleBar},
|
||||||
created() {
|
created() {
|
||||||
this.getUser()
|
this.getUser()
|
||||||
|
httpClient.searchUser(this.$store.getters.getToken, {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
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
@ -47,6 +75,8 @@
|
||||||
activeUser: {
|
activeUser: {
|
||||||
username: null,
|
username: null,
|
||||||
},
|
},
|
||||||
|
allUsers: [],
|
||||||
|
user: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -54,7 +84,7 @@
|
||||||
if (this.activeUser.username === e.username) {
|
if (this.activeUser.username === e.username) {
|
||||||
this.activeUser = {username: null}
|
this.activeUser = {username: null}
|
||||||
} else {
|
} else {
|
||||||
this.activeUser = {...e}
|
this.activeUser = e
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
createAmount(creditList) {
|
createAmount(creditList) {
|
||||||
|
@ -159,9 +189,6 @@
|
||||||
if (a.firstname < b.firstname) return -1
|
if (a.firstname < b.firstname) return -1
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(this.users)
|
|
||||||
},
|
},
|
||||||
addAmount(data) {
|
addAmount(data) {
|
||||||
httpClient.addAmountFinanzer(this.$store.getters.getToken, {userId: data.user.username, amount: data.amount * 100, year: data.year, month: data.month})
|
httpClient.addAmountFinanzer(this.$store.getters.getToken, {userId: data.user.username, amount: data.amount * 100, year: data.year, month: data.month})
|
||||||
|
@ -171,13 +198,15 @@
|
||||||
let index = this.users.indexOf(user)
|
let index = this.users.indexOf(user)
|
||||||
let list = {}
|
let list = {}
|
||||||
for (let creditList in response.data) {
|
for (let creditList in response.data) {
|
||||||
|
if (creditList !== 'locked') {
|
||||||
let amount = this.createAmount(response.data[creditList])
|
let amount = this.createAmount(response.data[creditList])
|
||||||
let credit = this.createCredit(response.data[creditList])
|
let credit = this.createCredit(response.data[creditList])
|
||||||
let sum = this.createSum(credit, amount)
|
let sum = this.createSum(credit, amount)
|
||||||
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.users[index].creditList = list
|
this.users[index].creditList = list
|
||||||
|
this.users[index].locked = response.data.locked
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
|
@ -187,6 +216,7 @@
|
||||||
}
|
}
|
||||||
this.users = []
|
this.users = []
|
||||||
})
|
})
|
||||||
|
this.users.find(a => {return a.username === this.activeUser.username})
|
||||||
},
|
},
|
||||||
addCredit(data) {
|
addCredit(data) {
|
||||||
|
|
||||||
|
@ -197,13 +227,15 @@
|
||||||
let index = this.users.indexOf(user)
|
let index = this.users.indexOf(user)
|
||||||
let list = {}
|
let list = {}
|
||||||
for (let creditList in response.data) {
|
for (let creditList in response.data) {
|
||||||
|
if (creditList !== 'locked') {
|
||||||
let amount = this.createAmount(response.data[creditList])
|
let amount = this.createAmount(response.data[creditList])
|
||||||
let credit = this.createCredit(response.data[creditList])
|
let credit = this.createCredit(response.data[creditList])
|
||||||
let sum = this.createSum(credit, amount)
|
let sum = this.createSum(credit, amount)
|
||||||
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
list[creditList] = [{...credit}, {...amount}, {...sum}]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.users[index].creditList = list
|
this.users[index].creditList = list
|
||||||
|
this.users[index].locked = response.data.locked
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
|
@ -213,6 +245,7 @@
|
||||||
}
|
}
|
||||||
this.users = []
|
this.users = []
|
||||||
})
|
})
|
||||||
|
this.users.find(a => {return a.username === this.activeUser.username})
|
||||||
},
|
},
|
||||||
deactivateAllUser() {
|
deactivateAllUser() {
|
||||||
for (let user in this.users) {
|
for (let user in this.users) {
|
||||||
|
@ -249,6 +282,43 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,6 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
login() {
|
login() {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
let o = {username: this.username, password: this.password}
|
let o = {username: this.username, password: this.password}
|
||||||
this.$store.dispatch("doLogin", o)
|
this.$store.dispatch("doLogin", o)
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue