|
@@ -57,18 +57,11 @@
|
|
|
<Field name="OrderQty" label="自定义">
|
|
<Field name="OrderQty" label="自定义">
|
|
|
<template #input>
|
|
<template #input>
|
|
|
<div class="g-qty-group__stepper">
|
|
<div class="g-qty-group__stepper">
|
|
|
- <Stepper v-model="formData.OrderQty" theme="round" button-size="22" :min="1" :step="qtyStep" integer />
|
|
|
|
|
|
|
+ <Stepper v-model="orderQty" theme="round" button-size="22" :min="1" :step="qtyStep" integer />
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
</Field>
|
|
</Field>
|
|
|
</Form>
|
|
</Form>
|
|
|
- <template #footer v-if="collection">
|
|
|
|
|
- <div class="g-form__footer inset">
|
|
|
|
|
- <Button type="danger" block round :disabled="formData.OrderQty === 0" @click="onBeforeSubmit(BuildType.Open)">
|
|
|
|
|
- {{ $t('operation.buynow') }}
|
|
|
|
|
- </Button>
|
|
|
|
|
- </div>
|
|
|
|
|
- </template>
|
|
|
|
|
<Tabs v-model:active="active">
|
|
<Tabs v-model:active="active">
|
|
|
<template v-for="(item, index) in components.filter(e => e.show === true)" :key="index">
|
|
<template v-for="(item, index) in components.filter(e => e.show === true)" :key="index">
|
|
|
<Tab :title="item.title" :name="item.name">
|
|
<Tab :title="item.title" :name="item.name">
|
|
@@ -76,7 +69,16 @@
|
|
|
<component :is="item.component" v-bind="{ pictureurl }" />
|
|
<component :is="item.component" v-bind="{ pictureurl }" />
|
|
|
</Tab>
|
|
</Tab>
|
|
|
</template>
|
|
</template>
|
|
|
- </Tabs>
|
|
|
|
|
|
|
+ </Tabs>
|
|
|
|
|
+ <template #footer v-if="collection">
|
|
|
|
|
+ <div class="g-form__footer inset">
|
|
|
|
|
+ <Button type="danger" block round :disabled="orderQty === 0" @click="onSubmit">
|
|
|
|
|
+ {{ orderType === 1 ? $t('operation.buynow') : orderTypeStepList.find(e => e.value === orderType)?.label }}
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <component ref="componentRef" :is="componentMap.get(componentId)" v-bind="{ goodsid, collectionid, orderType, orderQty }"
|
|
|
|
|
+ @closed="closeComponent" v-if="componentId" />
|
|
|
|
|
+ </template>
|
|
|
</app-view>
|
|
</app-view>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -85,13 +87,12 @@ import { shallowRef, onMounted, onUnmounted, computed, defineAsyncComponent } fr
|
|
|
import { Form, Field, Button, FormInstance, Radio, RadioGroup, Tab, Tabs } from 'vant'
|
|
import { Form, Field, Button, FormInstance, Radio, RadioGroup, Tab, Tabs } from 'vant'
|
|
|
import { useFuturesStore, useUserStore, i18n, useAccountStore } from '@/stores'
|
|
import { useFuturesStore, useUserStore, i18n, useAccountStore } from '@/stores'
|
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
|
-import { useOrder } from '@/business/trade'
|
|
|
|
|
-import { BuildType } from '@/constants/order'
|
|
|
|
|
import { formatDecimal, handleNumberValue } from '@/filters'
|
|
import { formatDecimal, handleNumberValue } from '@/filters'
|
|
|
|
|
+import { getGoodsUnitName } from '@/constants/unit'
|
|
|
|
|
+import { useComponent } from '@/hooks/component'
|
|
|
import quoteSocket from '@/services/websocket/quote'
|
|
import quoteSocket from '@/services/websocket/quote'
|
|
|
import Stepper from '@mobile/components/base/stepper/index.vue'
|
|
import Stepper from '@mobile/components/base/stepper/index.vue'
|
|
|
import Banner from '@mobile/components/base/banner/index.vue'
|
|
import Banner from '@mobile/components/base/banner/index.vue'
|
|
|
-import { getGoodsUnitName } from '@/constants/unit'
|
|
|
|
|
|
|
|
|
|
const { getQueryStringToNumber } = useNavigation()
|
|
const { getQueryStringToNumber } = useNavigation()
|
|
|
const futuresStore = useFuturesStore()
|
|
const futuresStore = useFuturesStore()
|
|
@@ -103,12 +104,12 @@ const collection = futuresStore.collections.find(e => e.collectionid === collect
|
|
|
const { global: { t } } = i18n
|
|
const { global: { t } } = i18n
|
|
|
const subscribe = quoteSocket.createSubscribe()
|
|
const subscribe = quoteSocket.createSubscribe()
|
|
|
|
|
|
|
|
-const { formData, formSubmit } = useOrder()
|
|
|
|
|
const formRef = shallowRef<FormInstance>()
|
|
const formRef = shallowRef<FormInstance>()
|
|
|
|
|
|
|
|
const { getSystemParamValue } = useUserStore()
|
|
const { getSystemParamValue } = useUserStore()
|
|
|
|
|
|
|
|
const active = shallowRef('images')
|
|
const active = shallowRef('images')
|
|
|
|
|
+const { componentRef, componentId, openComponent, closeComponent } = useComponent()
|
|
|
|
|
|
|
|
// 数量步长列表
|
|
// 数量步长列表
|
|
|
const qtyStepList = computed(() => {
|
|
const qtyStepList = computed(() => {
|
|
@@ -117,6 +118,7 @@ const qtyStepList = computed(() => {
|
|
|
return result.map((value) => +system_1009 * value)
|
|
return result.map((value) => +system_1009 * value)
|
|
|
})
|
|
})
|
|
|
const qtyStep = shallowRef(qtyStepList.value[0]) // 数量步长
|
|
const qtyStep = shallowRef(qtyStepList.value[0]) // 数量步长
|
|
|
|
|
+const orderQty = shallowRef(qtyStepList.value[0]) // 默认数量
|
|
|
|
|
|
|
|
// 订单模型列表
|
|
// 订单模型列表
|
|
|
const orderTypeStepList = computed(() => {
|
|
const orderTypeStepList = computed(() => {
|
|
@@ -174,7 +176,7 @@ const pictureurl = computed(() => {
|
|
|
|
|
|
|
|
// 数量切换
|
|
// 数量切换
|
|
|
const onQtyRadioChange = (value: number) => {
|
|
const onQtyRadioChange = (value: number) => {
|
|
|
- formData.OrderQty = value
|
|
|
|
|
|
|
+ orderQty.value = value
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 订单类型切换
|
|
// 订单类型切换
|
|
@@ -238,12 +240,12 @@ const usedMargin = computed(() => {
|
|
|
if (fixed && ratio) {
|
|
if (fixed && ratio) {
|
|
|
if (marketmarginalgorithm === 1) {
|
|
if (marketmarginalgorithm === 1) {
|
|
|
const qty = Math.trunc(avaiableMoney / ratio)
|
|
const qty = Math.trunc(avaiableMoney / ratio)
|
|
|
- result.deposit = (formData.OrderQty ?? 0) * ratio
|
|
|
|
|
|
|
+ result.deposit = (orderQty.value ?? 0) * ratio
|
|
|
result.enableQty = qty > 0 ? qty : 0
|
|
result.enableQty = qty > 0 ? qty : 0
|
|
|
}
|
|
}
|
|
|
if (marketmarginalgorithm === 2) {
|
|
if (marketmarginalgorithm === 2) {
|
|
|
const qty = Math.trunc(avaiableMoney / fixed)
|
|
const qty = Math.trunc(avaiableMoney / fixed)
|
|
|
- result.deposit = (formData.OrderQty ?? 0) * fixed
|
|
|
|
|
|
|
+ result.deposit = (orderQty.value ?? 0) * fixed
|
|
|
result.enableQty = qty > 0 ? qty : 0
|
|
result.enableQty = qty > 0 ? qty : 0
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -259,70 +261,24 @@ const components = [
|
|
|
},
|
|
},
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
-// const componentMap = new Map<string, unknown>([
|
|
|
|
|
-// ['detail', defineAsyncComponent(() => import('../components/detail/Index.vue'))],
|
|
|
|
|
-// ['transfer', defineAsyncComponent(() => import('@mobile/views/order/position/components/pricing/detail2/components/transfer/Index.vue'))]
|
|
|
|
|
-// ])
|
|
|
|
|
-
|
|
|
|
|
-const onBeforeSubmit = (buildType: BuildType) => {
|
|
|
|
|
- // formData.BuildType = buildType
|
|
|
|
|
- // if (buildType === BuildType.Close) {
|
|
|
|
|
- // // const { ask = 0, bid = 0 } = quote.value ?? {}
|
|
|
|
|
- // // formData.OrderPrice = formData.BuyOrSell === BuyOrSell.Buy ? ask : bid
|
|
|
|
|
-
|
|
|
|
|
- // // const datas = position.value.filter(item => formData.BuyOrSell === BuyOrSell.Buy ? item.buyorsell === BuyOrSell.Sell : item.buyorsell === BuyOrSell.Buy) // 反方向持仓
|
|
|
|
|
- // // if (datas.length > 0) {
|
|
|
|
|
- // // formData.OrderQty = datas[0].enableqty
|
|
|
|
|
- // // }
|
|
|
|
|
- // } else {
|
|
|
|
|
- // formData.RelatedID = undefined
|
|
|
|
|
- // }
|
|
|
|
|
- formRef.value?.submit()
|
|
|
|
|
-}
|
|
|
|
|
|
|
+const componentMap = new Map<string, unknown>([
|
|
|
|
|
+ ['fullpayment', defineAsyncComponent(() => import('../fullpayment/Index.vue'))],
|
|
|
|
|
+ ['prepayment', defineAsyncComponent(() => import('../prepayment/Index.vue'))],
|
|
|
|
|
+])
|
|
|
|
|
|
|
|
// 委托下单
|
|
// 委托下单
|
|
|
const onSubmit = () => {
|
|
const onSubmit = () => {
|
|
|
- // const { goodsid, marketid } = quote.value ?? {}
|
|
|
|
|
- // formData.GoodsID = goodsid
|
|
|
|
|
- // formData.MarketID = marketid
|
|
|
|
|
- // // 市价
|
|
|
|
|
- // // if (formData.PriceMode === PriceMode.Market) { formData.OrderPrice = marketPrice.value }
|
|
|
|
|
-
|
|
|
|
|
- // fullloading((hideLoading) => {
|
|
|
|
|
- // formSubmit().then(() => {
|
|
|
|
|
- // hideLoading()
|
|
|
|
|
- // dialog({ message: t('common.submitsuccess'), confirmButtonText: t('operation.confirm') }).then(() => {
|
|
|
|
|
- // // 成交通知
|
|
|
|
|
- // eventBus.$emit('OrderDealedNtf')
|
|
|
|
|
- // })
|
|
|
|
|
- // }).catch((err) => {
|
|
|
|
|
- // hideLoading(err, 'fail')
|
|
|
|
|
- // })
|
|
|
|
|
- // })
|
|
|
|
|
|
|
+ console.log(orderType.value)
|
|
|
|
|
+ if (orderType.value === 1) {
|
|
|
|
|
+ // 全款购买
|
|
|
|
|
+ openComponent('fullpayment')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 预付款以及回购
|
|
|
|
|
+ openComponent('prepayment')
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
- // quote.value = futuresStore.getGoodsQuote(goodsCode.value).value
|
|
|
|
|
- // console.log(quote.value)
|
|
|
|
|
- // formData.BuyOrSell = BuyOrSell.Buy
|
|
|
|
|
- // formData.BuildType = BuildType.Open
|
|
|
|
|
- // formData.PriceMode = PriceMode.Market
|
|
|
|
|
- // formData.MarketMaxSub = 100.0
|
|
|
|
|
- // /// 默认价格和数量
|
|
|
|
|
- // const { last = 0, presettle = 0 } = quote.value ?? {}
|
|
|
|
|
- // formData.OrderPrice = last || presettle
|
|
|
|
|
- // formData.OrderQty = qtyStep.value
|
|
|
|
|
-
|
|
|
|
|
- // /// 如果是从头寸点进来的
|
|
|
|
|
- // if (buildType === BuildType.Close) {
|
|
|
|
|
- // formData.OrderQty = orderQty
|
|
|
|
|
- // formData.BuyOrSell = buyOrSell
|
|
|
|
|
- // formData.BuildType = buildType
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- //
|
|
|
|
|
// 默认第一个商品集合的第一个商品
|
|
// 默认第一个商品集合的第一个商品
|
|
|
onOrderTypeRadioChange(1)
|
|
onOrderTypeRadioChange(1)
|
|
|
// 订阅商品行情
|
|
// 订阅商品行情
|