소스 검색

增加我的持仓-掉期持仓

Handy_Cao 2 년 전
부모
커밋
ec524daf6b

+ 2 - 0
src/packages/mobile/views/order/position/Index.vue

@@ -10,6 +10,7 @@
             <Tab title="转让持仓">
             </Tab>
             <Tab title="掉期持仓">
+               <Swap />
             </Tab>
             <Tab title="订单持仓">
             </Tab>
@@ -25,6 +26,7 @@ import { shallowRef } from 'vue'
 import { Tab, Tabs } from 'vant'
 import Presale from './components/presale/list/Index.vue'
 import Spot from './components/spot/list/Index.vue'
+import Swap from './components/swap/list/Index.vue'
 
 const active = shallowRef(0)
 </script>

+ 0 - 0
src/packages/mobile/views/order/position/components/swap/close/Index.vue


+ 95 - 0
src/packages/mobile/views/order/position/components/swap/list/Index.vue

@@ -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>

+ 4 - 1
src/services/api/order/index.ts

@@ -175,6 +175,9 @@ export function queryTradeOrderDetail(config: RequestConfig<Model.TradeOrderDeta
 export function queryTradePosition(config: RequestConfig<Model.TradePositionReq> = {}) {
     return http.commonRequest<Model.TradePositionRsp[]>({
         url: '/Order/QueryTradePosition',
-        params: config.data,
+        params: {
+            accountID: accountStore.accountId,
+            ...config.data
+        },
     })
 }

+ 1 - 1
src/types/model/order.d.ts

@@ -910,7 +910,7 @@ declare namespace Model {
     /*  查询我的持仓/掉期持仓 请求*/
     interface TradePositionReq {
         /// 资金账户 - 格式:1,2,3
-        accountID: string
+        accountID?: string
         /// 交易模式 - 格式:1,2,3
         tradeMode?: string
     }