|
|
@@ -145,7 +145,6 @@ import { useFuturesStore, useSBYJOrderStore, useUserStore, useAccountStore } fro
|
|
|
import { fullloading, dialog } from '@/utils/vant'
|
|
|
import { useOrder } from '@/business/trade'
|
|
|
import { BuyOrSell, getGoodsCurrencyItemName, PriceMode } from '@/constants/order'
|
|
|
-import { useSpotAccountStore } from '../../../wallet/components/spot/composables'
|
|
|
import AppSelect from '@mobile/components/base/select/index.vue'
|
|
|
import AppStepper from '@mobile/components/base/stepper/index.vue'
|
|
|
import ContractPosition from '../../components/position/list/index.vue'
|
|
|
@@ -155,7 +154,6 @@ import ContractAccount from '../../components/account/index.vue'
|
|
|
const { router, getQueryStringToNumber, getGlobalUrlParams } = useNavigation()
|
|
|
const goodsId = getQueryStringToNumber('id')
|
|
|
const futuresStore = useFuturesStore()
|
|
|
-const spotAccountStore = useSpotAccountStore()
|
|
|
const tabIndex = shallowRef(0)
|
|
|
|
|
|
const formRef = shallowRef<FormInstance>()
|
|
|
@@ -173,8 +171,6 @@ const { getSBYJMyOrders } = useSBYJOrderStore()
|
|
|
const goods = computed(() => futuresStore.getGoods(goodsId ?? 0)) ?? {}
|
|
|
|
|
|
const quote = computed(() => futuresStore.getQuoteItem({ goodsid: goodsId }))
|
|
|
-const baseAccount = computed(() => spotAccountStore.getAccountItem({ currencyid: quote.value?.goodscurrencyid })) // 基础货币账户
|
|
|
-const quoteAccount = computed(() => spotAccountStore.getAccountItem({ currencyid: quote.value?.currencyid })) // 计价货币账户
|
|
|
|
|
|
const options = computed(() => {
|
|
|
return [{
|
|
|
@@ -287,9 +283,8 @@ const tpsl = computed(() => {
|
|
|
const calculations = computed(() => {
|
|
|
|
|
|
const buyFeeValue = futuresStore.getFeeValue(quote.value, 101)
|
|
|
- const sellFeeValue = futuresStore.getFeeValue(quote.value, 102)
|
|
|
|
|
|
- const { last = 0, agreeunit = 0 } = quote.value ?? {}
|
|
|
+ const { last = 0, agreeunit = 0, currencyid = 0, goodscurrencyid = 0 } = quote.value ?? {}
|
|
|
const { OrderPrice = 0, OrderQty = 0 } = formData
|
|
|
|
|
|
const price = formData.PriceMode === PriceMode.Market ? last : OrderPrice
|
|
|
@@ -298,28 +293,21 @@ const calculations = computed(() => {
|
|
|
// 预估金额
|
|
|
const estimatedAmount = price * amount
|
|
|
|
|
|
+ const accountStore = useAccountStore()
|
|
|
+ const account = computed(() => accountStore.filterAccountsByCurrencyId(currencyid, goodscurrencyid)).value[0] ?? {}
|
|
|
+
|
|
|
// 可用余额
|
|
|
- const maxBalance = spotAccountStore.getAvailableBalance(quoteAccount.value)
|
|
|
+ const maxBalance = account.avaiableBalance
|
|
|
// 预估手续费
|
|
|
const buyEstimatedFee = (buyFeeValue.FeeAlgorithm === 2 ? amount : estimatedAmount) * buyFeeValue.feeValue
|
|
|
- // 可买数量
|
|
|
+ // 可开数量
|
|
|
const maxBuyQty = price ? (maxBalance - buyEstimatedFee) / (price * agreeunit) : 0
|
|
|
|
|
|
- // 可卖数量
|
|
|
- const maxSellQty = spotAccountStore.getAvailableBalance(baseAccount.value)
|
|
|
- // 可获金额
|
|
|
- const maxAmount = price * maxSellQty * agreeunit
|
|
|
- // 预估手续费
|
|
|
- const sellEstimatedFee = (sellFeeValue.FeeAlgorithm === 2 ? amount : estimatedAmount) * sellFeeValue.feeValue
|
|
|
-
|
|
|
return {
|
|
|
estimatedAmount,
|
|
|
maxBalance,
|
|
|
maxBuyQty,
|
|
|
buyEstimatedFee,
|
|
|
- maxAmount,
|
|
|
- maxSellQty,
|
|
|
- sellEstimatedFee
|
|
|
}
|
|
|
})
|
|
|
|