|
@@ -54,32 +54,32 @@
|
|
|
</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"
|
|
|
v-if="formData.PriceMode === PriceMode.Limit && formData.BuildType === BuildType.Open">
|
|
v-if="formData.PriceMode === PriceMode.Limit && formData.BuildType === BuildType.Open">
|
|
|
<template #label>
|
|
<template #label>
|
|
|
<Checkbox v-model="sl">止损</Checkbox>
|
|
<Checkbox v-model="sl">止损</Checkbox>
|
|
|
</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 name="SpPrice" :rules="formRules.SpPrice"
|
|
|
|
|
|
|
+ </Field> -->
|
|
|
|
|
+ <!-- <Field name="SpPrice" :rules="formRules.SpPrice"
|
|
|
v-if="formData.PriceMode === PriceMode.Limit && formData.BuildType === BuildType.Open">
|
|
v-if="formData.PriceMode === PriceMode.Limit && formData.BuildType === BuildType.Open">
|
|
|
<template #label>
|
|
<template #label>
|
|
|
<Checkbox v-model="sp">止盈</Checkbox>
|
|
<Checkbox v-model="sp">止盈</Checkbox>
|
|
|
</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">
|
|
|
<Field label="预估可订立量">
|
|
<Field label="预估可订立量">
|
|
|
<template #input>
|
|
<template #input>
|
|
@@ -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,14 +161,13 @@ 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 sp = shallowRef(false) // 止盈
|
|
|
|
|
|
|
+// const sl = shallowRef(false) // 止损
|
|
|
|
|
+// const sp = shallowRef(false) // 止盈
|
|
|
const position = shallowRef<Model.TradePositionRsp[]>([]) // 持仓汇总
|
|
const position = shallowRef<Model.TradePositionRsp[]>([]) // 持仓汇总
|
|
|
// 是否刷新父组件数据
|
|
// 是否刷新父组件数据
|
|
|
const refresh = shallowRef(true)
|
|
const refresh = shallowRef(true)
|
|
@@ -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))
|
|
|
|
|
|
|
@@ -232,50 +227,26 @@ const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
|
|
|
return true
|
|
return true
|
|
|
}
|
|
}
|
|
|
}],
|
|
}],
|
|
|
- SlPrice: [{
|
|
|
|
|
- message: '请输入止损价',
|
|
|
|
|
- validator: () => {
|
|
|
|
|
- if (sl.value) {
|
|
|
|
|
- return !!formData.SlPrice
|
|
|
|
|
- }
|
|
|
|
|
- return true
|
|
|
|
|
- }
|
|
|
|
|
- }],
|
|
|
|
|
- SpPrice: [{
|
|
|
|
|
- message: '请输入止盈价',
|
|
|
|
|
- validator: () => {
|
|
|
|
|
- if (sp.value) {
|
|
|
|
|
- return !!formData.SpPrice
|
|
|
|
|
- }
|
|
|
|
|
- return true
|
|
|
|
|
- }
|
|
|
|
|
- }],
|
|
|
|
|
|
|
+ // SlPrice: [{
|
|
|
|
|
+ // message: '请输入止损价',
|
|
|
|
|
+ // validator: () => {
|
|
|
|
|
+ // if (sl.value) {
|
|
|
|
|
+ // return !!formData.SlPrice
|
|
|
|
|
+ // }
|
|
|
|
|
+ // return true
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }],
|
|
|
|
|
+ // SpPrice: [{
|
|
|
|
|
+ // message: '请输入止盈价',
|
|
|
|
|
+ // validator: () => {
|
|
|
|
|
+ // if (sp.value) {
|
|
|
|
|
+ // return !!formData.SpPrice
|
|
|
|
|
+ // }
|
|
|
|
|
+ // return true
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }],
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-onMounted(() => {
|
|
|
|
|
- subscribe.start(props.goodsCode)
|
|
|
|
|
- formData.BuyOrSell = props.buyOrSell
|
|
|
|
|
- formData.BuildType = BuildType.Open
|
|
|
|
|
- formData.PriceMode = PriceMode.Market
|
|
|
|
|
- formData.MarketMaxSub = 100.0
|
|
|
|
|
-})
|
|
|
|
|
-
|
|
|
|
|
-onUnmounted(() => subscribe.stop())
|
|
|
|
|
-
|
|
|
|
|
-// 获取当前商品持仓汇总
|
|
|
|
|
-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 ?? {}
|
|
@@ -323,8 +294,8 @@ const onSubmit = () => {
|
|
|
// 市价
|
|
// 市价
|
|
|
if (formData.PriceMode === PriceMode.Market) { formData.OrderPrice = marketPrice.value }
|
|
if (formData.PriceMode === PriceMode.Market) { formData.OrderPrice = marketPrice.value }
|
|
|
// 限价
|
|
// 限价
|
|
|
- if (!sl.value) { formData.SlPrice = undefined }
|
|
|
|
|
- if (!sp.value) { formData.SpPrice = undefined }
|
|
|
|
|
|
|
+ // if (!sl.value) { formData.SlPrice = undefined }
|
|
|
|
|
+ // if (!sp.value) { formData.SpPrice = undefined }
|
|
|
|
|
|
|
|
fullloading((hideLoading) => {
|
|
fullloading((hideLoading) => {
|
|
|
formSubmit().then(() => {
|
|
formSubmit().then(() => {
|
|
@@ -355,6 +326,17 @@ const closed = (isRefresh = true) => {
|
|
|
showModal.value = false
|
|
showModal.value = false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ formData.BuyOrSell = props.buyOrSell
|
|
|
|
|
+ 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
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
// 暴露组件属性给父组件调用
|
|
// 暴露组件属性给父组件调用
|
|
|
defineExpose({
|
|
defineExpose({
|
|
|
closed,
|
|
closed,
|