li.shaoyi 3 年之前
父节点
当前提交
b73f14d433

+ 50 - 15
src/views/market/spot_trade/components/buy-sell-market/components/delisting/setup.ts

@@ -3,13 +3,15 @@ import { EnumRouterName } from "@/common/constants/enumRouterName";
 import { queryResultLoadingAndInfo } from "@/common/methods/request/resultInfo";
 import { getAccountTypeList, getCanUseMoney } from "@/services/bus/account";
 import { getGoodsAgreeunitByGoodsCode, getQuoteDayInfoByCodeFindPrice } from "@/services/bus/goods";
-import { getRules } from '@/services/bus/rules';
+import { getRulesByMarketid } from '@/services/bus/rules';
 import { AccountListItem } from "@/services/dataCenter/interafce/account";
 import { queryHoldLB, queryWrPosition } from '@/services/go/wrtrade';
 import { QueryWrPositionReq, WrHoldLB, WrOrderQuote, WrOrderQuoteDetail, WrPosition } from "@/services/go/wrtrade/interface";
 import { reactive, Ref, ref, UnwrapRef } from "vue";
 import { handleIs } from "../../setup";
 import { ListingForm, Wrhold } from "./interface";
+import APP from '@/services'
+import { TjmdMarketSectionConfig } from '@/services/go/Tjmd/interface'
 
 export function handleForm(data: WrOrderQuoteDetail) {
     const formRef = ref();
@@ -72,17 +74,55 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
     // 获取选中的资金账号
     const getSelectedAccount = () => accountList.find((e) => e.accountid === formState.accountid);
     // 交易规则
-    const rules = getRules()
-    // 是否有规则
-    const hasRule = () => rules.length > 0;
-    const { buymarginvalue, buymarginalgorithm } = rules.length ? rules[0] : { buymarginvalue: 0, buymarginalgorithm: 1 }
+    const rules = getRulesByMarketid(selectedRow.marketid ?? 0)
+
     //保证金模式 1: 比率 2: 固定
-    const marginMethod = () => buymarginalgorithm === 1
+    const marginMethod = () => {
+        if (rules) {
+            switch (selectedRow.buyorsell) {
+                case BuyOrSell.buy: {
+                    return rules.buymarginalgorithm === 1;
+                }
+                case BuyOrSell.sell: {
+                    return rules.sellmarginalgorithm === 1;
+                }
+            }
+        }
+        return true;
+    }
+
+    // 获取保证金比例
+    const getMarginValue = () => {
+        if (rules) {
+            switch (selectedRow.buyorsell) {
+                case BuyOrSell.sell: {
+                    return rules.buymarginvalue;
+                }
+                case BuyOrSell.buy: {
+                    const market = APP.get('markets').find((e: TjmdMarketSectionConfig) => e.marketid === selectedRow.marketid)
+                    if (market) {
+                        switch (market.auctionwrtype) {
+                            // 无仓单
+                            case 1: {
+                                return rules.sellmarginvalue2;
+                            }
+                            // 有仓单
+                            default: {
+                                return rules.sellmarginvalue;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return 0;
+    }
+
     const { fixedprice, orderqty, pricemove } = selectedRow;
     // 获取摘牌最大可摘量
     function getMaxNum() {
         let result = 0;
-        if (hasRule()) {
+        if (rules) {
             let marginMoney = 0;
             // 可用资金
             const canUseMoney = Number(getCanUseMoney(getSelectedAccount() as AccountListItem))
@@ -94,11 +134,11 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
                         // 估算总价
                         const predictTotal = pricemove + (goodsPrice as number);
                         // 买方履约保证金比例*估算总价
-                        marginMoney = marginMethod() ? (buymarginvalue * predictTotal) : (buymarginvalue + predictTotal)
+                        marginMoney = marginMethod() ? (rules.buymarginvalue * predictTotal) : (rules.buymarginvalue + predictTotal)
                     }
                 } else {
                     // 买方履约保证金比例*挂牌价格
-                    marginMoney = marginMethod() ? (buymarginvalue * fixedprice) : (buymarginvalue + fixedprice)
+                    marginMoney = marginMethod() ? (rules.buymarginvalue * fixedprice) : (rules.buymarginvalue + fixedprice)
                 }
                 if (marginMoney > 0) {
                     // 摘买 最大数量
@@ -149,12 +189,7 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
         // fixed bull  履约保证金=买方履约保证金比例*摘牌金额
         // floor sell  履约保证金=卖方履约保证金比例*估算总额,履约保证金为0则括号内容不显示
         //  floor  buy 履约保证金=买方履约保证金比例*估算总额
-        let result = 0
-        if (hasRule()) {
-            const { buymarginvalue, sellmarginvalue } = rules[0]
-            const margin = isBuy() ? sellmarginvalue : buymarginvalue
-            result = marginMethod() ? margin * getMoney() : margin + getMoney()
-        }
+        const result = marginMethod() ? getMarginValue() * getMoney() : getMarginValue() + getMoney()
         return Number(result.toFixed(2))
     }
     return { getMaxNum, getMoney, getMargin }

+ 0 - 1
src/views/market/spot_trade/components/post_buying/index.vue

@@ -230,7 +230,6 @@ export default defineComponent({
         }
       } else {
         message.error('市场参数未配置')
-        return;
       }
     }
 

+ 0 - 1
src/views/market/spot_trade/components/post_buying/setup.ts

@@ -99,7 +99,6 @@ export function handleNumAndPrice(enumName: EnumRouterName, selectedMarket: Tjmd
         return 0;
     }
 
-
     // 挂牌最大数量
     function getMaxNum() {
         // 可用资金