Ver código fonte

添加浮动价行情订阅

huangbin 4 anos atrás
pai
commit
17e1e9b7f2

+ 26 - 14
src/views/market/spot_trade/components/buy-sell-market/index.vue

@@ -39,7 +39,8 @@
           <div class="last">{{selectedRow.buyqty}}</div>
         </div>
       </div>
-      <div class="market">
+      <div class="market"
+           v-if="isFloatPrice()">
         <div class="first">{{selectedRow.goodscode}}</div>
         <div class="last red">{{getGoodsPrice()}}</div>
         <LineChartOutlined />
@@ -47,8 +48,6 @@
       <BtnList :btnList="firstBtn"
                :record="selectedRow"
                @click="openComponent" />
-      <!-- <a-button class="publishBuy">发布求购</a-button>
-      <a-button class="detailBtn">详情</a-button> -->
     </div>
     <a-row>
       <a-col :span="12"
@@ -75,20 +74,19 @@
 
 <script lang="ts">
 import { EnumRouterName } from '@/common/constants/enumRouterName';
-import { ComposeTableParam, defineAsyncComponent, defineComponent, BtnList, handleComposeTable, ModalEnum, queryTableList } from '@/common/export/commonTable';
+import { defineAsyncComponent, defineComponent, BtnList, 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 { WrOrderQuote } from '@/services/go/wrtrade/interface';
 import { LeftOutlined } from '@ant-design/icons-vue';
-import { handleBuyAndSellList, handleChildComponentMethod } from './setup';
+import { handleChildComponentMethod } from './setup';
 import Buy from './components/buy/index.vue';
 import Sell from './components/sell/index.vue';
 import { LineChartOutlined } from '@ant-design/icons-vue';
-// import { getBuyAndSellMarketData } from '../../setup';
 import { handleModalComponent } from '@/common/setup/asyncComponent';
-import { PropType, ref } from 'vue';
+import { onMounted, PropType, ref } from 'vue';
 import { handleSpotBtnList } from '../../setup';
-import { addSubscribeQuotation } from '@/services/socket/quota';
+import { v4 } from 'uuid';
+import { addSubscribeQuotation, removeSubscribeQuotation } from '@/services/socket/quota';
 import Bus from '@/utils/eventBus/index';
 import { getQuoteDayInfoByCode } from '@/services/bus/goods';
 
@@ -116,24 +114,38 @@ export default defineComponent({
     },
     setup(props, context) {
         const { visible, cancel } = _closeModal(context);
-        console.log(props.selectedRow);
         // 买卖大厅 配置数据
         // 表格操作按钮列表
         const { firstBtn, buyMarket, sellMarket } = handleSpotBtnList(props.enumName);
-        const quoteData = getQuoteDayInfoByCode(props.selectedRow.goodscode);
+        /*** ====== 处理浮动价 =======******/
+        // 是否为浮动价
+        function isFloatPrice() {
+            return props.enumName === EnumRouterName.warehouse_receipt_trade_floating_price || props.enumName === EnumRouterName.warehouse_pre_sale_floating_price;
+        }
+        // 获取浮动价商品实时价格
         function getGoodsPrice() {
-            // const quoteData = getQuoteDayInfoByCode(props.selectedRow.goodscode);
-            console.log('quoteData', quoteData);
+            const quoteData = getQuoteDayInfoByCode(props.selectedRow.goodscode);
             return quoteData ? quoteData.ask : '--';
         }
+        const uuid = v4();
+        if (isFloatPrice()) {
+            // 如果是浮动价需要行情订阅
+            const arr = [{ exchangeCode: 250, goodsCode: props.selectedRow.goodscode, subState: 0 }];
+            addSubscribeQuotation(uuid, arr);
+        }
+        onMounted(() => {
+            removeSubscribeQuotation(uuid);
+        });
         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,
+            isFloatPrice,
             getGoodsPrice,
             visible,
             firstBtn,