| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <!DOCTYPE html>
- <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
- <head>
- <th:block th:include="include :: header('修改代金券')" />
- </head>
- <body class="white-bg">
- <div class="wrapper wrapper-content animated fadeInRight ibox-content">
- <form class="form-horizontal m" id="form-voucher-edit" th:object="${beilvVoucher}">
- <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>
- <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>
- </div>
- </div>
- </div>
- <div class="col-xs-12">
- <div class="form-group">
- <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>
- </div>
- </div>
- </div>
- <div class="col-xs-12">
- <div class="form-group">
- <label class="col-sm-3 control-label is-required">门槛金额:</label>
- <div class="col-sm-8">
- <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>
- <div class="col-sm-8">
- <input name="voucherPrice" th:field="*{voucherPrice}" class="form-control" type="text" required>
- </div>
- </div>
- </div>
- </form>
- </div>
- <th:block th:include="include :: footer" />
- <script th:inline="javascript">
- var prefix = ctx + "voucher";
- $("#form-voucher-edit").validate({
- focusCleanup: true,
- rules:{
- voucherName:{
- required:true
- },
- voucherPrice:{
- required: true, // 必填
- digits: true, // 必须为整数
- min: 1 // 最小值为1,确保为正整数
- },
- voucherType:{
- required:true
- },
- instantDiscount:{
- required: true, // 必填
- digits: true, // 必须为整数
- min: 1 // 最小值为1,确保为正整数
- },
- },
- messages: {
- voucherPrice: {
- 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());
- }
- }
- </script>
- </body>
- </html>
|