show wallets

This commit is contained in:
2026-06-10 11:36:45 +03:30
parent 689c51c27d
commit 5b525bd2c7
5 changed files with 50 additions and 18 deletions
+2 -9
View File
@@ -82,6 +82,7 @@ import { usePriceWithoutType } from '@/utils/usePrice'
import { useConfigStore } from '@/store/configStore'
import { useWalletAssets } from '@/composables/useWalletAssets'
import type { WalletMetalTotal } from '@/models/walletAssets'
import { resolveSummaryMetalWeight } from '@/utils/productAssets'
const nameProject = useConfigStore().config.name
const { assetsSummary, loadWalletAssets } = useWalletAssets()
@@ -107,16 +108,8 @@ onMounted(async () => {
}
})
function summaryMetalWeight(metal: WalletMetalTotal) {
if (inventoryCards.value.length > 0) {
return metal.product_weight
}
return metal.total_weight
}
function formatMetalTotal(metal: WalletMetalTotal) {
return `${summaryMetalWeight(metal)}${metal.unit}`
return `${resolveSummaryMetalWeight(metal, inventoryCards.value)}${metal.unit}`
}
</script>
@@ -47,6 +47,7 @@ import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import { usePriceWithoutType } from '@/utils/usePrice'
import { useWalletAssets } from '@/composables/useWalletAssets'
import type { WalletMetalTotal } from '@/models/walletAssets'
import { resolveSummaryMetalWeight } from '@/utils/productAssets'
const { assetsSummary, loadWalletAssets } = useWalletAssets()
@@ -68,15 +69,7 @@ onMounted(() => {
void loadWalletAssets()
})
function summaryMetalWeight(metal: WalletMetalTotal) {
if (inventoryCards.value.length > 0) {
return metal.product_weight
}
return metal.total_weight
}
function formatMetalTotal(metal: WalletMetalTotal) {
return `${summaryMetalWeight(metal)}${metal.unit}`
return `${resolveSummaryMetalWeight(metal, inventoryCards.value)}${metal.unit}`
}
</script>
@@ -12,6 +12,14 @@
is-line
:value="formatMetalTotal(metal)"
/>
<template v-for="card in cardsByMetal(metal.metal_id)" :key="`card-${card.product_id}`">
<BasicInfoItem
class="flex justify-between mr-4 text-sm"
:title="card.title"
is-line
:value="formatInventoryCardValue(card)"
/>
</template>
<a-divider class="!my-1" />
</template>
<BasicInfoItem
@@ -41,6 +49,7 @@ import BasicInfoItem from '@/components/BasicPacks/BasicInfoItem.vue'
import { usePrice } from '@/utils/usePrice'
import { useWalletAssets } from '@/composables/useWalletAssets'
import type { WalletMetalTotal } from '@/models/walletAssets'
import { formatInventoryCardValue } from '@/utils/productAssets'
const props = defineProps<{
show: boolean
@@ -59,6 +68,7 @@ const visible = computed({
set: (val) => emit('update:show', val),
})
const inventoryCards = computed(() => assetsSummary.value?.inventory_cards ?? [])
const metalTotals = computed(() => assetsSummary.value?.metal_totals ?? [])
const cashWallet = computed(() => assetsSummary.value?.cash_wallet ?? 0)
const totalRialValue = computed(() => assetsSummary.value?.total_rial_value ?? 0)
@@ -76,6 +86,10 @@ watch(
}
)
function cardsByMetal(metalId: number) {
return inventoryCards.value.filter((card) => Number(card.metal_id) === metalId)
}
function formatMetalTotal(metal: WalletMetalTotal) {
return `${metal.total_weight} ${metal.unit}`
}