|
|
@@ -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: '商品代码/名称' },
|