cmSvipCouponForm.jsp 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  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. <style>
  9. .coupon-wrap {
  10. border: 1px solid #aaa;
  11. padding: 20px 20px 0;
  12. margin-bottom: 20px;
  13. }
  14. .couponType {
  15. margin-right: 15px;
  16. }
  17. </style>
  18. <script type="text/javascript">
  19. $(document).ready(function () {
  20. var dateList = [];
  21. if (${not empty useDateList}) {
  22. <c:forEach items="${useDateList}" var="date" varStatus="index">
  23. dateList.push("${date}");
  24. </c:forEach>
  25. }
  26. $("#inputForm").validate({
  27. submitHandler: function (form) {
  28. if (imageList1.length > 0) {
  29. var productInfo1 = JSON.stringify(imageList1);
  30. $('#productInfo1').val(productInfo1);
  31. }
  32. if (imageList2.length > 0) {
  33. var productInfo2 = JSON.stringify(imageList2);
  34. $('#productInfo2').val(productInfo2);
  35. }
  36. if (imageList3.length > 0) {
  37. var productInfo3 = JSON.stringify(imageList3);
  38. $('#productInfo3').val(productInfo3);
  39. }
  40. if (imageList4.length > 0) {
  41. var productInfo4 = JSON.stringify(imageList4);
  42. $('#productInfo4').val(productInfo4);
  43. }
  44. var couponType1 = $("#couponType1").val();
  45. var shopId1 = $("#shopId1").val();
  46. if (couponType1 == 3) {
  47. if (shopId1 == "" || shopId1 == null) {
  48. alert("店铺券供应商不能为空 !");
  49. return false;
  50. }
  51. }
  52. var month = $("#month").val();
  53. // 判断月份 ...
  54. if (month == null || month == "") {
  55. alert("请选择生效时间! ");
  56. return false;
  57. }
  58. var endMonth = $("#endMonth").val();
  59. if (endMonth < month) {
  60. $.jBox.alert('优惠月份设置错误','提示');
  61. return false;
  62. }
  63. var vipId = $("#id").val();
  64. if (!vipId && dateList.indexOf(month)>=0){
  65. alert("已存在该月优惠券,请修改月份!");
  66. return false;
  67. }
  68. var couponAmount1 = $("#couponAmount1").val() * 1;
  69. var touchPrice1 = $("#touchPrice1").val() * 1;
  70. if (couponAmount1 == "") {
  71. alertx("【优惠券1】优惠券金额不能为空");
  72. return false;
  73. }
  74. if (touchPrice1 == "") {
  75. alertx("【优惠券1】优惠条件不能为空");
  76. return false;
  77. }
  78. if (couponAmount1 >= touchPrice1) {
  79. alertx("【优惠券1】优惠券金额必须小于优惠条件金额");
  80. return false;
  81. }
  82. var couponAmount2 = $("#couponAmount2").val() * 1;
  83. var touchPrice2 = $("#touchPrice2").val() * 1;
  84. if (couponAmount2 == "") {
  85. alertx("【优惠券2】优惠券金额不能为空");
  86. return false;
  87. }
  88. if (touchPrice2 == "") {
  89. alertx("【优惠券2】优惠条件不能为空");
  90. return false;
  91. }
  92. if (couponAmount2 >= touchPrice2) {
  93. alertx("【优惠券2】优惠券金额必须小于优惠条件金额");
  94. return false;
  95. }
  96. var couponAmount3 = $("#couponAmount3").val() * 1;
  97. var touchPrice3 = $("#touchPrice3").val() * 1;
  98. if (couponAmount3 == "") {
  99. alertx("【优惠券3】优惠券金额不能为空");
  100. return false;
  101. }
  102. if (touchPrice3 == "") {
  103. alertx("【优惠券3】优惠条件不能为空");
  104. return false;
  105. }
  106. if (couponAmount3 >= touchPrice3) {
  107. alertx("【优惠券3】优惠券金额必须小于优惠条件金额");
  108. return false;
  109. }
  110. var couponAmount4 = $("#couponAmount4").val() * 1;
  111. var touchPrice4 = $("#touchPrice4").val() * 1;
  112. if (couponAmount4 == "") {
  113. alertx("【优惠券4】优惠券金额不能为空");
  114. return false;
  115. }
  116. if (touchPrice4 == "") {
  117. alertx("【优惠券4】优惠条件不能为空");
  118. return false;
  119. }
  120. if (couponAmount4 >= touchPrice4) {
  121. alertx("【优惠券4】优惠券金额必须小于优惠条件金额");
  122. return false;
  123. }
  124. loading('正在提交,请稍等...');
  125. form.submit();
  126. },
  127. errorContainer: "#messageBox",
  128. errorPlacement: function (error, element) {
  129. $("#messageBox").text("输入有误,请先更正。");
  130. if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
  131. error.appendTo(element.parent().parent());
  132. } else {
  133. error.insertAfter(element);
  134. }
  135. }
  136. });
  137. });
  138. </script>
  139. </head>
  140. <body>
  141. <ul class="nav nav-tabs">
  142. <li><a href="${ctx}/vip/cmCoupon/">超级会员专属优惠券</a></li>
  143. <li class="active"><a href="${ctx}/vip/cmCoupon/form?id=${cmVipCoupon.id}&endTime=${cmVipCoupon.endTime}">${not empty cmVipCoupon.id?'编辑':'添加'}</a>
  144. </li>
  145. </ul><br>
  146. <form:form id="inputForm" modelAttribute="svipcouponForm" action="${ctx}/vip/cmCoupon/save" method="post" class="form-horizontal">
  147. <sys:message content="${message}"/>
  148. <form:hidden path="id" value="${cmVipCoupon.id}"/>
  149. <div class="control-group">
  150. <label class="control-label"><font color="red">*</font>优惠月份:</label>
  151. <div class="controls">
  152. <form:input path="month" type="text" maxlength="20" class="input-medium Wdate" value="${useTime}"
  153. onclick="WdatePicker({dateFmt:'yyyy-MM',isShowClear:false});"/>&nbsp;&nbsp; —— &nbsp;&nbsp;
  154. <form:input path="endMonth" type="text" maxlength="20" class="input-medium Wdate" value="${endMonth}" disabled="true"
  155. onclick="WdatePicker({dateFmt:'yyyy-MM',isShowClear:false});"/>
  156. </div>
  157. </div>
  158. <div class="coupon-wrap" id="couponWrap1">
  159. <div class="control-group">
  160. <label class="control-label"><font color="red">*</font><b>优惠券1:</b></label>
  161. <div class="controls">
  162. <form:radiobutton path="couponType1" class="couponType" label="请选择" value="" checked="true"></form:radiobutton>
  163. <form:radiobutton path="couponType1" class="couponType" label="活动券" value="0"></form:radiobutton>
  164. <form:radiobutton path="couponType1" class="couponType" label="品类券" value="1" onclick="cType(1)"></form:radiobutton>
  165. <form:radiobutton path="couponType1" class="couponType" label="店铺券" value="3" onclick="cType(1)"></form:radiobutton>
  166. </div>
  167. </div>
  168. <form:hidden path="couponId1" id="couponId1"/>
  169. <div class="control-group coupon-line l0" ${svipcouponForm.couponType1 ne '3' ? 'style="display:none"':''}>
  170. <label class="control-label"><font color="red">*</font>供应商:</label>
  171. <div class="controls">
  172. <a href="javascript:void(0);" onclick="showSelectShop(1)" id="chooseShop1">请选择供应商</a>
  173. <form:hidden path="shopId1" id="shopId1"/>
  174. <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
  175. <thead></thead>
  176. <tbody class="hotSearchShop"></tbody>
  177. </table>
  178. </div>
  179. </div>
  180. <div class="control-group coupon-line l1" ${empty svipcouponForm.couponId1 ? 'style="display:none"':''}>
  181. <label class="control-label"><font color="red">*</font>优惠券金额:</label>
  182. <div class="controls">
  183. <form:input path="couponAmount1" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
  184. </div>
  185. </div>
  186. <div class="control-group coupon-line l2" ${empty svipcouponForm.couponId1 ? 'style="display:none"':''}>
  187. <label class="control-label"><font color="red">*</font>优惠条件:</label>
  188. <div class="controls"> 订单商品总额满
  189. <form:input path="touchPrice1" htmlEscape="false" maxlength="20" class="input-medium required"/>
  190. </div>
  191. </div>
  192. <div class="control-group coupon-line l3" ${svipcouponForm.couponType1 ne '1' ? 'style="display:none"':''}>
  193. <label class="control-label"><font color="red">*</font>优惠品类:</label>
  194. <div class="controls">
  195. <form:radiobutton path="categoryType1" value="1" label="产品"/>
  196. <form:radiobutton path="categoryType1" value="2" label="仪器"/>
  197. </div>
  198. </div>
  199. <div class="control-group coupon-line l4" ${svipcouponForm.couponType1 ne '0' ? 'style="display:none"':''}>
  200. <label class="control-label"><font color="red">*</font>优惠商品:</label>
  201. <div class="controls">
  202. <form:radiobutton path="productType1" value="1" label="全商城商品" onclick="productShow(value,1)"/>
  203. <form:radiobutton path="productType1" value="2" label="指定商品" onclick="productShow(value,1)"/>
  204. </div>
  205. </div>
  206. <div class="productData1" hidden="hidden">
  207. <form:hidden path="productInfo1" id="productInfo1"/>
  208. <div class="control-group">
  209. <input class="btn del" style="width: 50px" onclick="batchDeletion(1)" value="删除"/>
  210. <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(1)" value="添加"/>
  211. <br><br>
  212. <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
  213. <thead></thead>
  214. <tbody class="hotSearchProduct"></tbody>
  215. </table>
  216. </div>
  217. </div>
  218. </div>
  219. <div class="coupon-wrap" id="couponWrap2">
  220. <div class="control-group">
  221. <label class="control-label"><font color="red">*</font><b>优惠券2:</b></label>
  222. <div class="controls">
  223. <form:radiobutton path="couponType2" class="couponType" label="请选择" value="" checked="true"></form:radiobutton>
  224. <form:radiobutton path="couponType2" class="couponType" label="活动券" value="0"></form:radiobutton>
  225. <form:radiobutton path="couponType2" class="couponType" label="品类券" value="1" onclick="cType(2)"></form:radiobutton>
  226. <form:radiobutton path="couponType2" class="couponType" label="店铺券" value="3" onclick="cType(2)"></form:radiobutton>
  227. </div>
  228. </div>
  229. <form:hidden path="couponId2" id="couponId2"/>
  230. <div class="control-group coupon-line l0" ${svipcouponForm.couponType2 ne '3' ? 'style="display:none"':''}>
  231. <label class="control-label"><font color="red">*</font>供应商:</label>
  232. <div class="controls">
  233. <a href="javascript:void(0);" onclick="showSelectShop(2)" id="chooseShop2">请选择供应商</a>
  234. <form:hidden path="shopId2" id="shopId2"/>
  235. <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
  236. <thead></thead>
  237. <tbody class="hotSearchShop"></tbody>
  238. </table>
  239. </div>
  240. </div>
  241. <div class="control-group coupon-line l1" ${empty svipcouponForm.couponId2 ? 'style="display:none"':''}>
  242. <label class="control-label"><font color="red">*</font>优惠券金额:</label>
  243. <div class="controls">
  244. <form:input path="couponAmount2" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
  245. </div>
  246. </div>
  247. <div class="control-group coupon-line l2" ${empty svipcouponForm.couponId2 ? 'style="display:none"':''}>
  248. <label class="control-label"><font color="red">*</font>优惠条件:</label>
  249. <div class="controls"> 订单商品总额满
  250. <form:input path="touchPrice2" htmlEscape="false" maxlength="20" class="input-medium required"/>
  251. </div>
  252. </div>
  253. <div class="control-group coupon-line l3" ${svipcouponForm.couponType2 ne '1' ? 'style="display:none"':''}>
  254. <label class="control-label"><font color="red">*</font>优惠品类:</label>
  255. <div class="controls">
  256. <form:radiobutton path="categoryType2" value="1" label="产品"/>
  257. <form:radiobutton path="categoryType2" value="2" label="仪器"/>
  258. </div>
  259. </div>
  260. <div class="control-group coupon-line l4" ${svipcouponForm.couponType2 ne '0' ? 'style="display:none"':''}>
  261. <label class="control-label"><font color="red">*</font>优惠商品:</label>
  262. <div class="controls">
  263. <form:radiobutton path="productType2" value="1" label="全商城商品" onclick="productShow(value,2)"/>
  264. <form:radiobutton path="productType2" value="2" label="指定商品" onclick="productShow(value,2)"/>
  265. </div>
  266. </div>
  267. <div class="productData2" hidden="hidden">
  268. <form:hidden path="productInfo2" id="productInfo2"/>
  269. <div class="control-group">
  270. <input class="btn del" style="width: 50px" onclick="batchDeletion(2)" value="删除"/>
  271. <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(2)" value="添加"/>
  272. <br><br>
  273. <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
  274. <thead></thead>
  275. <tbody class="hotSearchProduct"></tbody>
  276. </table>
  277. </div>
  278. </div>
  279. </div>
  280. <div class="coupon-wrap" id="couponWrap3">
  281. <div class="control-group">
  282. <label class="control-label"><font color="red">*</font><b>优惠券3:</b></label>
  283. <div class="controls">
  284. <form:radiobutton path="couponType3" class="couponType" label="请选择" value="" checked="true"></form:radiobutton>
  285. <form:radiobutton path="couponType3" class="couponType" label="活动券" value="0"></form:radiobutton>
  286. <form:radiobutton path="couponType3" class="couponType" label="品类券" value="1" onclick="cType(3)"></form:radiobutton>
  287. <form:radiobutton path="couponType3" class="couponType" label="店铺券" value="3" onclick="cType(3)"></form:radiobutton>
  288. </div>
  289. </div>
  290. <form:hidden path="couponId3" id="couponId3"/>
  291. <div class="control-group coupon-line l0" ${svipcouponForm.couponType3 ne '3' ? 'style="display:none"':''}>
  292. <label class="control-label"><font color="red">*</font>供应商:</label>
  293. <div class="controls">
  294. <a href="javascript:void(0);" onclick="showSelectShop(3)" id="chooseShop3">请选择供应商</a>
  295. <form:hidden path="shopId3" id="shopId3"/>
  296. <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
  297. <thead></thead>
  298. <tbody class="hotSearchShop"></tbody>
  299. </table>
  300. </div>
  301. </div>
  302. <div class="control-group coupon-line l1" ${empty svipcouponForm.couponId3 ? 'style="display:none"':''}>
  303. <label class="control-label"><font color="red">*</font>优惠券金额:</label>
  304. <div class="controls">
  305. <form:input path="couponAmount3" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
  306. </div>
  307. </div>
  308. <div class="control-group coupon-line l2" ${empty svipcouponForm.couponId3 ? 'style="display:none"':''}>
  309. <label class="control-label"><font color="red">*</font>优惠条件:</label>
  310. <div class="controls"> 订单商品总额满
  311. <form:input path="touchPrice3" htmlEscape="false" maxlength="20" class="input-medium required"/>
  312. </div>
  313. </div>
  314. <div class="control-group coupon-line l3" ${svipcouponForm.couponType3 ne '1' ? 'style="display:none"':''}>
  315. <label class="control-label"><font color="red">*</font>优惠品类:</label>
  316. <div class="controls">
  317. <form:radiobutton path="categoryType3" value="1" label="产品"/>
  318. <form:radiobutton path="categoryType3" value="2" label="仪器"/>
  319. </div>
  320. </div>
  321. <div class="control-group coupon-line l4" ${svipcouponForm.couponType3 ne '0' ? 'style="display:none"':''}>
  322. <label class="control-label"><font color="red">*</font>优惠商品:</label>
  323. <div class="controls">
  324. <form:radiobutton path="productType3" value="1" label="全商城商品" onclick="productShow(value,3)"/>
  325. <form:radiobutton path="productType3" value="2" label="指定商品" onclick="productShow(value,3)"/>
  326. </div>
  327. </div>
  328. <div class="productData3" hidden="hidden">
  329. <form:hidden path="productInfo3" id="productInfo3"/>
  330. <div class="control-group">
  331. <input class="btn del" style="width: 50px" onclick="batchDeletion(3)" value="删除"/>
  332. <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(3)" value="添加"/>
  333. <br><br>
  334. <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
  335. <thead></thead>
  336. <tbody class="hotSearchProduct"></tbody>
  337. </table>
  338. </div>
  339. </div>
  340. </div>
  341. <div class="coupon-wrap" id="couponWrap4">
  342. <div class="control-group">
  343. <label class="control-label"><font color="red">*</font><b>优惠券4:</b></label>
  344. <div class="controls">
  345. <form:radiobutton path="couponType4" class="couponType" label="请选择" value="" checked="true"></form:radiobutton>
  346. <form:radiobutton path="couponType4" class="couponType" label="活动券" value="0"></form:radiobutton>
  347. <form:radiobutton path="couponType4" class="couponType" label="品类券" value="1" onclick="cType(1)"></form:radiobutton>
  348. <form:radiobutton path="couponType4" class="couponType" label="店铺券" value="3" onclick="cType(1)"></form:radiobutton>
  349. </div>
  350. </div>
  351. <form:hidden path="couponId4" id="couponId4"/>
  352. <div class="control-group coupon-line l0" ${svipcouponForm.couponType4 ne '3' ? 'style="display:none"':''}>
  353. <label class="control-label"><font color="red">*</font>供应商:</label>
  354. <div class="controls">
  355. <a href="javascript:void(0);" onclick="showSelectShop(4)" id="chooseShop4">请选择供应商</a>
  356. <form:hidden path="shopId4" id="shopId4"/>
  357. <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
  358. <thead></thead>
  359. <tbody class="hotSearchShop"></tbody>
  360. </table>
  361. </div>
  362. </div>
  363. <div class="control-group coupon-line l1" ${empty svipcouponForm.couponId4 ? 'style="display:none"':''}>
  364. <label class="control-label"><font color="red">*</font>优惠券金额:</label>
  365. <div class="controls">
  366. <form:input path="couponAmount4" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
  367. </div>
  368. </div>
  369. <div class="control-group coupon-line l2" ${empty svipcouponForm.couponId4 ? 'style="display:none"':''}>
  370. <label class="control-label"><font color="red">*</font>优惠条件:</label>
  371. <div class="controls"> 订单商品总额满
  372. <form:input path="touchPrice4" htmlEscape="false" maxlength="20" class="input-medium required"/>
  373. </div>
  374. </div>
  375. <div class="control-group coupon-line l3" ${svipcouponForm.couponType4 ne '1' ? 'style="display:none"':''}>
  376. <label class="control-label"><font color="red">*</font>优惠品类:</label>
  377. <div class="controls">
  378. <form:radiobutton path="categoryType4" value="1" label="产品"/>
  379. <form:radiobutton path="categoryType4" value="2" label="仪器"/>
  380. </div>
  381. </div>
  382. <div class="control-group coupon-line l4" ${svipcouponForm.couponType4 ne '0' ? 'style="display:none"':''}>
  383. <label class="control-label"><font color="red">*</font>优惠商品:</label>
  384. <div class="controls">
  385. <form:radiobutton path="productType4" value="1" label="全商城商品" onclick="productShow(value,4)"/>
  386. <form:radiobutton path="productType4" value="2" label="指定商品" onclick="productShow(value,4)"/>
  387. </div>
  388. </div>
  389. <div class="productData4" hidden="hidden">
  390. <form:hidden path="productInfo4" id="productInfo4"/>
  391. <div class="control-group">
  392. <input class="btn del" style="width: 50px" onclick="batchDeletion(4)" value="删除"/>
  393. <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(4)" value="添加"/>
  394. <br><br>
  395. <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
  396. <thead></thead>
  397. <tbody class="hotSearchProduct"></tbody>
  398. </table>
  399. </div>
  400. </div>
  401. </div>
  402. <div class="form-actions">
  403. <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
  404. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  405. </div>
  406. </form:form>
  407. <script type="text/javascript">
  408. $(".contentTableShop thead").html('<tr><th>供应商名称</th><th>供应商简称</th><th>联系人</th><th>手机号</th><th>操作</th></tr>');
  409. $(".contentTableProduct thead").html('<tr><th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this)"/>全选</th>' +
  410. '<th>商品图片</th><th>商品名称</th><th>供应商</th><th>网站状态</th><th>小程序状态</th><th>排序</th><th>添加时间</th><th>操作</th></tr>');
  411. var productIds1 = '';
  412. var productIds2 = '';
  413. var productIds3 = '';
  414. var productIds4 = '';
  415. var imageList1 = [];
  416. var imageList2 = [];
  417. var imageList3 = [];
  418. var imageList4 = [];
  419. //店铺券供应商回显
  420. if (${not empty svipcouponForm.shop1}) {
  421. var shop = {
  422. "shopId": "${svipcouponForm.shop1.shopID}",
  423. "name": "${svipcouponForm.shop1.name}",
  424. "sname": "${svipcouponForm.shop1.sname}",
  425. "linkMan": "${svipcouponForm.shop1.linkMan}",
  426. "contractMobile": "${svipcouponForm.shop1.contractMobile}"
  427. }
  428. appendShopOrderHead(shop, 1);
  429. }
  430. if (${not empty svipcouponForm.shop2}) {
  431. var shop = {
  432. "shopId": "${svipcouponForm.shop2.shopID}",
  433. "name": "${svipcouponForm.shop2.name}",
  434. "sname": "${svipcouponForm.shop2.sname}",
  435. "linkMan": "${svipcouponForm.shop2.linkMan}",
  436. "contractMobile": "${svipcouponForm.shop2.contractMobile}"
  437. }
  438. appendShopOrderHead(shop, 2);
  439. }
  440. if (${not empty svipcouponForm.shop3}) {
  441. var shop = {
  442. "shopId": "${svipcouponForm.shop3.shopID}",
  443. "name": "${svipcouponForm.shop3.name}",
  444. "sname": "${svipcouponForm.shop3.sname}",
  445. "linkMan": "${svipcouponForm.shop3.linkMan}",
  446. "contractMobile": "${svipcouponForm.shop3.contractMobile}"
  447. }
  448. appendShopOrderHead(shop, 3);
  449. }
  450. if (${not empty svipcouponForm.shop4}) {
  451. var shop = {
  452. "shopId": "${svipcouponForm.shop4.shopID}",
  453. "name": "${svipcouponForm.shop4.name}",
  454. "sname": "${svipcouponForm.shop4.sname}",
  455. "linkMan": "${svipcouponForm.shop4.linkMan}",
  456. "contractMobile": "${svipcouponForm.shop4.contractMobile}"
  457. }
  458. appendShopOrderHead(shop, 4);
  459. }
  460. //产品回显
  461. if (${not empty svipcouponForm.associateList1}) {
  462. <c:forEach items="${svipcouponForm.associateList1}" var="associate" varStatus="index">
  463. imageList1.push({
  464. id: "${associate.id}",
  465. productId: "${empty associate.productId ? "":associate.productId}",
  466. image: "${associate.image}",
  467. productName: "${associate.productName}",
  468. shopName: "${associate.shopName}",
  469. sort: "${associate.sort}",
  470. pcStatus: "${associate.pcStatus}",
  471. appletsStatus: "${associate.appletsStatus}",
  472. addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
  473. });
  474. </c:forEach>
  475. if (imageList1.length > 0) {
  476. $('#couponWrap1').find('.contentTableProduct').show();
  477. batchSaveSort(1);
  478. productShow(2,1);
  479. }
  480. }
  481. if (${not empty svipcouponForm.associateList2}) {
  482. <c:forEach items="${svipcouponForm.associateList2}" var="associate" varStatus="index">
  483. imageList2.push({
  484. id: "${associate.id}",
  485. productId: "${empty associate.productId ? "":associate.productId}",
  486. image: "${associate.image}",
  487. productName: "${associate.productName}",
  488. shopName: "${associate.shopName}",
  489. sort: "${associate.sort}",
  490. pcStatus: "${associate.pcStatus}",
  491. appletsStatus: "${associate.appletsStatus}",
  492. addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
  493. });
  494. </c:forEach>
  495. if (imageList2.length > 0) {
  496. $('#couponWrap2').find('.contentTableProduct').show();
  497. batchSaveSort(2);
  498. productShow(2,2);
  499. }
  500. }
  501. if (${not empty svipcouponForm.associateList3}) {
  502. <c:forEach items="${svipcouponForm.associateList3}" var="associate" varStatus="index">
  503. imageList3.push({
  504. id: "${associate.id}",
  505. productId: "${empty associate.productId ? "":associate.productId}",
  506. image: "${associate.image}",
  507. productName: "${associate.productName}",
  508. shopName: "${associate.shopName}",
  509. sort: "${associate.sort}",
  510. pcStatus: "${associate.pcStatus}",
  511. appletsStatus: "${associate.appletsStatus}",
  512. addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
  513. });
  514. </c:forEach>
  515. if (imageList3.length > 0) {
  516. $('#couponWrap3').find('.contentTableProduct').show();
  517. batchSaveSort(3);
  518. productShow(2,3);
  519. }
  520. }
  521. if (${not empty svipcouponForm.associateList4}) {
  522. <c:forEach items="${svipcouponForm.associateList4}" var="associate" varStatus="index">
  523. imageList4.push({
  524. id: "${associate.id}",
  525. productId: "${empty associate.productId ? "":associate.productId}",
  526. image: "${associate.image}",
  527. productName: "${associate.productName}",
  528. shopName: "${associate.shopName}",
  529. sort: "${associate.sort}",
  530. pcStatus: "${associate.pcStatus}",
  531. appletsStatus: "${associate.appletsStatus}",
  532. addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
  533. });
  534. </c:forEach>
  535. if (imageList4.length > 0) {
  536. $('#couponWrap4').find('.contentTableProduct').show();
  537. batchSaveSort(4);
  538. productShow(2,4);
  539. }
  540. }
  541. $("body").on("change", ".couponType", function () {
  542. var value = $(this).parent().find('input.couponType:checked').val() * 1;
  543. $(this).parents(".coupon-wrap").find(".coupon-line").hide();
  544. if (0 === value) {
  545. $(this).parents(".coupon-wrap").find(".coupon-line.l1").show();
  546. $(this).parents(".coupon-wrap").find(".coupon-line.l2").show();
  547. $(this).parents(".coupon-wrap").find(".coupon-line.l4").show();
  548. } else if (1 === value) {
  549. $(this).parents(".coupon-wrap").find(".coupon-line.l1").show();
  550. $(this).parents(".coupon-wrap").find(".coupon-line.l2").show();
  551. $(this).parents(".coupon-wrap").find(".coupon-line.l3").show();
  552. } else if (3 === value) {
  553. $(this).parents(".coupon-wrap").find(".coupon-line.l0").show();
  554. $(this).parents(".coupon-wrap").find(".coupon-line.l1").show();
  555. $(this).parents(".coupon-wrap").find(".coupon-line.l2").show();
  556. }
  557. });
  558. function cType(id) {
  559. $("#couponWrap" + id).find(".productData" + id).hide();
  560. }
  561. // 点击添加供应商
  562. function showSelectShop(id) {
  563. var url = "${ctx}/coupon/cmCoupon/toAddShop";
  564. var title = '';
  565. title = "选择供应商";
  566. top.$.jBox("iframe:" + url, {
  567. iframeScrolling: 'yes',
  568. width: $(top.document).width() - 400,
  569. height: $(top.document).height() - 160,
  570. persistent: true,
  571. title: title,
  572. buttons: {"确定": '1', "取消": '-1'},
  573. submit: function (v, h, f) {
  574. //确定
  575. var $jboxFrame = top.$('#jbox-iframe');
  576. var $mainFrame = top.$('#mainFrame');
  577. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  578. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  579. console.log(items);
  580. appendShopOrderHead(items, id);
  581. }
  582. return true;
  583. }
  584. });
  585. }
  586. function productShow(value, id) {
  587. if (value == 2) {
  588. $(".productData" + id).show();
  589. } else {
  590. $(".productData" + id).hide();
  591. }
  592. }
  593. //点击添加
  594. function showSelectProduct(id) {
  595. var url = "${ctx}/coupon/cmCoupon/toAddProduct?productIds=";
  596. if (id * 1 === 1) {
  597. url += productIds1;
  598. }
  599. if (id * 1 === 2) {
  600. url += productIds2;
  601. }
  602. if (id * 1 === 3) {
  603. url += productIds3;
  604. }
  605. if (id * 1 === 4) {
  606. url += productIds4;
  607. }
  608. var title = '';
  609. title = "选择商品";
  610. top.$.jBox("iframe:" + url, {
  611. iframeScrolling: 'yes',
  612. width: $(top.document).width() - 400,
  613. height: $(top.document).height() - 160,
  614. persistent: true,
  615. title: title,
  616. buttons: {"确定": '1', "取消": '-1'},
  617. submit: function (v, h, f) {
  618. //确定
  619. var $jboxFrame = top.$('#jbox-iframe');
  620. var $mainFrame = top.$('#mainFrame');
  621. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  622. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  623. console.log(items);
  624. console.log(items[0]);
  625. for (var i = 0; i < items.length; i++) {
  626. console.log(items[i]);
  627. if (id * 1 === 1) {
  628. imageList1.push(items[i]);
  629. }
  630. if (id * 1 === 2) {
  631. imageList2.push(items[i]);
  632. }
  633. if (id * 1 === 3) {
  634. imageList3.push(items[i]);
  635. }
  636. if (id * 1 === 4) {
  637. imageList4.push(items[i]);
  638. }
  639. $("#couponWrap" + id).find(".contentTableProduct").show();
  640. $(".del").removeAttr("disabled");
  641. batchSaveSort(id);
  642. }
  643. ;
  644. }
  645. return true;
  646. }
  647. });
  648. }
  649. //一键排序
  650. function batchSaveSort(id) {
  651. if (id * 1 === 1) {
  652. imageList1.sort(sort);
  653. insertHtmlProduct(imageList1, id);
  654. }
  655. if (id * 1 === 2) {
  656. imageList2.sort(sort);
  657. insertHtmlProduct(imageList2, id);
  658. }
  659. if (id * 1 === 3) {
  660. imageList3.sort(sort);
  661. insertHtmlProduct(imageList3, id);
  662. }
  663. if (id * 1 === 4) {
  664. imageList4.sort(sort);
  665. insertHtmlProduct(imageList4, id);
  666. }
  667. }
  668. //根据sort值 从小到大排序
  669. function sort(a, b) {
  670. return a.sort - b.sort;
  671. }
  672. //相关图片列表数据
  673. function appendProductOrderHead(data, index, id) {
  674. var html = '<tr id ="ai' + index + '">' +
  675. '<td>' +
  676. '<input class="check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
  677. '</td>' +
  678. '<td>' +
  679. '<img src="' + data.image + '" width="60px" border="none" title="启用">' +
  680. '</td>' +
  681. '<td>' +
  682. data.productName +
  683. '</td>' +
  684. '<td>' +
  685. data.shopName +
  686. '</td>' +
  687. '<td>' +
  688. (data.pcStatus == 1 ? (
  689. '<font color="green">已启用</font>' +
  690. '<a href="javascript:void(0);" onclick="updatePcStatus(0,' + index + ',' + id + ');" >' +
  691. '停用</a>'
  692. ) : (
  693. '<font color="red">已停用</font>' +
  694. '<a href="javascript:void(0)" onclick="updatePcStatus(1,' + index + ',' + id + ');">' +
  695. '启用</a>'
  696. )) +
  697. '</td>' +
  698. '<td>' +
  699. (data.appletsStatus == 1 ? (
  700. '<font color="green">已启用</font>' +
  701. '<a href="javascript:void(0);" onclick="updateAppletsStatus(0,' + index + ',' + id + ');" >' +
  702. '停用</a>'
  703. ) : (
  704. '<font color="red">已停用</font>' +
  705. '<a href="javascript:void(0)" onclick="updateAppletsStatus(1,' + index + ',' + id + ');">' +
  706. '启用</a>'
  707. )) +
  708. '</td>' +
  709. '<td>' +
  710. '<input name="sort" style="width:50px;" value="' + data.sort + '" onkeyup="onlynum(this)" onchange="changeSort(' + index + ',this,' + id + ')"></td>' +
  711. '</td>' +
  712. '<td>' +
  713. (data.addTime == '' ? (
  714. '<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
  715. ) : (
  716. data.addTime
  717. )) +
  718. '</td>' +
  719. '<td>' +
  720. '<a href="javascript:;" onclick="delect(' + index + ',' + id + ')">删除</a>' +
  721. '</td>' +
  722. '</tr>';
  723. return html;
  724. }
  725. function insertHtmlProduct(list, id) {
  726. var html = '';
  727. tempIds = '';
  728. if (list && list.length > 0) {
  729. list.forEach(function (item, index) {
  730. html += appendProductOrderHead(item, index, id);
  731. tempIds += "," + item.productId;
  732. });
  733. }
  734. if (id * 1 === 1) {
  735. productIds1 = tempIds;
  736. }
  737. if (id * 1 === 2) {
  738. productIds2 = tempIds;
  739. }
  740. if (id * 1 === 3) {
  741. productIds3 = tempIds;
  742. }
  743. if (id * 1 === 4) {
  744. productIds4 = tempIds;
  745. }
  746. $("#couponWrap" + id).find(".hotSearchProduct").html(html);
  747. }
  748. function changeSort(index, sortThis, id) {
  749. var sort = sortThis.value;
  750. if (sort > 0) {
  751. var image;
  752. if (id * 1 === 1) {
  753. image = imageList1[index];
  754. }
  755. if (id * 1 === 2) {
  756. image = imageList2[index];
  757. }
  758. if (id * 1 === 3) {
  759. image = imageList3[index];
  760. }
  761. if (id * 1 === 4) {
  762. image = imageList4[index];
  763. }
  764. if (image) {
  765. image.sort = sort;
  766. }
  767. }
  768. }
  769. function updatePcStatus(status, index, id) {
  770. var image;
  771. if (id * 1 === 1) {
  772. image = imageList1[index];
  773. }
  774. if (id * 1 === 2) {
  775. image = imageList2[index];
  776. }
  777. if (id * 1 === 3) {
  778. image = imageList3[index];
  779. }
  780. if (id * 1 === 4) {
  781. image = imageList4[index];
  782. }
  783. if (image) {
  784. confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
  785. image.pcStatus = status;
  786. batchSaveSort(id);
  787. });
  788. }
  789. }
  790. function updateAppletsStatus(status, index, id) {
  791. var image;
  792. if (id * 1 === 1) {
  793. image = imageList1[index];
  794. }
  795. if (id * 1 === 2) {
  796. image = imageList2[index];
  797. }
  798. if (id * 1 === 3) {
  799. image = imageList3[index];
  800. }
  801. if (id * 1 === 4) {
  802. image = imageList4[index];
  803. }
  804. if (image) {
  805. confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
  806. image.appletsStatus = status;
  807. batchSaveSort(id);
  808. });
  809. }
  810. }
  811. /**
  812. * 批量删除
  813. */
  814. function batchDeletion(id) {
  815. var index = -1;
  816. var i = 1;
  817. return confirmx("确定删除吗?", function () {
  818. $('input[name="info"]:checked').each(function () {
  819. var thisIndex = $(this).val();
  820. if (index >= 0 && index < thisIndex) {
  821. thisIndex = thisIndex - i;
  822. i++;
  823. } else {
  824. index = thisIndex;
  825. }
  826. var image, tempList;
  827. if (id * 1 === 1) {
  828. image = imageList1[index];
  829. if (image.productId != '') {
  830. productIds1 = productIds1.replace(image.productId, "");
  831. }
  832. imageList1.splice(thisIndex, 1);
  833. tempList = imageList1;
  834. }
  835. if (id * 1 === 2) {
  836. image = imageList2[index];
  837. if (image.productId != '') {
  838. productIds2 = productIds2.replace(image.productId, "");
  839. }
  840. imageList2.splice(thisIndex, 1);
  841. tempList = imageList2;
  842. }
  843. if (id * 1 === 3) {
  844. image = imageList3[index];
  845. if (image.productId != '') {
  846. productIds3 = productIds3.replace(image.productId, "");
  847. }
  848. imageList3.splice(thisIndex, 1);
  849. tempList = imageList3;
  850. }
  851. if (id * 1 === 4) {
  852. image = imageList4[index];
  853. if (image.productId != '') {
  854. productIds4 = productIds4.replace(image.productId, "");
  855. }
  856. imageList4.splice(thisIndex, 1);
  857. tempList = imageList4;
  858. }
  859. insertHtmlProduct(tempList, id);
  860. if (tempList.length == 0) {
  861. $("#couponWrap" + id).find('.contentTableProduct').hide();
  862. $(".del").attr("disabled", "disabled");
  863. }
  864. });
  865. });
  866. }
  867. function appendShopOrderHead(data, id) {
  868. var html = '<tr>' +
  869. '<td>' +
  870. data.name +
  871. '</td>' +
  872. '<td>' +
  873. data.sname +
  874. '</td>' +
  875. '<td>' +
  876. data.linkMan +
  877. '</td>' +
  878. '<td>' +
  879. data.contractMobile +
  880. '</td>' +
  881. '<td>' +
  882. '<a href="javascript:;" onclick="delectShop(' + id + ')">删除</a>' +
  883. '</td>' +
  884. '</tr>';
  885. $("#couponWrap" + id).find(".hotSearchShop").html(html);
  886. $("#chooseShop" + id).hide();
  887. $("#couponWrap" + id).find(".contentTableShop").show();
  888. $("#shopId" + id).val(data.shopId);
  889. }
  890. function delectShop(id) {
  891. return confirmx("确定删除吗?", function () {
  892. $("#chooseShop" + id).show();
  893. $("#couponWrap" + id).find(".contentTableShop").hide();
  894. $("#shopId" + id).val("");
  895. });
  896. }
  897. /**
  898. * 删除操作
  899. */
  900. function delect(index, id) {
  901. return confirmx("确定删除吗?", function () {
  902. var image;
  903. if (id * 1 === 1) {
  904. image = imageList1[index];
  905. if (image.productId != '') {
  906. productIds1 = productIds1.replace(image.productId, "");
  907. }
  908. imageList1.splice(index, 1);
  909. insertHtmlProduct(imageList1, id);
  910. if (imageList1.length == 0) {
  911. $("#couponWrap" + id).find('#contentTableProduct').hide();
  912. $(".del").attr("disabled", "disabled");
  913. }
  914. }
  915. if (id * 1 === 2) {
  916. image = imageList2[index];
  917. if (image.productId != '') {
  918. productIds2 = productIds2.replace(image.productId, "");
  919. }
  920. imageList2.splice(index, 1);
  921. insertHtmlProduct(imageList2, id);
  922. if (imageList2.length == 0) {
  923. $("#couponWrap" + id).find('#contentTableProduct').hide();
  924. $(".del").attr("disabled", "disabled");
  925. }
  926. }
  927. if (id * 1 === 3) {
  928. image = imageList3[index];
  929. if (image.productId != '') {
  930. productIds3 = productIds3.replace(image.productId, "");
  931. }
  932. imageList3.splice(index, 1);
  933. insertHtmlProduct(imageList3, id);
  934. if (imageList3.length == 0) {
  935. $("#couponWrap" + id).find('#contentTableProduct').hide();
  936. $(".del").attr("disabled", "disabled");
  937. }
  938. }
  939. if (id * 1 === 4) {
  940. image = imageList4[index];
  941. if (image.productId != '') {
  942. productIds4 = productIds4.replace(image.productId, "");
  943. }
  944. imageList4.splice(index, 1);
  945. insertHtmlProduct(imageList4, id);
  946. if (imageList4.length == 0) {
  947. $("#couponWrap" + id).find('#contentTableProduct').hide();
  948. $(".del").attr("disabled", "disabled");
  949. }
  950. }
  951. });
  952. }
  953. function clickAllSelect(ckb) {
  954. var isChecked = ckb.checked;
  955. $(".check-item").attr('checked', isChecked);
  956. }
  957. /**
  958. * @param obj
  959. * jquery控制input只能输入数字
  960. */
  961. function onlynum(obj) {
  962. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  963. }
  964. </script>
  965. </body>
  966. </html>