huangbin 4 rokov pred
rodič
commit
ad8a82fa86

+ 21 - 4
src/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/components/post_buying/index.vue

@@ -149,7 +149,8 @@ import { validateAction } from '@/common/setup/form';
 import { _closeModal } from '@/common/setup/modal/modal';
 import { useListingTradeNumAndPrice } from '@/common/setup/trade';
 import { ListingTradeNumAndPrice } from '@/common/setup/trade/interface';
-import { getGoodsByCode, getQuoteDayInfoByCodeFindPrice } from '@/services/bus/goods';
+import { useTodayMargin } from '@/hooks/margin';
+import { getGoodsAgreeunitByGoodsCode, getGoodsByCode, getQuoteDayInfoByCodeFindPrice } from '@/services/bus/goods';
 import { geLoginID_number } from '@/services/bus/login';
 import { getMarketByTradeMode } from '@/services/bus/market';
 import { QueryQuoteDayRsp } from '@/services/go/quote/interface';
@@ -179,6 +180,8 @@ export default defineComponent({
         },
     },
     setup(props, context) {
+        // 获取保证金比例
+        const { getReckonMarginValueByTradeMode } = useTodayMargin();
         // 控制弹窗
         const { visible, cancel } = _closeModal(context);
         // 表单
@@ -195,11 +198,25 @@ export default defineComponent({
             isFloat,
             canUseMoney,
         };
-        const { getFloatPrice, getListingBuyMaxNum, getListingSellMaxNum, getListingBuyMargin, getListingSellMargin, getMoney } = useListingTradeNumAndPrice<FormParam>(param);
+        const { getFloatPrice, getMoney } = useListingTradeNumAndPrice<FormParam>(param);
         // 保证金
-        const getMargin = isBuy() ? getListingBuyMargin : getListingBuyMargin;
+        const getMargin = () => {
+            const marginvalue = getReckonMarginValueByTradeMode(TradeMode.DiaoQi);
+            return marginvalue ? marginvalue : '--';
+        };
         // 最大数量
-        const getMaxNum = isBuy() ? getListingBuyMaxNum : getListingBuyMaxNum;
+        const getMaxNum = () => {
+            let result = 0;
+            // 可用资金
+            const temp = +canUseMoney();
+
+            const money = temp > 0 ? temp : 0;
+            const agreeunit = getGoodsAgreeunitByGoodsCode(props.selectedRow.goodscode);
+            if (money && formState.FixedPrice) {
+                result = +(money / (formState.FixedPrice * agreeunit)).toFixed(0);
+            }
+            return result;
+        };
 
         function submit() {
             validateAction<FormParam>(formRef, formState).then((res) => {