Prechádzať zdrojové kódy

代金券增加校验

Memory_LG 1 týždeň pred
rodič
commit
f251a30ffa

+ 20 - 3
qmjszx-admin/src/main/resources/templates/voucher/add.html

@@ -56,24 +56,41 @@
                     digits: true, // 必须为整数
                     min: 1 // 最小值为1,确保为正整数
                 },
+                instantDiscount:{
+                    required: true, // 必填
+                    digits: true, // 必须为整数
+                    min: 1 // 最小值为1,确保为正整数
+                },
                 voucherType:{
                     required:true
                 },
-                instantDiscount:{
-                    double:true
-                },
             },
             messages: {
                 voucherPrice: {
                     required: "代金券金额不能为空",
                     digits: "代金券金额必须为整数",
                     min: "代金券金额必须大于0"
+                },
+                instantDiscount: {
+                    required: "门槛金额不能为空",
+                    digits: "门槛金额必须为整数",
+                    min: "门槛金额必须大于0"
                 }
             }
         });
 
         function submitHandler() {
             if ($.validate.form()) {
+                //提交之前增加校验, voucherPrice !>instantDiscount
+                // 提交之前增加校验: 代金券金额不能大于门槛金额
+                var voucherPrice = parseInt($("input[name='voucherPrice']").val());
+                var instantDiscount = parseInt($("input[name='instantDiscount']").val());
+
+                if (voucherPrice > instantDiscount) {
+                    $.modal.alertWarning("代金券金额不能大于门槛金额");
+                    return false;
+                }
+
                 $.operate.save(prefix + "/add", $('#form-voucher-add').serialize());
             }
         }