|
|
@@ -0,0 +1,95 @@
|
|
|
+<!-- 我的持仓-掉期持仓 -->
|
|
|
+<template>
|
|
|
+ <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">
|
|
|
+ <div class="g-order-list__box" v-for="(item, index) in dataList" :key="index">
|
|
|
+ <div class="g-order-list__titlebar">
|
|
|
+ <div class="left">
|
|
|
+ <h4>({{ item.goodscode }}/{{ item.goodsname }}/'--')</h4>
|
|
|
+ </div>
|
|
|
+ <div class="right">
|
|
|
+ <span>{{ getBuyOrSellName(item.buyorsell) }}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="g-order-list__content">
|
|
|
+ <ul>
|
|
|
+ <li>
|
|
|
+ <span>持有数量:</span>
|
|
|
+ <span>{{ item.curpositionqty }}</span>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <span>持仓均价:</span>
|
|
|
+ <span>{{ item.averageprice === 0.0 ? '--' : item.averageprice}}</span>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <span>冻结数量:</span>
|
|
|
+ <span>{{ item.frozenqty }}</span>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <span>持仓金额:</span>
|
|
|
+ <span>{{ item.curholderamount }}</span>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <span>可用数量:</span>
|
|
|
+ <span>{{ item.enableqty }}</span>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <span>参考损益:</span>
|
|
|
+ <span>--</span>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ <div class="g-order-list__btnbar">
|
|
|
+ <Button size="small" @click="showComponent('close', item)" round>平仓</Button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <component ref="componentRef" v-bind="{ selectedRow }" :is="componentMap.get(componentId)" @closed="closeComponent"
|
|
|
+ v-if="componentId" />
|
|
|
+ </app-pull-refresh>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { shallowRef, defineAsyncComponent } from 'vue'
|
|
|
+import { Button } from 'vant'
|
|
|
+import { useComponent } from '@/hooks/component'
|
|
|
+import { useRequest } from '@/hooks/request'
|
|
|
+import { queryTradePosition } from '@/services/api/order'
|
|
|
+import AppPullRefresh from '@mobile/components/base/pull-refresh/index.vue'
|
|
|
+import { getBuyOrSellName } from '@/constants/order'
|
|
|
+
|
|
|
+const componentMap = new Map<string, unknown>([
|
|
|
+ ['close', defineAsyncComponent(() => import('../close/Index.vue'))],
|
|
|
+])
|
|
|
+
|
|
|
+const dataList = shallowRef<Model.TradePositionRsp[]>([])
|
|
|
+const selectedRow = shallowRef<Model.TradePositionRsp>()
|
|
|
+const error = shallowRef(false)
|
|
|
+const pullRefreshRef = shallowRef()
|
|
|
+
|
|
|
+const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => {
|
|
|
+ pullRefreshRef.value?.refresh()
|
|
|
+})
|
|
|
+
|
|
|
+const { loading, pageIndex, pageCount, run } = useRequest(queryTradePosition, {
|
|
|
+ params: {
|
|
|
+ pagesize: 20,
|
|
|
+ tradeMode: '46'
|
|
|
+ },
|
|
|
+ onSuccess: (res) => {
|
|
|
+ if (pageIndex.value === 1) {
|
|
|
+ dataList.value = []
|
|
|
+ }
|
|
|
+ dataList.value.push(...res.data)
|
|
|
+ },
|
|
|
+ onError: () => {
|
|
|
+ error.value = true
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const showComponent = (componentName: string, row: Model.TradePositionRsp) => {
|
|
|
+ selectedRow.value = row
|
|
|
+ openComponent(componentName)
|
|
|
+}
|
|
|
+</script>
|