Przeglądaj źródła

feat: 新增商品掉期 查询礼列表

huangbin 4 lat temu
rodzic
commit
500098f765

+ 13 - 0
src/services/bus/market.ts

@@ -7,6 +7,19 @@ export function getMarketByTradeMode(trademode: TradeMode): Market | undefined {
     return APP.get('markets').find((el: Market) => el.trademode === trademode)
 }
 
+// 通过 trademode 获取市场信息列表
+export function getMarketsByTradeMode(trademode: TradeMode): Market[] {
+    return APP.get('markets').filter((el: Market) => el.trademode === trademode)
+}
+
+//  通过 trademode 获取市场ids
+export function getMarketIdsByTradeMode(trademode: TradeMode): string {
+    const arr = getMarketsByTradeMode(trademode)
+    return arr.reduce((str: string, current: Market) => {
+        return str ? (str + ',' + current.marketid) : current.marketid.toString()
+    }, '')
+}
+
 // 获取市场运行信息
 export function getMarketRunByTradeMode(trademode: TradeMode): Marketrun | null {
     const marketInfo = getMarketByTradeMode(trademode)

+ 1 - 1
src/services/bus/user.ts

@@ -5,7 +5,7 @@ import { Arearole, Ermcp3RootUserAccount } from '../go/useInfo/interface';
  * 获取用户账户类型
  * @returns
  */
-export function getUserAccountType() {
+export function getUserAccountType(): number {
     return APP.get('userAccount').usertype
 }
 

+ 1 - 0
src/utils/eventBus/index.ts

@@ -5,6 +5,7 @@ interface EnentNames {
     blocsTrade: string; // 贸易圈 挂牌成功
     moneyChangedNtf_UI: string; // /接收到资金变化通知 UI 成 使用
     financing_manager: string; // 融资摘牌
+    changeTheme: string; // 切换主题
 }
 
 /** 一个事件只能存储一个回调 */

+ 1 - 1
src/views/market/spot_trade/spot_trade_order_transaction/setup.ts

@@ -24,7 +24,7 @@ export function handleDeliveryRelation(param: deliverytype[]) {
             allDeliverGoods.value = res
             deliverGoods.value = getDeliverGoods()
             res.forEach(el => {
-                // 找到行情数据
+                // 找到盘面数据
                 const quote = getQuoteDayInfoByCode(el.goodscode);
                 if (quote) {
                     Object.assign(quote, { goodsname: el.goodsname, deliverytype: el.deliverytype })

+ 11 - 10
src/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/index.vue

@@ -2,7 +2,7 @@
   <!--订单交易 挂牌转让-->
   <div class="topTableHeight">
     <a-table :columns="columns"
-             :class="['srcollYTable', isBottom ? 'secondTabTable' : 'secondTabTableNoBottom', getQuoteList().length ? 'noPlaceHolder' : 'hasPlaceHolder']"
+             :class="['srcollYTable', isBottom ? 'secondTabTable' : 'secondTabTableNoBottom', goodsList.length ? 'noPlaceHolder' : 'hasPlaceHolder']"
              :scroll="{ x: '100%', y: isBottom ? 'calc(100vh- 407px)' : 'calc(100vh - 167px)' }"
              :pagination="false"
              :loading="loading"
@@ -10,7 +10,7 @@
              :customRow="Rowclick"
              rowKey="goodscode"
              ref="tableRef"
-             :data-source="getQuoteList()">
+             :data-source="goodsList">
       <template #totalturnover="{ text }">
         <span>{{changeUnit(text)}}</span>
       </template>
@@ -57,7 +57,6 @@
     <component :is="componentId"
                v-if="componentId"
                :selectedRow="selectedRow"
-               :deliverGoods="findDeilverGoodsByGoodsCode(selectedRow.goodscode)"
                @cancel="closeComponent"></component>
   </div>
 </template>
@@ -70,7 +69,6 @@ import { handleDeliveryRelation } from '../setup';
 
 import { handleSubcriteOnDemandQuote, handleQuotePriceColor, quoteChange, quoteAmplitude, quoteAmplituOfVibration } from '@/common/setup/table/tableQuote';
 import { QueryDeliveryRelationRsp } from '@/services/go/delivery/interface';
-import { columnsList } from '../setup';
 
 import { handleTableEventAndData } from '@/common/setup/table/compose';
 import { TableParam } from '@/common/setup/table/interface';
@@ -78,6 +76,10 @@ import { BtnListType } from '@/common/components/btnList/interface';
 import { QueryQuoteDayRsp } from '@/services/go/quote/interface';
 import { getShowBottomValue } from '@/common/config/constrolBottom';
 import { ref } from 'vue';
+import { useQueryData } from '@/common/setup/request';
+import { QueryQuoteGoodsListReq } from '@/services/go/Tjmd/interface';
+import { queryQuoteGoodsList } from '@/services/go/Tjmd';
+import { useSwapList, columnsList } from './setup';
 
 export default defineComponent({
     name: 'spot_trade_order_transaction_swap',
@@ -89,7 +91,9 @@ export default defineComponent({
     },
     setup() {
         const isBottom = getShowBottomValue();
-        const loading = ref<boolean>(false);
+        const { loading, goodsList } = useSwapList();
+
+        // const loading = ref<boolean>(false);
         const param: TableParam = {
             columnsList,
             queryFn: () => {},
@@ -100,21 +104,18 @@ export default defineComponent({
             { lable: '详情', code: 'Detail', className: 'btnDeafault' },
             { lable: '买卖大厅', code: 'BuyAndSell', className: 'btnDeafault' },
         ];
-        const { deliverGoods, getQuoteList, goodsList, findDeilverGoodsByGoodsCode } = handleDeliveryRelation([1, 3]);
+        // const { deliverGoods, getQuoteList, goodsList, findDeilverGoodsByGoodsCode } = handleDeliveryRelation([1, 3]);
         // 行情按需订阅
-        handleSubcriteOnDemandQuote<QueryDeliveryRelationRsp>(deliverGoods);
+        handleSubcriteOnDemandQuote<QueryQuoteDayRsp>(goodsList);
 
         return {
             isBottom,
             ...handleTableEventAndData<QueryQuoteDayRsp>(param),
-            deliverGoods,
             btnList,
             handleQuotePriceColor,
             quoteChange,
             quoteAmplitude,
             quoteAmplituOfVibration,
-            getQuoteList,
-            findDeilverGoodsByGoodsCode,
             goodsList,
             loading,
         };

+ 71 - 0
src/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/setup.ts

@@ -0,0 +1,71 @@
+import { TradeMode } from "@/common/constants/enumCommon"
+import { initData } from "@/common/methods"
+import { queryTableList } from "@/common/setup/table"
+import { getQuoteDayInfoByCode } from "@/services/bus/goods"
+import { getMarketIdsByTradeMode } from "@/services/bus/market"
+import { getUserAccountType } from "@/services/bus/user"
+import { QueryQuoteDayRsp } from "@/services/go/quote/interface"
+import { queryQuoteGoodsList } from "@/services/go/Tjmd"
+import { QueryQuoteGoodsListReq, QueryQuoteGoodsListRsp } from "@/services/go/Tjmd/interface"
+import { ref } from "vue"
+
+// 获取 商品掉期 商品列表
+export const useSwapList = () => {
+    const { loading, tableList, queryTable } = queryTableList<QueryQuoteGoodsListRsp>();
+    // 行情商品
+    const goodsList = ref<QueryQuoteDayRsp[]>([])
+    initData(() => {
+        // 组装 参数
+        const marketids = getMarketIdsByTradeMode(TradeMode.ListingAndSelection)
+        const param: QueryQuoteGoodsListReq = {
+            usertype: getUserAccountType(),
+        }
+        if (marketids) {
+            param.marketids = marketids
+        }
+        // 开始查询 商品掉期
+        queryTable(queryQuoteGoodsList, param).then(res => {
+            goodsList.value.length = 0
+            res.forEach(el => {
+                // 找到盘面数据
+                const quote = getQuoteDayInfoByCode(el.goodscode);
+                if (quote) {
+                    Object.assign(quote, { goodsname: el.goodsname, refgoodsname: el.refgoodsname })
+                    goodsList.value.push(quote)
+                }
+            })
+        })
+    })
+    return { loading, goodsList }
+}
+
+export const columnsList = [
+    { title: '序号', key: 'index', width: 80 },
+    { title: '代码', key: 'goodscode' },
+    { title: '名称', key: 'goodsname' },
+
+    { title: '标的合约', key: 'refgoodsname' },
+
+    { title: '买价', key: 'bid' },
+    { title: '买量', key: 'bidvolume' },
+    { title: '卖价', key: 'ask' },
+    { title: '卖量', key: 'askvolume' },
+
+    { title: '当前价', key: 'last' },
+    { title: '涨跌', key: 'change' }, // 最新价 - 昨结价
+    { title: '幅度', key: 'amplitude' }, // (最新价 - 昨结价) / 100 %
+    { title: '开盘', key: 'opened' },
+    { title: '最高', key: 'highest' },
+    { title: '最低', key: 'lowest' },
+
+    { title: '结算', key: 'settle' },
+
+    { title: '昨结算', key: 'presettle' },
+
+    // { title: '振幅', key: 'vibration' }, // (最高价 - 最低价 ) / 最新价  * 100 %
+    // { title: '总量', key: 'totalvolume' },
+    // { title: '现量', key: 'lastvolume' },
+    // { title: '持仓量', key: 'holdvolume' },
+    // { title: '日增', key: 'holdincrement' },
+    // { title: '金额', key: 'totalturnover' },
+];