Memory_LG 1 tydzień temu
rodzic
commit
f09a80dd5a

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

@@ -8,38 +8,39 @@
         <form class="form-horizontal m" id="form-voucher-add">
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">代金券名称:</label>
+                    <label class="col-sm-3 control-label is-required">代金券类型:</label>
                     <div class="col-sm-8">
-                        <input name="voucherName" class="form-control" type="text" required>
+                        <select name="voucherType" class="form-control" th:with="type=${@dict.getType('voucher_type')}">
+                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
+                        </select>
                     </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">代金券金额:</label>
+                    <label class="col-sm-3 control-label is-required">代金券名称:</label>
                     <div class="col-sm-8">
-                        <input name="voucherPrice" class="form-control" type="text" required>
+                        <input name="voucherName" class="form-control" type="text" required>
                     </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">代金券类型:</label>
+                    <label class="col-sm-3 control-label is-required">门槛金额:</label>
                     <div class="col-sm-8">
-                        <select name="voucherType" class="form-control" th:with="type=${@dict.getType('voucher_type')}">
-                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
-                        </select>
+                        <input name="instantDiscount" class="form-control" type="text" required>
                     </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">满多少元立减:</label>
+                    <label class="col-sm-3 control-label is-required">代金券金额:</label>
                     <div class="col-sm-8">
-                        <input name="instantDiscount" class="form-control" type="text" required>
+                        <input name="voucherPrice" class="form-control" type="text" required>
                     </div>
                 </div>
             </div>
+
         </form>
     </div>
     <th:block th:include="include :: footer" />
@@ -81,7 +82,6 @@
 
         function submitHandler() {
             if ($.validate.form()) {
-                //提交之前增加校验, voucherPrice !>instantDiscount
                 // 提交之前增加校验: 代金券金额不能大于门槛金额
                 var voucherPrice = parseInt($("input[name='voucherPrice']").val());
                 var instantDiscount = parseInt($("input[name='instantDiscount']").val());

+ 30 - 11
qmjszx-admin/src/main/resources/templates/voucher/edit.html

@@ -9,38 +9,41 @@
             <input name="id" th:field="*{id}" type="hidden">
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">代金券名称:</label>
+                    <label class="col-sm-3 control-label is-required">代金券类型:</label>
                     <div class="col-sm-8">
-                        <input name="voucherName" th:field="*{voucherName}" class="form-control" type="text" required>
+                        <select name="voucherType" class="form-control" th:with="type=${@dict.getType('voucher_type')}" required>
+                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{voucherType}"></option>
+                        </select>
                     </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">代金券金额:</label>
+                    <label class="col-sm-3 control-label is-required">代金券名称:</label>
                     <div class="col-sm-8">
-                        <input name="voucherPrice" th:field="*{voucherPrice}" class="form-control" type="text" required>
+                        <input name="voucherName" th:field="*{voucherName}" class="form-control" type="text" required>
                     </div>
                 </div>
             </div>
+
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">代金券类型:</label>
+                    <label class="col-sm-3 control-label is-required">门槛金额:</label>
                     <div class="col-sm-8">
-                        <select name="voucherType" class="form-control" th:with="type=${@dict.getType('voucher_type')}" required>
-                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{voucherType}"></option>
-                        </select>
+                        <input name="instantDiscount" class="form-control" type="text" required>
                     </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">满多少元立减:</label>
+                    <label class="col-sm-3 control-label is-required">代金券金额:</label>
                     <div class="col-sm-8">
-                        <input name="instantDiscount" th:field="*{instantDiscount}" class="form-control" type="text" required>
+                        <input name="voucherPrice" th:field="*{voucherPrice}" class="form-control" type="text" required>
                     </div>
                 </div>
             </div>
+
+
         </form>
     </div>
     <th:block th:include="include :: footer" />
@@ -61,7 +64,9 @@
                     required:true
                 },
                 instantDiscount:{
-                    double:true
+                    required: true, // 必填
+                    digits: true, // 必须为整数
+                    min: 1 // 最小值为1,确保为正整数
                 },
             },
             messages: {
@@ -69,12 +74,26 @@
                     required: "代金券金额不能为空",
                     digits: "代金券金额必须为整数",
                     min: "代金券金额必须大于0"
+                },
+                instantDiscount: {
+                    required: "门槛金额不能为空",
+                    digits: "门槛金额必须为整数",
+                    min: "门槛金额必须大于0"
                 }
             }
         });
 
         function submitHandler() {
             if ($.validate.form()) {
+                // 提交之前增加校验: 代金券金额不能大于门槛金额
+                var voucherPrice = parseInt($("input[name='voucherPrice']").val());
+                var instantDiscount = parseInt($("input[name='instantDiscount']").val());
+
+                if (voucherPrice > instantDiscount) {
+                    $.modal.alertWarning("代金券金额不能大于门槛金额");
+                    return false;
+                }
+
                 $.operate.save(prefix + "/edit", $('#form-voucher-edit').serialize());
             }
         }