Просмотр исходного кода

修改资金信息的浮动盈亏

huangbin 4 лет назад
Родитель
Сommit
2fde4f2aab

+ 2 - 1
src/views/order/funding_information/components/funding_information_funding_summary/index.vue

@@ -91,7 +91,7 @@ export default defineComponent({
   setup() {
     // 表格列表数据
     const { loading, tableList, queryTable } = queryTableList<Taaccount>();
-    const { handleProfitloss, hazardRates, netWorth, canUseMoney, getHoldsList, handleHoldPrice } = useHazardRates();
+    const { handleProfitloss, getSwapList, hazardRates, netWorth, canUseMoney, getHoldsList, handleHoldPrice } = useHazardRates();
     // 获取列表数据
     const queryTableAction = () => {
       const param: GetTaAccountsReq = {
@@ -100,6 +100,7 @@ export default defineComponent({
       queryTable(getTaAccounts, param);
       // 获取头寸
       getHoldsList(loading)
+      getSwapList()
     };
 
     // 资金变化,重新加载数据

+ 24 - 4
src/views/order/funding_information/components/funding_information_funding_summary/setup.ts

@@ -1,12 +1,18 @@
 import { isOemByEnum, OemType } from '@/common/config/projectName';
+import { TradeMode } from '@/common/constants/enumCommon';
 import { queryResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
+import { queryTableList } from '@/common/setup/table';
 import { hasSystemParam } from '@/hooks/system';
 import { useHolderprice, useProfitloss } from '@/services/bus/holdPosition';
-import { getMarketTradePropertyByGoodsId } from '@/services/bus/market';
+import { getMarketIdsByTradeMode, getMarketTradePropertyByGoodsId } from '@/services/bus/market';
+import { getUserAccountType } from '@/services/bus/user';
 import { AccountListItem } from '@/services/dataCenter/interafce/account';
 import { queryTradePosition } from '@/services/go/ermcp/order';
 import { QueryTradePositionRsp } from '@/services/go/ermcp/order/interface';
 import { Taaccount } from '@/services/go/TaAccount/interface';
+import { queryQuoteGoodsList } from '@/services/go/Tjmd';
+import { QueryQuoteGoodsListReq, QueryQuoteGoodsListRsp } from '@/services/go/Tjmd/interface';
+import { findGoodsCode } from '@/views/order/swap_the_order/components/swap_commodity_contract_summary/setup';
 import { ref, Ref } from 'vue';
 
 export const tableColumns = () => {
@@ -142,7 +148,20 @@ export const useHazardRates = () => {
             holdsList.value = res;
         })
     }
-
+        // 交割商品
+    const swapList = ref<QueryQuoteGoodsListRsp[]>([]);
+    function getSwapList() {
+      const {  queryTable } = queryTableList<QueryQuoteGoodsListRsp>();
+      // 组装 参数
+      const marketids = getMarketIdsByTradeMode(TradeMode.DiaoQi)
+      const param: QueryQuoteGoodsListReq = {
+        usertype: getUserAccountType(),
+      }
+      if (marketids) {
+        param.marketids = marketids
+      }
+       queryTable(queryQuoteGoodsList, param).then(res => swapList.value = res)
+    }
     // 获取报价小数位
     function getDecimalplace() {
         return holdsList.value.length > 0 ? holdsList.value[0].decimalplace : 2
@@ -160,7 +179,8 @@ export const useHazardRates = () => {
             let temp = 0
             if (tradeproperty === 1) {
                 // 资金 只算 收益权
-                const profitloos = useProfitloss(current)
+                const goodscode = findGoodsCode(current.goodsid, current.goodscode, swapList.value)
+                const profitloos = useProfitloss(current, goodscode)
                 temp = profitloos === '--' ? 0 : Number(profitloos)
             }
             return acc + temp
@@ -247,6 +267,6 @@ export const useHazardRates = () => {
         return result.toFixed(decimalplace)
     }
 
-    return { handleProfitloss, hazardRates, netWorth, canUseMoney, getHoldsList, handleHoldPrice }
+    return { handleProfitloss,getSwapList, hazardRates, netWorth, canUseMoney, getHoldsList, handleHoldPrice }
 }