浏览代码

修改 商品掉期

huangbin 4 年之前
父节点
当前提交
4c87d048b0

+ 1 - 1
public/config/app.config.json

@@ -1,3 +1,3 @@
 {
-    "apiUrl": "http://192.168.31.139:8080/cfg?key=test_139"
+    "apiUrl": "http://192.168.31.204:8080/cfg?key=test_204"
 }

+ 47 - 5
src/common/setup/table/tableQuote.ts

@@ -1,3 +1,4 @@
+import { getGoodsDecimalplaceByGoodsCode, getQuoteDayInfoByCode } from '@/services/bus/goods';
 import { QueryQuoteDayRsp } from '@/services/go/quote/interface';
 import { addSubscribeQuotation, removeSubscribeQuotation } from '@/services/socket/quota';
 import TimerUtils from '@/utils/timer/timerUtil';
@@ -140,12 +141,41 @@ export function handleQuotePriceColor(value: number, presettle: number) {
     return result
 }
 
+// 外部行情 获取某个值
+export function getQuoteValue_out(goodscode: string, val: keyof QueryQuoteDayRsp) {
+    const obj = getQuoteDayInfoByCode(goodscode)
+    return obj ? obj[val] : '--'
+}
+
+// 外部行情  处理行情价格颜色
+export function handleQuotePriceColor_out(goodscode: string, val: keyof QueryQuoteDayRsp) {
+    const obj = getQuoteDayInfoByCode(goodscode)
+    let result = ''
+    if (obj) {
+        result = handleQuotePriceColor(obj[val] as number, obj.presettle)
+    }
+    return result
+}
+
 // 涨跌 最新价 - 昨结价
-export function quoteChange(record: QueryQuoteDayRsp, decimalplace = 2) {
-    const { presettle, last } = record
+export function quoteChange(record: QueryQuoteDayRsp | undefined, decimalplace = 2) {
     let result = '--'
-    if (isPrice(last, presettle)) {
-        result = (last - presettle).toFixed(decimalplace)
+    if (record) {
+        const { presettle, last } = record
+        if (isPrice(last, presettle)) {
+            result = (last - presettle).toFixed(decimalplace)
+        }
+    }
+    return result
+}
+
+// 外部行情 涨跌 最新价 - 昨结价
+export function quoteChange_out(goodscode: string) {
+    const obj = getQuoteDayInfoByCode(goodscode)
+    let result = '--'
+    const decimalplace = getGoodsDecimalplaceByGoodsCode(goodscode)
+    if (obj) {
+        result = quoteChange(obj, decimalplace)
     }
     return result
 }
@@ -156,6 +186,17 @@ export function quoteAmplitude(record: QueryQuoteDayRsp, decimalplace = 2) {
     return result === '--' ? '--' : (+result / record.presettle * 100).toFixed(decimalplace) + '%'
 }
 
+// 外部行情 幅度(最新价 - 昨结价) / 昨结价) *  100 %
+export function quoteAmplitude_out(goodscode: string) {
+    const obj = getQuoteDayInfoByCode(goodscode)
+    let result = '--'
+    const decimalplace = getGoodsDecimalplaceByGoodsCode(goodscode)
+    if (obj) {
+        result = quoteAmplitude(obj, decimalplace)
+    }
+    return result
+}
+
 // 振幅 (最高价 - 最低价 ) / 最新价  * 100 %
 export function quoteAmplituOfVibration(record: QueryQuoteDayRsp, decimalplace = 2) {
     const { highest, lowest, last } = record
@@ -171,4 +212,5 @@ export function quoteAmplituOfVibration(record: QueryQuoteDayRsp, decimalplace =
 // 处理 空值  或者 0的时候,显示 --  的情况,
 export function handleNoneValue(value: number | string) {
     return value ? value : '--'
-}
+}
+

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

@@ -131,4 +131,10 @@ export function getGoodsAgreeunitByGoodsCode(goodscode: string): number {
 export function findGoodsTradeModeById(goodsid: number) {
     const marketid = getGoodsById(goodsid)!.marketid
     return APP.get('markets').find((el: Market) => el.marketid === marketid).trademode
+}
+
+// 通过 goodscode 获取商品小数位
+export function getGoodsDecimalplaceByGoodsCode(goodscode: string) {
+    const obj = getGoodsByCode(goodscode)
+    return obj ? obj.decimalplace : 1
 }

+ 46 - 23
src/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/index.vue

@@ -23,19 +23,19 @@
              :loading="loading"
              :expandedRowKeys="expandedRowKeys"
              :customRow="Rowclick"
-             rowKey="goodscode"
+             rowKey="refgoodscode"
              ref="tableRef"
              :data-source="goodsList">
-      <template #totalturnover="{ text }">
+      <!-- <template #totalturnover="{ text }">
         <span>{{changeUnit(text)}}</span>
-      </template>
+      </template> -->
       <!-- 涨跌 -->
       <template #change="{ record }">
-        <span>{{quoteChange(record, record.decimalplace)}}</span>
+        <span>{{quoteChange_out(record.refgoodscode)}}</span>
       </template>
       <!-- 幅度 -->
       <template #amplitude="{ record }">
-        <span>{{quoteAmplitude(record, record.decimalplace)}}</span>
+        <span>{{quoteAmplitude_out(record.refgoodscode)}}</span>
       </template>
       <!-- 振幅 -->
       <template #vibration="{ record }">
@@ -45,24 +45,44 @@
         <span>{{index + 1}}</span>
       </template>
       <!-- 买价 -->
-      <template #bid="{ text, record }">
-        <span :class="handleQuotePriceColor(text, record.presettle)">{{text}}</span>
-      </template>
+      <!-- <template #bid="{ record }">
+        <span :class="handleQuotePriceColor_out(record.refgoodscode, 'bid')">
+          {{getQuoteValue_out(record.refgoodscode, 'bid')}}</span>
+      </template> -->
       <!-- 卖价 -->
-      <template #ask="{ text, record }">
-        <span :class="handleQuotePriceColor(text, record.presettle)">{{text}}</span>
-      </template>
+      <!-- <template #ask="{  record }">
+        <span :class="handleQuotePriceColor_out(record.refgoodscode, 'ask')">
+          {{getQuoteValue_out(record.refgoodscode, 'ask')}}</span>
+      </template> -->
       <!-- 最新价 -->
-      <template #last="{ text, record }">
-        <span :class="handleQuotePriceColor(text, record.presettle)">{{text}}</span>
+      <template #last="{ record }">
+        <span :class="handleQuotePriceColor_out(record.refgoodscode, 'last')">
+          {{getQuoteValue_out(record.refgoodscode, 'last')}}</span>
+      </template>
+      <!-- 开盘 -->
+      <template #opened="{ record }">
+        <span :class="handleQuotePriceColor_out(record.refgoodscode, 'last')">
+          {{getQuoteValue_out(record.refgoodscode, 'opened')}}</span>
+      </template>
+      <!-- 结算 -->
+      <template #settle="{ record }">
+        <span>
+          {{getQuoteValue_out(record.refgoodscode, 'settle')}}</span>
+      </template>
+      <!-- 昨结算 -->
+      <template #presettle="{ record }">
+        <span>
+          {{getQuoteValue_out(record.refgoodscode, 'presettle')}}</span>
       </template>
       <!-- 最低价 -->
-      <template #lowest="{ text, record }">
-        <span :class="handleQuotePriceColor(text, record.presettle)">{{text}}</span>
+      <template #lowest="{record }">
+        <span :class="handleQuotePriceColor_out(record.refgoodscode, 'lowest')">
+          {{getQuoteValue_out(record.refgoodscode, 'lowest')}}</span>
       </template>
       <!-- 最高价 -->
-      <template #highest="{ text, record }">
-        <span :class="handleQuotePriceColor(text, record.presettle)">{{text}}</span>
+      <template #highest="{ record }">
+        <span :class="handleQuotePriceColor_out(record.refgoodscode, 'highest')">
+          {{getQuoteValue_out(record.refgoodscode, 'highest')}}</span>
       </template>
     </a-table>
     <!-- 右键 -->
@@ -81,10 +101,12 @@ import { getShowBottomValue } from '@/common/config/constrolBottom';
 import { contextMenu, defineAsyncComponent, defineComponent } from '@/common/export/commonTable';
 import { handleTableEventAndData } from '@/common/setup/table/compose';
 import { TableParam } from '@/common/setup/table/interface';
-import { handleQuotePriceColor, handleSubcriteOnDemandQuote, quoteAmplitude, quoteAmplituOfVibration, quoteChange } from '@/common/setup/table/tableQuote';
+import { handleQuotePriceColor_out, handleSubcriteOnDemandQuote, quoteAmplitude_out, quoteAmplituOfVibration, quoteChange_out, getQuoteValue_out } from '@/common/setup/table/tableQuote';
 import { QueryQuoteDayRsp } from '@/services/go/quote/interface';
 import { RefGoodsList } from './interface';
 import { columnsList, getBtnList, useSwapList } from './setup';
+import { getAllQuoteDayInfo, getQuoteDayInfoByCode } from '@/services/bus/goods';
+import { QueryQuoteGoodsListRsp } from '@/services/go/Tjmd/interface';
 
 export default defineComponent({
     name: 'spot_trade_order_transaction_swap',
@@ -105,27 +127,28 @@ export default defineComponent({
         };
 
         // 行情按需订阅
-        let stopSubcribe = handleSubcriteOnDemandQuote<QueryQuoteDayRsp>(goodsList, 'refgoodscode');
+        let stopSubcribe = handleSubcriteOnDemandQuote<QueryQuoteGoodsListRsp>(goodsList, 'refgoodscode');
         // 过滤标的合约
         function goodsChange(value: string) {
             filterGoodsList(value);
             // 停止上次订阅
             stopSubcribe();
             // 重新发起订阅
-            stopSubcribe = handleSubcriteOnDemandQuote<QueryQuoteDayRsp>(goodsList, 'refgoodscode');
+            stopSubcribe = handleSubcriteOnDemandQuote<QueryQuoteGoodsListRsp>(goodsList, 'refgoodscode');
         }
         return {
             isBottom,
             ...handleTableEventAndData<QueryQuoteDayRsp>(param),
             btnList: getBtnList(true),
-            handleQuotePriceColor,
-            quoteChange,
-            quoteAmplitude,
+            handleQuotePriceColor_out,
+            quoteChange_out,
+            quoteAmplitude_out,
             quoteAmplituOfVibration,
             getRefGoodsList,
             goodsList,
             loading,
             goodsChange,
+            getQuoteValue_out,
         };
     },
 });

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

@@ -2,16 +2,13 @@ import { BtnListType } from "@/common/components/btnList/interface"
 import { TradeMode } from "@/common/constants/enumCommon"
 import { initData } from "@/common/methods"
 import { queryTableList } from "@/common/setup/table"
-import { getAllQuoteDayInfo, 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"
 
 const refGoods = ref<QueryQuoteGoodsListRsp[]>([])
-const allGoodsList = ref<QueryQuoteDayRsp[]>([])
 
 export function findItemGoods(goodscode: string) {
     return refGoods.value.find(el => el.goodscode === goodscode)!
@@ -34,31 +31,12 @@ export function getSwapList() {
 // 获取 商品掉期 商品列表
 export const useSwapList = () => {
     // 行情商品
-    const goodsList = ref<QueryQuoteDayRsp[]>([])
+    const goodsList = ref<QueryQuoteGoodsListRsp[]>([])
     initData(() => {
         // 开始查询 商品掉期
         getSwapList().then(res => {
             refGoods.value = res
-            goodsList.value.length = 0
-            allGoodsList.value.length = 0
-            console.log('getAllQuoteDayInfo()', getAllQuoteDayInfo())
-            res.forEach(el => {
-                // 找到盘面数据
-                const quote = getQuoteDayInfoByCode(el.refgoodscode);
-                if (quote) {
-                    const obj = {
-                        goodsname: el.goodsname,
-                        goodsid: el.goodsid,
-                        refgoodsname: el.refgoodsname,
-                        refgoodscode: el.refgoodscode
-                    }
-                    Object.assign(quote, obj)
-                    goodsList.value.push(quote)
-                    allGoodsList.value.push(quote)
-                }
-                console.log('allGoodsList.value', allGoodsList.value)
-            })
-            console.log('商品掉期', res)
+            goodsList.value = res
         })
     })
     // 获取标记商品列表
@@ -72,13 +50,13 @@ export const useSwapList = () => {
     // 过滤标的合约
     function filterGoodsList(value: string) {
         if (value === '全部标的合约') {
-            goodsList.value = allGoodsList.value
+            goodsList.value = refGoods.value
         } else {
-            goodsList.value = allGoodsList.value.filter(goods => goods.refgoodsname === value)
+            goodsList.value = refGoods.value.filter(goods => goods.refgoodsname === value)
         }
     }
 
-    return { loading, goodsList, getRefGoodsList, filterGoodsList }
+    return { loading, goodsList, getRefGoodsList, filterGoodsList, refGoods }
 }
 
 export const columnsList = [

+ 2 - 2
src/views/order/commodity_contract/components/commodity_contract_summary/index.vue

@@ -70,11 +70,11 @@ import { QueryTradePositionRsp } from '@/services/go/ermcp/order/interface';
 import { getBuyOrSellName, getChannelBuildName } from '@/common/constants/enumsName';
 import { isInvestment } from '@/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/components/setup';
 import { useIsDiaoQi, findGoodsCode } from './setup';
-import { getSwapList } from '@/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/setup';
+// import { getSwapList } from '@/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/setup';
 import { ref } from 'vue';
 import { QueryQuoteGoodsListRsp } from '@/services/go/Tjmd/interface';
 import Bus from '@/utils/eventBus/index';
-import { tabColumns } from './setup';
+import { tabColumns, getSwapList } from './setup';
 import { handleNoneValue } from '@/common/setup/table/tableQuote';
 
 export default defineComponent({

+ 18 - 1
src/views/order/commodity_contract/components/commodity_contract_summary/setup.ts

@@ -1,8 +1,12 @@
 // 获取最新价
 
 import { TradeMode } from "@/common/constants/enumCommon";
+import { queryTableList } from "@/common/setup/table";
 import { findGoodsTradeModeById } from "@/services/bus/goods";
-import { QueryQuoteGoodsListRsp } from "@/services/go/Tjmd/interface";
+import { getMarketIdsByTradeMode } from "@/services/bus/market";
+import { getUserAccountType } from "@/services/bus/user";
+import { queryQuoteGoodsList } from "@/services/go/Tjmd";
+import { QueryQuoteGoodsListReq, QueryQuoteGoodsListRsp } from "@/services/go/Tjmd/interface";
 
 export const useIsDiaoQi = (goodsid: number) => {
     return findGoodsTradeModeById(goodsid) === TradeMode.DiaoQi
@@ -15,6 +19,19 @@ export function findGoodsCode(goodsid: number, goodscode: string, swapList: Quer
     return result ? result : ''
 }
 
+export function getSwapList() {
+    const { loading, queryTable } = queryTableList<QueryQuoteGoodsListRsp>();
+    // 组装 参数
+    const marketids = getMarketIdsByTradeMode(TradeMode.DiaoQi)
+    const param: QueryQuoteGoodsListReq = {
+        usertype: getUserAccountType(),
+    }
+    if (marketids) {
+        param.marketids = marketids
+    }
+    return queryTable(queryQuoteGoodsList, param)
+}
+
 export const tabColumns = [
     {
         key: '10th',