tables display
This commit is contained in:
@@ -5,6 +5,7 @@ import {computedAsync} from "@vueuse/core";
|
|||||||
import {TransactionResponse} from "@/generated/mammon";
|
import {TransactionResponse} from "@/generated/mammon";
|
||||||
import {formatEveDate} from "@/formaters.ts";
|
import {formatEveDate} from "@/formaters.ts";
|
||||||
import {IskLabel} from "@/market";
|
import {IskLabel} from "@/market";
|
||||||
|
import {SortableHeader, useSort, VirtualScrollTable} from "@/components/table";
|
||||||
|
|
||||||
const {ledgerId} = useLedgerParam();
|
const {ledgerId} = useLedgerParam();
|
||||||
|
|
||||||
@@ -15,6 +16,15 @@ const transactions = computedAsync<TransactionResponse[]>(async () => {
|
|||||||
return [];
|
return [];
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const { sortedArray, headerProps } = useSort(() => transactions.value.map(transaction => {
|
||||||
|
return {
|
||||||
|
transactionId: transaction.transactionId,
|
||||||
|
description: transaction.description,
|
||||||
|
date: new Date(transaction.datetime),
|
||||||
|
balance: getIskBalance(transaction)
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
const getIskBalance = (transaction: TransactionResponse) => {
|
const getIskBalance = (transaction: TransactionResponse) => {
|
||||||
if (!ledgerId.value) {
|
if (!ledgerId.value) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -37,10 +47,25 @@ const getIskBalance = (transaction: TransactionResponse) => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<div class="flex items-end gap-2 mt-2" v-for="transaction in transactions" :key="transaction.transactionId">
|
<VirtualScrollTable :list="sortedArray" :itemHeight="33" bottom="1rem">
|
||||||
<span>{{formatEveDate(new Date(transaction.datetime))}}</span>
|
<template #default="{ list }">
|
||||||
<IskLabel :amount="getIskBalance(transaction)" />
|
<thead>
|
||||||
<span>{{transaction.description}}</span>
|
<tr>
|
||||||
</div>
|
<SortableHeader v-bind="headerProps" sortKey="date">Date</SortableHeader>
|
||||||
|
<SortableHeader v-bind="headerProps" sortKey="balance">Balance</SortableHeader>
|
||||||
|
<SortableHeader v-bind="headerProps" sortKey="description">Description</SortableHeader>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="t in list" :key="t.data.transactionId">
|
||||||
|
<td>{{formatEveDate(t.data.date)}}</td>
|
||||||
|
<td class="text-right">
|
||||||
|
<IskLabel :amount="t.data.balance" />
|
||||||
|
</td>
|
||||||
|
<td>{{t.data.description}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</template>
|
||||||
|
</VirtualScrollTable>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {SortableHeader, useSort, VirtualScrollTable} from "@/components/table";
|
|||||||
|
|
||||||
const {ledgers} = storeToRefs(useLedgersStore());
|
const {ledgers} = storeToRefs(useLedgersStore());
|
||||||
|
|
||||||
const { sortedArray, headerProps } = useSort<Ledger>(ledgers)
|
const { sortedArray, headerProps } = useSort<Ledger>(ledgers);
|
||||||
|
|
||||||
const editModal = ref<typeof EditLedgerModal>();
|
const editModal = ref<typeof EditLedgerModal>();
|
||||||
const editingLedgerId = ref("");
|
const editingLedgerId = ref("");
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
import {getLedgerBalance, useLedgerParam} from "@/ledger";
|
import {getLedgerBalance, useLedgerParam} from "@/ledger";
|
||||||
import {computedAsync} from "@vueuse/core";
|
import {computedAsync} from "@vueuse/core";
|
||||||
import {BalanceResponse} from "@/generated/mammon";
|
import {BalanceResponse} from "@/generated/mammon";
|
||||||
import {IskLabel, MarketTypeLabel} from "@/market";
|
import {getMarketType, IskLabel, MarketTypeLabel} from "@/market";
|
||||||
|
import {SortableHeader, useSort, VirtualScrollTable} from "@/components/table";
|
||||||
|
|
||||||
const {ledgerId} = useLedgerParam();
|
const {ledgerId} = useLedgerParam();
|
||||||
|
|
||||||
@@ -13,16 +14,47 @@ const balance = computedAsync<BalanceResponse>(async () => {
|
|||||||
return undefined;
|
return undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { sortedArray, headerProps } = useSort(computedAsync(async () => {
|
||||||
|
const itemBalances = balance.value?.itemBalances;
|
||||||
|
|
||||||
|
if (!itemBalances) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return await Promise.all(itemBalances.map(async i => {
|
||||||
|
const item = await getMarketType(i.typeId);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...i,
|
||||||
|
name: item.name
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
}, []));
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="balance" class="mt-4">
|
<div v-if="balance" class="mt-4">
|
||||||
<div class="border-b-1">
|
<div class="flex justify-end w-full">
|
||||||
<IskLabel class="mb-2" :amount="balance.iskBalance" />
|
<IskLabel class="mb-2" :amount="balance.iskBalance" />
|
||||||
</div>
|
</div>
|
||||||
<div v-for="item in balance.itemBalances" :key="item.typeId" class="mt-2 flex gap-2">
|
<VirtualScrollTable :list="sortedArray" :itemHeight="33" bottom="1rem">
|
||||||
<MarketTypeLabel :id="item.typeId" />
|
<template #default="{ list }">
|
||||||
<span>{{item.quantity}}</span>
|
<thead>
|
||||||
</div>
|
<tr>
|
||||||
|
<SortableHeader v-bind="headerProps" sortKey="name">Item</SortableHeader>
|
||||||
|
<SortableHeader v-bind="headerProps" sortKey="quantity">Balance</SortableHeader>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="i in list" :key="i.data.typeId">
|
||||||
|
<td>
|
||||||
|
<MarketTypeLabel :id="i.data.typeId" :name="i.data.name" />
|
||||||
|
</td>
|
||||||
|
<td class="text-right">{{i.data.quantity}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</template>
|
||||||
|
</VirtualScrollTable>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user