Handy_Cao 2 rokov pred
rodič
commit
db3232f5a3

+ 1 - 1
src/packages/mobile/views/order/position/components/goods/detail/components/transfer/Index.vue

@@ -55,7 +55,7 @@ import { formatDecimal, handleNumberValue, handleRequestBigNumber, handlePriceCo
 import { useOrder } from '@/business/trade'
 import { dialog, fullloading } from '@/utils/vant'
 import { useFuturesStore, usePositionStore } from '@/stores'
-import { EBuildType, EDelistingType, EListingSelectType, EOrderOperateType, EPriceMode, EValidType } from '@/constants/client'
+import { EBuildType, EDelistingType, EListingSelectType, EPriceMode, EValidType } from '@/constants/client'
 
 const props = defineProps({
     selectedRow: {

+ 20 - 2
src/packages/pc/views/footer/swap/position/close/index.vue

@@ -1,6 +1,6 @@
 <!-- 掉期市场-持仓汇总-平仓 -->
 <template>
-    <app-drawer title="平仓" v-model:show="show" :width="960" :loading="loading" :refresh="refresh">
+    <app-drawer title="平仓" v-model:show="show" :width="1200" :loading="loading" :refresh="refresh">
         <app-table :data="dataList" v-model:columns="tableColumns" :loading="loading" :row-key="rowKey"
         :expand-row-keys="expandKeys" @row-click="rowClick">
             <!-- 商品代码/名称 -->
@@ -25,6 +25,10 @@
             <template #expiredate="{ value }">
                 <span>{{ formatDate(value, 'YYYY/MM/DD') }}</span>
             </template>
+            <!-- 平仓盈亏 -->
+            <template #closepl="{ row }">
+                <span :class="handlePriceColor(closepl(row))">{{ formatDecimal(closepl(row)) }}</span>
+            </template>
             <!-- 展开行 -->
             <template #expand="{ row }">
                 <div class="buttonbar">
@@ -45,12 +49,14 @@ import { useComposeTable } from '@pc/components/base/table'
 import { useRequest } from '@/hooks/request'
 import { useHolderClose } from '@/business/trade'
 import { queryTradeHolderDetail } from '@/services/api/order'
-import { formatDate, formatDecimal, handleRequestBigNumber } from '@/filters'
+import { formatDate, formatDecimal, handlePriceColor, handleRequestBigNumber } from '@/filters'
 import { getBuyOrSellName } from '@/constants/order'
 import { ETradeMode } from '@/constants/client'
 import AppDrawer from '@pc/components/base/drawer/index.vue'
 import AppTable from '@pc/components/base/table/index.vue'
 import quoteSocket from '@/services/websocket/quote'
+import { useFuturesStore } from '@/stores'
+import { BuyOrSell } from '@/constants/order'
 
 const { rowKey, expandKeys, rowClick } = useComposeTable<Model.TradeHolderDetailRsp>({ rowKey: 'tradeid' })
 
@@ -67,6 +73,8 @@ const dataList = shallowRef<Model.TradeHolderDetailRsp[]>([])
 const error = shallowRef(false)
 const subscribe = quoteSocket.createSubscribe()
 const { holderCloseSubmit, formData } = useHolderClose()
+const futuresStore = useFuturesStore()
+const quote = futuresStore.getGoodsQuote(props.position.goodscode)
 
 const { loading, pageIndex } = useRequest(queryTradeHolderDetail, {
     params: {
@@ -93,6 +101,16 @@ const { loading, pageIndex } = useRequest(queryTradeHolderDetail, {
     }
 })
 
+// 损益
+const closepl = (row: Model.TradeHolderDetailRsp) => {
+    const { presettle = 0, last = 0 } = quote.value ?? {}
+    const { holderqty, holderamount, agreeunit, buyorsell } = row
+    const price = last || presettle // 没有最新价取昨结价
+    // 计算市值 = 现价 * 数量 * 合约单位
+    const marketValue = price ? price * holderqty * agreeunit : 0
+    return price ? (marketValue - holderamount) * (buyorsell === BuyOrSell.Buy ? 1 : -1) : 0
+}
+
 const tableColumns = shallowRef<Model.TableColumn[]>([
     { prop: 'tradeid', label: '单号' },
     { prop: 'goodsname', label: '商品代码/名称' },

+ 2 - 3
src/packages/pc/views/market/trade/swap/detail/order/index.vue

@@ -14,8 +14,8 @@
         <app-table class="buy" :data="buyList" v-model:columns="buyColumns" :row-key="rowKey" :expand-row-keys="expandKeys"
             @row-click="rowClick" showIndex>
             <!-- 展开行 -->
-            <template #expand="{ row, index }">
-                <div class="buttonbar" v-if="index === 0">
+            <template #expand="{ row }">
+                <div class="buttonbar">
                     <el-button type="primary" size="small" :disabled="row.userid === loginStore.userId"
                         @click="showComponent('delisting', row)">摘牌</el-button>
                 </div>
@@ -36,7 +36,6 @@ import { queryTjmdTradeOrderDetail } from '@/services/api/swap'
 import { useLoginStore, useFuturesStore } from '@/stores'
 import AppTable from '@pc/components/base/table/index.vue'
 import eventBus from '@/services/bus'
-import { onMounted } from 'vue'
 
 const props = defineProps({
     goodsId: {