Przeglądaj źródła

修改 商品掉期 买卖大厅 价格排序

huangbin 4 lat temu
rodzic
commit
0a738da832

+ 2 - 0
src/utils/timer/timerUtil.ts

@@ -8,6 +8,8 @@ export interface IntervalTimerNames {
     accountStauts: string; // 账号状态
     spotTrade: string; // 仓单报价列表
     buyAndSellMartet: string; // 买卖大厅
+    buyMarket: string; // 买大厅
+    sellMarket: string; // 卖大厅
     realTime: string; // 实时敞口监控
     countdown: string; // 倒计时
     quoteSucribe: string; // 行情订阅

+ 23 - 20
src/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/components/buy/index.vue

@@ -9,7 +9,7 @@
            :customRow="Rowclick"
            :expandIcon="expandIcon"
            :expandIconAsCell="false"
-           rowKey="key"
+           rowKey="orderid"
            :data-source="tableList">
     <!-- ,  -->
     <!-- 额外的展开行 -->
@@ -36,28 +36,21 @@
 </template>
 
 <script lang="ts">
-import { EnumRouterName } from '@/common/constants/enumRouterName';
-import { ComposeTableParam, BtnList, defineComponent, handleComposeTable, queryTableList, ModalEnum } from '@/common/export/commonTable';
-import { _closeModal } from '@/common/setup/modal/modal';
-import { queryOrderQuoteDetail } from '@/services/go/wrtrade';
-import { QueryOrderQuoteDetailReq, WrOrderQuote, WrOrderQuoteDetail } from '@/services/go/wrtrade/interface';
-import { defineAsyncComponent, PropType } from 'vue';
-import { BtnListType } from '@/common/components/btnList/interface';
+import { getShowBottomValue } from '@/common/config/constrolBottom';
 import { BuyOrSell } from '@/common/constants/enumCommon';
+import { EnumRouterName } from '@/common/constants/enumRouterName';
+import { BtnList, ComposeTableParam, defineComponent, handleComposeTable, queryTableList } from '@/common/export/commonTable';
 import { expandIcon } from '@/common/setup/table/clolumn';
-import { ColumnType } from '@/common/methods/table/interface';
-import { Moment } from 'moment';
-import moment from 'moment';
-import { getShowBottomValue } from '@/common/config/constrolBottom';
-import { queryTjmdTradeOrderDetail } from '@/services/go/Tjmd';
-import { QueryTjmdTradeOrderDetailReq, QueryTjmdTradeOrderDetailRsp } from '@/services/go/Tjmd/interface';
 import { getUserId } from '@/services/bus/account';
 import { getUserAccountType } from '@/services/bus/user';
-import { useBuyOrSellBtnList, getBuyOrSellMarketPrice, sortPirce } from '../setup';
-import { findItemGoods } from '../../setup';
-import { RefGoodsList } from '../../interface';
-import { sortTime } from '@/utils/time';
+import { queryTjmdTradeOrderDetail } from '@/services/go/Tjmd';
+import { QueryTjmdTradeOrderDetailReq, QueryTjmdTradeOrderDetailRsp } from '@/services/go/Tjmd/interface';
+import { WrOrderQuoteDetail } from '@/services/go/wrtrade/interface';
 import TimerUtils from '@/utils/timer/timerUtil';
+import { defineAsyncComponent, onBeforeUnmount, PropType } from 'vue';
+import { RefGoodsList } from '../../interface';
+import { findItemGoods } from '../../setup';
+import { getBuyOrSellMarketPrice, sortPirce, useBuyOrSellBtnList, hasFloat } from '../setup';
 
 const columns = [
     {
@@ -131,10 +124,20 @@ export default defineComponent({
                 goodsid: findItemGoods(props.parantSelectedRow.goodscode)?.goodsid,
             };
             queryTable(queryTjmdTradeOrderDetail, param).then((res) => {
-                console.log('ddddddddddddddddddd', res);
-                tableList.value = sortPirce(res);
+                // 先置空 要不然数据变更了,视图不更新
+                const fn = () => {
+                    tableList.value = [];
+                    tableList.value = sortPirce(res, props.parantSelectedRow);
+                };
+                if (hasFloat(res)) {
+                    // 有浮动价, 则每三秒更新一次数据
+                    TimerUtils.setInterval(fn, 3 * 1000, 'buyMarket');
+                }
             });
         };
+        onBeforeUnmount(() => {
+            TimerUtils.clearInterval('buyMarket');
+        });
         // 表格通用逻辑
         const param: ComposeTableParam = {
             queryFn: queryTableAction,

+ 15 - 3
src/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/components/sell/index.vue

@@ -39,7 +39,7 @@ import { ComposeTableParam, BtnList, defineComponent, handleComposeTable, queryT
 import { _closeModal } from '@/common/setup/modal/modal';
 import { queryOrderQuoteDetail } from '@/services/go/wrtrade';
 import { QueryOrderQuoteDetailReq, WrOrderQuote, WrOrderQuoteDetail } from '@/services/go/wrtrade/interface';
-import { defineAsyncComponent, PropType } from 'vue';
+import { defineAsyncComponent, onBeforeUnmount, PropType } from 'vue';
 import { BtnListType } from '@/common/components/btnList/interface';
 import { BuyOrSell } from '@/common/constants/enumCommon';
 import { expandIcon } from '@/common/setup/table/clolumn';
@@ -47,13 +47,14 @@ import { ColumnType } from '@/common/methods/table/interface';
 import { Moment } from 'moment';
 import moment from 'moment';
 import { getShowBottomValue } from '@/common/config/constrolBottom';
-import { useBuyOrSellBtnList, getBuyOrSellMarketPrice, sortPirce } from '../setup';
+import { useBuyOrSellBtnList, getBuyOrSellMarketPrice, sortPirce, hasFloat } from '../setup';
 import { getUserId } from '@/services/bus/account';
 import { getUserAccountType } from '@/services/bus/user';
 import { queryTjmdTradeOrderDetail } from '@/services/go/Tjmd';
 import { QueryTjmdTradeOrderDetailReq, QueryTjmdTradeOrderDetailRsp } from '@/services/go/Tjmd/interface';
 import { findItemGoods } from '../../setup';
 import { RefGoodsList } from '../../interface';
+import TimerUtils from '@/utils/timer/timerUtil';
 
 const columns = [
     {
@@ -129,9 +130,20 @@ export default defineComponent({
                 goodsid: findItemGoods(props.parantSelectedRow.goodscode)?.goodsid,
             };
             queryTable(queryTjmdTradeOrderDetail, param).then((res) => {
-                tableList.value = sortPirce(res);
+                // 先置空 要不然数据变更了,视图不更新
+                const fn = () => {
+                    tableList.value = [];
+                    tableList.value = sortPirce(res, props.parantSelectedRow);
+                };
+                if (hasFloat(res)) {
+                    // 有浮动价, 则每三秒更新一次数据
+                    TimerUtils.setInterval(fn, 3 * 1000, 'sellMarket');
+                }
             });
         };
+        onBeforeUnmount(() => {
+            TimerUtils.clearInterval('sellMarket');
+        });
         // 表格通用逻辑
         const param: ComposeTableParam = {
             queryFn: queryTableAction,

+ 7 - 5
src/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/components/setup.ts

@@ -69,9 +69,11 @@ export function getBuyOrSellMarketPrice(record: QueryTjmdTradeOrderDetailRsp, se
 }
 
 // 价格排序
-export function sortPirce(arr: QueryTjmdTradeOrderDetailRsp[]) {
-    const fn = ({ pricemode, marketmaxsub, orderprice }: QueryTjmdTradeOrderDetailRsp) => {
-        return pricemode === 3 ? orderprice + marketmaxsub : orderprice
-    }
-    return arr.sort((a, b) => fn(a) - fn(b))
+export function sortPirce(arr: QueryTjmdTradeOrderDetailRsp[], selectedRow: RefGoodsList) {
+    return arr.sort((a, b) => getBuyOrSellMarketPrice(b, selectedRow) - getBuyOrSellMarketPrice(a, selectedRow))
+}
+
+// 是否有浮动价
+export function hasFloat(arr: QueryTjmdTradeOrderDetailRsp[]) {
+    return arr.find(e => e.pricemode === 3) ? true : false
 }