add search for baruser
TODO: maybe we can change the filter in finanzerview too
This commit is contained in:
parent
1bd0d87034
commit
708f40938a
|
@ -1,10 +1,13 @@
|
|||
<template>
|
||||
<div>
|
||||
<div v-for="user in users" :key="users.indexOf(user)">
|
||||
<div v-if="isFiltered(user)">
|
||||
<v-container>
|
||||
<v-card>
|
||||
<v-list-item>
|
||||
<v-list-item-title class="title">{{user.firstname}} {{user.lastname}}</v-list-item-title>
|
||||
<v-list-item-title class="title"
|
||||
>{{ user.firstname }} {{ user.lastname }}</v-list-item-title
|
||||
>
|
||||
</v-list-item>
|
||||
<v-card-text>
|
||||
<v-row>
|
||||
|
@ -14,28 +17,37 @@
|
|||
<v-btn
|
||||
class="creditBtn"
|
||||
block
|
||||
@click="addAmount({username: user.username, amount: 200})"
|
||||
@click="
|
||||
addAmount({ username: user.username, amount: 200 })
|
||||
"
|
||||
:color="color"
|
||||
:disabled="user.locked"
|
||||
>2 €</v-btn>
|
||||
>2 €</v-btn
|
||||
>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-btn
|
||||
class="creditBtn"
|
||||
block
|
||||
@click="addAmount({username: user.username, amount: 100})"
|
||||
@click="
|
||||
addAmount({ username: user.username, amount: 100 })
|
||||
"
|
||||
:color="color"
|
||||
:disabled="user.locked"
|
||||
>1 €</v-btn>
|
||||
>1 €</v-btn
|
||||
>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-btn
|
||||
class="creditBtn"
|
||||
block
|
||||
@click="addAmount({username: user.username, amount: 50})"
|
||||
@click="
|
||||
addAmount({ username: user.username, amount: 50 })
|
||||
"
|
||||
:color="color"
|
||||
:disabled="user.locked"
|
||||
>0,50 €</v-btn>
|
||||
>0,50 €</v-btn
|
||||
>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
|
@ -43,50 +55,64 @@
|
|||
<v-btn
|
||||
class="creditBtn"
|
||||
block
|
||||
@click="addAmount({username:user.username, amount: 40})"
|
||||
@click="
|
||||
addAmount({ username: user.username, amount: 40 })
|
||||
"
|
||||
:color="color"
|
||||
:disabled="user.locked"
|
||||
>0,40 €</v-btn>
|
||||
>0,40 €</v-btn
|
||||
>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-btn
|
||||
class="creditBtn"
|
||||
block
|
||||
@click="addAmount({username: user.username, amount: 20})"
|
||||
@click="
|
||||
addAmount({ username: user.username, amount: 20 })
|
||||
"
|
||||
:color="color"
|
||||
:disabled="user.locked"
|
||||
>0,20 €</v-btn>
|
||||
>0,20 €</v-btn
|
||||
>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-btn
|
||||
class="creditBtn"
|
||||
block
|
||||
@click="addAmount({username: user.username, amount: 10})"
|
||||
@click="
|
||||
addAmount({ username: user.username, amount: 10 })
|
||||
"
|
||||
:color="color"
|
||||
:disabled="user.locked"
|
||||
>0,10 €</v-btn>
|
||||
>0,10 €</v-btn
|
||||
>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
<v-col align-self="center">
|
||||
<v-row>
|
||||
<v-list-item>
|
||||
<v-list-item-action-text
|
||||
:class="getColor(user.type)"
|
||||
>{{(user.amount/100).toFixed(2)}} €</v-list-item-action-text>
|
||||
<v-list-item-action-text :class="getColor(user.type)"
|
||||
>{{
|
||||
(user.amount / 100).toFixed(2)
|
||||
}}
|
||||
€</v-list-item-action-text
|
||||
>
|
||||
</v-list-item>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-alert
|
||||
v-if="user.locked"
|
||||
type="error"
|
||||
>{{user.firstname}} darf nicht mehr anschreiben. {{user.firstname}} sollte sich lieber mal beim Finanzer melden.</v-alert>
|
||||
<v-alert v-if="user.locked" type="error"
|
||||
>{{ user.firstname }} darf nicht mehr anschreiben.
|
||||
{{ user.firstname }} sollte sich lieber mal beim Finanzer
|
||||
melden.</v-alert
|
||||
>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-container>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -102,8 +128,6 @@ export default {
|
|||
},
|
||||
created() {
|
||||
this.getUsers()
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(this.users)
|
||||
},
|
||||
methods: {
|
||||
...mapActions({
|
||||
|
@ -112,10 +136,23 @@ export default {
|
|||
}),
|
||||
getColor(type) {
|
||||
return type === 'credit' ? 'title green--text' : 'title red--text'
|
||||
},
|
||||
isFiltered(user) {
|
||||
try {
|
||||
return (
|
||||
user.firstname.toLowerCase().includes(this.filter.toLowerCase()) ||
|
||||
user.lastname.toLowerCase().includes(this.filter.toLowerCase())
|
||||
)
|
||||
} catch (e) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({ users: 'barUsers/users' })
|
||||
...mapGetters({
|
||||
users: 'barUsers/users',
|
||||
filter: 'barUsers/filter'
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
item-text="fullName"
|
||||
prepend-inner-icon="search"
|
||||
full-width
|
||||
:search-input.sync="filter"
|
||||
/>
|
||||
<v-btn text @click="addUser">Hinzufügen</v-btn>
|
||||
</v-toolbar-items>
|
||||
|
@ -28,7 +29,8 @@ export default {
|
|||
props: {},
|
||||
data() {
|
||||
return {
|
||||
user: null
|
||||
user: null,
|
||||
filter: ''
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -37,7 +39,8 @@ export default {
|
|||
methods: {
|
||||
...mapActions({
|
||||
getAllUsers: 'barUsers/getAllUsers',
|
||||
addCreditList: 'barUsers/addCreditList'
|
||||
addCreditList: 'barUsers/addCreditList',
|
||||
setFilter: 'barUsers/setFilter'
|
||||
}),
|
||||
addUser() {
|
||||
this.addCreditList(this.user)
|
||||
|
@ -46,9 +49,13 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
...mapGetters({ allUsers: 'barUsers/allUsers' })
|
||||
},
|
||||
watch: {
|
||||
filter(val) {
|
||||
this.setFilter(val)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
<style scoped></style>
|
||||
|
|
|
@ -17,7 +17,12 @@
|
|||
<v-spacer />
|
||||
<v-toolbar-items>
|
||||
<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-text-field
|
||||
v-model="filter"
|
||||
style="margin-top: 3px"
|
||||
append-icon="search"
|
||||
outlined
|
||||
></v-text-field>
|
||||
</v-toolbar-items>
|
||||
</v-toolbar>
|
||||
<v-expand-transition>
|
||||
|
@ -28,7 +33,7 @@
|
|||
text
|
||||
icon
|
||||
style="margin-right: 5px"
|
||||
@click="errorExpand ? errorExpand = false : errorExpand = true"
|
||||
@click="errorExpand ? (errorExpand = false) : (errorExpand = true)"
|
||||
>
|
||||
<v-icon :class="isExpand(errorExpand)" dense>$expand</v-icon>
|
||||
</v-btn>
|
||||
|
@ -40,13 +45,17 @@
|
|||
:key="errorMails.indexOf(error)"
|
||||
dense
|
||||
:type="computeError(error.error)"
|
||||
>{{errorMessage(error)}}</v-alert>
|
||||
>{{ 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">
|
||||
<v-card
|
||||
v-if="user.creditList[year] && isFiltered(user)"
|
||||
style="margin-top: 3px"
|
||||
>
|
||||
<v-card-title>{{ user.lastname }}, {{ user.firstname }}</v-card-title>
|
||||
<Table v-bind:user="user" v-bind:year="year" />
|
||||
<v-container fluid>
|
||||
|
@ -60,7 +69,10 @@
|
|||
<v-chip
|
||||
outlined
|
||||
:text-color="getLastColor(user.creditList[year][1].last)"
|
||||
>{{(user.creditList[year][1].last / 100).toFixed(2)}}</v-chip>
|
||||
>{{
|
||||
(user.creditList[year][1].last / 100).toFixed(2)
|
||||
}}</v-chip
|
||||
>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
|
@ -71,10 +83,23 @@
|
|||
<v-chip
|
||||
outlined
|
||||
x-large
|
||||
:text-color="getLastColor(getAllSum(user.creditList[year][2].sum ,user.creditList[year][1].last))"
|
||||
:text-color="
|
||||
getLastColor(
|
||||
getAllSum(
|
||||
user.creditList[year][2].sum,
|
||||
user.creditList[year][1].last
|
||||
)
|
||||
)
|
||||
"
|
||||
>
|
||||
{{(getAllSum(user.creditList[year][2].sum ,user.creditList[year][1].last) /
|
||||
100).toFixed(2)}}
|
||||
{{
|
||||
(
|
||||
getAllSum(
|
||||
user.creditList[year][2].sum,
|
||||
user.creditList[year][1].last
|
||||
) / 100
|
||||
).toFixed(2)
|
||||
}}
|
||||
</v-chip>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
@ -85,18 +110,26 @@
|
|||
<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-chip outlined :text-color="getLockedColor(user.locked)">{{
|
||||
user.locked ? 'Gesperrt' : 'nicht Gesperrt'
|
||||
}}</v-chip>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-card outlined>
|
||||
<v-row>
|
||||
<v-card-title class="subtitle-2">Geld transferieren</v-card-title>
|
||||
<v-card-title class="subtitle-2"
|
||||
>Geld transferieren</v-card-title
|
||||
>
|
||||
<v-spacer />
|
||||
<v-btn text icon style="margin-right: 5px" @click="setExpand(user)">
|
||||
<v-icon :class="isExpand(user.expand)" dense>$expand</v-icon>
|
||||
<v-btn
|
||||
text
|
||||
icon
|
||||
style="margin-right: 5px"
|
||||
@click="setExpand(user)"
|
||||
>
|
||||
<v-icon :class="isExpand(user.expand)" dense
|
||||
>$expand</v-icon
|
||||
>
|
||||
</v-btn>
|
||||
</v-row>
|
||||
<v-expand-transition>
|
||||
|
@ -104,14 +137,21 @@
|
|||
<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-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'}]"
|
||||
:items="[
|
||||
{ value: 'amount', text: 'Schulden' },
|
||||
{ value: 'credit', text: 'Guthaben' }
|
||||
]"
|
||||
item-text="text"
|
||||
item-value="value"
|
||||
></v-select>
|
||||
|
@ -191,10 +231,7 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(this.getData(this.createYears()))
|
||||
},
|
||||
created() {},
|
||||
methods: {
|
||||
...mapActions({
|
||||
createYears: 'finanzerUsers/createYears',
|
||||
|
|
|
@ -3,7 +3,8 @@ import url from '@/plugins/routes'
|
|||
|
||||
const state = {
|
||||
users: [],
|
||||
allUsers: []
|
||||
allUsers: [],
|
||||
filter: ''
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
|
@ -16,11 +17,7 @@ const mutations = {
|
|||
}
|
||||
},
|
||||
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
|
||||
})
|
||||
|
@ -43,8 +40,6 @@ const mutations = {
|
|||
})
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(state.users)
|
||||
mutations.sortUsers(state)
|
||||
},
|
||||
sortUsers: state => {
|
||||
|
@ -55,6 +50,9 @@ const mutations = {
|
|||
if (a.firstname < b.firstname) return -1
|
||||
return 0
|
||||
})
|
||||
},
|
||||
setFilter: (state, filter) => {
|
||||
state.filter = filter
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,8 +63,6 @@ const actions = {
|
|||
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)
|
||||
|
@ -100,23 +96,20 @@ const actions = {
|
|||
}
|
||||
},
|
||||
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 })
|
||||
}
|
||||
},
|
||||
setFilter({ commit }, data) {
|
||||
commit('setFilter', data)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,6 +119,9 @@ const getters = {
|
|||
},
|
||||
allUsers: state => {
|
||||
return state.allUsers
|
||||
},
|
||||
filter: state => {
|
||||
return state.filter
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,11 +47,7 @@ const mutations = {
|
|||
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(
|
||||
|
@ -67,9 +63,6 @@ const mutations = {
|
|||
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
|
||||
|
@ -92,9 +85,6 @@ const mutations = {
|
|||
}
|
||||
}
|
||||
mutations.sortUsers(state)
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(state.users)
|
||||
},
|
||||
createAmount(creditList) {
|
||||
let amount = {
|
||||
|
@ -240,8 +230,6 @@ const mutations = {
|
|||
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,
|
||||
|
@ -261,12 +249,8 @@ const actions = {
|
|||
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 })
|
||||
|
|
Loading…
Reference in New Issue