some trigger handled

This commit is contained in:
2026-06-10 18:40:29 +03:30
parent 5b525bd2c7
commit 84db7b013d
13 changed files with 264 additions and 117 deletions
@@ -12,7 +12,7 @@
icon="vuesax-linear:info-circle"
size="18"
color="tertiary"
@click="$emit('openGoldModal')"
@click="$emit('openGoldModal', primaryMetalTotal)"
/>
</div>
</template>
@@ -29,13 +29,13 @@
icon="vuesax-linear:info-circle"
size="18"
color="tertiary"
@click="$emit('openGoldModal')"
@click="$emit('openGoldModal', metal)"
/>
</div>
</template>
<div class="flex mt-2 justify-center text-tertiary w-full z-20">
دارایی ریالی:
<div class="text-l mr-2 font-bold">{{ usePriceWithoutType(cashWallet) }} ریال</div>
<div class="text-l mr-2 font-bold">{{ usePriceWithoutType(totalRialValue) }} ریال</div>
<BasicIcon @click="$emit('openRialModal')" icon="vuesax-linear:info-circle" size="18" color="tertiary" />
</div>
</div>
@@ -52,14 +52,14 @@ import { resolveSummaryMetalWeight } from '@/utils/productAssets'
const { assetsSummary, loadWalletAssets } = useWalletAssets()
defineEmits<{
openGoldModal: []
openGoldModal: [metal: WalletMetalTotal]
openRialModal: []
}>()
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 totalRialValue = computed(() => assetsSummary.value?.total_rial_value ?? 0)
const inventoryCards = computed(() => assetsSummary.value?.inventory_cards ?? [])
const countBasedInventory = computed(() =>
(assetsSummary.value?.count_products ?? []).reduce((sum, item) => sum + Number(item.quantity ?? 0), 0)
@@ -31,7 +31,14 @@
<a-divider class="!my-1" />
<BasicInfoItem
class="flex justify-between"
title="معادل ریالی مجموع دارایی ها"
title="معادل ریالی محصولات"
is-line
:value="usePrice(assetsRialValue)"
/>
<a-divider class="!my-1" />
<BasicInfoItem
class="flex justify-between"
title="مجموع دارایی ریالی"
is-line
:value="usePrice(totalRialValue)"
/>
@@ -49,7 +56,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'
import { formatInventoryCardValue, assetSheetInventoryCards } from '@/utils/productAssets'
const props = defineProps<{
show: boolean
@@ -71,6 +78,7 @@ const visible = computed({
const inventoryCards = computed(() => assetsSummary.value?.inventory_cards ?? [])
const metalTotals = computed(() => assetsSummary.value?.metal_totals ?? [])
const cashWallet = computed(() => assetsSummary.value?.cash_wallet ?? 0)
const assetsRialValue = computed(() => assetsSummary.value?.assets_rial_value ?? 0)
const totalRialValue = computed(() => assetsSummary.value?.total_rial_value ?? 0)
onMounted(() => {
@@ -87,7 +95,7 @@ watch(
)
function cardsByMetal(metalId: number) {
return inventoryCards.value.filter((card) => Number(card.metal_id) === metalId)
return assetSheetInventoryCards(inventoryCards.value, metalId)
}
function formatMetalTotal(metal: WalletMetalTotal) {
+15 -11
View File
@@ -83,10 +83,12 @@ import {loading, removeToken} from '@/utils'
import {useUserStore} from '@/store/userStore'
import {useWalletStore} from '@/store/walletStore'
import { useWalletAssets } from '@/composables/useWalletAssets'
import type { WalletMetalTotal } from '@/models/walletAssets'
import { formatMetalAssetsInfoText, formatRialAssetsInfoText } from '@/utils/productAssets'
import {useConfigStore} from '@/store/configStore'
import {useFundUserStore} from '@/store/fundStore'
import {usePrice, usePriceWithoutType} from '../../../utils/usePrice'
import {getLastPrices, lastPrice, price, setIntervalGetAllPrice, stopPriceInterval} from '@/utils/price'
import {usePriceWithoutType} from '../../../utils/usePrice'
import {getLastPrices, lastPrice, price, startLastPricePolling, stopLastPricePolling} from '@/utils/price'
import {getConstByKey} from '@/api/const'
import {message, Modal} from 'ant-design-vue'
@@ -119,6 +121,7 @@ const userStore = useUserStore()
const walletStore = useWalletStore()
const configStore = useConfigStore()
const fundStore = useFundUserStore()
const { assetsSummary, loadWalletAssets } = useWalletAssets()
// Config
const isGaroosi = computed(() => configStore.config.name === 'garoosi')
@@ -211,11 +214,9 @@ async function logout() {
window.location.reload()
}
function openGoldModal() {
const goldAmount = (walletStore.walletInfo?.gold ?? 0).toFixed(3)
const walletsAmount = (walletStore.walletInfo?.count_gold_wallets ?? 0).toFixed(3)
function openGoldModal(metal: WalletMetalTotal) {
Modal.confirm({
title: `مجموع کل وزن طلای آبشده (${goldAmount}) + ارزش دارایی ها (${walletsAmount}) گرم`,
title: formatMetalAssetsInfoText(metal),
okText: 'متوجه شدم',
centered: true,
cancelButtonProps: {style: {display: 'none'}}
@@ -223,10 +224,12 @@ function openGoldModal() {
}
function openRialModal() {
const cashWallet = usePrice(walletStore?.walletInfo?.count_cash_wallet ?? 0)
const cashWallets = usePrice(walletStore?.walletInfo?.count_cash_wallets ?? 0)
const summary = assetsSummary.value
Modal.confirm({
title: `مجموع کیف پول ریالی (${cashWallet}) + معادل ریالی محصولات (${cashWallets}) ریال`,
title: formatRialAssetsInfoText(
summary?.cash_wallet ?? 0,
summary?.assets_rial_value ?? 0
),
okText: 'متوجه شدم',
centered: true,
cancelButtonProps: {style: {display: 'none'}}
@@ -261,9 +264,10 @@ onMounted(async () => {
loading.value = true
await Promise.all([
loadFunds(),
loadWalletAssets(),
getLastPrices(),
fetchPrices(),
setIntervalGetAllPrice(),
startLastPricePolling(),
loadBanners()
])
@@ -274,7 +278,7 @@ onMounted(async () => {
onUnmounted(() => {
clearInterval(updateInterval)
stopPriceInterval()
stopLastPricePolling()
})
} catch (error) {
console.error('Initialization error:', error)