|
|
@@ -5,6 +5,10 @@
|
|
|
<template #header>
|
|
|
<app-navbar title="掉期持仓-平仓" @back="closed" />
|
|
|
</template>
|
|
|
+ <div>
|
|
|
+ <span>商品:{{ selectedRow.goodsname }}/{{ selectedRow.goodscode }}</span>
|
|
|
+ <span>{{ lastPrice }}</span>
|
|
|
+ </div>
|
|
|
<app-pull-refresh ref="pullRefreshRef" v-model:loading="loading" v-model:error="error" v-model:pageIndex="pageIndex"
|
|
|
:page-count="pageCount" @refresh="run">
|
|
|
<div class="g-order-list">
|
|
|
@@ -56,7 +60,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, PropType } from 'vue'
|
|
|
+import { shallowRef, PropType, computed } from 'vue'
|
|
|
import { useRequest } from '@/hooks/request'
|
|
|
import { queryTradeHolderDetail } from '@/services/api/order';
|
|
|
import { ETradeMode } from '@/constants/client';
|
|
|
@@ -65,14 +69,20 @@ import { getBuyOrSellName } from '@/constants/order'
|
|
|
import { formatDate, formatDecimal } from '@/filters'
|
|
|
import { useHolderClose } from '@/business/trade'
|
|
|
import { dialog, fullloading } from '@/utils/vant'
|
|
|
+import { v4 } from 'uuid'
|
|
|
+import { useFuturesStore } from '@/stores'
|
|
|
|
|
|
+import quoteSocket from '@/services/websocket/quote'
|
|
|
import AppModal from '@/components/base/modal/index.vue'
|
|
|
import AppPullRefresh from '@mobile/components/base/pull-refresh/index.vue'
|
|
|
|
|
|
+const futuresStore = useFuturesStore()
|
|
|
const dataList = shallowRef<Model.TradeHolderDetailRsp[]>([])
|
|
|
const showModal = shallowRef(true)
|
|
|
-const refresh = shallowRef(false) // 是否刷新父组件数据
|
|
|
+/// 是否刷新父组件数据
|
|
|
+const refresh = shallowRef(false)
|
|
|
const error = shallowRef(false)
|
|
|
+const subscribeId = v4()
|
|
|
|
|
|
const { holderCloseSubmit, formData } = useHolderClose()
|
|
|
|
|
|
@@ -83,6 +93,12 @@ const props = defineProps({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+const subscribe = () => {
|
|
|
+ const { refgoodscode } = props.selectedRow
|
|
|
+ const subscribe = quoteSocket.addSubscribe([refgoodscode], subscribeId)
|
|
|
+ subscribe.start()
|
|
|
+}
|
|
|
+
|
|
|
const { loading, pageIndex, pageCount, run } = useRequest(queryTradeHolderDetail, {
|
|
|
params: {
|
|
|
pagesize: 20,
|
|
|
@@ -100,20 +116,26 @@ const { loading, pageIndex, pageCount, run } = useRequest(queryTradeHolderDetail
|
|
|
dataList.value = []
|
|
|
}
|
|
|
dataList.value.push(...res.data)
|
|
|
+ /// 订阅行情
|
|
|
+ subscribe()
|
|
|
},
|
|
|
onError: () => {
|
|
|
error.value = true
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+const lastPrice = computed(() => {
|
|
|
+ const quote = futuresStore.getQuoteInfo(props.selectedRow.refgoodscode)
|
|
|
+ const { last } = quote.value ?? {}
|
|
|
+ return last
|
|
|
+})
|
|
|
+
|
|
|
const onCloseSubmit = (row: Model.TradeHolderDetailRsp) => {
|
|
|
dialog({
|
|
|
message: '确认要平仓吗?',
|
|
|
showCancelButton: true,
|
|
|
}).then(() => {
|
|
|
- // TradeID: tradeid,
|
|
|
const { marketid, goodsid, buyorsell, tradeid } = row
|
|
|
- /// 市场ID
|
|
|
formData.Header = { MarketID: marketid }
|
|
|
formData.GoodsID = goodsid
|
|
|
formData.BuyOrSell = buyorsell
|