Handy_Cao 1 mēnesi atpakaļ
vecāks
revīzija
5a3508ffab

+ 11 - 1
src/packages/digital/views/contract/components/order/index.vue

@@ -108,7 +108,7 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, defineAsyncComponent } from 'vue'
+import { shallowRef, defineAsyncComponent, onUnmounted } from 'vue'
 import { useRequest } from '@/hooks/request'
 import { Button } from 'vant'
 import { useComponent } from '@/hooks/component'
@@ -118,6 +118,7 @@ import { getBuyOrSellName, getWRTradeOrderStatusName } from '@/constants/order'
 import AppPullRefresh from '@mobile/components/base/pull-refresh/index.vue'
 import AppSelect from '@mobile/components/base/select/index.vue'
 import AppCalendar from '@mobile/components/base/calendar/index.vue'
+import eventBus from '@/services/bus'
 
 const props = defineProps({
     goodsId: Number
@@ -195,4 +196,13 @@ const onRefresh = () => {
     })
 }
 
+// 接收委托回应通知
+const orderRspNotify = eventBus.$on('OrderRsp', () => {
+    run()
+})
+
+onUnmounted(() => {
+    orderRspNotify.cancel()
+})
+
 </script>

+ 7 - 4
src/packages/digital/views/contract/components/position/close/index.vue

@@ -22,7 +22,7 @@
                     </Cell>
                     <Field v-if="formData.PriceMode === EPriceMode.PRICEMODE_LIMIT" name="OrderPrice" :rules="formRules.OrderPrice" label="价格">
                         <template #input>
-                            <app-stepper v-model="formData.OrderPrice" min="0.0" :decimal-length="quote?.decimalplace"
+                            <app-stepper v-model="formData.OrderPrice" min="0.0" :decimal-length="selectedRow.decimalPlace"
                             :step="quote?.decimalvalue" :auto-fixed="false" />
                         </template>
                     </Field>
@@ -54,7 +54,7 @@ import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
 import { formatDecimal, handleRequestBigNumber, handlePriceColor } from '@/filters'
 import { useOrder } from '@/business/trade'
 import { dialog, fullloading } from '@/utils/vant'
-import { useFuturesStore, usePositionStore, i18n } from '@/stores'
+import { useFuturesStore, usePositionStore, i18n, useUserStore } from '@/stores'
 import { EBuildType, EDelistingType, EListingSelectType, EPriceMode, EValidType } from '@/constants/client'
 import AppStepper from '@mobile/components/base/stepper/index.vue'
 import AppSelect from '@mobile/components/base/select/index.vue'
@@ -74,6 +74,7 @@ const options = computed(() => {
     }]
 })
 
+const userStore = useUserStore()
 const futuresStore = useFuturesStore()
 const positionStore = usePositionStore()
 const quote = futuresStore.getGoodsQuote(props.selectedRow.goodsCode)
@@ -139,6 +140,8 @@ const onCloseSumit = () => {
         formData.TimevalidType = EValidType.VALIDTYPE_DR
         formData.OperateType = 24
         formData.RelatedID = handleRequestBigNumber(tradeID)
+        const param112 = userStore.getSystemParamValue('112')
+        formData.MarketMaxSub = Number(param112) || 100
 
         /// loding....
         fullloading((hideLoading) => {
@@ -163,10 +166,10 @@ onMounted(() => {
     const { buyOrSell } = props.selectedRow.tHDetailEx
     switch (buyOrSell) {
         case BuyOrSell.Buy:
-            formData.OrderPrice = ask || presettle
+            formData.OrderPrice = bid || presettle
             break
         case BuyOrSell.Sell:
-            formData.OrderPrice = bid || presettle
+            formData.OrderPrice = ask || presettle
             break
         default:
             formData.OrderPrice = presettle

+ 10 - 1
src/packages/digital/views/contract/components/position/index.vue

@@ -83,7 +83,7 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, defineAsyncComponent } from 'vue'
+import { shallowRef, defineAsyncComponent, onUnmounted } from 'vue'
 import { Button } from 'vant'
 import { getBuyOrSellName } from '@/constants/order'
 import { useComponent } from '@/hooks/component'
@@ -92,6 +92,7 @@ import { formatDate, formatDecimal, formatAmount, parsePercent } from '@/filters
 import { getCurrencyName } from '@/constants/order'
 import AppPullRefresh from '@mobile/components/base/pull-refresh/index.vue'
 import AppSelect from '@mobile/components/base/select/index.vue'
+import eventBus from '@/services/bus'
 
 const props = defineProps({
     goodsId: Number
@@ -130,4 +131,12 @@ const closePositionAtMarket = (row: Model.SBYJMyOrderRsp) => {
     selectedRow.value = row
     openComponent('MarketClose')
 }
+
+// 接收头寸变化通知通知
+const posChangedNtf = eventBus.$on('PosChangedNtf', () => getSBYJMyOrders())
+
+onUnmounted(() => {
+    posChangedNtf.cancel()
+})
+
 </script>

+ 30 - 17
src/packages/digital/views/contract/components/position/market-close/index.vue

@@ -8,11 +8,13 @@
 <script lang="ts" setup>
 import { shallowRef, onMounted, PropType } from 'vue'
 import { Dialog } from 'vant'
-import { useHolderClose } from '@/business/trade'
+import { useOrder } from '@/business/trade'
 import { handleRequestBigNumber } from '@/filters'
 import { fullloading } from '@/utils/vant'
 import { i18n } from '@/stores'
-
+import { EPriceMode, EValidType, EBuildType, EOrderOperateType } from '@/constants/client'
+import { BuyOrSell } from '@/constants/order'
+import { useUserStore } from '@/stores'
 
 const props = defineProps({
     selectedRow: {
@@ -21,11 +23,12 @@ const props = defineProps({
     }
 })
 
-const { holderCloseSubmit, formData } = useHolderClose()
+const { formData, formSubmit } = useOrder()
 const emit = defineEmits(['closed'])
 const { global: { t } } = i18n
 const showDialog = shallowRef(false)
 const refresh = shallowRef(false) // 是否刷新父组件数据
+const userStore = useUserStore()
 
 const onBeforeClose = (action: string) => {
     if (action === 'confirm') {
@@ -41,21 +44,31 @@ const onClosed = () => {
 
 const marketClose = () => {
     
-    const { marketID, goodsID, buyOrSell, tradeID } = props.selectedRow.tHDetailEx
-        formData.Header = { MarketID: marketID }
-        formData.GoodsID = goodsID
-        formData.BuyOrSell = buyOrSell
-        formData.MarketID = marketID
-        formData.TradeID = handleRequestBigNumber(tradeID)
-        /// loding....
-        fullloading((hideLoading) => {
-            holderCloseSubmit().then(() => {
-                hideLoading(t('position.swap.tips2'))
-                onClosed()
-            }).catch((err) => {
-                hideLoading(err, 'fail')
-            })
+    const { tHDetailEx, agreeUnit } = props.selectedRow ?? {}
+    const { marketID, goodsID, holderQty } = tHDetailEx
+    
+    /// 获取对应的市场ID
+    formData.Header = { GoodsID: goodsID, MarketID: marketID }
+    formData.MarketID = marketID
+    formData.PriceMode = EPriceMode.PRICEMODE_MARKET
+    formData.GoodsID = goodsID
+    formData.TimevalidType = EValidType.VALIDTYPE_DR
+    formData.OperateType = EOrderOperateType.ORDEROPERATETYPE_HOLDER_CLOSE
+    formData.BuildType = EBuildType.BUILDTYPE_CLOSE
+    formData.OrderQty = holderQty / agreeUnit // 数量÷合约乘数
+    formData.RelatedID = handleRequestBigNumber(tHDetailEx.tradeID) // 关联单号
+    formData.BuyOrSell = tHDetailEx.buyOrSell === BuyOrSell.Buy ? BuyOrSell.Sell : BuyOrSell.Buy // 持仓反方向
+    const param112 = userStore.getSystemParamValue('112')
+    formData.MarketMaxSub = Number(param112) || 100
+
+    fullloading((hideLoading) => {
+        formSubmit().then(() => {
+            hideLoading('提交成功', 'success')
+            onClosed()
+        }).catch((err) => {
+            hideLoading(err, 'fail')
         })
+    })
 }
 
 onMounted(() => {

+ 5 - 1
src/packages/digital/views/contract/goods/detail/index.vue

@@ -87,7 +87,7 @@ import { Form, Button, CellGroup, Field, Cell, Tab, Tabs, FieldRule, Col, Row }
 import { EPriceMode, EValidType, EOrderOperateType, EBuildType } from '@/constants/client'
 import { formatDecimal, parsePercent } from '@/filters'
 import { useNavigation } from '@mobile/router/navigation'
-import { useFuturesStore, useSBYJOrderStore } from '@/stores'
+import { useFuturesStore, useSBYJOrderStore, useUserStore } from '@/stores'
 import { fullloading, dialog } from '@/utils/vant'
 import { useOrder } from '@/business/trade'
 import { useSpotAccountStore } from '../../../wallet/components/spot/composables'
@@ -103,6 +103,7 @@ const goodsId = getQueryStringToNumber('id')
 const futuresStore = useFuturesStore()
 const tabIndex = shallowRef(0)
 
+const userStore = useUserStore()
 const { formData, formSubmit } = useOrder()
 const { getSBYJMyOrders } = useSBYJOrderStore()
 const quote = computed(() => futuresStore.getQuoteInfo({ goodsid: goodsId }))
@@ -238,6 +239,8 @@ const onSubmit = () => {
         formData.TimevalidType = EValidType.VALIDTYPE_DR
         formData.OperateType = EOrderOperateType.ORDEROPERATETYPE_NORMAL
         formData.BuildType = EBuildType.BUILDTYPE_OPEN
+        const param112 = userStore.getSystemParamValue('112')
+        formData.MarketMaxSub = Number(param112) || 100
 
         fullloading((hideLoading) => {
             formSubmit().then(() => {
@@ -256,6 +259,7 @@ onMounted(() => {
         formData.BuyOrSell = BuyOrSell.Buy
         formData.PriceMode = EPriceMode.PRICEMODE_MARKET
         formData.OrderPrice = formData.BuyOrSell === BuyOrSell.Buy ? quote.value.ask : quote.value.bid
+        formData.PriceMode = EPriceMode.PRICEMODE_MARKET
     }
 })
 </script>