Gründe für Freigetränke können erstellt und gelöscht werden
Außerdem wurd überall ein Loading balken hinzugefügt.
This commit is contained in:
parent
6c5c67f45b
commit
c8a6ab7d35
|
@ -35,6 +35,7 @@
|
||||||
</v-toolbar-items>
|
</v-toolbar-items>
|
||||||
<v-spacer/>
|
<v-spacer/>
|
||||||
</v-toolbar>
|
</v-toolbar>
|
||||||
|
<v-progress-linear indeterminate v-if="loading" />
|
||||||
<div>
|
<div>
|
||||||
<router-view />
|
<router-view />
|
||||||
</div>
|
</div>
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapActions } from 'vuex'
|
import { mapActions, mapGetters } from 'vuex'
|
||||||
export default {
|
export default {
|
||||||
name: 'FreeDrinkList',
|
name: 'FreeDrinkList',
|
||||||
data() {
|
data() {
|
||||||
|
@ -88,7 +89,7 @@ export default {
|
||||||
'get_free_drink_list_config',
|
'get_free_drink_list_config',
|
||||||
'get_free_drink_list_history_from_to',
|
'get_free_drink_list_history_from_to',
|
||||||
'get_free_drink_list_reasons',
|
'get_free_drink_list_reasons',
|
||||||
'get_free_drink_types'
|
'get_free_drink_types',
|
||||||
]),
|
]),
|
||||||
...mapActions('priceList', ['getPriceList']),
|
...mapActions('priceList', ['getPriceList']),
|
||||||
change_month(payload) {
|
change_month(payload) {
|
||||||
|
@ -96,11 +97,23 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapGetters('freeDrinkList', [
|
||||||
|
'free_drink_list_config_loading',
|
||||||
|
'free_drink_list_history_loading',
|
||||||
|
'free_drink_list_reasons_loading',
|
||||||
|
'free_drink_types_loading'
|
||||||
|
]),
|
||||||
|
...mapGetters('priceList', [
|
||||||
|
'priceListLoading'
|
||||||
|
]),
|
||||||
to_date() {
|
to_date() {
|
||||||
return new Date(this.date.getFullYear(), this.date.getMonth()+1,1)
|
return new Date(this.date.getFullYear(), this.date.getMonth()+1,1)
|
||||||
},
|
},
|
||||||
from_date() {
|
from_date() {
|
||||||
return new Date(this.date.getFullYear(), this.date.getMonth(), 1)
|
return new Date(this.date.getFullYear(), this.date.getMonth(), 1)
|
||||||
|
},
|
||||||
|
loading() {
|
||||||
|
return this.free_drink_types_loading || this.free_drink_list_reasons_loading || this.free_drink_list_history_loading || this.free_drink_list_config_loading || this.priceListLoading
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
@ -37,6 +37,36 @@
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card tile>
|
<v-card tile>
|
||||||
<v-card-title>Gründe für Freigetränke</v-card-title>
|
<v-card-title>Gründe für Freigetränke</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
<v-list>
|
||||||
|
<template
|
||||||
|
v-for="(free_drink_reason, index) in free_drink_list_reasons">
|
||||||
|
<v-list-item
|
||||||
|
:key="free_drink_reason.name"
|
||||||
|
dense
|
||||||
|
>
|
||||||
|
<v-list-item-content>
|
||||||
|
<FreeDrinkListConfigReasonItem :free_drink_reason="free_drink_reason" @save="save_reason" @delete_free_drink_list_reason="delete_free_drink_reason" />
|
||||||
|
</v-list-item-content>
|
||||||
|
</v-list-item>
|
||||||
|
<v-divider
|
||||||
|
v-if="(index + 1 < free_drink_list_reasons.length) || new_free_drink_list_reason"
|
||||||
|
:key="index"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<v-list-item v-if="new_free_drink_list_reason">
|
||||||
|
<v-list-item-content>
|
||||||
|
<FreeDrinkListConfigReasonItem :free_drink_reason="default_model_reason" @save="save_reason" @delete_free_drink_reason="new_free_drink_list_reason=false"/>
|
||||||
|
</v-list-item-content>
|
||||||
|
</v-list-item>
|
||||||
|
</v-list>
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-actions dense>
|
||||||
|
<v-spacer />
|
||||||
|
<v-btn fab small color="success" @click="new_free_drink_list_reason=true" v-if="!new_free_drink_list_reason">
|
||||||
|
<v-icon>mdi-plus</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
|
||||||
<v-dialog v-model="check_delete_free_drink_list_config" max-width="400">
|
<v-dialog v-model="check_delete_free_drink_list_config" max-width="400">
|
||||||
|
@ -55,6 +85,23 @@
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
|
<v-dialog v-model="check_delete_free_drink_list_reason" max-width="400">
|
||||||
|
<v-card>
|
||||||
|
<v-card-title>
|
||||||
|
Wirklich löschen?
|
||||||
|
</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
Willst du wirklich den Grund <span class="font-weight-black">{{check_model_reason.name}}</span> löschen?
|
||||||
|
Wenn du dies löscht, wird auch der im Verlauf alle dieser Gründe gelöscht.. Dh. es ist nicht mehr vollständig nachvollziehbar, aus welchem Grund ein Freigetränk rausgegeben wurde.
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-spacer/>
|
||||||
|
<v-btn @click="cancel_delete_reason()">Abbrechen</v-btn>
|
||||||
|
<v-btn @click="accept_delete_reason()" color="error">Löschen</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -62,12 +109,15 @@
|
||||||
import { mapGetters, mapActions} from 'vuex'
|
import { mapGetters, mapActions} from 'vuex'
|
||||||
import FreeDrinkListConfigConfigItem
|
import FreeDrinkListConfigConfigItem
|
||||||
from '@/components/vorstand/FreeDrinkList/FreeDrinkListConfigComponents/FreeDrinkListConfigConfigItem'
|
from '@/components/vorstand/FreeDrinkList/FreeDrinkListConfigComponents/FreeDrinkListConfigConfigItem'
|
||||||
|
import FreeDrinkListConfigReasonItem
|
||||||
|
from '@/components/vorstand/FreeDrinkList/FreeDrinkListConfigComponents/FreeDrinkListConfigReasonItem'
|
||||||
export default {
|
export default {
|
||||||
name: 'FreeDrinkListConfig',
|
name: 'FreeDrinkListConfig',
|
||||||
components: { FreeDrinkListConfigConfigItem },
|
components: { FreeDrinkListConfigConfigItem, FreeDrinkListConfigReasonItem },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
new_free_drink_list_config: false,
|
new_free_drink_list_config: false,
|
||||||
|
new_free_drink_list_reason: false,
|
||||||
default_model: {
|
default_model: {
|
||||||
id: -1,
|
id: -1,
|
||||||
label: null,
|
label: null,
|
||||||
|
@ -83,11 +133,22 @@ export default {
|
||||||
label: null,
|
label: null,
|
||||||
drink: {name: null}
|
drink: {name: null}
|
||||||
},
|
},
|
||||||
check_delete_free_drink_list_config: false
|
check_delete_free_drink_list_config: false,
|
||||||
|
check_delete_free_drink_list_reason: false,
|
||||||
|
default_model_reason: {
|
||||||
|
id: -1,
|
||||||
|
name: null
|
||||||
|
},
|
||||||
|
check_model_reason: {
|
||||||
|
name: null
|
||||||
|
},
|
||||||
|
default_check_model_reason: {
|
||||||
|
name: null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('freeDrinkList', ['set_free_drink_list_config', 'delete_free_drink_list_config', 'update_free_drink_list_config']),
|
...mapActions('freeDrinkList', ['set_free_drink_list_config', 'delete_free_drink_list_config', 'update_free_drink_list_config', 'set_free_drink_list_reason', 'update_free_drink_list_reason', 'delete_free_drink_list_reason']),
|
||||||
log() {
|
log() {
|
||||||
console.log(this.free_drink_list_config)
|
console.log(this.free_drink_list_config)
|
||||||
},
|
},
|
||||||
|
@ -118,8 +179,27 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
this.set_free_drink_list_config(free_drink_config)
|
this.set_free_drink_list_config(free_drink_config)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
delete_free_drink_reason(free_drink_reason) {
|
||||||
|
Object.assign(this.check_model_reason, free_drink_reason)
|
||||||
|
this.check_delete_free_drink_list_reason = true
|
||||||
|
},
|
||||||
|
save_reason(free_drink_reason) {
|
||||||
|
if (free_drink_reason.id > 0) {
|
||||||
|
this.update_free_drink_list_reason(free_drink_reason)
|
||||||
|
} else {
|
||||||
|
this.set_free_drink_list_reason(free_drink_reason)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
cancel_delete_reason() {
|
||||||
|
this.check_delete_free_drink_list_reason = false
|
||||||
|
this.check_model_reason = Object.assign({}, this.default_check_model_reason)
|
||||||
|
},
|
||||||
|
accept_delete_reason() {
|
||||||
|
this.delete_free_drink_list_reason(this.check_model_reason)
|
||||||
|
this.cancel_delete_reason()
|
||||||
|
},
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters('freeDrinkList', [
|
...mapGetters('freeDrinkList', [
|
||||||
'free_drink_list_config',
|
'free_drink_list_config',
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<v-row>
|
||||||
|
<v-col>
|
||||||
|
<v-text-field
|
||||||
|
outlined
|
||||||
|
label="Name"
|
||||||
|
:value="free_drink_reason.name"
|
||||||
|
@change="set_model($event)"
|
||||||
|
dense />
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-row justify="end">
|
||||||
|
<v-btn
|
||||||
|
v-if="free_drink_reason.id > 0"
|
||||||
|
icon
|
||||||
|
class="mr-3"
|
||||||
|
@click="$emit('delete_free_drink_list_reason', free_drink_reason)">
|
||||||
|
<v-icon>mdi-delete</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
<v-btn
|
||||||
|
v-else
|
||||||
|
fab
|
||||||
|
color="error"
|
||||||
|
x-small
|
||||||
|
class="mr-4"
|
||||||
|
@click="$emit('delete_free_drink_reason')"
|
||||||
|
>
|
||||||
|
<v-icon>mdi-minus</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
<v-btn
|
||||||
|
v-if="!is_same || free_drink_reason.id < 0"
|
||||||
|
class="mr-3"
|
||||||
|
color="success"
|
||||||
|
@click="() => {$emit('save', model); $emit('delete_free_drink_reason'); model = null}"
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</v-btn>
|
||||||
|
</v-row>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "FreeDrinkListConfigReason",
|
||||||
|
props: ['free_drink_reason'],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
model: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
set_model(event) {
|
||||||
|
if (!this.model) {
|
||||||
|
this.model = Object.assign({}, this.free_drink_reason)
|
||||||
|
}
|
||||||
|
this.model.name = event
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
is_same() {
|
||||||
|
return this.model ? JSON.stringify(this.model) == JSON.stringify(this.free_drink_reason): true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
|
@ -94,7 +94,7 @@ name: "FreeDrinkListWorkgroup",
|
||||||
label: drink_config.label,
|
label: drink_config.label,
|
||||||
name: drink_config.drink.name,
|
name: drink_config.drink.name,
|
||||||
user: `${history_config.user.firstname} ${history_config.user.lastname}`,
|
user: `${history_config.user.firstname} ${history_config.user.lastname}`,
|
||||||
reason: history_config.free_drink_list_reason.name,
|
reason: history_config.free_drink_list_reason ? history_config.free_drink_list_reason.name : null,
|
||||||
description: history_config.description,
|
description: history_config.description,
|
||||||
pricepro: (drink_config.price / 100).toFixed(2)
|
pricepro: (drink_config.price / 100).toFixed(2)
|
||||||
})
|
})
|
||||||
|
|
|
@ -33,6 +33,7 @@ const url = {
|
||||||
freeDrinkListHistoryFromTo: main + 'freeDrinkListHistoryFromTo',
|
freeDrinkListHistoryFromTo: main + 'freeDrinkListHistoryFromTo',
|
||||||
deleteDrinkListHistory: main + 'deleteDrinkListHistory',
|
deleteDrinkListHistory: main + 'deleteDrinkListHistory',
|
||||||
freeDrinkListReasons: main + 'freeDrinkListReasons',
|
freeDrinkListReasons: main + 'freeDrinkListReasons',
|
||||||
|
deleteFreeDrinkListReason: main + 'deleteFreeDrinkListReason',
|
||||||
freeDrinkTypes: main + 'freeDrinkTypes',
|
freeDrinkTypes: main + 'freeDrinkTypes',
|
||||||
deleteFreeDrinkListConfig: main + 'deleteFreeDrinkListConfig',
|
deleteFreeDrinkListConfig: main + 'deleteFreeDrinkListConfig',
|
||||||
vorstand: {
|
vorstand: {
|
||||||
|
|
|
@ -266,7 +266,66 @@ const actions = {
|
||||||
} finally {
|
} finally {
|
||||||
commit('set_free_drink_list_config_loading', false)
|
commit('set_free_drink_list_config_loading', false)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
async set_free_drink_list_reason({ commit, dispatch, rootState }, data) {
|
||||||
|
try {
|
||||||
|
commit('set_free_drink_list_reasons_loading', true)
|
||||||
|
const response = await axios.post(url.freeDrinkListReasons, {...data},{
|
||||||
|
headers: { Token: rootState.login.user.accessToken },
|
||||||
|
timeout
|
||||||
|
})
|
||||||
|
commit('set_free_drink_list_reasons', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
dispatch('connectionError/addError', null, { root: true })
|
||||||
|
if (e.message == 'Network Error') {
|
||||||
|
dispatch('connectionError/addError', null, { root: true })
|
||||||
}
|
}
|
||||||
|
if (e.response)
|
||||||
|
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||||
|
} finally {
|
||||||
|
commit('set_free_drink_list_reasons_loading', false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
,
|
||||||
|
async update_free_drink_list_reason({ commit, dispatch, rootState }, data) {
|
||||||
|
try {
|
||||||
|
commit('set_free_drink_list_reasons_loading', true)
|
||||||
|
const response = await axios.put(url.freeDrinkListReasons, {...data},{
|
||||||
|
headers: { Token: rootState.login.user.accessToken },
|
||||||
|
timeout
|
||||||
|
})
|
||||||
|
commit('set_free_drink_list_reasons', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
dispatch('connectionError/addError', null, { root: true })
|
||||||
|
if (e.message == 'Network Error') {
|
||||||
|
dispatch('connectionError/addError', null, { root: true })
|
||||||
|
}
|
||||||
|
if (e.response)
|
||||||
|
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||||
|
} finally {
|
||||||
|
commit('set_free_drink_list_reasons_loading', false)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async delete_free_drink_list_reason({ commit, dispatch, rootState }, data) {
|
||||||
|
try {
|
||||||
|
commit('set_free_drink_list_reasons_loading', true)
|
||||||
|
const response = await axios.post(url.deleteFreeDrinkListReason, {...data},{
|
||||||
|
headers: { Token: rootState.login.user.accessToken },
|
||||||
|
timeout
|
||||||
|
})
|
||||||
|
commit('set_free_drink_list_reasons', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
dispatch('connectionError/addError', null, { root: true })
|
||||||
|
if (e.message == 'Network Error') {
|
||||||
|
dispatch('connectionError/addError', null, { root: true })
|
||||||
|
}
|
||||||
|
if (e.response)
|
||||||
|
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||||
|
} finally {
|
||||||
|
commit('set_free_drink_list_reasons_loading', false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const getters = {
|
const getters = {
|
||||||
|
@ -356,6 +415,12 @@ const getters = {
|
||||||
free_drink_types(state) {
|
free_drink_types(state) {
|
||||||
return state.free_drink_types
|
return state.free_drink_types
|
||||||
},
|
},
|
||||||
|
free_drink_list_history_loading(state) {
|
||||||
|
return state.free_drink_list_history_loading
|
||||||
|
},
|
||||||
|
free_drink_list_config_loading(state) {
|
||||||
|
return state.free_drink_list_config_loading
|
||||||
|
},
|
||||||
free_drink_types_loading(state) {
|
free_drink_types_loading(state) {
|
||||||
return state.free_drink_types_loading
|
return state.free_drink_types_loading
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue