widthdraw and deposit
This commit is contained in:
@@ -1,36 +1,82 @@
|
||||
<template>
|
||||
<div class="bg-primary rounded-lg p-2 py-3 mt-2">
|
||||
<div class="flex justify-center text-tertiary w-full z-20">
|
||||
<div v-if="meta?.has_count_based_products" class="flex justify-center text-tertiary w-full z-20">
|
||||
محصولات:
|
||||
<div class="text-l mr-2 font-bold">{{ userStore?.userInfo?.wallet?.count_product ?? 0 }} عدد</div>
|
||||
</div>
|
||||
<div v-if="!isBoursecuProject()" class="flex mt-2 justify-center text-tertiary w-full z-20">
|
||||
{{ metalAssetLabel }}:
|
||||
<div class="text-l mr-2 font-bold">{{ (userStore?.userInfo?.wallet?.count_gold ?? 0).toFixed(3) }} {{ weightUnit }}</div>
|
||||
<BasicIcon @click="$emit('openGoldModal')" icon="vuesax-linear:info-circle" size="18" color="tertiary" />
|
||||
<div class="text-l mr-2 font-bold">{{ countBasedInventory }} عدد</div>
|
||||
</div>
|
||||
<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>
|
||||
<div class="flex mt-2 justify-center text-tertiary w-full z-20">
|
||||
دارایی ریالی:
|
||||
<div class="text-l mr-2 font-bold">{{ usePriceWithoutType(userStore?.userInfo?.wallet?.count_cash ?? 0) }} ریال</div>
|
||||
<div class="text-l mr-2 font-bold">{{ usePriceWithoutType(cashWallet) }} ریال</div>
|
||||
<BasicIcon @click="$emit('openRialModal')" icon="vuesax-linear:info-circle" size="18" color="tertiary" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { computed, onMounted } from 'vue'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import {usePriceWithoutType} from "../../../../utils/usePrice";
|
||||
import { isBoursecuProject } from '@/utils/config'
|
||||
import { getMetalAssetLabel, getWeightUnit } from '@/utils/productDealMethod'
|
||||
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||
import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||
import type { WalletMetalTotal } from '@/models/walletAssets'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const metalAssetLabel = computed(() => getMetalAssetLabel())
|
||||
const weightUnit = computed(() => getWeightUnit())
|
||||
const { assetsSummary, loadWalletAssets } = useWalletAssets()
|
||||
|
||||
defineEmits<{
|
||||
openGoldModal: []
|
||||
openRialModal: []
|
||||
}>()
|
||||
</script>
|
||||
|
||||
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>
|
||||
|
||||
@@ -5,50 +5,27 @@
|
||||
<div class="w-full text-center font-bold">موجودی ها</div>
|
||||
<div class="h-30vh overflow-y-auto">
|
||||
<div class="mt-5">
|
||||
<BasicInfoItem
|
||||
<template v-for="metal in metalTotals" :key="metal.metal_id">
|
||||
<BasicInfoItem
|
||||
class="flex justify-between"
|
||||
:title="`مجموعه کل دارایی ${settingsStore.metalTypeLabel}`"
|
||||
:title="metal.label"
|
||||
is-line
|
||||
:info="`در این قسمت مجموع کل وزن ${settingsStore.metalTypeLabel} آبشده (${(walletInfo?.gold ?? 0)?.toFixed(3)}) + ارزش دارایی ها (${(walletInfo?.treasure_sum ?? 0)?.toFixed(3)} ) را مشاهده میفرمایید.`"
|
||||
:infoHead="`مجموع کل دارایی ${settingsStore.metalTypeLabel}`"
|
||||
:value="parseFloat((walletInfo?.gold_sum ?? 0).toFixed(2)) + ' ' + weightUnit"
|
||||
:value="formatMetalTotal(metal)"
|
||||
/>
|
||||
<a-divider class="!my-1" />
|
||||
</template>
|
||||
<BasicInfoItem
|
||||
class="flex justify-between"
|
||||
title="دارایی کیف پول ریالی"
|
||||
is-line
|
||||
:value="usePrice(cashWallet)"
|
||||
/>
|
||||
<a-divider class="!my-1" />
|
||||
<BasicInfoItem
|
||||
class="flex justify-between"
|
||||
title="دارایی کیف پول ریالی"
|
||||
is-line
|
||||
:value="usePrice(walletInfo?.cash ?? 0)"
|
||||
/>
|
||||
<a-divider class="!my-1" />
|
||||
<BasicInfoItem
|
||||
class="flex justify-between"
|
||||
:title="`دارایی کیف پول ${settingsStore.metalTypeLabel}`"
|
||||
is-line
|
||||
:value="(walletInfo?.count_gold_wallet ?? 0) + ' ' + weightUnit"
|
||||
/>
|
||||
<a-divider v-if="nameProject === 'goldsun'" class="!my-1" />
|
||||
<BasicInfoItem
|
||||
v-if="nameProject === 'goldsun'"
|
||||
class="flex justify-between"
|
||||
title="دارایی کیف پول نقره"
|
||||
is-line
|
||||
:value="(walletInfo?.count_silver ?? 0) + ' گرم'"
|
||||
/>
|
||||
<a-divider v-if="nameProject === 'goldsun'" class="!my-1" />
|
||||
<BasicInfoItem
|
||||
v-if="nameProject === 'goldsun'"
|
||||
class="flex justify-between"
|
||||
title="دارایی کیف پول مس"
|
||||
is-line
|
||||
:value="(walletInfo?.count_copper ?? 0) + ' گرم'"
|
||||
/>
|
||||
<a-divider class="!my-1" />
|
||||
<BasicInfoItem
|
||||
class="flex justify-between"
|
||||
title="معادل ریالی مجموع دارایی ها"
|
||||
is-line
|
||||
:value="usePrice(walletInfo?.count_cash_total ?? 0)"
|
||||
class="flex justify-between"
|
||||
title="معادل ریالی مجموع دارایی ها"
|
||||
is-line
|
||||
:value="usePrice(totalRialValue)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -58,13 +35,12 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, onMounted, watch } from 'vue'
|
||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||
import BasicInfoItem from '@/components/BasicPacks/BasicInfoItem.vue'
|
||||
import { useConfigStore } from '@/store/configStore'
|
||||
import { useSettingsStore } from '@/store/settingsStore'
|
||||
import { getWeightUnit } from '@/utils/productDealMethod'
|
||||
import {usePrice} from "@/utils/usePrice";
|
||||
import { usePrice } from '@/utils/usePrice'
|
||||
import { useWalletAssets } from '@/composables/useWalletAssets'
|
||||
import type { WalletMetalTotal } from '@/models/walletAssets'
|
||||
|
||||
const props = defineProps<{
|
||||
show: boolean
|
||||
@@ -76,13 +52,31 @@ const emit = defineEmits<{
|
||||
'update:show': [value: boolean]
|
||||
}>()
|
||||
|
||||
const config = useConfigStore()
|
||||
const nameProject = config.config.name
|
||||
const settingsStore = useSettingsStore()
|
||||
const weightUnit = computed(() => getWeightUnit())
|
||||
const { assetsSummary, loadWalletAssets } = useWalletAssets()
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.show,
|
||||
set: (val) => emit('update:show', val)
|
||||
set: (val) => emit('update:show', val),
|
||||
})
|
||||
</script>
|
||||
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user