|
@@ -54,10 +54,10 @@
|
|
|
</template>
|
|
</template>
|
|
|
</Field>
|
|
</Field>
|
|
|
<!-- 限价 -->
|
|
<!-- 限价 -->
|
|
|
- <Field name="OrderPrice" :rules="formRules.OrderPrice" label="价格"
|
|
|
|
|
- v-if="formData.PriceMode === PriceMode.Limit">
|
|
|
|
|
|
|
+ <Field name="OrderPrice" :rules="formRules.OrderPrice" label="价格" v-if="formData.PriceMode === PriceMode.Limit">
|
|
|
<template #input>
|
|
<template #input>
|
|
|
- <Stepper v-model="formData.OrderPrice" theme="round" button-size="22" :auto-fixed="false" />
|
|
|
|
|
|
|
+ <Stepper v-model="formData.OrderPrice" theme="round" button-size="22" :min="0"
|
|
|
|
|
+ :auto-fixed="false" :decimal-length="quote?.decimalplace" :step="quote?.decimalvalue" />
|
|
|
</template>
|
|
</template>
|
|
|
</Field>
|
|
</Field>
|
|
|
<Field name="SlPrice" :rules="formRules.SlPrice"
|
|
<Field name="SlPrice" :rules="formRules.SlPrice"
|
|
@@ -67,7 +67,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
<template #input>
|
|
<template #input>
|
|
|
<Stepper v-model="formData.SlPrice" :disabled="!sl" theme="round" button-size="22" allow-empty
|
|
<Stepper v-model="formData.SlPrice" :disabled="!sl" theme="round" button-size="22" allow-empty
|
|
|
- :default-value="0" :min="0" integer />
|
|
|
|
|
|
|
+ :default-value="0" :min="0" :decimal-length="quote?.decimalplace" :step="quote?.decimalvalue" />
|
|
|
</template>
|
|
</template>
|
|
|
</Field>
|
|
</Field>
|
|
|
<Field name="SpPrice" :rules="formRules.SpPrice"
|
|
<Field name="SpPrice" :rules="formRules.SpPrice"
|
|
@@ -77,7 +77,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
<template #input>
|
|
<template #input>
|
|
|
<Stepper v-model="formData.SpPrice" :disabled="!sp" theme="round" button-size="22" allow-empty
|
|
<Stepper v-model="formData.SpPrice" :disabled="!sp" theme="round" button-size="22" allow-empty
|
|
|
- :default-value="0" :min="0" integer />
|
|
|
|
|
|
|
+ :default-value="0" :min="0" :decimal-length="quote?.decimalplace" :step="quote?.decimalvalue" />
|
|
|
</template>
|
|
</template>
|
|
|
</Field>
|
|
</Field>
|
|
|
<template v-if="formData.BuyOrSell === BuyOrSell.Buy || quote?.tradeproperty !== 2">
|
|
<template v-if="formData.BuyOrSell === BuyOrSell.Buy || quote?.tradeproperty !== 2">
|
|
@@ -132,14 +132,11 @@
|
|
|
import { useFuturesStore, useAccountStore, usePositionStore } from '@/stores'
|
|
import { useFuturesStore, useAccountStore, usePositionStore } from '@/stores'
|
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
|
import { handleNumberValue } from '@/filters'
|
|
import { handleNumberValue } from '@/filters'
|
|
|
-import quoteSocket from '@/services/websocket/quote'
|
|
|
|
|
-import { shallowRef, onMounted, onUnmounted, computed, defineAsyncComponent } from 'vue'
|
|
|
|
|
|
|
+import { shallowRef, onMounted, computed, defineAsyncComponent } from 'vue'
|
|
|
import { Form, Field, Button, FieldRule, FormInstance, Radio, RadioGroup, Checkbox, CellGroup } from 'vant'
|
|
import { Form, Field, Button, FieldRule, FormInstance, Radio, RadioGroup, Checkbox, CellGroup } from 'vant'
|
|
|
import { useOrder } from '@/business/trade'
|
|
import { useOrder } from '@/business/trade'
|
|
|
import { BuyOrSell, getBuyOrSellList, BuildType, getPricemode2List, PriceMode } from '@/constants/order'
|
|
import { BuyOrSell, getBuyOrSellList, BuildType, getPricemode2List, PriceMode } from '@/constants/order'
|
|
|
import { fullloading, dialog } from '@/utils/vant'
|
|
import { fullloading, dialog } from '@/utils/vant'
|
|
|
-import { useRequest } from '@/hooks/request'
|
|
|
|
|
-import { queryTradePosition } from '@/services/api/order'
|
|
|
|
|
import AppModal from '@/components/base/modal/index.vue'
|
|
import AppModal from '@/components/base/modal/index.vue'
|
|
|
import Stepper from '@mobile/components/base/stepper/index.vue'
|
|
import Stepper from '@mobile/components/base/stepper/index.vue'
|
|
|
|
|
|
|
@@ -164,12 +161,11 @@ const positionStore = usePositionStore()
|
|
|
const formRef = shallowRef<FormInstance>()
|
|
const formRef = shallowRef<FormInstance>()
|
|
|
const { formData, formSubmit } = useOrder()
|
|
const { formData, formSubmit } = useOrder()
|
|
|
|
|
|
|
|
|
|
+const quote = futuresStore.getGoodsQuote(props.goodsCode)
|
|
|
const marketPrice = computed(() => {
|
|
const marketPrice = computed(() => {
|
|
|
const { ask = 0, bid = 0 } = quote.value ?? {}
|
|
const { ask = 0, bid = 0 } = quote.value ?? {}
|
|
|
return formData.BuyOrSell === BuyOrSell.Buy ? ask : bid
|
|
return formData.BuyOrSell === BuyOrSell.Buy ? ask : bid
|
|
|
})
|
|
})
|
|
|
-const quote = futuresStore.getGoodsQuote(props.goodsCode)
|
|
|
|
|
-const subscribe = quoteSocket.createSubscribe()
|
|
|
|
|
const sl = shallowRef(false) // 止损
|
|
const sl = shallowRef(false) // 止损
|
|
|
const sp = shallowRef(false) // 止盈
|
|
const sp = shallowRef(false) // 止盈
|
|
|
const position = shallowRef<Model.TradePositionRsp[]>([]) // 持仓汇总
|
|
const position = shallowRef<Model.TradePositionRsp[]>([]) // 持仓汇总
|
|
@@ -210,7 +206,6 @@ const total = computed(() => {
|
|
|
|
|
|
|
|
// 买方向持仓数量
|
|
// 买方向持仓数量
|
|
|
const buyQty = computed(() => positionStore.getOrderQty(BuyOrSell.Buy, props.goodsCode))
|
|
const buyQty = computed(() => positionStore.getOrderQty(BuyOrSell.Buy, props.goodsCode))
|
|
|
-
|
|
|
|
|
// 卖方向持仓数量
|
|
// 卖方向持仓数量
|
|
|
const sellQty = computed(() => positionStore.getOrderQty(BuyOrSell.Sell, props.goodsCode))
|
|
const sellQty = computed(() => positionStore.getOrderQty(BuyOrSell.Sell, props.goodsCode))
|
|
|
|
|
|
|
@@ -252,20 +247,6 @@ const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
|
|
|
}],
|
|
}],
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 获取当前商品持仓汇总
|
|
|
|
|
-useRequest(queryTradePosition, {
|
|
|
|
|
- params: {
|
|
|
|
|
- tradeMode: '10'
|
|
|
|
|
- },
|
|
|
|
|
- onSuccess: (res) => {
|
|
|
|
|
- position.value = res.data.filter(item => item.goodscode === props.goodsCode)
|
|
|
|
|
- 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
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
-})
|
|
|
|
|
-
|
|
|
|
|
const onBuyOrSellChanged = () => {
|
|
const onBuyOrSellChanged = () => {
|
|
|
if (formData.PriceMode === PriceMode.Limit) {
|
|
if (formData.PriceMode === PriceMode.Limit) {
|
|
|
const { ask = 0, bid = 0 } = quote.value ?? {}
|
|
const { ask = 0, bid = 0 } = quote.value ?? {}
|
|
@@ -346,7 +327,6 @@ const closed = (isRefresh = true) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
- subscribe.start(props.goodsCode)
|
|
|
|
|
formData.BuyOrSell = props.buyOrSell
|
|
formData.BuyOrSell = props.buyOrSell
|
|
|
formData.BuildType = BuildType.Open
|
|
formData.BuildType = BuildType.Open
|
|
|
formData.PriceMode = PriceMode.Market
|
|
formData.PriceMode = PriceMode.Market
|
|
@@ -357,8 +337,6 @@ onMounted(() => {
|
|
|
formData.OrderQty = qtyStep.value
|
|
formData.OrderQty = qtyStep.value
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-onUnmounted(() => subscribe.stop())
|
|
|
|
|
-
|
|
|
|
|
// 暴露组件属性给父组件调用
|
|
// 暴露组件属性给父组件调用
|
|
|
defineExpose({
|
|
defineExpose({
|
|
|
closed,
|
|
closed,
|