Backend Connection für Freigetränke Band und Dienste
Es wurde die Verbindung zur Schnittstelle aufgebaut. Freigetränke werden Dynamisch gehalten.
This commit is contained in:
parent
22c5ebce1b
commit
8ac74c9f64
|
@ -9,106 +9,30 @@
|
||||||
<v-icon>{{ menuIcon }}</v-icon>
|
<v-icon>{{ menuIcon }}</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-subtitle v-if="(limit - amount) > 0">
|
<v-card-subtitle v-if="(limit - free_drink_list_history_job_credit) > 0">
|
||||||
Noch {{ ((limit - amount) / 100).toFixed(2) }} €
|
Noch {{ ((limit - free_drink_list_history_job_credit) / 100).toFixed(2) }} €
|
||||||
übrig!!
|
übrig!!
|
||||||
</v-card-subtitle>
|
</v-card-subtitle>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-row v-if="!loading">
|
<v-row v-if="!loading">
|
||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col cols="6" xs="3" sm="4" class="drinkCol">
|
<v-col v-for="freeDrink in free_drink_list_config_job" :key="freeDrink.id" cols="6" xs="3" sm="4" class="drinkCol">
|
||||||
<v-btn
|
<v-btn
|
||||||
class="drinkBtn"
|
class="drinkBtn"
|
||||||
:disabled="locked"
|
block
|
||||||
:color="color"
|
:disabled="locked"
|
||||||
@click="addAmount(140)"
|
:color="color"
|
||||||
>Bier</v-btn>
|
@click="addAmount(freeDrink, freeDrinkTypeJob)"
|
||||||
</v-col>
|
>{{freeDrink.label}}</v-btn>
|
||||||
<v-col cols="6" xs="3" sm="4" class="drinkCol">
|
|
||||||
<v-btn
|
|
||||||
class="drinkBtn"
|
|
||||||
block
|
|
||||||
:disabled="locked"
|
|
||||||
:color="color"
|
|
||||||
@click="addAmount(200)"
|
|
||||||
>Cuba</v-btn>
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="6" xs="3" sm="4" class="drinkCol">
|
|
||||||
<v-btn
|
|
||||||
class="drinkBtn"
|
|
||||||
block
|
|
||||||
:disabled="locked"
|
|
||||||
:color="color"
|
|
||||||
@click="addAmount(50)"
|
|
||||||
>Schnaps</v-btn>
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="6" xs="3" sm="4" class="drinkCol">
|
|
||||||
<v-btn
|
|
||||||
class="drinkBtn"
|
|
||||||
block
|
|
||||||
:disabled="locked"
|
|
||||||
:color="color"
|
|
||||||
@click="addAmount(200)"
|
|
||||||
>Wein</v-btn>
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="6" xs="3" sm="4" class="drinkCol">
|
|
||||||
<v-btn
|
|
||||||
class="drinkBtn"
|
|
||||||
block
|
|
||||||
:disabled="locked"
|
|
||||||
:color="color"
|
|
||||||
@click="addAmount(200)"
|
|
||||||
>Gin Tonic</v-btn>
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="6" xs="3" sm="4" class="drinkCol">
|
|
||||||
<v-btn
|
|
||||||
class="drinkBtn"
|
|
||||||
block
|
|
||||||
:disabled="locked"
|
|
||||||
:color="color"
|
|
||||||
@click="addAmount(100)"
|
|
||||||
>Fritz</v-btn>
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="6" xs="3" sm="4" class="drinkCol">
|
|
||||||
<v-btn
|
|
||||||
class="drinkBtn"
|
|
||||||
block
|
|
||||||
:disabled="locked"
|
|
||||||
:color="color"
|
|
||||||
@click="addAmount(100)"
|
|
||||||
>Saft</v-btn>
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="6" xs="3" sm="4" class="drinkCol">
|
|
||||||
<v-btn
|
|
||||||
class="drinkBtn"
|
|
||||||
block
|
|
||||||
:disabled="locked"
|
|
||||||
:color="color"
|
|
||||||
@click="addAmount(30)"
|
|
||||||
>Wasser</v-btn>
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row v-if="!loading">
|
<v-row v-if="!loading" class="justify-end">
|
||||||
<v-col cols="8">
|
<v-col cols="3">
|
||||||
<v-text-field
|
|
||||||
outlined
|
|
||||||
type="number"
|
|
||||||
label="Benutzerdefinierter Betrag"
|
|
||||||
:disabled="locked"
|
|
||||||
v-model="customValue"
|
|
||||||
></v-text-field>
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="2">
|
|
||||||
<v-btn fab :color="color" :disabled="locked" @click="addAmount(customValue)">
|
|
||||||
<v-icon>{{ plus }}</v-icon>
|
|
||||||
</v-btn>
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="2">
|
|
||||||
<v-list-item>
|
<v-list-item>
|
||||||
<v-list-item-content class="text-center">
|
<v-list-item-content class="text-center">
|
||||||
<v-list-item-action-text :class="getColor()">
|
<v-list-item-action-text :class="getColor()">
|
||||||
{{ (amount / 100).toFixed(2) }}
|
{{ (free_drink_list_history_job_credit / 100).toFixed(2) }}
|
||||||
€
|
€
|
||||||
</v-list-item-action-text>
|
</v-list-item-action-text>
|
||||||
</v-list-item-content>
|
</v-list-item-content>
|
||||||
|
@ -119,6 +43,41 @@
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
<v-card class="mx-auto" outlined>
|
||||||
|
<v-card-title>
|
||||||
|
<div class="title">Bandgetränke</div>
|
||||||
|
<v-btn class="menuBtn" @click.stop="isMenuShow = !isMenuShow" icon>
|
||||||
|
<v-icon>{{ menuIcon }}</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
<v-row v-if="!loading">
|
||||||
|
<v-col cols="12">
|
||||||
|
<v-row>
|
||||||
|
<v-col v-for="freeDrink in free_drink_list_config_band" :key="freeDrink.id" cols="6" xs="3" sm="4" class="drinkCol">
|
||||||
|
<v-btn
|
||||||
|
class="drinkBtn"
|
||||||
|
block
|
||||||
|
:color="color_fix"
|
||||||
|
@click="addAmount(freeDrink, freeDrinkTypeBand)"
|
||||||
|
>{{freeDrink.label}}</v-btn>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-row v-if="!loading" class="justify-end">
|
||||||
|
<v-col cols="3">
|
||||||
|
<v-list-item>
|
||||||
|
<v-list-item-content class="text-center">
|
||||||
|
<v-list-item-action-text class="title">
|
||||||
|
{{ free_drink_list_history_band_without_canceled.length }} Getränke
|
||||||
|
</v-list-item-action-text>
|
||||||
|
</v-list-item-content>
|
||||||
|
</v-list-item>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
</v-container>
|
</v-container>
|
||||||
|
|
||||||
<v-navigation-drawer v-model="isMenuShow" right app clipped>
|
<v-navigation-drawer v-model="isMenuShow" right app clipped>
|
||||||
|
@ -127,13 +86,13 @@
|
||||||
<v-list-item-title class="headline">Verlauf</v-list-item-title>
|
<v-list-item-title class="headline">Verlauf</v-list-item-title>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
<v-divider />
|
<v-divider />
|
||||||
<div
|
<!-- <div
|
||||||
v-for="message in messages"
|
v-for="message in messages"
|
||||||
three-line
|
three-line
|
||||||
:key="messages.indexOf(message)"
|
:key="messages.indexOf(message)"
|
||||||
class="history-item"
|
class="history-item"
|
||||||
>
|
>
|
||||||
<v-list-item three-line inactive @click="stornoAmount(message)">
|
<v-list-item three-line inactive @click="canceledAmount(message)">
|
||||||
<v-list-item-content>
|
<v-list-item-content>
|
||||||
<v-list-item-title>{{ now(message.date) }}</v-list-item-title>
|
<v-list-item-title>{{ now(message.date) }}</v-list-item-title>
|
||||||
<v-list-item-subtitle>
|
<v-list-item-subtitle>
|
||||||
|
@ -141,9 +100,28 @@
|
||||||
createMessage(message)
|
createMessage(message)
|
||||||
}}
|
}}
|
||||||
</v-list-item-subtitle>
|
</v-list-item-subtitle>
|
||||||
<v-list-item-subtitle class="red--text" v-if="message.storno">STORNIERT!!!</v-list-item-subtitle>
|
<v-list-item-subtitle class="red--text" v-if="message.canceled">STORNIERT!!!</v-list-item-subtitle>
|
||||||
<v-list-item-action-text
|
<v-list-item-action-text
|
||||||
v-if="isStronoEnabled(message.date) && !message.storno"
|
v-if="isStronoEnabled(message.date) && !message.canceled"
|
||||||
|
>Klicken um zu Stornieren</v-list-item-action-text>
|
||||||
|
</v-list-item-content>
|
||||||
|
</v-list-item>
|
||||||
|
</div> -->
|
||||||
|
<div
|
||||||
|
v-for="freeDrinkHistory in free_drink_list_history"
|
||||||
|
:key="freeDrinkHistory.id"
|
||||||
|
>
|
||||||
|
<v-list-item three-line inactive @click="canceledAmount(freeDrinkHistory)">
|
||||||
|
<v-list-item-content>
|
||||||
|
<v-list-item-title>{{ now(freeDrinkHistory.timestamp) }}</v-list-item-title>
|
||||||
|
<v-list-item-subtitle>{{ freeDrinkHistory.free_drink_type.name }}: {{ freeDrinkHistory.free_drink_config.label }} wurde für
|
||||||
|
{{
|
||||||
|
(freeDrinkHistory.free_drink_config.price/100).toFixed(2)
|
||||||
|
}} € hinzugefügt
|
||||||
|
</v-list-item-subtitle>
|
||||||
|
<v-list-item-subtitle class="red--text" v-if="freeDrinkHistory.canceled">STORNIERT!!!</v-list-item-subtitle>
|
||||||
|
<v-list-item-action-text
|
||||||
|
v-if="isStronoEnabled(freeDrinkHistory.timestamp) && !freeDrinkHistory.canceled"
|
||||||
>Klicken um zu Stornieren</v-list-item-action-text>
|
>Klicken um zu Stornieren</v-list-item-action-text>
|
||||||
</v-list-item-content>
|
</v-list-item-content>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
@ -151,18 +129,16 @@
|
||||||
</v-list-item-group>
|
</v-list-item-group>
|
||||||
</v-navigation-drawer>
|
</v-navigation-drawer>
|
||||||
|
|
||||||
<v-dialog v-model="showConfirmStornoDialog" max-width="290">
|
<v-dialog v-model="showConfirmCanceledDialog" max-width="290">
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-card-title>Willst du wirklich??</v-card-title>
|
<v-card-title>Willst du wirklich??</v-card-title>
|
||||||
<v-card-text v-if="stornoMessage">
|
<v-card-text v-if="canceledMessage">
|
||||||
Willst du wirklich den Betrag
|
{{canceledMessage.free_drink_type.name}}: Willst du wirklich ein {{canceledMessage.free_drink_config.label}} im Wert von {{(canceledMessage.free_drink_config.price/100).toFixed(2)}} € stornieren?
|
||||||
{{ (stornoMessage.amount / 100).toFixed(2) }}€ von
|
|
||||||
den Dienstgetränke stornieren?
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-spacer />
|
<v-spacer />
|
||||||
<v-btn text @click="cancelStorno">Abbrechen</v-btn>
|
<v-btn text @click="cancelCanceled">Abbrechen</v-btn>
|
||||||
<v-btn text @click="acceptStorno">Stornieren</v-btn>
|
<v-btn text @click="acceptCanceled">Stornieren</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
@ -176,58 +152,66 @@
|
||||||
<script>
|
<script>
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
import AddAmountSkeleton from '../user/Skeleton/AddAmountSkeleton'
|
import AddAmountSkeleton from '../user/Skeleton/AddAmountSkeleton'
|
||||||
|
import { mapActions, mapGetters } from 'vuex'
|
||||||
import { mdiPlus, mdiMenu } from '@mdi/js'
|
import { mdiPlus, mdiMenu } from '@mdi/js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'BarFreedrinks',
|
name: 'BarFreedrinks',
|
||||||
components: { AddAmountSkeleton },
|
components: { AddAmountSkeleton },
|
||||||
created() {
|
created() {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.timer = setInterval(() => (this.componentRenderer += 1), 1000)
|
this.timer = setInterval(() => (this.componentRenderer += 1), 1000)
|
||||||
|
this.get_free_drink_list_config()
|
||||||
|
this.get_free_drink_list_history()
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
plus: mdiPlus,
|
plus: mdiPlus,
|
||||||
menuIcon: mdiMenu,
|
menuIcon: mdiMenu,
|
||||||
loading: true,
|
loading: true,
|
||||||
locked: false,
|
showConfirmCanceledDialog: false,
|
||||||
showConfirmStornoDialog: false,
|
canceledMessage: null,
|
||||||
stornoMessage: null,
|
|
||||||
limit: 1000,
|
limit: 1000,
|
||||||
amount: 0,
|
amount: 0,
|
||||||
customValue: null,
|
customValue: null,
|
||||||
color: 'green accent-4',
|
color: 'green accent-4',
|
||||||
|
color_fix: 'green accent-4',
|
||||||
messages: [],
|
messages: [],
|
||||||
timer: '',
|
timer: '',
|
||||||
componentRenderer: 0,
|
componentRenderer: 0,
|
||||||
isMenuShow: false
|
isMenuShow: false,
|
||||||
|
freeDrinkTypeJob: 1,
|
||||||
|
freeDrinkTypeBand: 3
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addAmount(amount) {
|
...mapActions('freeDrinkList', ['get_free_drink_list_config', 'get_free_drink_list_history','set_free_drink_list_history', 'update_free_drink_list_history']),
|
||||||
if (amount) {
|
output() {
|
||||||
|
console.log(this.free_drink_list_config)
|
||||||
|
},
|
||||||
|
addAmount(freeDrink, free_drink_type_id) {
|
||||||
|
this.set_free_drink_list_history({...freeDrink, free_drink_type_id})
|
||||||
|
/*if (amount) {
|
||||||
this.amount += amount
|
this.amount += amount
|
||||||
this.generateMessage(amount)
|
this.generateMessage(amount)
|
||||||
}
|
}
|
||||||
this.checkLocked()
|
this.checkLocked()*/
|
||||||
},
|
},
|
||||||
stornoAmount(message) {
|
canceledAmount(historyElement) {
|
||||||
if (!this.isStronoEnabled(message.date) || message.storno) {
|
if (!this.isStronoEnabled(historyElement.timestamp)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
this.showConfirmCanceledDialog = true
|
||||||
this.showConfirmStornoDialog = true
|
this.canceledMessage = historyElement
|
||||||
this.stornoMessage = message
|
|
||||||
},
|
},
|
||||||
|
|
||||||
cancelStorno() {
|
cancelCanceled() {
|
||||||
this.showConfirmStornoDialog = null
|
this.showConfirmCanceledDialog = null
|
||||||
this.stornoMessage = null
|
this.canceledMessage = null
|
||||||
},
|
},
|
||||||
generateMessage(amount) {
|
generateMessage(amount) {
|
||||||
this.messages.push({
|
this.messages.push({
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
storno: false,
|
canceled: false,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
error: false,
|
error: false,
|
||||||
visible: true,
|
visible: true,
|
||||||
|
@ -254,14 +238,14 @@ export default {
|
||||||
getColor() {
|
getColor() {
|
||||||
return this.locked ? 'title red--text' : 'title'
|
return this.locked ? 'title red--text' : 'title'
|
||||||
},
|
},
|
||||||
acceptStorno() {
|
acceptCanceled() {
|
||||||
this.stornoMessage.storno = true
|
this.canceledMessage.canceled = true
|
||||||
this.amount -= this.stornoMessage.amount
|
this.update_free_drink_list_history(this.canceledMessage)
|
||||||
console.log(this.amount, this.stornoMessage)
|
this.cancelCanceled()
|
||||||
this.cancelStorno()
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapGetters('freeDrinkList', ['free_drink_list_config_job', 'free_drink_list_config_band', 'free_drink_list_history', 'free_drink_list_history_job_credit', 'free_drink_list_history_band', 'free_drink_list_history_band_without_canceled']),
|
||||||
now() {
|
now() {
|
||||||
return now => {
|
return now => {
|
||||||
var actual = new Date()
|
var actual = new Date()
|
||||||
|
@ -316,6 +300,9 @@ export default {
|
||||||
var actual = new Date()
|
var actual = new Date()
|
||||||
return actual - now < 60000
|
return actual - now < 60000
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
locked() {
|
||||||
|
return this.free_drink_list_history_job_credit >= 1000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//const main = 'https://192.168.5.128:5000/'
|
//const main = 'https://192.168.5.128:5000/'
|
||||||
//const main = 'http://localhost:5000/'
|
const main = 'http://localhost:5000/'
|
||||||
//const main = 'http://192.168.5.118:5000/'
|
//const main = 'http://192.168.5.118:5000/'
|
||||||
const main = 'https://groeger-clan.duckdns.org:5000/'
|
//const main = 'https://groeger-clan.duckdns.org:5000/'
|
||||||
//const main = 'https://flaschengeist.wu5.de:5000/'
|
//const main = 'https://flaschengeist.wu5.de:5000/'
|
||||||
|
|
||||||
const url = {
|
const url = {
|
||||||
|
@ -28,6 +28,9 @@ const url = {
|
||||||
saveLifeTime: main + 'saveLifeTime',
|
saveLifeTime: main + 'saveLifeTime',
|
||||||
getLifeTime: main + 'getLifeTime',
|
getLifeTime: main + 'getLifeTime',
|
||||||
resetPassword: main + 'passwordReset',
|
resetPassword: main + 'passwordReset',
|
||||||
|
freeDrinkListConfig: main + 'freeDrinkListConfig',
|
||||||
|
freeDrinkListHistory: main + 'freeDrinkListHistory',
|
||||||
|
deleteDrinkListHistory: main + 'deleteDrinkListHistory',
|
||||||
vorstand: {
|
vorstand: {
|
||||||
sm: {
|
sm: {
|
||||||
addUser: main + 'sm/addUser',
|
addUser: main + 'sm/addUser',
|
||||||
|
|
|
@ -13,6 +13,7 @@ import jkm from '@/store/modules/jobkindManager'
|
||||||
import jobInvites from '@/store/modules/jobInvites'
|
import jobInvites from '@/store/modules/jobInvites'
|
||||||
import jobRequests from '@/store/modules/jobRequests'
|
import jobRequests from '@/store/modules/jobRequests'
|
||||||
import connectionError from '@/store/modules/connectionError'
|
import connectionError from '@/store/modules/connectionError'
|
||||||
|
import freeDrinkList from '@/store/modules/freeDrinkList'
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ export default new Vuex.Store({
|
||||||
jkm,
|
jkm,
|
||||||
jobInvites,
|
jobInvites,
|
||||||
jobRequests,
|
jobRequests,
|
||||||
connectionError
|
connectionError,
|
||||||
|
freeDrinkList
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,155 @@
|
||||||
|
import axios from 'axios'
|
||||||
|
import url from '@/plugins/routes'
|
||||||
|
const timeout = 20000
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
free_drink_list_config: [],
|
||||||
|
free_drink_list_history: []
|
||||||
|
}
|
||||||
|
|
||||||
|
const mutations = {
|
||||||
|
set_free_drink_list_config(state, data) {
|
||||||
|
state.free_drink_list_config = data
|
||||||
|
},
|
||||||
|
set_free_drink_list_history(state, data) {
|
||||||
|
data.forEach(item => {
|
||||||
|
item.timestamp = new Date(
|
||||||
|
item.timestamp.year,
|
||||||
|
item.timestamp.month - 1,
|
||||||
|
item.timestamp.day,
|
||||||
|
item.timestamp.hour,
|
||||||
|
item.timestamp.minute,
|
||||||
|
item.timestamp.second
|
||||||
|
)
|
||||||
|
})
|
||||||
|
state.free_drink_list_history = data
|
||||||
|
state.free_drink_list_history.reverse()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const actions = {
|
||||||
|
async get_free_drink_list_config({ commit, dispatch, rootState }) {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(url.freeDrinkListConfig, {
|
||||||
|
headers: { Token: rootState.login.user.accessToken },
|
||||||
|
timeout
|
||||||
|
})
|
||||||
|
commit('set_free_drink_list_config', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
if (e.message == 'Network Error') {
|
||||||
|
dispatch('connectionError/addError', null, { root: true })
|
||||||
|
}
|
||||||
|
if (e.response)
|
||||||
|
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async get_free_drink_list_history({ commit, dispatch, rootState }) {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(url.freeDrinkListHistory, {
|
||||||
|
headers: { Token: rootState.login.user.accessToken },
|
||||||
|
timeout
|
||||||
|
})
|
||||||
|
commit('set_free_drink_list_history', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
if (e.message == 'Network Error') {
|
||||||
|
dispatch('connectionError/addError', null, { root: true })
|
||||||
|
}
|
||||||
|
if (e.response)
|
||||||
|
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async set_free_drink_list_history({ commit, dispatch, rootState }, data) {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(
|
||||||
|
url.freeDrinkListHistory,
|
||||||
|
{ ...data },
|
||||||
|
{
|
||||||
|
headers: { Token: rootState.login.user.accessToken },
|
||||||
|
timeout
|
||||||
|
}
|
||||||
|
)
|
||||||
|
commit('set_free_drink_list_history', response.data)
|
||||||
|
} catch (e) {
|
||||||
|
if (e.message == 'Network Error') {
|
||||||
|
dispatch('connectionError/addError', null, { root: true })
|
||||||
|
}
|
||||||
|
if (e.response)
|
||||||
|
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async update_free_drink_list_history({ commit, dispatch, rootState }, data) {
|
||||||
|
try {
|
||||||
|
await axios.put(
|
||||||
|
url.freeDrinkListHistory,
|
||||||
|
{ ...data },
|
||||||
|
{ headers: { Token: rootState.login.user.accessToken }, timeout }
|
||||||
|
)
|
||||||
|
commit('set_free_drink_list_history', data)
|
||||||
|
} catch (e) {
|
||||||
|
if (e.message == 'Network Error') {
|
||||||
|
dispatch('connectionError/addError', null, { root: true })
|
||||||
|
}
|
||||||
|
if (e.response)
|
||||||
|
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getters = {
|
||||||
|
free_drink_list_config(state) {
|
||||||
|
return state.free_drink_list_config
|
||||||
|
},
|
||||||
|
free_drink_list_config_job(state) {
|
||||||
|
return state.free_drink_list_config.filter(item => {
|
||||||
|
console.log(item)
|
||||||
|
return item.free_drink_types.find(drink_type => {
|
||||||
|
return drink_type.id == 1
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
free_drink_list_config_workgroup(state) {
|
||||||
|
return state.free_drink_list_config.filter(item => {
|
||||||
|
return item.free_drink_types.find(drink_type => {
|
||||||
|
return drink_type.id == 2
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
free_drink_list_config_band(state) {
|
||||||
|
return state.free_drink_list_config.filter(item => {
|
||||||
|
return item.free_drink_types.find(drink_type => {
|
||||||
|
return drink_type.id == 3
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
free_drink_list_history(state) {
|
||||||
|
return state.free_drink_list_history
|
||||||
|
},
|
||||||
|
free_drink_list_history_band(state) {
|
||||||
|
return state.free_drink_list_history.filter(item => {
|
||||||
|
return item.free_drink_type.id == 3
|
||||||
|
})
|
||||||
|
},
|
||||||
|
free_drink_list_history_band_without_canceled(state) {
|
||||||
|
return state.free_drink_list_history.filter(item => {
|
||||||
|
return item.free_drink_type.id == 3 && !item.canceled
|
||||||
|
})
|
||||||
|
},
|
||||||
|
free_drink_list_history_job_credit(state) {
|
||||||
|
let jobDrinks = state.free_drink_list_history.filter(item => {
|
||||||
|
return item.free_drink_type.id == 1 && !item.storno
|
||||||
|
})
|
||||||
|
let credit = 0
|
||||||
|
jobDrinks.forEach(item => {
|
||||||
|
credit += item.free_drink_config.price
|
||||||
|
})
|
||||||
|
return credit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
namespaced: true,
|
||||||
|
state,
|
||||||
|
mutations,
|
||||||
|
actions,
|
||||||
|
getters
|
||||||
|
}
|
Loading…
Reference in New Issue