2026-05-14 13:44:43 +03:30
|
|
|
<template>
|
|
|
|
|
<div class="bg-primary rounded-lg p-2 py-3 mt-2">
|
2026-06-09 21:04:22 +03:30
|
|
|
<div v-if="meta?.has_count_based_products" class="flex justify-center text-tertiary w-full z-20">
|
2026-05-14 13:44:43 +03:30
|
|
|
محصولات:
|
2026-06-09 21:04:22 +03:30
|
|
|
<div class="text-l mr-2 font-bold">{{ countBasedInventory }} عدد</div>
|
2026-05-14 13:44:43 +03:30
|
|
|
</div>
|
2026-06-09 21:04:22 +03:30
|
|
|
<template v-if="meta?.single_metal && primaryMetalTotal">
|
|
|
|
|
<div class="flex mt-2 justify-center text-tertiary w-full z-20">
|
|
|
|
|
{{ primaryMetalTotal.label }}:
|
|
|
|
|
<div class="text-l mr-2 font-bold">{{ formatMetalTotal(primaryMetalTotal) }}</div>
|
|
|
|
|
<BasicIcon
|
|
|
|
|
icon="vuesax-linear:info-circle"
|
|
|
|
|
size="18"
|
|
|
|
|
color="tertiary"
|
|
|
|
|
@click="$emit('openGoldModal')"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<div
|
|
|
|
|
v-for="metal in metalTotals"
|
|
|
|
|
:key="metal.metal_id"
|
|
|
|
|
class="flex mt-2 justify-center text-tertiary w-full z-20"
|
|
|
|
|
>
|
|
|
|
|
{{ metal.label }}:
|
|
|
|
|
<div class="text-l mr-2 font-bold">{{ formatMetalTotal(metal) }}</div>
|
|
|
|
|
<BasicIcon
|
|
|
|
|
v-if="metal.metal_id === metalTotals[0]?.metal_id"
|
|
|
|
|
icon="vuesax-linear:info-circle"
|
|
|
|
|
size="18"
|
|
|
|
|
color="tertiary"
|
|
|
|
|
@click="$emit('openGoldModal')"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2026-05-14 13:44:43 +03:30
|
|
|
<div class="flex mt-2 justify-center text-tertiary w-full z-20">
|
|
|
|
|
دارایی ریالی:
|
2026-06-09 21:04:22 +03:30
|
|
|
<div class="text-l mr-2 font-bold">{{ usePriceWithoutType(cashWallet) }} ریال</div>
|
2026-05-14 13:44:43 +03:30
|
|
|
<BasicIcon @click="$emit('openRialModal')" icon="vuesax-linear:info-circle" size="18" color="tertiary" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-06-09 21:04:22 +03:30
|
|
|
import { computed, onMounted } from 'vue'
|
2026-05-14 13:44:43 +03:30
|
|
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
2026-06-09 21:04:22 +03:30
|
|
|
import { usePriceWithoutType } from '@/utils/usePrice'
|
|
|
|
|
import { useWalletAssets } from '@/composables/useWalletAssets'
|
|
|
|
|
import type { WalletMetalTotal } from '@/models/walletAssets'
|
2026-05-14 13:44:43 +03:30
|
|
|
|
2026-06-09 21:04:22 +03:30
|
|
|
const { assetsSummary, loadWalletAssets } = useWalletAssets()
|
2026-05-14 13:44:43 +03:30
|
|
|
|
|
|
|
|
defineEmits<{
|
|
|
|
|
openGoldModal: []
|
|
|
|
|
openRialModal: []
|
|
|
|
|
}>()
|
2026-06-09 21:04:22 +03:30
|
|
|
|
|
|
|
|
const meta = computed(() => assetsSummary.value?.meta)
|
|
|
|
|
const metalTotals = computed(() => assetsSummary.value?.metal_totals ?? [])
|
|
|
|
|
const primaryMetalTotal = computed(() => metalTotals.value[0])
|
|
|
|
|
const cashWallet = computed(() => assetsSummary.value?.cash_wallet ?? 0)
|
|
|
|
|
const inventoryCards = computed(() => assetsSummary.value?.inventory_cards ?? [])
|
|
|
|
|
const countBasedInventory = computed(() =>
|
|
|
|
|
(assetsSummary.value?.count_products ?? []).reduce((sum, item) => sum + Number(item.quantity ?? 0), 0)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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}`
|
|
|
|
|
}
|
|
|
|
|
</script>
|