couponUserExclusiveForm.jsp 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <%@ page import="java.util.Date" %>
  2. <%@ page contentType="text/html;charset=UTF-8" %>
  3. <%@ include file="/WEB-INF/views/include/taglib.jsp" %>
  4. <html>
  5. <head>
  6. <title>优惠券管理</title>
  7. <meta name="decorator" content="default"/>
  8. <script type="text/javascript">
  9. $(document).ready(function () {
  10. //$("#name").focus();
  11. $("#inputForm").validate({
  12. submitHandler: function (form) {
  13. var couponAmount = $("#couponAmount").val();
  14. var touchPrice = $("#touchPrice").val();
  15. if (couponAmount >= touchPrice) {
  16. alertx("优惠券金额必须小于优惠条件金额");
  17. return false;
  18. }
  19. var startDate = $("#startDate").val();
  20. var endDate = $("#endDate").val();
  21. if (startDate >= endDate) {
  22. alertx("结束时间不能早于开始时间");
  23. return false;
  24. }
  25. var userId = $("#userId").val();
  26. if (userId == null || userId == "") {
  27. alertx("请选择机构");
  28. return false;
  29. }
  30. loading('正在提交,请稍等...');
  31. form.submit();
  32. },
  33. errorContainer: "#messageBox",
  34. errorPlacement: function (error, element) {
  35. $("#messageBox").text("输入有误,请先更正。");
  36. if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
  37. error.appendTo(element.parent().parent());
  38. } else {
  39. error.insertAfter(element);
  40. }
  41. }
  42. });
  43. });
  44. </script>
  45. </head>
  46. <body>
  47. <ul class="nav nav-tabs">
  48. <li><a href="${ctx}/coupon/cmCoupon/list?couponType=2">用户专享券</a></li>
  49. <li class="active"><a
  50. href="${ctx}/coupon/cmCoupon/form?couponType=2&id=${cmCoupon.id}">${not empty cmCoupon.id?'编辑':'添加'}</a>
  51. </li>
  52. </ul>
  53. <br/>
  54. <font style="color: red;margin-left: 20px">用户专享券适合在需要给特定客户返利时创建,并且适用于商城全部商品(不包括二手商品)。</font><br><br>
  55. <form:form id="inputForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/save" method="post" class="form-horizontal">
  56. <form:hidden path="id"/>
  57. <form:hidden path="productInfo" id="productInfo"/>
  58. <input type="hidden" name="couponType" value="2"/>
  59. <sys:message content="${message}"/>
  60. <div class="control-group">
  61. <label class="control-label"><font color="red">*</font>机构:</label>
  62. <div class="controls">
  63. <a href="javascript:void(0);" onclick="showSelect()" id="chooseClub">请选择机构</a>
  64. <input type="hidden" name="userId" id="userId" value="${cmCoupon.userId}">
  65. <table id="contentTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
  66. <thead>
  67. <tr>
  68. <th>机构名称</th>
  69. <th>机构简称</th>
  70. <th>联系人</th>
  71. <th>手机号</th>
  72. <th>操作</th>
  73. </tr>
  74. </thead>
  75. <tbody id="hotSearch"></tbody>
  76. </table>
  77. </div>
  78. </div>
  79. <div class="control-group">
  80. <label class="control-label"><font color="red">*</font>优惠券金额:</label>
  81. <div class="controls">
  82. <input type="number" id="couponAmount" name="couponAmount" value="${cmCoupon.couponAmount}" min="0"
  83. required>
  84. </div>
  85. </div>
  86. <div class="control-group">
  87. <label class="control-label"><font color="red">*</font>优惠条件:</label>
  88. <div class="controls">
  89. 订单商品总额满&nbsp;&nbsp;&nbsp;&nbsp;<input type="number" name="touchPrice" id="touchPrice"
  90. value="${cmCoupon.touchPrice}" min="0" required>
  91. </div>
  92. </div>
  93. <div class="control-group">
  94. <label class="control-label"><font color="red">*</font>开始时间:</label>
  95. <div class="controls">
  96. <input name="startDate" id="startDate" type="text" required readonly="readonly" maxlength="20"
  97. class="input-medium Wdate "
  98. value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd 00:00:00"/>"
  99. onclick="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00',isShowClear:false});"/>
  100. </div>
  101. </div>
  102. <div class="control-group">
  103. <label class="control-label"><font color="red">*</font>结束时间:</label>
  104. <div class="controls">
  105. <input name="endDate" id="endDate" type="text" required readonly="readonly" maxlength="20"
  106. class="input-medium Wdate "
  107. value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd 23:59:59"/>"
  108. onclick="WdatePicker({dateFmt:'yyyy-MM-dd 23:59:59',isShowClear:false});"/>
  109. </div>
  110. </div>
  111. <div class="control-group">
  112. <label class="control-label"><font color="red">*</font>优惠状态:</label>
  113. <div class="controls">
  114. <label id="initializeShow">
  115. <c:if test="${empty cmCoupon.status || cmCoupon.status eq 0}">
  116. <font color="#800080">未生效</font>
  117. </c:if>
  118. <c:if test="${cmCoupon.status eq 1}">
  119. <font color="#00CC66">已生效</font>
  120. </c:if>
  121. <c:if test="${cmCoupon.status eq 2}">
  122. <font color="red">已关闭</font>
  123. </c:if>
  124. <c:if test="${cmCoupon.status eq 3}">
  125. <font color="#FF6600">已失效</font>
  126. </c:if>
  127. </label>
  128. <label id="closeShow" style="display: none">
  129. <font color="red">已关闭</font>
  130. </label>
  131. <input type="hidden" id="hiddenStatus" name="status" value="">
  132. <input type="checkbox" id="status" name="status" value="2" ${cmCoupon.status eq "2" ? "checked" : ""}
  133. onclick="statusShow()"/>关闭
  134. </div>
  135. </div>
  136. <c:if test="${not empty cmCoupon.id}">
  137. <div class="control-group">
  138. <label class="control-label">领取状态:</label>
  139. <div class="controls">
  140. </div>
  141. </div>
  142. <div class="control-group">
  143. <label class="control-label">使用状态:</label>
  144. <div class="controls">
  145. </div>
  146. </div>
  147. </c:if>
  148. <div class="form-actions">
  149. <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
  150. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  151. </div>
  152. </form:form>
  153. <script>
  154. $(function () {
  155. if (${not empty cmUser}){
  156. var items = {
  157. "userID": "${cmUser.userID}",
  158. "name": "${cmUser.name}",
  159. "shortName": "${cmUser.shortName}",
  160. "linkMan": "${empty cmUser.userName ? '':cmUser.userName}",
  161. "contractMobile": "${empty cmUser.bindMobile ? '':cmUser.bindMobile}"
  162. };
  163. insertHtml(items);
  164. }
  165. });
  166. function insertHtml(data) {
  167. var html = '<tr>' +
  168. '<td>' +
  169. data.name +
  170. '</td>' +
  171. '<td>' +
  172. data.shortName +
  173. '</td>' +
  174. '<td>' +
  175. data.linkMan +
  176. '</td>' +
  177. '<td>' +
  178. data.contractMobile +
  179. '</td>' +
  180. '<td>' +
  181. '<a href="javascript:;" onclick="deleteClub()">删除</a>' +
  182. '</td>' +
  183. '</tr>';
  184. $("#contentTable").show();
  185. $("#chooseClub").hide();
  186. $("#hotSearch").html(html);
  187. $("#userId").val(data.userID);
  188. }
  189. function deleteClub() {
  190. $("#hotSearch").html("");
  191. $("#contentTable").hide();
  192. $("#chooseClub").show();
  193. $("#userId").val("");
  194. }
  195. function statusShow() {
  196. var status = $("input[name='status']:checked").val();
  197. if (status == 2) {
  198. $("#initializeShow").hide();
  199. $("#closeShow").show();
  200. } else {
  201. $("#initializeShow").show();
  202. $("#closeShow").hide();
  203. $("#hiddenStatus").val(0);
  204. }
  205. }
  206. //点击添加
  207. function showSelect() {
  208. var url = "${ctx}/coupon/cmCoupon/toAddClub";
  209. var title = '';
  210. title = "选择机构";
  211. top.$.jBox("iframe:" + url, {
  212. iframeScrolling: 'yes',
  213. width: $(top.document).width() - 400,
  214. height: $(top.document).height() - 160,
  215. persistent: true,
  216. title: title,
  217. buttons: {"确定": '1', "取消": '-1'},
  218. submit: function (v, h, f) {
  219. //确定
  220. var $jboxFrame = top.$('#jbox-iframe');
  221. var $mainFrame = top.$('#mainFrame');
  222. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  223. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  224. console.log(items);
  225. insertHtml(items);
  226. }
  227. return true;
  228. }
  229. });
  230. }
  231. /**
  232. * @param obj
  233. * jquery控制input只能输入数字
  234. */
  235. function onlynum(obj) {
  236. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  237. }
  238. </script>
  239. </body>
  240. </html>