Przeglądaj źródła

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

huangbin 4 lat temu
rodzic
commit
bda5f8f5d4

+ 1 - 1
src/views/order/pre_sale_warehouse_receipt/components/pre_sale_warehouse_receipt_deal/components/pre_sale_warehouse_receipt_deal_detail/index.vue

@@ -30,7 +30,7 @@ export default defineComponent({
     components: { Drawer, BtnList },
     emits: ['cancel', 'update'],
     props: {
-        tableName: Object as PropType<keyof TableKey>,
+        tableName: String as PropType<keyof TableKey>,
         selectedRow: {
             type: Object as PropType<QueryWrTradeBargainApplyQsp & WrOrderDetail>,
             default: {},

+ 1 - 1
src/views/order/spot_warran/components/spot_warrant_deal/components/spot_warrant_deal_detail/index.vue

@@ -30,7 +30,7 @@ export default defineComponent({
     components: { Drawer, BtnList },
     emits: ['cancel', 'update'],
     props: {
-        tableName: Object as PropType<keyof TableKey>,
+        tableName: String as PropType<keyof TableKey>,
         selectedRow: {
             type: Object as PropType<QueryWrTradeBargainApplyQsp & WrOrderDetail>,
             default: {},

+ 20 - 19
src/views/order/spot_warran/components/spot_warrant_spot_details/components/listing/setup.ts

@@ -39,7 +39,6 @@ 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 {
@@ -47,33 +46,35 @@ export function handleForm(data: WrHoldLB) {
         }
     };
 
-    const v_move = async (rule: RuleObject, value: number) => {
-        console.log('formState', formState)
+    // 验证基差上下限
+    const v_basis = async (rule: RuleObject, value: number) => {
         if (formState.goodsid) {
             if (value) {
-                return Promise.reject('请输入基差');
-            }
-            const goodsCode = getGoodsById(formState.goodsid)?.goodscode;
-            if (goodsCode) {
+                const goodsCode = getGoodsById(formState.goodsid)?.goodscode as string;
                 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)
+                    // 最小值 = 基差下限百分比 * 昨日收盘价 * -1
+                    const minValue = basisdownratio * quote.presettle * -1;
+                    // 最大值 = 基差上限百分比 * 昨日收盘价
+                    const maxValue = basisupratio * quote.presettle;
 
-                    if (value < minValue) {
-                        return Promise.reject(`基差下限不能小于${minValue}`);
+                    if (value > minValue && value < maxValue) {
+                        return Promise.resolve();
+                    } else {
+                        if (value < minValue) {
+                            return Promise.reject(`基差下限不能小于${minValue.toFixed(2)}`);
+                        }
+                        if (value > maxValue) {
+                            return Promise.reject(`基差上限不能大于${maxValue.toFixed(2)}`);
+                        }
                     }
-                    if (value > maxValue) {
-                        return Promise.reject(`基差上限不能大于${maxValue}`);
-                    }
-                    return Promise.resolve();
                 }
+            } else {
+                return Promise.reject('请输入基差');
             }
         } else {
-            return Promise.reject('没有商品合约');
+            return Promise.reject('没有合约商品');
         }
     }
 
@@ -83,7 +84,7 @@ export function handleForm(data: WrHoldLB) {
         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, validator: v_move, trigger: 'blur', type: 'number', }],
+        PriceMove: [{ required: true, validator: v_basis, trigger: 'blur', type: 'number', }],
         goodsid: [{ required: true, validator: v_group, }],
     }
     Object.assign(rules, rule)