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

修改 单据记录 商品合约 合约汇总

huangbin 4 лет назад
Родитель
Сommit
1e9648468b

+ 1 - 117
src/views/order/commodity_contract/components/commodity_contract_summary/index.vue

@@ -31,10 +31,6 @@
       <template #averageprice="{ text }">
         <a>{{ text ? text : 0 }}</a>
       </template>
-      <!-- 持仓金额  -->
-      <!-- <template #holderprice="{ record }">
-        <a>{{ useHolderprice(record) }}</a>
-      </template> -->
       <!-- 持仓盈亏 -->
       <template #profitloss="{ record }">
         <span>{{ record.averageprice ? useProfitloss(record, findGoodsCode(record.goodsid, record.goodscode, swapList)) : '--' }}</span>
@@ -78,119 +74,7 @@ import { getSwapList } from '@/views/market/spot_trade/spot_trade_order_transact
 import { ref } from 'vue';
 import { QueryQuoteGoodsListRsp } from '@/services/go/Tjmd/interface';
 import Bus from '@/utils/eventBus/index';
-
-const tabColumns = [
-    {
-        key: '10th',
-        dataIndex: 'goodsname',
-        title: '订单合约',
-        align: 'center',
-        slots: {
-            customRender: 'goodsname',
-        },
-        width: 120,
-    },
-    {
-        key: '7th',
-        dataIndex: 'buyorsell',
-        title: '方向',
-        align: 'center',
-        slots: {
-            customRender: 'buyorsell',
-        },
-        width: 120,
-    },
-    {
-        key: '8th',
-        dataIndex: 'curpositionqty',
-        title: '持有数量',
-        align: 'center',
-        slots: {
-            customRender: 'curpositionqty',
-        },
-        width: 120,
-    },
-    {
-        key: '9th',
-        dataIndex: 'enableqty',
-        title: '可用数量',
-        align: 'center',
-        slots: {
-            customRender: 'enableqty',
-        },
-        width: 120,
-    },
-    {
-        key: '0th',
-        dataIndex: 'frozenqty',
-        title: '冻结数量',
-        align: 'center',
-        slots: {
-            customRender: 'frozenqty',
-        },
-        width: 120,
-    },
-    {
-        key: '1th',
-        dataIndex: 'averageprice',
-        title: '均价',
-        align: 'center',
-        slots: {
-            customRender: 'averageprice',
-        },
-        width: 120,
-    },
-    {
-        key: '2th',
-        dataIndex: 'lastprice',
-        title: '现价',
-        align: 'center',
-        slots: {
-            customRender: 'lastprice',
-        },
-        width: 120,
-    },
-    {
-        key: '3th',
-        dataIndex: 'curholderamount',
-        title: '持仓金额',
-        align: 'center',
-        slots: {
-            customRender: 'curholderamount',
-        },
-        width: 120,
-    },
-    {
-        key: '4th',
-        dataIndex: 'usedmargin',
-        title: '占用保证金',
-        align: 'center',
-        slots: {
-            customRender: 'usedmargin',
-        },
-        width: 130,
-    },
-    {
-        key: '5th',
-        dataIndex: 'marketamount',
-        title: '市值',
-        align: 'center',
-        slots: {
-            customRender: 'marketamount',
-        },
-        width: 120,
-    },
-    {
-        key: '6th',
-        dataIndex: 'profitloss',
-        title: '浮动盈亏',
-        align: 'center',
-        slots: {
-            customRender: 'profitloss',
-        },
-        width: 120,
-    },
-];
+import { tabColumns } from './setup';
 
 export default defineComponent({
     name: enumOrderComponents.commodity_contract_summary,

+ 114 - 1
src/views/order/commodity_contract/components/commodity_contract_summary/setup.ts

@@ -13,4 +13,117 @@ export const useIsDiaoQi = (goodsid: number) => {
 export function findGoodsCode(goodsid: number, goodscode: string, swapList: QueryQuoteGoodsListRsp[]) {
     const result = useIsDiaoQi(goodsid) ? swapList.find((el) => goodsid === goodsid)?.refgoodscode : goodscode;
     return result ? result : ''
-}
+}
+
+export const tabColumns = [
+    {
+        key: '10th',
+        dataIndex: 'goodsname',
+        title: '订单合约',
+        align: 'center',
+        slots: {
+            customRender: 'goodsname',
+        },
+        width: 120,
+    },
+    {
+        key: '7th',
+        dataIndex: 'buyorsell',
+        title: '方向',
+        align: 'center',
+        slots: {
+            customRender: 'buyorsell',
+        },
+        width: 120,
+    },
+    {
+        key: '8th',
+        dataIndex: 'curpositionqty',
+        title: '持有数量',
+        align: 'center',
+        slots: {
+            customRender: 'curpositionqty',
+        },
+        width: 120,
+    },
+    {
+        key: '9th',
+        dataIndex: 'enableqty',
+        title: '可用数量',
+        align: 'center',
+        slots: {
+            customRender: 'enableqty',
+        },
+        width: 120,
+    },
+    {
+        key: '0th',
+        dataIndex: 'frozenqty',
+        title: '冻结数量',
+        align: 'center',
+        slots: {
+            customRender: 'frozenqty',
+        },
+        width: 120,
+    },
+    {
+        key: '1th',
+        dataIndex: 'averageprice',
+        title: '均价',
+        align: 'center',
+        slots: {
+            customRender: 'averageprice',
+        },
+        width: 120,
+    },
+    {
+        key: '2th',
+        dataIndex: 'lastprice',
+        title: '现价',
+        align: 'center',
+        slots: {
+            customRender: 'lastprice',
+        },
+        width: 120,
+    },
+    {
+        key: '3th',
+        dataIndex: 'curholderamount',
+        title: '持仓金额',
+        align: 'center',
+        slots: {
+            customRender: 'curholderamount',
+        },
+        width: 120,
+    },
+    {
+        key: '4th',
+        dataIndex: 'usedmargin',
+        title: '占用保证金',
+        align: 'center',
+        slots: {
+            customRender: 'usedmargin',
+        },
+        width: 130,
+    },
+    {
+        key: '5th',
+        dataIndex: 'marketamount',
+        title: '市值',
+        align: 'center',
+        slots: {
+            customRender: 'marketamount',
+        },
+        width: 120,
+    },
+    {
+        key: '6th',
+        dataIndex: 'profitloss',
+        title: '浮动盈亏',
+        align: 'center',
+        slots: {
+            customRender: 'profitloss',
+        },
+        width: 120,
+    },
+];

+ 85 - 24
src/views/search/search_document_records/search_commodity_contract/search_document_records_contract_summary/index.vue

@@ -1,40 +1,93 @@
 <template>
-    <!-- 单据记录 商品合约-->
-    <div class="topTableHeight">
-        <a-table
-            :columns="columns"
-            class="srcollYTable"
-            :scroll="{ x: '100%', y: 'calc(100vh - 405px)' }"
-            :pagination="false"
-            :loading="loading"
-            :expandedRowKeys="expandedRowKeys"
-            :customRow="Rowclick"
-            rowKey="key"
-            :data-source="tableList"
-        ></a-table>
-    </div>
+  <!-- 单据记录 商品合约-->
+  <div class="topTableHeight">
+    <a-table :columns="tabColumns"
+             class="srcollYTable"
+             :scroll="{ x: '100%', y: 'calc(100vh - 405px)' }"
+             :pagination="false"
+             :loading="loading"
+             :expandedRowKeys="expandedRowKeys"
+             :customRow="Rowclick"
+             rowKey="key"
+             :data-source="tableList">
+      <template #createtime="{ record }">
+        <a>{{ formatTime(record.createtime) }}</a>
+      </template>
+      <!-- 现价 -->
+      <template #lastprice="{ record }">
+        <a>{{ getLastprice(record) }}</a>
+      </template>
+      <!-- 均价 -->
+      <template #averageprice="{ text }">
+        <a>{{ text ? text : 0 }}</a>
+      </template>
+      <!-- 持仓盈亏 -->
+      <template #profitloss="{ record }">
+        <span>{{ record.averageprice ? useProfitloss(record, findGoodsCode(record.goodsid, record.goodscode, swapList)) : '--' }}</span>
+      </template>
+      <template #buyorsell="{ record }">
+        <span>{{ getBuyOrSellName(record.buyorsell) }}</span>
+      </template>
+      <template #marketamount="{ record, text }">
+        <span>{{ isDiaoQi(record) ? '--' : text }}</span>
+      </template>
+    </a-table>
+  </div>
 </template>
 
 <script lang="ts">
+import { TradeMode } from '@/common/constants/enumCommon';
 import { EnumRouterName } from '@/common/constants/enumRouterName';
-import { queryTableList, defineComponent, ComposeTableParam } from '@/common/export/commonTable';
-import { QueryOrderQuoteReq, WrOrderQuote } from '@/services/go/wrtrade/interface';
-import { queryOrderQuote } from '@/services/go/wrtrade';
+import { getBuyOrSellName } from '@/common/constants/enumsName';
+import { ComposeTableParam, defineComponent, queryTableList } from '@/common/export/commonTable';
+import { formatTime } from '@/common/methods';
+import { handleSubcriteQuote } from '@/common/setup/table/tableQuote';
+import { findGoodsTradeModeById, getQuoteDayInfoByCodeFindPrice } from '@/services/bus/goods';
+import { useProfitloss } from '@/services/bus/holdPosition';
+import { queryTradePosition } from '@/services/go/ermcp/order';
+import { QueryTradePositionRsp } from '@/services/go/ermcp/order/interface';
+import { QueryQuoteGoodsListRsp } from '@/services/go/Tjmd/interface';
 import { handleComposeTable } from '@/views/market/spot_trade/setup';
+import { getSwapList } from '@/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/setup';
+import { findGoodsCode, tabColumns } from '@/views/order/commodity_contract/components/commodity_contract_summary/setup';
+import { ref } from 'vue';
 
 export default defineComponent({
     name: EnumRouterName.search_document_records_contract_summary,
     setup() {
         // 表格列表数据
-        const { loading, tableList, queryTable } = queryTableList<WrOrderQuote>();
+        const { loading, tableList, queryTable } = queryTableList<QueryTradePositionRsp>();
+        const { subscribeAction } = handleSubcriteQuote();
+        const swapList = ref<QueryQuoteGoodsListRsp[]>([]);
         // 获取列表数据
         const queryTableAction = () => {
-            const param: QueryOrderQuoteReq = {
-                wrpricetype: 1,
-                haswr: 0,
-            };
-            queryTable(queryOrderQuote, param);
+            Promise.all([queryTable(queryTradePosition), getSwapList()]).then((res) => {
+                swapList.value = res[1];
+                tableList.value = res[0];
+                const goodsSet = new Set<string>();
+                res[0].forEach((el) => {
+                    // 商品掉期取参考行情最新价,挂牌点选取自己行情的最新价
+                    const goodscode = findGoodsCode(el.goodsid, el.goodscode, swapList.value);
+                    if (goodscode) {
+                        goodsSet.add(goodscode);
+                    }
+                });
+                //  行情订阅
+                subscribeAction([...goodsSet]);
+            });
         };
+        // 现价
+        function getLastprice(record: QueryTradePositionRsp) {
+            let result: number | string = '--';
+            const goodscode = findGoodsCode(record.goodsid, record.goodscode, swapList.value);
+            if (goodscode) {
+                result = getQuoteDayInfoByCodeFindPrice(goodscode);
+            }
+            return result;
+        }
+        function isDiaoQi(record: QueryTradePositionRsp) {
+            return findGoodsTradeModeById(record.goodsid) === TradeMode.DiaoQi;
+        }
         // 表格通用逻辑
         const param: ComposeTableParam = {
             queryFn: queryTableAction,
@@ -45,9 +98,17 @@ export default defineComponent({
         };
 
         return {
-            ...handleComposeTable<WrOrderQuote>(param),
+            ...handleComposeTable<QueryTradePositionRsp>(param),
             loading,
             tableList,
+            tabColumns,
+            formatTime,
+            getLastprice,
+            useProfitloss,
+            findGoodsCode,
+            swapList,
+            getBuyOrSellName,
+            isDiaoQi,
         };
     },
 });