edit.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('修改代金券')" />
  5. </head>
  6. <body class="white-bg">
  7. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  8. <form class="form-horizontal m" id="form-voucher-edit" th:object="${beilvVoucher}">
  9. <input name="id" th:field="*{id}" type="hidden">
  10. <div class="col-xs-12">
  11. <div class="form-group">
  12. <label class="col-sm-3 control-label is-required">代金券类型:</label>
  13. <div class="col-sm-8">
  14. <select name="voucherType" class="form-control" th:with="type=${@dict.getType('voucher_type')}" required>
  15. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{voucherType}"></option>
  16. </select>
  17. </div>
  18. </div>
  19. </div>
  20. <div class="col-xs-12">
  21. <div class="form-group">
  22. <label class="col-sm-3 control-label is-required">代金券名称:</label>
  23. <div class="col-sm-8">
  24. <input name="voucherName" th:field="*{voucherName}" class="form-control" type="text" required>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="col-xs-12">
  29. <div class="form-group">
  30. <label class="col-sm-3 control-label is-required">门槛金额:</label>
  31. <div class="col-sm-8">
  32. <input name="instantDiscount" class="form-control" type="text" required>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="col-xs-12">
  37. <div class="form-group">
  38. <label class="col-sm-3 control-label is-required">代金券金额:</label>
  39. <div class="col-sm-8">
  40. <input name="voucherPrice" th:field="*{voucherPrice}" class="form-control" type="text" required>
  41. </div>
  42. </div>
  43. </div>
  44. </form>
  45. </div>
  46. <th:block th:include="include :: footer" />
  47. <script th:inline="javascript">
  48. var prefix = ctx + "voucher";
  49. $("#form-voucher-edit").validate({
  50. focusCleanup: true,
  51. rules:{
  52. voucherName:{
  53. required:true
  54. },
  55. voucherPrice:{
  56. required: true, // 必填
  57. digits: true, // 必须为整数
  58. min: 1 // 最小值为1,确保为正整数
  59. },
  60. voucherType:{
  61. required:true
  62. },
  63. instantDiscount:{
  64. required: true, // 必填
  65. digits: true, // 必须为整数
  66. min: 1 // 最小值为1,确保为正整数
  67. },
  68. },
  69. messages: {
  70. voucherPrice: {
  71. required: "代金券金额不能为空",
  72. digits: "代金券金额必须为整数",
  73. min: "代金券金额必须大于0"
  74. },
  75. instantDiscount: {
  76. required: "门槛金额不能为空",
  77. digits: "门槛金额必须为整数",
  78. min: "门槛金额必须大于0"
  79. }
  80. }
  81. });
  82. function submitHandler() {
  83. if ($.validate.form()) {
  84. // 提交之前增加校验: 代金券金额不能大于门槛金额
  85. var voucherPrice = parseInt($("input[name='voucherPrice']").val());
  86. var instantDiscount = parseInt($("input[name='instantDiscount']").val());
  87. if (voucherPrice > instantDiscount) {
  88. $.modal.alertWarning("代金券金额不能大于门槛金额");
  89. return false;
  90. }
  91. $.operate.save(prefix + "/edit", $('#form-voucher-edit').serialize());
  92. }
  93. }
  94. </script>
  95. </body>
  96. </html>