|
|
@@ -3,16 +3,21 @@
|
|
|
<app-modal direction="right-top" height="100%" width="100%" v-model:show="showModal">
|
|
|
<app-view class="g-form">
|
|
|
<template #header>
|
|
|
- <app-navbar title="汇总平仓" @back="closed" />
|
|
|
+ <app-navbar title="止盈止损" @back="closed" />
|
|
|
</template>
|
|
|
<Form ref="formRef" class="g-form__container" @submit="onCloseSumit">
|
|
|
<CellGroup :title="t('position.goods.subtitle')" inset>
|
|
|
- <Cell :title="t('digital.goodscode')" :value="`${selectedRow.goodscode}/${selectedRow.goodsname}`" />
|
|
|
- <Cell :title="t('position.transfer.buyorsell')" :value="getBuyOrSellName(selectedRow.buyorsell, 1)" />
|
|
|
- <Cell :title="`${t('position.goods.holddetail.holderprice')}(${getGoodsCurrencyItemName(selectedRow.currencyid)})`"
|
|
|
- :value="selectedRow.averageprice" />
|
|
|
- <Cell :title="`${t('quote.holdvolume')}(${selectedRow.goodscode})`" :value="selectedRow.curpositionqty" />
|
|
|
- <Cell :title="`${t('position.goods.frozenqty')}(${selectedRow.goodscode})`" :value="selectedRow.frozenqty" />
|
|
|
+ <Cell :title="t('digital.goodscode')"
|
|
|
+ :value="`${selectedRow.goodscode}/${selectedRow.goodsname}`" />
|
|
|
+ <Cell :title="t('position.transfer.buyorsell')"
|
|
|
+ :value="getBuyOrSellName(selectedRow.buyorsell, 1)" />
|
|
|
+ <Cell
|
|
|
+ :title="`${t('position.goods.holddetail.holderprice')}(${getGoodsCurrencyItemName(selectedRow.currencyid)})`"
|
|
|
+ :value="selectedRow.holderprice" />
|
|
|
+ <Cell :title="`${t('quote.holdvolume')}(${selectedRow.goodscode})`"
|
|
|
+ :value="selectedRow.holderqty" />
|
|
|
+ <Cell :title="`${t('position.goods.frozenqty')}(${selectedRow.goodscode})`"
|
|
|
+ :value="selectedRow.freezeqty" />
|
|
|
<Cell :title="`${t('digital.quoteprice')}(${getGoodsCurrencyItemName(selectedRow.currencyid)})`">
|
|
|
<template #value>
|
|
|
<span :class="selectedRow.lastPriceClass">
|
|
|
@@ -20,7 +25,8 @@
|
|
|
</span>
|
|
|
</template>
|
|
|
</Cell>
|
|
|
- <Cell :title="`${t('position.goods.holddetail.profitLoss')}(${getGoodsCurrencyItemName(selectedRow.currencyid)})`">
|
|
|
+ <Cell
|
|
|
+ :title="`${t('position.goods.holddetail.profitLoss')}(${getGoodsCurrencyItemName(selectedRow.currencyid)})`">
|
|
|
<template #value>
|
|
|
<span :class="selectedRow.profitLossClass">
|
|
|
{{ selectedRow.profitLoss.toFixed(selectedRow.decimalplace) }}
|
|
|
@@ -29,30 +35,32 @@
|
|
|
</Cell>
|
|
|
</CellGroup>
|
|
|
<CellGroup :title="t('digital.spsl')" inset>
|
|
|
- <Cell :value="`${t('mine.setting.price')} (>=${pricePoints.takeProfit.toFixed(selectedRow.decimalplace)})`">
|
|
|
+ <Cell
|
|
|
+ :value="`${t('mine.setting.price')} (>=${pricePoints.takeProfit.toFixed(selectedRow.decimalplace)})`">
|
|
|
<template #title>
|
|
|
<Checkbox v-model="formData.TPFlag">{{ $t('digital.sp') }}</Checkbox>
|
|
|
</template>
|
|
|
</Cell>
|
|
|
- <Field name="SpPrice" :rules="formRules.SpPrice">
|
|
|
+ <Field name="TPPrice" :rules="formRules.TPPrice">
|
|
|
<template #input>
|
|
|
- <app-stepper v-model="formData.SpPrice" :min="pricePoints.takeProfit"
|
|
|
- :decimal-length="quote?.decimalplace" :step="quote?.decimalvalue" :button-size="32"
|
|
|
- :disabled="!formData.TPFlag" />
|
|
|
+ <app-stepper v-model="formData.TPPrice" :decimal-length="quote?.decimalplace"
|
|
|
+ :step="quote?.decimalvalue" :button-size="32" :disabled="!formData.TPFlag"
|
|
|
+ :auto-fixed="false" />
|
|
|
</template>
|
|
|
</Field>
|
|
|
</CellGroup>
|
|
|
<CellGroup inset>
|
|
|
- <Cell :value="`${t('mine.setting.price')} (>=${pricePoints.stopLoss.toFixed(selectedRow.decimalplace)})`">
|
|
|
+ <Cell
|
|
|
+ :value="`${t('mine.setting.price')} (<=${pricePoints.stopLoss.toFixed(selectedRow.decimalplace)})`">
|
|
|
<template #title>
|
|
|
<Checkbox v-model="formData.SLFlag">{{ $t('digital.sl') }}</Checkbox>
|
|
|
</template>
|
|
|
</Cell>
|
|
|
- <Field name="SlPrice" :rules="formRules.SlPrice">
|
|
|
+ <Field name="SLPrice" :rules="formRules.SLPrice">
|
|
|
<template #input>
|
|
|
- <app-stepper v-model="formData.SlPrice" :max="pricePoints.stopLoss"
|
|
|
- :decimal-length="quote?.decimalplace" :step="quote?.decimalvalue" :button-size="32"
|
|
|
- :disabled="!formData.SLFlag" />
|
|
|
+ <app-stepper v-model="formData.SLPrice" :decimal-length="quote?.decimalplace"
|
|
|
+ :step="quote?.decimalvalue" :button-size="32" :disabled="!formData.SLFlag"
|
|
|
+ :auto-fixed="false" />
|
|
|
</template>
|
|
|
</Field>
|
|
|
</CellGroup>
|
|
|
@@ -65,19 +73,19 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, PropType, onMounted, computed } from 'vue'
|
|
|
+import { shallowRef, reactive, PropType, computed, onMounted } from 'vue'
|
|
|
import { CellGroup, Cell, Button, FieldRule, Form, Field, FormInstance, Checkbox } from 'vant'
|
|
|
import { dialog, fullloading } from '@/utils/vant'
|
|
|
+import { handleRequestBigNumber } from '@/filters'
|
|
|
import { getBuyOrSellName, getGoodsCurrencyItemName, BuyOrSell } from '@/constants/order'
|
|
|
-import { useOrder } from '@/business/trade'
|
|
|
-import { i18n, useFuturesStore, useUserStore } from '@/stores'
|
|
|
-import { EBuildType, EDelistingType, EOrderOperateType, EListingSelectType, EPriceMode, EValidType } from '@/constants/client'
|
|
|
+import { holderTPSLSet } from '@/services/api/trade'
|
|
|
+import { i18n, useFuturesStore } from '@/stores'
|
|
|
import AppModal from '@/components/base/modal/index.vue'
|
|
|
import AppStepper from '@mobile/components/base/stepper/index.vue'
|
|
|
|
|
|
const props = defineProps({
|
|
|
selectedRow: {
|
|
|
- type: Object as PropType<Model.TradePositionRsp & {
|
|
|
+ type: Object as PropType<Model.TradeHolderDetailRsp & {
|
|
|
lastPrice: number;
|
|
|
lastPriceClass: string;
|
|
|
profitLoss: number;
|
|
|
@@ -88,14 +96,24 @@ const props = defineProps({
|
|
|
})
|
|
|
|
|
|
const { global: { t } } = i18n
|
|
|
-const userStore = useUserStore()
|
|
|
const futuresStore = useFuturesStore()
|
|
|
const formRef = shallowRef<FormInstance>()
|
|
|
const showModal = shallowRef(true)
|
|
|
|
|
|
-const quote = computed(() => futuresStore.getQuoteItem({ goodsid: props.selectedRow.goodsid }))
|
|
|
+const formData = reactive<Partial<Proto.HolderTPSLSetReq>>({
|
|
|
+ Header: {
|
|
|
+ MarketID: props.selectedRow.marketid,
|
|
|
+ AccountID: props.selectedRow.accountid,
|
|
|
+ },
|
|
|
+ TradeID: handleRequestBigNumber(props.selectedRow.tradeid),
|
|
|
+ AccountID: props.selectedRow.accountid,
|
|
|
+ BuyOrSell: props.selectedRow.buyorsell,
|
|
|
+ GoodsID: props.selectedRow.goodsid,
|
|
|
+ TPFlag: props.selectedRow.tpsl_tpflag,
|
|
|
+ SLFlag: props.selectedRow.tpsl_slflag
|
|
|
+})
|
|
|
|
|
|
-const { formSubmit, formData } = useOrder()
|
|
|
+const quote = computed(() => futuresStore.getQuoteItem({ goodsid: props.selectedRow.goodsid }))
|
|
|
|
|
|
const pricePoints = computed(() => {
|
|
|
const { decimalplace = 0, buyslpoint, buytppoint, sellslpoint, selltppoint } = quote.value ?? {}
|
|
|
@@ -134,43 +152,44 @@ const pricePoints = computed(() => {
|
|
|
|
|
|
// 表单验证规则
|
|
|
const formRules: { [key: string]: FieldRule[] } = {
|
|
|
- SpPrice: [{
|
|
|
+ TPPrice: [{
|
|
|
message: '请输入止盈价格',
|
|
|
validator: () => {
|
|
|
- return !!formData.SpPrice
|
|
|
+ if (formData.TPFlag) {
|
|
|
+ const value = Number(formData.TPPrice)
|
|
|
+ if (value < pricePoints.value.takeProfit) {
|
|
|
+ return '价格不在有效范围内'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true
|
|
|
}
|
|
|
}],
|
|
|
- SlPrice: [{
|
|
|
+ SLPrice: [{
|
|
|
message: '请输入止损价格',
|
|
|
validator: () => {
|
|
|
- return !!formData.SlPrice
|
|
|
+ if (formData.SLFlag) {
|
|
|
+ const value = Number(formData.SLFlag)
|
|
|
+ if (value > pricePoints.value.stopLoss) {
|
|
|
+ return '价格不在有效范围内'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true
|
|
|
}
|
|
|
}],
|
|
|
}
|
|
|
|
|
|
const onCloseSumit = () => {
|
|
|
dialog({
|
|
|
- message: '确认要平仓吗?',
|
|
|
+ message: '确认提交吗?',
|
|
|
showCancelButton: true,
|
|
|
}).then(() => {
|
|
|
-
|
|
|
- const { marketid, goodsid, buyorsell } = props.selectedRow
|
|
|
- /// 市场ID
|
|
|
- formData.Header = { GoodsID: goodsid }
|
|
|
- formData.MarketID = marketid
|
|
|
- formData.BuyOrSell = buyorsell === BuyOrSell.Buy ? BuyOrSell.Sell : BuyOrSell.Buy
|
|
|
- formData.GoodsID = goodsid
|
|
|
- formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTINGTHENLISTING
|
|
|
- formData.DelistingType = EDelistingType.DELISTINGTYPE_PRICE
|
|
|
- formData.BuildType = EBuildType.BUILDTYPE_CLOSE
|
|
|
- formData.TimevalidType = EValidType.VALIDTYPE_DR
|
|
|
- formData.OperateType = EOrderOperateType.ORDEROPERATETYPE_NORMAL
|
|
|
- const param112 = userStore.getSystemParamValue('112')
|
|
|
- formData.MarketMaxSub = Number(param112) || 100
|
|
|
-
|
|
|
- /// loding....
|
|
|
fullloading((hideLoading) => {
|
|
|
- formSubmit().then(() => {
|
|
|
+ formData.TPFlag = Number(formData.TPFlag)
|
|
|
+ formData.SLFlag = Number(formData.SLFlag)
|
|
|
+
|
|
|
+ holderTPSLSet({
|
|
|
+ data: formData
|
|
|
+ }).then(() => {
|
|
|
hideLoading(t('common.submitsuccess'), 'success')
|
|
|
closed()
|
|
|
}).catch((err) => {
|
|
|
@@ -186,11 +205,8 @@ const closed = () => {
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
- formData.PriceMode = EPriceMode.PRICEMODE_MARKET
|
|
|
- formData.OrderPrice = props.selectedRow.lastPrice
|
|
|
- formData.OrderQty = props.selectedRow.enableqty
|
|
|
- formData.SpPrice = pricePoints.value.takeProfit
|
|
|
- formData.SlPrice = pricePoints.value.stopLoss
|
|
|
+ formData.TPPrice = Number(props.selectedRow.tpsl_tpprice) || pricePoints.value.takeProfit
|
|
|
+ formData.SLPrice = Number(props.selectedRow.tpsl_slprice) || pricePoints.value.stopLoss
|
|
|
})
|
|
|
|
|
|
// 暴露组件属性给父组件调用
|