|
|
@@ -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,
|
|
|
};
|
|
|
},
|
|
|
});
|