@@ -22,10 +22,16 @@
< / div >
< div v-if = "userStore" class=" mt-5 pb-2 mb-19vh" >
< ! - - < a -spin :spinning = "loading" > -- >
< div v-if = "!loading" :class="!isBuy? ' bg-red-100' : ' bg-green-100'"
class = "w-full relative rounded-lg h-[88px] flex flex-col justify-center background-color-transition" >
< img :src = "img1" alt = "" class = "h-[88px] absolute" >
< div class = "w-full items-center flex flex-col" >
< div
v-if = "!loading"
class = "w-full relative rounded-lg flex flex-col justify-center background-color-transition"
: class = "[
!isBuy ? 'bg-red-100' : 'bg-green-100',
selectedMeltedPaymentProduct ? 'min-h-[120px] py-3' : 'h-[88px]',
]"
>
< img :src = "img1" alt = "" class = "h-full min-h-[88px] absolute inset-0 w-full object-cover" >
< div class = "w-full items-center flex flex-col relative z-1" >
< div class = "text-gray-700 font-bold" > { { ! isBuy ? 'قیمت فروش' : 'قیمت خرید' } } < / div >
< div v-if = "price" class="flex gap-1 mt-3 text-xs items-center" >
< div : class = "!isBuy? 'text-red-700' : 'text-green-700'" class = "font-bold text-2xl color-transition" >
@@ -33,6 +39,16 @@
< / div >
ریال
< / div >
< div
v-if = "selectedMeltedPaymentProduct && price"
class = "flex gap-1 mt-2 text-xs items-center"
>
< div class = "text-gray-600" > قیمت { { selectedMeltedPaymentProduct . title } } : < / div >
< div : class = "!isBuy? 'text-red-700' : 'text-green-700'" class = "font-bold text-lg color-transition" >
{ { usePriceWithoutType ( selectedMeltedTradePrice ) } }
< / div >
< div > ریال < / div >
< / div >
< / div >
< / div >
< div v-else class = "w-full h-[88px]" >
@@ -48,7 +64,7 @@
< div class = "border-gray-200 border-1 rounded-xl p-5 relative" >
< bg_main / >
< div class = "z-100 relative" >
< a-form-item name = "method" :rules = "[required()]" >
< a-form-item v-if = "showDealMethodSelect" name=" method" :rules= "[required()]" >
< BasicSelect v -model :value = "form.method" :items = "typeDeal"
key -name = " key "
:show-search = "false"
@@ -60,7 +76,7 @@
< / a-form-item >
< a-form-item v-if = "isBuy" name="goldValue"
: rules = "[justNumber2(props?.ProductItem?.price , form.method , props?.ProductItem?.amount, true, props?.ProductItem?.group_type)]" >
: rules = "[justNumber2(props?.ProductItem?.price , form.method , props?.ProductItem?.amount, true, props?.ProductItem?.group_type, selectedMeltedPaymentBalance )]" >
< BasicInput v -model :value = "form.goldValue" addon -before = " تعداد " addon -bg -color = " # 000000FF "
addon -text -color = " white "
place -holder = " تعداد "
@@ -97,7 +113,7 @@
<!-- { { walletStore ? . walletInfo ? . gold } } -- >
< Transition mode = "out-in" name = "fade" class = "mt-2" >
< div v-if = "isBuy && (form.method === 'gold' || form.method === 'katod' )" class="font-bold text-xs" >
< div v-if = "isBuy && isMainMetalWalletDealMethod(form.method )" class="font-bold text-xs" >
< div > { { buyMetalWalletBalanceText } } < / div >
< / div >
< div v-else-if = "isBuy && form.method === 'cash'" class="font-bold text-xs" >
@@ -272,6 +288,7 @@ import { Product } from '@/models/products'
import BasicSelect from '@/components/BasicPacks/BasicSelect.vue'
import Bg _main from '@/components/bg_main.vue'
import { useFundUserStore } from '@/store/fundStore'
import { getProductsCatalogRef } from '@/composables/useProductsCatalog'
import {
getDefaultProductDealMethod ,
getProductDealMethodOptions ,
@@ -282,6 +299,12 @@ import {
formatMainMetalReceiveText ,
calcSellReceivedMetalWeight ,
isMainMetalWalletDealMethod ,
findMeltedDealMethodCard ,
findProductDealMethodProduct ,
getMeltedDealMethodBalance ,
shouldShowProductDealMethodSelect ,
resolveProductTradeBuyUnitPrice ,
resolveProductTradeSellUnitPrice ,
formatProductWeightAmount ,
getProductQuantityUnit ,
getProductTotalWeightLabel ,
@@ -296,10 +319,10 @@ import {
productMinOrderCash
} from '@/utils/productOrderLimit'
import { useWalletAssets } from '@/composables/useWalletAssets'
import { formatProductWalletBalanceText , getCashWalletBalance , getProductInventoryQuantity } from '@/utils/productAssets'
import { formatProductWalletBalanceText , formatInventoryCardValue , getCashWalletBalance , getProductInventoryQuantity } from '@/utils/productAssets'
import { isStoreClosed , getStoreClosedMessage } from '@/utils/storeHours'
const typeDeal = computed ( ( ) => getProductDealMethodOptions ( props ? . ProductItem ? . group _type , isBuy . value ) )
const catalogProducts = getProductsCatalogRef ( )
const isMetalReceiveDeal = computed ( ( ) =>
! isBuy . value && isMainMetalWalletDealMethod ( form . value . method )
@@ -347,12 +370,6 @@ const productWalletBalanceText = computed(() =>
)
)
const buyMetalWalletBalanceText = computed ( ( ) =>
form . value . method === 'katod'
? formatMainMetalWalletBalanceText ( walletStore ? . walletInfo ? . gold ? ? 0 )
: goldWalletBalanceText . value
)
const infoVisible = ref ( false )
const walletStore = useWalletStore ( )
const { assetsSummary , loadWalletAssets } = useWalletAssets ( )
@@ -566,18 +583,98 @@ const form = ref<Gold>({
goldVazn : undefined
} )
const inventoryCards = computed ( ( ) => assetsSummary . value ? . inventory _cards ? ? [ ] )
const dealMethodContext = computed ( ( ) => ( {
tradedProduct : props ? . ProductItem ? ? null ,
productMetalId : props ? . ProductItem ? . metal _id ,
inventoryCards : inventoryCards . value ,
catalog : catalogProducts . value ,
} ) )
const typeDeal = computed ( ( ) =>
getProductDealMethodOptions ( props ? . ProductItem ? . group _type , isBuy . value , dealMethodContext . value )
)
const showDealMethodSelect = computed ( ( ) =>
shouldShowProductDealMethodSelect ( props ? . ProductItem , typeDeal . value )
)
const selectedMeltedPaymentCard = computed ( ( ) =>
findMeltedDealMethodCard ( form . value . method , inventoryCards . value )
)
const selectedMeltedPaymentProduct = computed ( ( ) =>
findProductDealMethodProduct ( form . value . method , catalogProducts . value )
)
const selectedMeltedTradePrice = computed ( ( ) => {
const product = selectedMeltedPaymentProduct . value
if ( ! product ) {
return 0
}
return isBuy . value
? resolveProductTradeBuyUnitPrice ( product )
: resolveProductTradeSellUnitPrice ( product )
} )
const selectedMeltedPaymentBalance = computed ( ( ) =>
getMeltedDealMethodBalance (
form . value . method ,
inventoryCards . value ,
walletStore ? . walletInfo ? . gold
)
)
const buyMetalWalletBalanceText = computed ( ( ) => {
const card = selectedMeltedPaymentCard . value
const product = selectedMeltedPaymentProduct . value
if ( card ) {
return ` موجودی ${ card . title } : ${ formatInventoryCardValue ( card ) } `
}
if ( product ) {
return ` موجودی ${ product . title } : ۰ ${ getProductQuantityUnit ( product ) } `
}
if ( form . value . method === 'katod' ) {
return formatMainMetalWalletBalanceText ( walletStore ? . walletInfo ? . gold ? ? 0 )
}
return goldWalletBalanceText . value
} )
function resetDealMethod ( ) {
form . value . method = getDefaultProductDealMethod ( props ? . ProductItem ? . group _type , isBuy . value )
form . value . method = getDefaultProductDealMethod (
props ? . ProductItem ? . group _type ,
isBuy . value ,
dealMethodContext . value ,
)
}
watch (
( ) => [ props ? . ProductItem ? . id , props ? . ProductItem ? . group _type ] ,
( ) => [ props ? . ProductItem ? . id , props ? . ProductItem ? . group _type , props ? . ProductItem ? . amount , inventoryCards . value , catalogProducts . value ] ,
( ) => {
resetDealMethod ( )
} ,
{ immediate : true }
)
watch ( showDealMethodSelect , ( visible ) => {
if ( ! visible ) {
form . value . method = 'cash'
}
} )
watch (
( ) => form . value . method ,
( method ) => {
if ( ! typeDeal . value . some ( ( item ) => item . key === method ) ) {
resetDealMethod ( )
}
}
)
// تابع تبدیل اعداد فارسی به انگلیسی
const persianToEnglish = ( str : string | number | undefined ) : string => {
if ( ! str ) return ''
@@ -831,7 +928,11 @@ async function ok() {
goldValue : undefined ,
goldCash : undefined ,
percentWallet : undefined ,
method : getDefaultProductDealMethod ( props ? . ProductItem ? . group _type , isBuy . value )
method : getDefaultProductDealMethod (
props ? . ProductItem ? . group _type ,
isBuy . value ,
dealMethodContext . value ,
)
}
} catch ( e ) {
// console.log(e)