Pārlūkot izejas kodu

Merge branch 'master' of http://47.101.159.18:3000/Muchinfo/MTP2.0_WEB

huangbin 4 gadi atpakaļ
vecāks
revīzija
e1fd007d9a

+ 2 - 0
src/services/go/wrtrade/interface.ts

@@ -544,6 +544,8 @@ export interface QueryWrMarketTradeConfigReq {
  * 查询市场交易参数配置返回
  */
 export interface WrMarketTradeConfig {
+    basisdownratio: number;//浮动价基差下限比例(仓单贸易)
+    basisupratio: number;//浮动价基差上限比例(仓单贸易)
     buychargealgorithm: number;//买方手续费收取方式 1:比率 2:固定
     buychargealgorithm2: number;//回购买方手续费收取方式 1:比率 2:固定 --77:现货商城
     buychargealgorithmvalue: number;//买方手续费设置值(交易所部分)

+ 34 - 2
src/views/order/spot_warran/components/spot_warrant_spot_details/components/listing/setup.ts

@@ -2,7 +2,7 @@ import { TradeMode } from '@/common/constants/enumCommon';
 import { validateCommon } from '@/common/setup/validate';
 import { handleForm as useForm } from '@/common/setup/warehouse_receipt_trade/listing';
 import { useVerifyListingNum } from '@/hooks/form/verify';
-import { getGoodsGroupsByTradeMode, getIPOGoodsList, getQuoteDayInfoByCodeFindPrice } from '@/services/bus/goods';
+import { getGoodsGroupsByTradeMode, getIPOGoodsList, getGoodsById, getQuoteDayInfoByCodeFindPrice, getQuoteDayInfoByCode } from '@/services/bus/goods';
 import { getRules } from '@/services/bus/rules';
 import { Goods } from "@/services/go/ermcp/goodsInfo/interface";
 import { WrHoldLB } from "@/services/go/wrtrade/interface";
@@ -39,19 +39,51 @@ export function handleForm(data: WrHoldLB) {
     const { rules, formRef } = useForm();
 
     const v_group = async (rule: RuleObject, value: number) => {
+        console.log('formState', formState)
         if (formState.goodsgroupid) {
             return validateCommon(value, '请选择合约');
         } else {
             return Promise.reject('请选择商品')
         }
     };
+
+    const v_move = async (rule: RuleObject, value: number) => {
+        console.log('formState', formState)
+        if (formState.goodsid) {
+            if (value) {
+                return Promise.reject('请输入基差');
+            }
+            const goodsCode = getGoodsById(formState.goodsid)?.goodscode;
+            if (goodsCode) {
+                const quote = getQuoteDayInfoByCode(goodsCode);
+                if (quote) {
+                    const { basisdownratio, basisupratio } = getRules()[0];
+                    const minValue = basisdownratio * quote.presettle;
+                    const maxValue = basisupratio * quote.presettle * -1;
+
+                    console.log(basisdownratio, basisupratio)
+
+                    if (value < minValue) {
+                        return Promise.reject(`基差下限不能小于${minValue}`);
+                    }
+                    if (value > maxValue) {
+                        return Promise.reject(`基差上限不能大于${maxValue}`);
+                    }
+                    return Promise.resolve();
+                }
+            }
+        } else {
+            return Promise.reject('没有商品合约');
+        }
+    }
+
     const { v_num } = useVerifyListingNum<ListingForm, 'DelistMinQty'>(formState, 'DelistMinQty', minivalue, enableqty)
 
     const rule = {
         FixedPrice: [{ required: true, message: '请输入挂牌价格', trigger: 'blur', type: 'number', min: 1, }],
         DelistMinQty: [{ required: true, message: '请输入起摘数量', trigger: 'blur', type: 'number', min: 1, }],
         OrderQty: [{ required: true, validator: v_num, trigger: 'blur', type: 'number' }],
-        PriceMove: [{ required: true, message: '请输入升贴水', trigger: 'blur', type: 'number', }],
+        PriceMove: [{ required: true, validator: v_move, trigger: 'blur', type: 'number', }],
         goodsid: [{ required: true, validator: v_group, }],
     }
     Object.assign(rules, rule)