huangbin 4 yıl önce
ebeveyn
işleme
ac403b9c24

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

@@ -1,13 +1,26 @@
 import { TradeMode } from '@/common/constants/enumCommon';
 import APP from '@/services';
 import { Goods } from '../go/ermcp/goodsInfo/interface';
+import { QueryQuoteDayRsp } from '../go/quote/interface';
 import { Goodsgroup } from '../go/useInfo/interface';
 import { getMarketByTradeMode } from './market';
 
+// 获取全部商品信息
 export function getGoodsList(): Goods[] {
     return APP.get('Goods')
 }
 
+// 获取全部盘面信息
+export function getAllQuoteDayInfo(): QueryQuoteDayRsp[] {
+    return APP.get('quoteDayInfo')
+}
+
+// 通过goodscode获取对应的商品盘面信息
+export function getQuoteDayInfoByCode(goodsCode: string): QueryQuoteDayRsp | undefined {
+    return getAllQuoteDayInfo().find(e => e.goodscode === goodsCode)
+}
+
+// 获取全部商品组信息
 export function getAllGoodsGroups(): Goodsgroup[] {
     return APP.get('goodsgroups')
 }

+ 10 - 2
src/services/go/ermcp/goodsInfo/index.ts

@@ -4,12 +4,14 @@ import APP from '@/services';
 import { getUserId } from "@/services/bus/account";
 import { getUserAccountType } from "@/services/bus/user";
 import { commonSearch_go } from '@/services/go/index';
+import { QueryQuoteDay } from '../../quote';
 import {
     Ermcp3Brand, Ermcp3GoodsGroup, Ermcp3MiddleGoodsDetailEx,
     Ermcp3Wrstandard,
     ErmcpDeliveryGoodsDetailEx,
     ErmcpDeliveryGoodsReq,
-    ErmcpDeliveryGoodsRsp, ErmcpMiddleGoodsChangeLog, ErmcpMiddleGoodsModel
+    ErmcpDeliveryGoodsRsp, ErmcpMiddleGoodsChangeLog, ErmcpMiddleGoodsModel,
+    Goods
 } from './interface';
 
 /**
@@ -114,7 +116,13 @@ export function QueryMiddleGoodsDetail(middlegoodsid?: number): Promise<Ermcp3Mi
 export function GetErmcpGoods(lastUpdateTime?: string): Promise<string> {
     const param = lastUpdateTime ? { lastUpdateTime } : {}
     return commonSearch_go('/Ermcp/GetErmcpGoods', param).then(res => {
-        console.log('查询企业风管期货商品信息', res);
+
+        if (res.length) {
+            const result = res.reduce((acc: string, obj: Goods) => acc + obj.goodscode + ',', '')
+            // 登录的时候或者刷新的时候,需要获取一次盘面信息
+            QueryQuoteDay(result)
+        }
+        // console.log('查询企业风管期货商品信息', res);
         APP.set('Goods', res)
         return 'ok'
     }).catch((err) => {

+ 7 - 4
src/services/go/quote/index.ts

@@ -1,6 +1,6 @@
-import { commonSearch_go } from '../index'
+import APP from '@/services';
+import { commonSearch_go } from '../index';
 import * as type from './interface';
-
 /**
  * 查询行情历史数据
  * @param param QueryHistoryDatas
@@ -24,8 +24,11 @@ export function QueryHistoryTikDatas(param: type.QueryHistoryTikDatas): Promise<
  * @param goodsCodes 商品代码列表,格式:CU2102,CU2103,AL2107
  * @returns QueryQuoteDay
  */
-export function QueryQuoteDay(goodsCodes: string): Promise<type.QueryQuoteDayRsp> {
-    return commonSearch_go('/Quote/QueryQuoteDay', { goodsCodes })
+export function QueryQuoteDay(goodsCodes: string): Promise<string> {
+    return commonSearch_go('/Quote/QueryQuoteDay', { goodsCodes }).then(res => {
+        APP.set('quoteDayInfo', res)
+        return 'ok'
+    }).catch(err => { throw new Error(`获取商品盘面信息失败:${err}`) })
 }
 
 /**

+ 12 - 11
src/views/market/spot_trade/components/buy-sell-market/index.vue

@@ -40,8 +40,8 @@
         </div>
       </div>
       <div class="market">
-        <div class="first">IC2104</div>
-        <div class="last red">6291.0</div>
+        <div class="first">{{selectedRow.goodscode}}</div>
+        <div class="last red">{{getGoodsPrice()}}</div>
         <LineChartOutlined />
       </div>
       <BtnList :btnList="firstBtn"
@@ -80,7 +80,7 @@ import { _closeModal } from '@/common/setup/modal/modal';
 import { queryOrderQuoteDetail } from '@/services/go/wrtrade';
 import { QueryOrderQuoteDetailReq, WrOrderQuote, WrOrderQuoteDetail } from '@/services/go/wrtrade/interface';
 import { LeftOutlined } from '@ant-design/icons-vue';
-import { handleBuyAndSellList } from './setup';
+import { handleBuyAndSellList, handleChildComponentMethod } from './setup';
 import Buy from './components/buy/index.vue';
 import Sell from './components/sell/index.vue';
 import { LineChartOutlined } from '@ant-design/icons-vue';
@@ -90,6 +90,7 @@ import { PropType, ref } from 'vue';
 import { handleSpotBtnList } from '../../setup';
 import { addSubscribeQuotation } from '@/services/socket/quota';
 import Bus from '@/utils/eventBus/index';
+import { getQuoteDayInfoByCode } from '@/services/bus/goods';
 
 export default defineComponent({
     emits: ['cancel'],
@@ -119,21 +120,21 @@ export default defineComponent({
         // 买卖大厅 配置数据
         // 表格操作按钮列表
         const { firstBtn, buyMarket, sellMarket } = handleSpotBtnList(props.enumName);
-        const buyRef = ref<null | { queryTableAction: Function }>(null);
-        const sellRef = ref<null | { queryTableAction: Function }>(null);
-        function loadBuyData() {
-            buyRef.value?.queryTableAction();
+        const quoteData = getQuoteDayInfoByCode(props.selectedRow.goodscode);
+        function getGoodsPrice() {
+            // const quoteData = getQuoteDayInfoByCode(props.selectedRow.goodscode);
+            console.log('quoteData', quoteData);
+            return quoteData ? quoteData.ask : '--';
         }
-        function loadSellData() {
-            sellRef.value?.queryTableAction();
-        }
-
+        const { childRef: buyRef, loadChildComponentData: loadBuyData } = handleChildComponentMethod();
+        const { childRef: sellRef, loadChildComponentData: loadSellData } = handleChildComponentMethod();
         const { componentId, closeComponent, openComponent } = handleModalComponent(loadBuyData, ref({}));
         Bus.$on('spotTrade', loadSellData);
         return {
             buyRef,
             sellRef,
             cancel,
+            getGoodsPrice,
             visible,
             firstBtn,
             buyMarket,

+ 10 - 0
src/views/market/spot_trade/components/buy-sell-market/setup.ts

@@ -1,6 +1,7 @@
 import { EnumRouterName } from '@/common/constants/enumRouterName';
 import { TableKey } from '@/common/methods/table/interface';
 import { getTableColumns, getTableEvent, queryTableList } from "@/common/setup/table";
+import { ref } from 'vue';
 
 
 export function handleBuyAndSellList<T>(menuType: EnumRouterName, isDetail: boolean, tableName: keyof TableKey) {
@@ -72,3 +73,12 @@ export function getSellMarketParam(enumName: EnumRouterName) {
     }
     return { wrpricetype, haswr, tableKey }
 }
+
+
+export function handleChildComponentMethod() {
+    const childRef = ref<null | { queryTableAction: Function }>(null);
+    function loadChildComponentData() {
+        childRef.value?.queryTableAction();
+    }
+    return { childRef, loadChildComponentData }
+}