118 lines
4.8 KiB
Vue
118 lines
4.8 KiB
Vue
<template>
|
|
<div>
|
|
<div class="bg-white w-full py-3 px-3 text-primary font-bold drop-shadow fixed md:absolute top-0 flex h-12 z-20">
|
|
<div @click="router.back()">
|
|
<BasicIcon icon="vuesax-linear:arrow-right-1"/>
|
|
</div>
|
|
<div class="mr-2">دارایی ها</div>
|
|
</div>
|
|
<div class="text-tertiary bg-primary w-screen md:w-full h-[70vh] fixed md:absolute overflow-hidden">
|
|
<img :src="img" alt="" class="w-full absolute bottom-0 left-0 opacity-5 pointer-events-none z-0" />
|
|
<div class="pt-15 flex flex-col relative z-10">
|
|
<div class="text-tertiary font-bold mr-5 z-20">موجودی دارایی ها</div>
|
|
<div v-if="meta?.has_count_based_products" class="flex mt-4 justify-center mt-2 w-full z-20">
|
|
محصولات:
|
|
<div class="text-l mr-4 font-bold">{{ countBasedInventory }} عدد</div>
|
|
</div>
|
|
<template v-if="meta?.single_metal && primaryMetalTotal">
|
|
<div class="flex justify-center mt-2 w-full z-20">
|
|
{{ primaryMetalTotal.label }}:
|
|
<div class="text-l mr-4 font-bold">{{ formatMetalTotal(primaryMetalTotal) }}</div>
|
|
</div>
|
|
</template>
|
|
<template v-else>
|
|
<div
|
|
v-for="metal in metalTotals"
|
|
:key="`metal-${metal.metal_id}`"
|
|
class="flex justify-center mt-2 w-full z-20"
|
|
>
|
|
{{ metal.label }}:
|
|
<div class="text-l mr-4 font-bold">{{ formatMetalTotal(metal) }}</div>
|
|
</div>
|
|
</template>
|
|
<div v-if="meta?.has_count_based_products" class="flex justify-center mt-2 w-full z-20">
|
|
مجموع موجودی:
|
|
<div class="text-l mr-4 font-bold">{{ countBasedInventory }} عدد</div>
|
|
</div>
|
|
<div class="flex justify-center mt-2 w-full z-20">
|
|
دارایی ریالی:
|
|
<div class="text-l mr-4 font-bold">{{ usePriceWithoutType(cashWallet) }}ریال</div>
|
|
</div>
|
|
<div class="flex justify-center mt-2 w-full z-20">
|
|
معادل ریالی مجموع دارایی ها:
|
|
<div class="text-l mr-4 font-bold">{{ usePriceWithoutType(totalRialValue) }}ریال</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="pt-[20rem] ">
|
|
<div class="bg-gray-100 w-screen md:w-full z-20 relative rounded-t-3xl h-[calc(100vh-20rem-70px)] overflow-y-auto pb-15"
|
|
style="box-shadow: 0px -2px 4px -2px #0000001A;">
|
|
|
|
<div v-if="inventoryCards.length === 0 && !loading" class="w-full h-full flex justify-center items-center">
|
|
<div>
|
|
<img :src="empty" alt="" class="w-70 ">
|
|
<div v-if="nameProject !== 'abaeigold'" class="text-center text-lg">یک گنج جدید بساز!</div>
|
|
</div>
|
|
</div>
|
|
|
|
<a-spin :spinning="loading">
|
|
<div :class="loading ? 'h-[40vh]' : ''" class="grid grid-cols-2 gap-3 p-5">
|
|
<Item
|
|
v-for="item in inventoryCards"
|
|
:key="item.product_id"
|
|
:item="item"
|
|
@click="router.push({ name: 'fund_info', params: { id: item.product_id } })"
|
|
/>
|
|
</div>
|
|
</a-spin>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import router from '@/router'
|
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
|
import img from '@/assets/img/user_ly1.svg'
|
|
import empty from '@/assets/img/cash_empty.svg'
|
|
import Item from './components/Item.vue'
|
|
import { onMounted, computed } from 'vue'
|
|
import { loading } from '@/utils'
|
|
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()
|
|
|
|
const meta = computed(() => assetsSummary.value?.meta)
|
|
const inventoryCards = computed(() => assetsSummary.value?.inventory_cards ?? [])
|
|
const metalTotals = computed(() => assetsSummary.value?.metal_totals ?? [])
|
|
const primaryMetalTotal = computed(() => metalTotals.value[0])
|
|
const cashWallet = computed(() => assetsSummary.value?.cash_wallet ?? 0)
|
|
const totalRialValue = computed(() => assetsSummary.value?.total_rial_value ?? 0)
|
|
const countBasedInventory = computed(() =>
|
|
(assetsSummary.value?.count_products ?? []).reduce((sum, item) => sum + Number(item.quantity ?? 0), 0)
|
|
)
|
|
|
|
onMounted(async () => {
|
|
try {
|
|
loading.value = true
|
|
await loadWalletAssets(true)
|
|
} catch (e) {
|
|
console.log(e)
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
})
|
|
|
|
function formatMetalTotal(metal: WalletMetalTotal) {
|
|
return `${resolveSummaryMetalWeight(metal, inventoryCards.value)}${metal.unit}`
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
</style>
|