|
|
|
@@ -79,20 +79,27 @@
|
|
|
|
|
<div>{{ usePrice(form.goldCash ?? 0) }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="props?.ProductItem?.group_type !== 'سکه'" class="flex justify-between">
|
|
|
|
|
<div> وزن کل</div>
|
|
|
|
|
<div>{{ form.goldVazn ?? 0 }} {{ getWeightUnit() }}</div>
|
|
|
|
|
<div v-if="shouldShowProductTotalWeight(props?.ProductItem)" class="flex justify-between">
|
|
|
|
|
<div>وزن کل</div>
|
|
|
|
|
<div>{{ totalWeightDisplay }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
v-if="isCountBasedProductItem && hasProductUnitWeight(props?.ProductItem)"
|
|
|
|
|
class="flex justify-between text-xs text-gray-500"
|
|
|
|
|
>
|
|
|
|
|
<div>وزن هر عدد</div>
|
|
|
|
|
<div>{{ getProductUnitWeightLabel(props?.ProductItem) }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- {{walletStore?.walletInfo?.gold}}-->
|
|
|
|
|
<Transition mode="out-in" name="fade" class="mt-2">
|
|
|
|
|
<div v-if="isBuy && form.method === 'gold'" class="font-bold text-xs">
|
|
|
|
|
<div>{{ goldWalletBalanceText }}</div>
|
|
|
|
|
<div v-if="isBuy && (form.method === 'gold' || form.method === 'katod')" class="font-bold text-xs">
|
|
|
|
|
<div>{{ buyMetalWalletBalanceText }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else-if="isBuy" class="font-bold text-xs">
|
|
|
|
|
<div v-else-if="isBuy && form.method === 'cash'" class="font-bold text-xs">
|
|
|
|
|
{{ cashWalletBalanceText }}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="font-bold text-xs" v-else>{{ `موجودی محصول: ${getInventoryById(props?.ProductItem?.id)}` }}
|
|
|
|
|
<div class="font-bold text-xs" v-else>{{ `موجودی محصول: ${getInventoryById(props?.ProductItem?.id)} ${getProductQuantityUnit(props?.ProductItem)}` }}
|
|
|
|
|
</div>
|
|
|
|
|
</Transition>
|
|
|
|
|
<Transition mode="out-in" name="fade">
|
|
|
|
@@ -184,7 +191,7 @@
|
|
|
|
|
<div class="flex items-center">
|
|
|
|
|
<div class="font-bold">{{ form.goldValue }}</div>
|
|
|
|
|
<div class="text-xs mr-1"> عدد</div>
|
|
|
|
|
<div class="text-base font-bold mr-1"> عدد {{ props?.ProductItem?.title }}</div>
|
|
|
|
|
<div class="text-base font-bold mr-1"> {{ props?.ProductItem?.title }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex justify-between mt-3">
|
|
|
|
@@ -250,7 +257,7 @@ import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
|
|
|
|
import type { Transaction } from '@/models/transaction'
|
|
|
|
|
import type { TableEngineInput, TableOutput } from '@/models/table'
|
|
|
|
|
import { getTransactionTable } from '@/api/transaction'
|
|
|
|
|
import { getLastPrices, lastPrice} from '@/utils/price'
|
|
|
|
|
import { getLastPrices, getTradeBuyPrice, getTradeSellPrice, lastPrice, setIntervalGetAllPrice, stopPriceInterval } from '@/utils/price'
|
|
|
|
|
import { Product } from '@/models/products'
|
|
|
|
|
import BasicSelect from '@/components/BasicPacks/BasicSelect.vue'
|
|
|
|
|
import Bg_main from '@/components/bg_main.vue'
|
|
|
|
@@ -258,20 +265,46 @@ import { useFundUserStore } from '@/store/fundStore'
|
|
|
|
|
import {
|
|
|
|
|
getDefaultProductDealMethod,
|
|
|
|
|
getProductDealMethodOptions,
|
|
|
|
|
isCashLikeDealMethod,
|
|
|
|
|
formatCashWalletBalanceText,
|
|
|
|
|
formatGoldWalletBalanceText,
|
|
|
|
|
getWeightUnit,
|
|
|
|
|
formatMainMetalWalletBalanceText,
|
|
|
|
|
formatProductWeightAmount,
|
|
|
|
|
getProductQuantityUnit,
|
|
|
|
|
getProductTotalWeightLabel,
|
|
|
|
|
getProductUnitWeightLabel,
|
|
|
|
|
hasProductUnitWeight,
|
|
|
|
|
isCountBasedProduct,
|
|
|
|
|
shouldShowProductTotalWeight,
|
|
|
|
|
} from '@/utils/productDealMethod'
|
|
|
|
|
|
|
|
|
|
const typeDeal = computed(() => getProductDealMethodOptions(props?.ProductItem?.group_type))
|
|
|
|
|
|
|
|
|
|
const productGroupType = computed(() => props?.ProductItem?.group_type)
|
|
|
|
|
const isCountBasedProductItem = computed(() => isCountBasedProduct(props?.ProductItem))
|
|
|
|
|
const totalWeightDisplay = computed(() => {
|
|
|
|
|
const product = props?.ProductItem
|
|
|
|
|
if (!product) {
|
|
|
|
|
return formatProductWeightAmount(0, product)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isCountBasedProductItem.value) {
|
|
|
|
|
return getProductTotalWeightLabel(form.value.goldValue, product)
|
|
|
|
|
?? formatProductWeightAmount(0, product)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return formatProductWeightAmount(form.value.goldVazn ?? 0, product)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const goldWalletBalanceText = computed(() =>
|
|
|
|
|
formatGoldWalletBalanceText(walletStore?.walletInfo?.gold ?? 0, productGroupType.value)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const buyMetalWalletBalanceText = computed(() =>
|
|
|
|
|
form.value.method === 'katod'
|
|
|
|
|
? formatMainMetalWalletBalanceText(walletStore?.walletInfo?.gold ?? 0)
|
|
|
|
|
: goldWalletBalanceText.value
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const cashWalletBalanceText = computed(() =>
|
|
|
|
|
formatCashWalletBalanceText(
|
|
|
|
|
usePriceWithoutType(walletStore?.walletInfo?.cash ?? 0),
|
|
|
|
@@ -352,7 +385,8 @@ const disableTransaction = computed(() =>
|
|
|
|
|
form.value?.goldCash === undefined ||
|
|
|
|
|
(isBuy.value ? (form.value?.goldCash ?? 0) < 500000 : (form.value?.goldValue ?? 0) < 0.001) ||
|
|
|
|
|
// (!isBuy.value && form.value.goldValue > walletStore?.walletInfo?.gold) ||
|
|
|
|
|
price.value?.buy === undefined)
|
|
|
|
|
!lastPrice.value ||
|
|
|
|
|
(isBuy.value ? getTradeBuyPrice(lastPrice.value) <= 0 : getTradeSellPrice(lastPrice.value) <= 0))
|
|
|
|
|
|
|
|
|
|
function refreshTable() {
|
|
|
|
|
sellItems.value = []
|
|
|
|
@@ -557,8 +591,9 @@ function handleGoldValueChange(val: string | number | undefined) {
|
|
|
|
|
|
|
|
|
|
function calculateCash(val: number) {
|
|
|
|
|
priceErrorVisible.value = false
|
|
|
|
|
if (price.value) {
|
|
|
|
|
form.value.goldVazn = parseFloat(val * props?.ProductItem?.amount)
|
|
|
|
|
if (!lastPrice.value) return
|
|
|
|
|
|
|
|
|
|
form.value.goldVazn = parseFloat(String(val * props?.ProductItem?.amount))
|
|
|
|
|
// form.value.goldVazn = parseFloat((val * (( props?.ProductItem?.price) + (props?.ProductItem?.cash_fee_buy)))/lastPrice.value?.buy).toFixed(2)
|
|
|
|
|
if (isBuy.value) {
|
|
|
|
|
if (val){
|
|
|
|
@@ -589,7 +624,6 @@ function calculateCash(val: number) {
|
|
|
|
|
form.value.goldVazn = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*function calculateGold(val: number) {
|
|
|
|
@@ -673,9 +707,6 @@ async function initPrice() {
|
|
|
|
|
await getLastPrices()
|
|
|
|
|
// await setIntervalGetPrice()
|
|
|
|
|
loading.value = true
|
|
|
|
|
price.value = lastPrice.value
|
|
|
|
|
/*props.ProductItem.price = lastPrice.value?.buy * props.ProductItem?.amount
|
|
|
|
|
props.ProductItem.sellPrice = lastPrice.value?.sell * props.ProductItem?.amount*/
|
|
|
|
|
props.ProductItem.price = lastPrice?.value?.price? (lastPrice?.value?.price + props.ProductItem?.cash_fee_buy) * props.ProductItem?.amount: 0
|
|
|
|
|
props.ProductItem.sellPrice = lastPrice?.value?.price? (lastPrice?.value?.price - props.ProductItem?.percent_fee_sell) * props.ProductItem?.amount:0
|
|
|
|
|
} catch (e) {
|
|
|
|
|