Handy_Cao hai 1 ano
pai
achega
5bd9c6f245

+ 12 - 1
src/business/order/index.ts

@@ -17,6 +17,7 @@ export const useSBYJOrder = (selectedRow?: Model.SBYJMyOrderRsp) => {
     const orderComputedList = computed(() => {
         orderList.value.forEach((e) => {
             e.tHDetailEx.depositRate = calcDepositRate(e)
+            e.tHDetailEx.floatPL = floatpl(e)
         })
         return orderList.value
     })
@@ -25,9 +26,19 @@ export const useSBYJOrder = (selectedRow?: Model.SBYJMyOrderRsp) => {
     const detail = computed(() => {
         if (selectedRow) {
             selectedRow.depositRate = calcDepositRate(selectedRow)
+            selectedRow.tHDetailEx.floatPL = floatpl(selectedRow)
         }
         return selectedRow
-    })
+    }) 
+
+    const floatpl = ({ tHDetailEx }: Model.SBYJMyOrderRsp) => {
+        const quote = futuresStore.getGoodsQuote(tHDetailEx.goodsID)
+        const { ask = 0, bid = 0, agreeunit = 0 } = quote.value ?? {}
+        const price = tHDetailEx.buyOrSell === BuyOrSell.Buy ? bid : ask // 根据方向取买卖价
+        // 计算浮动盈亏 (价格 * 手数 * 合约乘数 - 持仓金额) * 方向标识
+        const float = price ? price * tHDetailEx.holderQty * agreeunit - tHDetailEx.holderAmount : 0
+        return float * (tHDetailEx.buyOrSell === BuyOrSell.Buy ? 1 : -1)
+    }
 
     // 计算定金率
     const calcDepositRate = ({ tHDetailEx }: Model.SBYJMyOrderRsp) => {

+ 9 - 1
src/packages/sbyj/views/order/detail/index.vue

@@ -15,6 +15,14 @@
                     <Cell title="可用数量"
                         :value="((detail.tHDetailEx.holderQty - detail.tHDetailEx.freezeQty) * detail.agreeUnit) + getGoodsUnitName(detail.goodsUnitID)" />
                     <Cell title="订单价格" :value="detail.tHDetailEx.holderPrice" />
+                    <Cell title="订单金额" :value="detail.tHDetailEx.tradeAmount" />
+                    <Cell title="浮动权益">
+                        <template #value>
+                            <span :class="handlePriceColor(detail.tHDetailEx.floatPL)">
+                                {{ detail.tHDetailEx.floatPL }}
+                            </span>
+                        </template>
+                    </Cell>
                     <Cell title="已付定金" :value="detail.tHDetailEx.payedDeposit" />
                     <Cell title="已补定金" :value="detail.tHDetailEx.restockDeposit" />
                     <Cell title="订单天数" :value="detail.tHDetailEx.holdDays" />
@@ -40,7 +48,7 @@
 <script lang="ts" setup>
 import { shallowRef, PropType } from 'vue'
 import { CellGroup, Cell } from 'vant'
-import { parsePercent } from '@/filters'
+import { parsePercent, handlePriceColor } from '@/filters'
 import { BuyOrSell } from '@/constants/order'
 import AppModal from '@/components/base/modal/index.vue'
 import { useSBYJOrder } from '@/business/order'

+ 8 - 3
src/packages/sbyj/views/order/history/index.vue

@@ -30,19 +30,24 @@
                                     {{ enableqty(item) + getGoodsUnitName(item.goodunitid) }}
                                 </span>
                             </li>
-                            <li>
+                            <!-- <li>
                                 <span>订单金额</span>
                                 <span>{{ item.tradeamount }}</span>
-                            </li>
+                            </li> -->
                             <li>
                                 <span>订单价格</span>
                                 <span>{{ formatDecimal(item.openprice) }}</span>
                             </li>
+                            
                             <li>
                                 <span>已付定金</span>
                                 <span>{{ item.payeddeposit }}</span>
                             </li>
                             <li>
+                                <span>浮动权益</span>
+                                <span :class="handlePriceColor(item.floatpl)">{{ item.floatpl }}</span>
+                            </li>
+                            <li>
                                 <span>已补定金</span>
                                 <span>{{ handleNumberValue(item.restockdeposit) }}</span>
                             </li>
@@ -64,7 +69,7 @@
 
 <script lang="ts" setup>
 import { shallowRef } from 'vue'
-import { formatDecimal, handleNumberValue } from '@/filters'
+import { formatDecimal, handleNumberValue, handlePriceColor } from '@/filters'
 import { BuyOrSell } from '@/constants/order'
 import { getGoodsUnitName } from '@/constants/unit'
 import { useRequest } from '@/hooks/request'

+ 1 - 5
src/packages/sbyj/views/order/list/index.vue

@@ -51,7 +51,7 @@
                             </li>
                             <li>
                                 <span>浮动权益</span>
-                                <span :class="handlePriceColor(item.tHDetailEx.floatPL)">{{ handleNumberValue(item.tHDetailEx.floatPL) }}</span>
+                                <span :class="handlePriceColor(item.tHDetailEx.floatPL)">{{ item.tHDetailEx.floatPL }}</span>
                             </li>
                             <li>
                                 <span>已补定金</span>
@@ -65,10 +65,6 @@
                                 <span>滞纳金</span>
                                 <span>{{ handleNumberValue(item.tHDetailEx.callAteFee) }}</span>
                             </li>
-                            <!-- <li>
-                                <span>订单金额</span>
-                                <span>{{ item.tHDetailEx.holderAmount }}</span>
-                            </li> -->
                         </ul>
                     </div>
                     <div class="g-order-list__btnbar">