ソースを参照

修改商品掉期 浮动盈亏

huangbin 4 年 前
コミット
d3ef5c7f48

+ 5 - 3
src/views/order/swap_the_order/components/swap_commodity_contract_summary/index.vue

@@ -38,8 +38,8 @@
           <!-- 持仓盈亏 -->
           <template #profitloss="{ record }">
             <span
-              :class="handleQuotePriceColor(+getDetailProfitloss(record), 0)"
-            >{{ getDetailProfitloss(record) }}</span>
+              :class="[+getDetailProfitloss(record, findGoodsCode(record.goodsid, record.goodscode, swapList)) > 0 ? 'up-quote-color' : +getDetailProfitloss(record, findGoodsCode(record.goodsid, record.goodscode, swapList)) < 0 ? 'down-quote-color' : '']"
+            >{{ getDetailProfitloss(record, findGoodsCode(record.goodsid, record.goodscode, swapList)) }}</span>
           </template>
           <!-- 市值 -->
           <template #marketamount="{ record }">
@@ -63,7 +63,9 @@
       </template>
       <!-- 持仓盈亏 -->
       <template #profitloss="{ record }">
-        <span>{{ record.averageprice ? useProfitloss(record, findGoodsCode(record.goodsid, record.goodscode, swapList)) : '--' }}</span>
+        <span
+          :class="[+useProfitloss(record, findGoodsCode(record.goodsid, record.goodscode, swapList)) > 0 ? 'up-quote-color' : +useProfitloss(record, findGoodsCode(record.goodsid, record.goodscode, swapList)) < 0 ? 'down-quote-color' : '']"
+        >{{ record.averageprice ? useProfitloss(record, findGoodsCode(record.goodsid, record.goodscode, swapList)) : '--' }}</span>
       </template>
       <template #buyorsell="{ record }">
         <span>{{ getBuyOrSellName(record.buyorsell) }}</span>

+ 2 - 2
src/views/order/swap_the_order/components/swap_commodity_contract_summary/setup.ts

@@ -111,9 +111,9 @@ export const useDetail = () => {
     // 浮动盈亏	持仓单:
     // 收益权=(最新价-持仓价)*持仓数量*合约单位*方向(买[1]:卖[-1])(*汇率)
     // 所有权=(最新价*持仓数量*合约单位(*汇率) - 持仓金额)
-    function getDetailProfitloss(record: QueryTradeHolderDetailRsp) {
+    function getDetailProfitloss(record: QueryTradeHolderDetailRsp, goodscode: string) {
         // 最新价
-        const lastPrice = getQuoteDayInfoByCodeFindPrice(record.goodscode);
+        const lastPrice = getQuoteDayInfoByCodeFindPrice(goodscode);
         if (lastPrice !== '--') {
             const { holderprice, decimalplace, agreeunit, holderqty, buyorsell } = record;
             const temp = buyorsell === BuyOrSell.buy ? 1 : -1