Files
boursecu_user/src/views/base/home/components/BalanceSheet.vue
T

83 lines
2.3 KiB
Vue
Raw Normal View History

2026-05-14 13:44:43 +03:30
<template>
<BasicActionSheet v-model:show="visible">
<div class="pb-20">
<div>
<div class="w-full text-center font-bold">موجودی ها</div>
<div class="h-30vh overflow-y-auto">
<div class="mt-5">
2026-06-09 21:04:22 +03:30
<template v-for="metal in metalTotals" :key="metal.metal_id">
<BasicInfoItem
2026-05-14 13:44:43 +03:30
class="flex justify-between"
2026-06-09 21:04:22 +03:30
:title="metal.label"
2026-05-14 13:44:43 +03:30
is-line
2026-06-09 21:04:22 +03:30
:value="formatMetalTotal(metal)"
/>
<a-divider class="!my-1" />
</template>
<BasicInfoItem
class="flex justify-between"
title="دارایی کیف پول ریالی"
is-line
:value="usePrice(cashWallet)"
2026-05-14 13:44:43 +03:30
/>
<a-divider class="!my-1" />
<BasicInfoItem
2026-06-09 21:04:22 +03:30
class="flex justify-between"
title="معادل ریالی مجموع دارایی ها"
is-line
:value="usePrice(totalRialValue)"
2026-05-14 13:44:43 +03:30
/>
</div>
</div>
</div>
</div>
</BasicActionSheet>
</template>
<script setup lang="ts">
2026-06-09 21:04:22 +03:30
import { computed, onMounted, watch } from 'vue'
2026-05-14 13:44:43 +03:30
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
import BasicInfoItem from '@/components/BasicPacks/BasicInfoItem.vue'
2026-06-09 21:04:22 +03:30
import { usePrice } from '@/utils/usePrice'
import { useWalletAssets } from '@/composables/useWalletAssets'
import type { WalletMetalTotal } from '@/models/walletAssets'
2026-05-14 13:44:43 +03:30
const props = defineProps<{
show: boolean
walletInfo: any
goldVal: number
}>()
const emit = defineEmits<{
'update:show': [value: boolean]
}>()
2026-06-09 21:04:22 +03:30
const { assetsSummary, loadWalletAssets } = useWalletAssets()
2026-05-14 13:44:43 +03:30
const visible = computed({
get: () => props.show,
2026-06-09 21:04:22 +03:30
set: (val) => emit('update:show', val),
2026-05-14 13:44:43 +03:30
})
2026-06-09 21:04:22 +03:30
const metalTotals = computed(() => assetsSummary.value?.metal_totals ?? [])
const cashWallet = computed(() => assetsSummary.value?.cash_wallet ?? 0)
const totalRialValue = computed(() => assetsSummary.value?.total_rial_value ?? 0)
onMounted(() => {
void loadWalletAssets()
})
watch(
() => props.show,
(open) => {
if (open) {
void loadWalletAssets(true)
}
}
)
function formatMetalTotal(metal: WalletMetalTotal) {
return `${metal.total_weight} ${metal.unit}`
}
</script>