2020-10-31 16:33:40 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2021-01-29 03:37:56 +00:00
|
|
|
<q-tabs v-model="tab" v-if="$q.screen.gt.sm">
|
|
|
|
<q-tab
|
|
|
|
v-for="(tabindex, index) in tabs"
|
|
|
|
:key="'tab' + index"
|
|
|
|
:name="tabindex.name"
|
|
|
|
:label="tabindex.label"
|
|
|
|
/>
|
|
|
|
</q-tabs>
|
|
|
|
<div class="fit row justify-end" v-else>
|
2021-03-18 16:23:57 +00:00
|
|
|
<q-btn
|
|
|
|
flat
|
|
|
|
round
|
|
|
|
icon="mdi-menu"
|
|
|
|
@click="
|
|
|
|
showDrawer = !showDrawer;
|
|
|
|
show = false;
|
|
|
|
"
|
|
|
|
/>
|
2021-01-29 03:37:56 +00:00
|
|
|
</div>
|
|
|
|
<q-drawer side="right" v-model="showDrawer" @click="showDrawer = !showDrawer" behavior="mobile">
|
2021-01-29 21:57:10 +00:00
|
|
|
<q-list v-model="tab" v-if="!$q.screen.gt.sm && !show">
|
2021-01-29 03:37:56 +00:00
|
|
|
<q-item
|
|
|
|
v-for="(tabindex, index) in tabs"
|
|
|
|
:key="'tab' + index"
|
|
|
|
:active="tab == tabindex.name"
|
|
|
|
clickable
|
|
|
|
@click="tab = tabindex.name"
|
|
|
|
>
|
|
|
|
<q-item-label>{{ tabindex.label }}</q-item-label>
|
|
|
|
</q-item>
|
|
|
|
</q-list>
|
2021-01-29 21:57:10 +00:00
|
|
|
<q-list v-if="show">
|
2021-01-31 16:09:29 +00:00
|
|
|
<div v-for="(transaction, index) in transactions" :key="index" class="col-sm-12">
|
2021-03-18 16:23:57 +00:00
|
|
|
<!-- TODO: In Vue3 use v-model:transaction="..." -->
|
2021-01-31 16:09:29 +00:00
|
|
|
<Transaction v-model:transaction="transactions[index]" />
|
2021-03-18 16:23:57 +00:00
|
|
|
</div>
|
2021-01-29 21:57:10 +00:00
|
|
|
</q-list>
|
2021-01-29 03:37:56 +00:00
|
|
|
</q-drawer>
|
|
|
|
<q-page padding class="fit row justify-left q-col-gutter-sm">
|
|
|
|
<q-tab-panels
|
|
|
|
v-model="tab"
|
|
|
|
style="background-color: transparent"
|
|
|
|
class="q-pa-none col-12"
|
|
|
|
animated
|
|
|
|
>
|
|
|
|
<q-tab-panel name="add" class="q-px-xs">
|
2021-03-18 16:23:57 +00:00
|
|
|
<BalanceAdd
|
|
|
|
@open-history="
|
|
|
|
showDrawer = !showDrawer;
|
|
|
|
show = true;
|
|
|
|
"
|
|
|
|
/>
|
2021-01-29 03:37:56 +00:00
|
|
|
</q-tab-panel>
|
|
|
|
<q-tab-panel name="transfer" class="q-px-xs">
|
2021-03-18 16:23:57 +00:00
|
|
|
<BalanceTransfer
|
|
|
|
@open-history="
|
|
|
|
showDrawer = !showDrawer;
|
|
|
|
show = true;
|
|
|
|
"
|
|
|
|
/>
|
2021-01-29 03:37:56 +00:00
|
|
|
</q-tab-panel>
|
|
|
|
</q-tab-panels>
|
2020-10-31 16:33:40 +00:00
|
|
|
</q-page>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-01-30 03:16:17 +00:00
|
|
|
import { computed, defineComponent, ref, onMounted } from 'vue';
|
2021-01-31 19:40:18 +00:00
|
|
|
import { Store, useStore } from 'vuex';
|
2021-01-29 03:37:56 +00:00
|
|
|
import { hasPermissions, hasSomePermissions } from 'src/utils/permission';
|
|
|
|
import PERMISSIONS from '../permissions';
|
|
|
|
import { Screen } from 'quasar';
|
|
|
|
import BalanceAdd from '../components/BalanceAdd.vue';
|
|
|
|
import BalanceTransfer from '../components/BalanceTransfer.vue';
|
|
|
|
import Transaction from '../components/Transaction.vue';
|
2021-01-31 19:40:18 +00:00
|
|
|
import { BalanceInterface, StateInterfaceBalance } from '../store/balance';
|
2021-01-29 03:37:56 +00:00
|
|
|
|
2020-10-31 16:33:40 +00:00
|
|
|
export default defineComponent({
|
2021-01-29 03:37:56 +00:00
|
|
|
name: 'BalanceManage',
|
|
|
|
components: { BalanceAdd, BalanceTransfer, Transaction },
|
2020-10-31 16:33:40 +00:00
|
|
|
setup(_, { root }) {
|
2021-01-31 19:40:18 +00:00
|
|
|
//const store = <Store<StateInterfaceBalance>>root.$store;
|
|
|
|
const store = useStore<Store<StateInterface>>();
|
|
|
|
const balanceState = <BalanceInterface>store.state.balance;
|
2021-03-18 16:23:57 +00:00
|
|
|
const now = new Date();
|
2021-01-29 21:57:10 +00:00
|
|
|
onMounted(() => {
|
2021-03-18 16:23:57 +00:00
|
|
|
void store.dispatch('balance/getTransactions', {
|
|
|
|
filter: { from: new Date(now.getFullYear(), now.getMonth(), now.getDate()) },
|
2021-01-30 10:23:18 +00:00
|
|
|
});
|
2021-03-18 16:23:57 +00:00
|
|
|
});
|
|
|
|
const transactions = computed(() => {
|
2021-01-31 19:40:18 +00:00
|
|
|
const a = balanceState.transactions
|
2021-03-18 16:23:57 +00:00
|
|
|
.filter((t) => t.original_id == undefined)
|
|
|
|
.filter((t) => t.time > new Date(now.getFullYear(), now.getMonth(), now.getDate()))
|
|
|
|
.sort((a, b) => (a.time >= b.time ? -1 : 1));
|
|
|
|
console.log(a);
|
|
|
|
return a;
|
|
|
|
});
|
2021-01-29 03:37:56 +00:00
|
|
|
|
|
|
|
const canAdd = () =>
|
|
|
|
hasSomePermissions([PERMISSIONS.DEBIT, PERMISSIONS.CREDIT, PERMISSIONS.DEBIT_OWN], store);
|
|
|
|
|
|
|
|
interface Tab {
|
|
|
|
name: string;
|
|
|
|
label: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const tabs: Tab[] = [
|
|
|
|
...(canAdd() ? [{ name: 'add', label: 'Anschreiben' }] : []),
|
|
|
|
...(hasSomePermissions([PERMISSIONS.SEND, PERMISSIONS.SEND_OTHER], store)
|
|
|
|
? [{ name: 'transfer', label: 'Übertragen' }]
|
2021-03-18 16:23:57 +00:00
|
|
|
: []),
|
2021-01-29 03:37:56 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
const drawer = ref<boolean>(false);
|
|
|
|
|
2021-03-18 16:23:57 +00:00
|
|
|
/* const showDrawer = computed({
|
2021-01-29 03:37:56 +00:00
|
|
|
get: () => {
|
|
|
|
return !Screen.gt.sm && drawer.value;
|
|
|
|
},
|
|
|
|
set: (val: boolean) => {
|
|
|
|
drawer.value = val;
|
|
|
|
}
|
2020-10-31 16:33:40 +00:00
|
|
|
});
|
2021-01-30 10:23:18 +00:00
|
|
|
*/
|
|
|
|
const showDrawer = ref<boolean>(false);
|
2021-01-29 03:37:56 +00:00
|
|
|
const tab = ref<string>(canAdd() ? 'add' : 'transfer');
|
2021-01-29 21:57:10 +00:00
|
|
|
const show = ref<boolean>(false);
|
2021-01-29 03:37:56 +00:00
|
|
|
return {
|
|
|
|
showDrawer,
|
|
|
|
tab,
|
|
|
|
tabs,
|
2021-01-29 21:57:10 +00:00
|
|
|
transactions,
|
2021-03-18 16:23:57 +00:00
|
|
|
show,
|
2021-01-29 03:37:56 +00:00
|
|
|
};
|
2021-03-18 16:23:57 +00:00
|
|
|
},
|
2020-10-31 16:33:40 +00:00
|
|
|
});
|
|
|
|
</script>
|