MoneyCouponForm.jsp 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992
  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. $("#inputForm").validate({
  11. submitHandler: function(form){
  12. if (imageList.length > 0) {
  13. var productInfo = JSON.stringify(imageList);
  14. $('#productInfo').val(productInfo);
  15. }
  16. var couponType = $("input[name='couponType']:checked").val();
  17. var productType = $("input[name='productType']:checked").val();
  18. if (couponType == 0 && productType == 2) {
  19. var pcBanner = $('#pcBanner').val();
  20. var appletsBanner = $('#appletsBanner').val();
  21. if (pcBanner == '' || appletsBanner == '') {
  22. alertx("请上传Banner图");
  23. return false;
  24. }
  25. }
  26. var couponAmount = $("#couponAmount").val()*1;
  27. var touchPrice = $("#touchPrice").val()*1;
  28. if (couponAmount >= touchPrice) {
  29. alertx("优惠券金额必须小于优惠条件金额");
  30. return false;
  31. }
  32. var startDate = $("#startDate").val();
  33. var endDate = $("#endDate").val();
  34. if (startDate >= endDate) {
  35. alertx("结束时间不能早于开始时间");
  36. return false;
  37. }
  38. loading('正在提交,请稍等...');
  39. form.submit();
  40. },
  41. errorContainer: "#messageBox",
  42. errorPlacement: function(error, element) {
  43. $("#messageBox").text("输入有误,请先更正。");
  44. if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
  45. error.appendTo(element.parent().parent());
  46. } else {
  47. error.insertAfter(element);
  48. }
  49. }
  50. });
  51. });
  52. </script>
  53. <style>
  54. .iconBox {
  55. font-size: 0;
  56. }
  57. .conList .btn:nth-of-type(1){
  58. margin-left: 25px;
  59. }
  60. .upload-content-image {
  61. margin-top: -70px;
  62. }
  63. .upload-content-image .conList .btn:nth-of-type(1) {
  64. width: 90px;
  65. height: 100px;
  66. border: 2px solid #eee;
  67. background: #fff;
  68. position: relative;
  69. }
  70. .upload-content-image .conList .btn:nth-of-type(1) > div {
  71. position: absolute;
  72. top: 50%;
  73. left: 50%;
  74. transform: translate(-50%, -50%);
  75. color: #666;
  76. }
  77. .upload-content-image .conList .btn:nth-of-type(1) span {
  78. font-size: 35px;
  79. }
  80. .upload-content-image .conList .btn:nth-of-type(1) h5 {
  81. color: #666;
  82. }
  83. .upload-content-image .conList ol li {
  84. width: 114px;
  85. min-height: 80px;
  86. text-align: center;
  87. background: #fff;
  88. position: relative;
  89. top: 120px;
  90. margin-left: 2px;
  91. }
  92. .cancel-upload-image {
  93. background: transparent;
  94. border: none;
  95. box-shadow: none;
  96. position: relative;
  97. top: -38px;
  98. left: -25px;
  99. cursor: pointer;
  100. z-index: 100;
  101. }
  102. .hide-pic-image {
  103. display: none !important;
  104. }
  105. </style>
  106. </head>
  107. <body>
  108. <ul class="nav nav-tabs">
  109. <li><a href="${ctx}/coupon/cmCoupon/list?moneyCouponFlag=1&&couponType=5">价值优惠券列表</a></li>
  110. <li class="active"><a href="${ctx}/coupon/cmCoupon/moneyCouponForm?id=${cmCoupon.id}">${not empty cmCoupon.id?'编辑':'添加'}</a></li>
  111. </ul><br/>
  112. <form:form id="inputForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/moneyCouponSave" method="post" class="form-horizontal">
  113. <form:hidden path="id"/>
  114. <form:hidden path="productInfo" id="productInfo"/>
  115. <sys:message content="${message}"/>
  116. <div class="control-group">
  117. <label class="control-label"><font color="red">*</font>优惠券名称:</label>
  118. <div class="controls">
  119. <form:input path="name" htmlEscape="false" maxlength="30" placeholder="30个汉字以内" class="input-xlarge required"/>
  120. </div>
  121. </div>
  122. <div class="control-group">
  123. <label class="control-label"><font color="red">*</font>优惠券金额:</label>
  124. <div class="controls">
  125. <input type="number" id="couponAmount" name="couponAmount" value="${cmCoupon.couponAmount}" min="0" required>
  126. </div>
  127. </div>
  128. <div class="control-group">
  129. <label class="control-label"><font color="red">*</font>优惠条件:</label>
  130. <div class="controls">
  131. 订单商品总额满&nbsp;&nbsp;&nbsp;&nbsp;<input type="number" name="touchPrice" id="touchPrice" value="${cmCoupon.touchPrice}" min="0" required>
  132. </div>
  133. </div>
  134. <div class="control-group">
  135. <label class="control-label"><font color="red">*</font>购买方式:</label>
  136. <div class="controls">
  137. <form:radiobutton path="couponPayWay" value="1" label="直接购买" class="required"/>
  138. <form:radiobutton path="couponPayWay" value="2" label="采美豆抵扣" class="required"/>
  139. </div>
  140. </div>
  141. <div class="control-group">
  142. <label class="control-label"><font color="red">*</font>购买价格:</label>
  143. <div class="controls">
  144. <input type="number" id="moneyCouponPrice" name="moneyCouponPrice" value="${cmCoupon.moneyCouponPrice}" min="0" required>
  145. </div>
  146. </div>
  147. <div class="control-group">
  148. <label class="control-label"><font color="red">*</font>上架时间:</label>
  149. <div class="controls">
  150. <input name="startDate" id="startDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
  151. value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd 00:00:00"/>"
  152. onclick="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00',isShowClear:false});" onblur="dateShow()"/>
  153. </div>
  154. </div>
  155. <div class="control-group">
  156. <label class="control-label"><font color="red">*</font>下架时间:</label>
  157. <div class="controls">
  158. <input name="endDate" id="endDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
  159. value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd 23:59:59"/>"
  160. onclick="WdatePicker({dateFmt:'yyyy-MM-dd 23:59:59',isShowClear:false});" onblur="dateShow()"/>
  161. </div>
  162. </div>
  163. <div class="control-group" style="display:none;">
  164. <label class="control-label"><font color="red">*</font>状态:</label>
  165. <div class="controls">
  166. <label id="initializeShow">
  167. <c:if test="${empty cmCoupon.status || cmCoupon.status eq 0}">
  168. <font color="#800080">未生效</font>
  169. </c:if>
  170. <c:if test="${cmCoupon.status eq 1}">
  171. <font color="#00CC66">已生效</font>
  172. </c:if>
  173. <c:if test="${cmCoupon.status eq 2}">
  174. <font color="red">已关闭</font>
  175. </c:if>
  176. <c:if test="${cmCoupon.status eq 3}">
  177. <font color="#FF6600">已失效</font>
  178. </c:if>
  179. </label>
  180. <label id="closeShow" style="display: none">
  181. <font color="red">已关闭</font>
  182. </label>
  183. <input type="hidden" id="hiddenStatus" name="status" value="">
  184. <input type="checkbox" id="status" name="status" value="2" ${cmCoupon.status eq "2" ? "checked" : ""}
  185. onclick="statusShow()"/>关闭
  186. </div>
  187. </div>
  188. <div class="control-group">
  189. <label class="control-label"><font color="red">*</font>购买期限:</label>
  190. <div class="controls">
  191. <input type="number" id="receivePeriod" name="receivePeriod" onkeyup="onlynum(this)" value="${cmCoupon.receivePeriod}" min="1" required> 天
  192. <input type="checkbox" id="receiveFlag" name="receiveFlag" style="margin-left:20px !important" value="${cmCoupon.receiveFlag eq 1?1:0}"
  193. ${cmCoupon.receiveFlag eq 1 ? "checked" : ""} onclick="changeCondition('receiveFlag','receivePeriod')" />同上下架时间
  194. <input id="receivePeriodTemp" type="hidden" value="${cmCoupon.receivePeriod}">
  195. </div>
  196. </div>
  197. <div class="control-group">
  198. <label class="control-label"><font color="red">*</font>使用期限:</label>
  199. <div class="controls">
  200. <input type="number" id="usePeriod" name="usePeriod" value="${cmCoupon.usePeriod}" min="1" required> 天
  201. </div>
  202. </div>
  203. <div class="control-group">
  204. <label class="control-label"><font color="red">*</font>优惠券属性:</label>
  205. <div class="controls">
  206. <form:radiobutton path="moneyCouponType" value="1" label="意向券" class="required" onclick="moneyCouponShow()"/>
  207. <form:radiobutton path="moneyCouponType" value="2" label="定向券" class="required" onclick="moneyCouponShow()"/>
  208. </div>
  209. </div>
  210. <div class="control-group" id="yxq">
  211. <label class="control-label"><font color="red">*</font>优惠券类型:</label>
  212. <div class="controls">
  213. <form:radiobutton name="hdq" path="couponType" value="0" label="活动券" class="required" onclick="couponShow()"/>
  214. <form:radiobutton id="plq" path="couponType" value="1" style="display:${cmCoupon.moneyCouponType eq 2 ? 'none':''}" label="品类券" class="required" onclick="couponShow()"/>
  215. <form:radiobutton id="zxq" path="couponType" value="2" style="display:${cmCoupon.moneyCouponType eq 2 ? 'none':''}" label="用户专享券" class="required" onclick="couponShow()"/>
  216. <form:radiobutton id="dpq" path="couponType" value="3" style="display:${cmCoupon.moneyCouponType eq 2 ? 'none':''}" label="店铺券" class="required" onclick="couponShow()"/>
  217. </div>
  218. </div>
  219. <div id="eventVoucher" class="yxq">
  220. <div class="control-group">
  221. <label class="control-label"><font color="red">*</font>优惠商品:</label>
  222. <div class="controls">
  223. <form:radiobutton id="qsc" path="productType" value="1" label="全商城商品" style="display: ${cmCoupon.moneyCouponType eq 2 ? 'none':''}" onclick="productShow()" checked ="${empty cmCoupon.productType ? true:false}" />
  224. <form:radiobutton path="productType" value="2" label="指定商品" onclick="productShow()"/>
  225. </div>
  226. </div>
  227. </div>
  228. <div class="control-group" id="couponCategory" hidden="hidden">
  229. <label class="control-label"><font color="red">*</font>优惠品类:</label>
  230. <div class="controls">
  231. <form:radiobutton path="categoryType" value="1" label="产品" checked ="${empty cmCoupon.categoryType ? true:false}"/>
  232. <form:radiobutton path="categoryType" value="2" label="仪器"/>
  233. </div>
  234. </div>
  235. <div class="control-group" id="couponClub" hidden="hidden">
  236. <label class="control-label"><font color="red">*</font>机构:</label>
  237. <div class="controls">
  238. <a href="javascript:void(0);" onclick="showSelectClub()" id="chooseClub">请选择机构</a>
  239. <input type="hidden" name="userId" id="userId" value="${cmCoupon.userId}">
  240. <table id="contentTableClub" class="table table-striped table-bordered table-condensed" hidden="hidden">
  241. <thead>
  242. <tr>
  243. <th>机构名称</th>
  244. <th>机构简称</th>
  245. <th>联系人</th>
  246. <th>手机号</th>
  247. <th>操作</th>
  248. </tr>
  249. </thead>
  250. <tbody id="hotSearchClub"></tbody>
  251. </table>
  252. </div>
  253. </div>
  254. <div class="control-group" id="couponShop" hidden="hidden">
  255. <label class="control-label"><font color="red">*</font>供应商:</label>
  256. <div class="controls">
  257. <a href="javascript:void(0);" onclick="showSelectShop()" id="chooseShop">请选择供应商</a>
  258. <form:hidden path="shopId" id="shopId"/>
  259. <table id="contentTableShop" class="table table-striped table-bordered table-condensed" hidden="hidden">
  260. <thead>
  261. <tr>
  262. <th>机构名称</th>
  263. <th>机构简称</th>
  264. <th>联系人</th>
  265. <th>手机号</th>
  266. <th>操作</th>
  267. </tr>
  268. </thead>
  269. <tbody id="hotSearchShop"></tbody>
  270. </table>
  271. </div>
  272. </div>
  273. <div class="productData" hidden="hidden">
  274. <div class="control-group">
  275. <label class="control-label"><font color="red">*</font>网站活动页banner:</label>
  276. <div class="controls upload-content-image iconBox">
  277. <div class="conList">
  278. <form:hidden id="pcBanner" path="pcBanner" htmlEscape="false" maxlength="255" class="input-xlarge"/>
  279. <sys:ckfinder input="pcBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  280. <br>
  281. </div>
  282. </div>
  283. </div>
  284. <div class="control-group">
  285. <label class="control-label"><font color="red">*</font>小程序活动页banner:</label>
  286. <div class="controls upload-content-image iconBox">
  287. <div class="conList">
  288. <form:hidden id="appletsBanner" path="appletsBanner" htmlEscape="false" maxlength="255" class="input-xlarge"/>
  289. <sys:ckfinder input="appletsBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  290. <br>
  291. </div>
  292. </div>
  293. </div>
  294. <div class="control-group">
  295. <input class="btn" id="del" style="width: 50px" onclick="batchDeletion()" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
  296. <input class="btn btn-primary" style="width: 70px" onclick="batchSaveSort()" value="一键排序"/>&nbsp;&nbsp;&nbsp;&nbsp;
  297. <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct()" value="添加"/>
  298. <br><br>
  299. <table id="contentTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
  300. <thead>
  301. <tr>
  302. <th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this)"/> 全选
  303. </th>
  304. <th>商品图片</th>
  305. <th>商品名称</th>
  306. <th>供应商</th>
  307. <th>网站状态</th>
  308. <th>小程序状态</th>
  309. <th>排序</th>
  310. <th>添加时间</th>
  311. <th>操作</th>
  312. </tr>
  313. </thead>
  314. <tbody id="hotSearch"></tbody>
  315. </table>
  316. </div>
  317. </div>
  318. <div class="form-actions">
  319. <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
  320. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  321. </div>
  322. </form:form>
  323. <script>
  324. //图片初始化
  325. $(function () {
  326. $('.upload-content-image .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
  327. $('.upload-content-image .conList .btn:nth-of-type(2)').after('<img class="cancel-upload-image" src="/static/images/close-btn1.png">').remove();
  328. $('.upload-content-image .conList').find('.cancel-upload-image').hide();
  329. var observeEleImage = document.getElementsByClassName('upload-content-image')[0];
  330. var observeEleImage1 = document.getElementsByClassName('upload-content-image')[1];
  331. var MutationObserverImage = window.MutationObserver || window.WebKitMutationObserver;
  332. var MutationObserverConfigImage = {
  333. childList: true,
  334. subtree: true,
  335. characterData: true
  336. };
  337. var observerImage = new MutationObserverImage(function (mutations) {
  338. $.each(mutations, function (index, item) {
  339. if (item.type === 'childList') {
  340. // 在创建新的 element 时调用
  341. var target = $(item.target),
  342. thisWrapper = target.closest('.conList'),
  343. nextEle = thisWrapper.next();
  344. thisWrapper.find('li').css('z-index', 99);
  345. thisWrapper.find('.cancel-upload-image').show();
  346. if (nextEle.hasClass('hide-pic-image')) {
  347. nextEle.removeClass('hide-pic-image');
  348. }
  349. }
  350. })
  351. });
  352. observerImage.observe(observeEleImage, MutationObserverConfigImage);
  353. observerImage.observe(observeEleImage1, MutationObserverConfigImage);
  354. $('body').on('click', '.upload-content-image li', function () {
  355. var index = $(this).closest('.conList').index() + 1,
  356. str = 'remarkImage' + index + 'FinderOpen';
  357. eval(str + '()');
  358. });
  359. $('body').on('click', '.cancel-upload-image', function () {
  360. var wrapper = $(this).closest('.conList');
  361. wrapper.find('li').css('z-index', '-1');
  362. wrapper.find('input').val('');
  363. $(this).hide();
  364. wrapper.removeClass("hide-pic-image");
  365. wrapper.parent().append(wrapper.clone());
  366. wrapper.remove();
  367. $(".conList").each(function (i, ele) {
  368. if ($(ele).find("input.input-xlarge").val()) {
  369. $(ele).next().removeClass("hide-pic-image")
  370. }
  371. })
  372. });
  373. $(window).on("load", function () {
  374. setTimeout(function () {
  375. var input = $("#pcBanner");
  376. if (input.val()) {
  377. input.next().find("li").css("z-index", "99");
  378. input.parents(".conList").find(".cancel-upload-image").show();
  379. input.parents(".conList").next().removeClass("hide-pic-image")
  380. }
  381. input = $("#appletsBanner");
  382. if (input.val()) {
  383. input.next().find("li").css("z-index", "99");
  384. input.parents(".conList").find(".cancel-upload-image").show();
  385. input.parents(".conList").next().removeClass("hide-pic-image")
  386. }
  387. }, 500);
  388. });
  389. productShow()
  390. });
  391. var productIds = '';
  392. var imageList = [];
  393. $(function () {
  394. //活动券商品回显
  395. <c:forEach items="${associateList}" var="associate" varStatus="index">
  396. imageList.push({
  397. id: "${associate.id}",
  398. productId: "${empty associate.productId ? "":associate.productId}",
  399. image: "${associate.image}",
  400. productName: "${associate.productName}",
  401. shopName: "${associate.shopName}",
  402. sort: "${associate.sort}",
  403. pcStatus: "${associate.pcStatus}",
  404. appletsStatus: "${associate.appletsStatus}",
  405. addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
  406. });
  407. </c:forEach>
  408. if (imageList.length > 0) {
  409. $('.productData').show();
  410. $('#contentTable').show();
  411. batchSaveSort();
  412. }
  413. if(${cmCoupon.moneyCouponType eq 2}){
  414. document.querySelector('[for="qsc"]').style.display='none';
  415. document.querySelector('[for="zxq"]').style.display='none';
  416. document.querySelector('[for="plq"]').style.display='none';
  417. document.querySelector('[for="dpq"]').style.display='none';
  418. }
  419. //用户专享券机构回显
  420. if (${not empty cmUser}){
  421. var items = {
  422. "userID": "${cmUser.userID}",
  423. "name": "${cmUser.name}",
  424. "shortName": "${cmUser.shortName}",
  425. "linkMan": "${empty cmUser.userName ? '':cmUser.userName}",
  426. "contractMobile": "${empty cmUser.bindMobile ? '':cmUser.bindMobile}"
  427. };
  428. insertHtmlClub(items);
  429. }
  430. //店铺券供应商回显
  431. if (${not empty cmCoupon.shop}) {
  432. var shop = {
  433. "shopId": "${cmCoupon.shop.shopID}",
  434. "name": "${cmCoupon.shop.name}",
  435. "sname": "${cmCoupon.shop.sname}",
  436. "linkMan": "${cmCoupon.shop.linkMan}",
  437. "contractMobile": "${cmCoupon.shop.contractMobile}"
  438. }
  439. appendShopOrderHead(shop);
  440. }
  441. couponShow();
  442. if(${cmCoupon.receiveFlag eq 1}){
  443. $("#receivePeriod").attr('readonly', true);
  444. $("#receivePeriod").attr('required', false);
  445. }
  446. });
  447. //点击添加商品
  448. function showSelectProduct() {
  449. var url = "${ctx}/coupon/cmCoupon/toAddProduct?productIds=" + productIds;
  450. var title = '';
  451. title = "选择商品";
  452. top.$.jBox("iframe:" + url, {
  453. iframeScrolling: 'yes',
  454. width: $(top.document).width() - 400,
  455. height: $(top.document).height() - 160,
  456. persistent: true,
  457. title: title,
  458. buttons: {"确定": '1', "取消": '-1'},
  459. submit: function (v, h, f) {
  460. //确定
  461. var $jboxFrame = top.$('#jbox-iframe');
  462. var $mainFrame = top.$('#mainFrame');
  463. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  464. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  465. console.log(items);
  466. console.log(items[0]);
  467. for (var i = 0; i < items.length; i++) {
  468. console.log(items[i]);
  469. imageList.push(items[i]);
  470. $('#contentTable').show();
  471. $("#del").removeAttr("disabled");
  472. batchSaveSort();
  473. };
  474. }
  475. return true;
  476. }
  477. });
  478. }
  479. /**
  480. * 一键排序
  481. */
  482. function batchSaveSort() {
  483. imageList.sort(sort);
  484. insertHtmlProduct(imageList);
  485. }
  486. //根据sort值 从小到大排序
  487. function sort(a, b) {
  488. return a.sort - b.sort;
  489. }
  490. //相关图片列表数据
  491. function appendProductOrderHead(data, index) {
  492. var html = '<tr id ="ai' + index + '">' +
  493. '<td>' +
  494. '<input class="check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
  495. '</td>' +
  496. '<td>' +
  497. '<img src="' + data.image + '" width="60px" border="none" title="启用">' +
  498. '</td>' +
  499. '<td>' +
  500. data.productName +
  501. '</td>' +
  502. '<td>' +
  503. data.shopName +
  504. '</td>' +
  505. '<td>' +
  506. (data.pcStatus == 1 ? (
  507. '<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
  508. '<a href="javascript:void(0);" onclick="updatePcStatus(0,' + index + ');" >' +
  509. '停用</a>'
  510. ) : (
  511. '<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
  512. '<a href="javascript:void(0)" onclick="updatePcStatus(1,' + index + ');">' +
  513. '启用</a>'
  514. )) +
  515. '</td>' +
  516. '<td>' +
  517. (data.appletsStatus == 1 ? (
  518. '<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
  519. '<a href="javascript:void(0);" onclick="updateAppletsStatus(0,' + index + ');" >' +
  520. '停用</a>'
  521. ) : (
  522. '<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
  523. '<a href="javascript:void(0)" onclick="updateAppletsStatus(1,' + index + ');">' +
  524. '启用</a>'
  525. )) +
  526. '</td>' +
  527. '<td>' +
  528. '<input name="sort" style="width:50px;" value="' + data.sort + '" onkeyup="onlynum(this)" onchange="changeSort(' + index + ',this)"></td>' +
  529. '</td>' +
  530. '<td>' +
  531. (data.addTime == '' ? (
  532. '<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
  533. ) : (
  534. data.addTime
  535. )) +
  536. '</td>' +
  537. '<td>' +
  538. '<a href="javascript:;" onclick="delect(' + index + ')">删除</a>' +
  539. '</td>' +
  540. '</tr>';
  541. return html;
  542. }
  543. function insertHtmlProduct(list) {
  544. var html = '';
  545. productIds = '';
  546. list.forEach(function (item, index) {
  547. html += appendProductOrderHead(item, index);
  548. productIds += "," + item.productId;
  549. });
  550. $("#hotSearch").html(html);
  551. }
  552. function changeSort(index, sortThis) {
  553. var sort = sortThis.value;
  554. if (sort <= 0) {
  555. }
  556. var image = imageList[index];
  557. image.sort = sort;
  558. }
  559. function updatePcStatus(status, index) {
  560. var image = imageList[index];
  561. confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
  562. image.pcStatus = status;
  563. batchSaveSort();
  564. })
  565. }
  566. function updateAppletsStatus(status, index) {
  567. var image = imageList[index];
  568. confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
  569. image.appletsStatus = status;
  570. batchSaveSort();
  571. })
  572. }
  573. function clickAllSelect(ckb) {
  574. var isChecked = ckb.checked;
  575. $(".check-item").attr('checked', isChecked);
  576. }
  577. /**
  578. * 删除操作
  579. */
  580. function delect(index) {
  581. return confirmx("确定删除吗?", function () {
  582. var image = imageList[index];
  583. if (image.productId != '') {
  584. productIds = productIds.replace(image.productId,"");
  585. }
  586. imageList.splice(index, 1);
  587. insertHtmlProduct(imageList);
  588. if (imageList.length == 0) {
  589. $('#contentTable').hide();
  590. $("#del").attr("disabled", "disabled");
  591. }
  592. });
  593. }
  594. /**
  595. * 批量删除
  596. */
  597. function batchDeletion() {
  598. var index = -1;
  599. var i = 1;
  600. return confirmx("确定删除吗?", function () {
  601. $('input[name="info"]:checked').each(function () {
  602. var thisIndex = $(this).val();
  603. if (index >= 0 && index < thisIndex) {
  604. thisIndex = thisIndex - i;
  605. i++;
  606. } else {
  607. index = thisIndex;
  608. }
  609. var image = imageList[thisIndex];
  610. if (image.productId != '') {
  611. productIds = productIds.replace(image.productId, "");
  612. }
  613. imageList.splice(thisIndex, 1);
  614. insertHtmlProduct(imageList);
  615. if (imageList.length == 0) {
  616. $('#contentTable').hide();
  617. $("#del").attr("disabled", "disabled");
  618. }
  619. });
  620. });
  621. }
  622. function productShow() {
  623. var productType = $("input[name='productType']:checked").val();
  624. var moneyCouponType = $("input[name='moneyCouponType']:checked").val();
  625. if(moneyCouponType == 2){
  626. $("#productType1").attr("checked",true);
  627. return;
  628. }
  629. if (productType == 2){
  630. $(".productData").show();
  631. }else {
  632. $(".productData").hide();
  633. }
  634. }
  635. function insertHtmlClub(data) {
  636. var html = '<tr>' +
  637. '<td>' +
  638. data.name +
  639. '</td>' +
  640. '<td>' +
  641. data.shortName +
  642. '</td>' +
  643. '<td>' +
  644. data.linkMan +
  645. '</td>' +
  646. '<td>' +
  647. data.contractMobile +
  648. '</td>' +
  649. '<td>' +
  650. '<a href="javascript:;" onclick="deleteClub()">删除</a>' +
  651. '</td>' +
  652. '</tr>';
  653. $("#contentTableClub").show();
  654. $("#chooseClub").hide();
  655. $("#hotSearchClub").html(html);
  656. $("#userId").val(data.userID);
  657. }
  658. function deleteClub() {
  659. $("#hotSearchClub").html("");
  660. $("#contentTableClub").hide();
  661. $("#chooseClub").show();
  662. $("#userId").val("");
  663. }
  664. function statusShow() {
  665. var status = $("input[name='status']:checked").val();
  666. if (status == 2) {
  667. $("#initializeShow").hide();
  668. $("#closeShow").show();
  669. } else {
  670. $("#initializeShow").show();
  671. $("#closeShow").hide();
  672. $("#hiddenStatus").val(0);
  673. }
  674. }
  675. function dateShow() {
  676. var startDate = $("#startDate").val();
  677. var startMs = new Date(startDate).getTime();
  678. var endDate = $("#endDate").val();
  679. var endMs = new Date(endDate).getTime();
  680. var nowMs = new Date().getTime();
  681. if (nowMs < startMs) {
  682. $("#initializeShow").html("<font color=\"#800080\">未生效</font>");
  683. } else if (nowMs > endMs) {
  684. $("#initializeShow").html("<font color=\"#FF6600\">已失效</font>");
  685. } else {
  686. $("#initializeShow").html("<font color=\"#00CC66\">已生效</font>");
  687. }
  688. }
  689. function showSelect(couponId) {
  690. if (couponId == null){
  691. alertx("暂未生成兑换码");
  692. return false;
  693. }
  694. var url = "${ctx}/coupon/cmCoupon/redemptionCode?couponId=" + couponId;
  695. var title = '';
  696. title = "查看兑换码";
  697. top.$.jBox("iframe:" + url, {
  698. iframeScrolling: 'yes',
  699. width: $(top.document).width() - 750,
  700. height: $(top.document).height() - 300,
  701. persistent: true,
  702. title: title,
  703. buttons: {"确定": '1'}
  704. });
  705. }
  706. /**
  707. * @param obj
  708. * jquery控制input只能输入数字
  709. */
  710. function onlynum(obj) {
  711. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  712. }
  713. //点击添加机构
  714. function showSelectClub() {
  715. var url = "${ctx}/coupon/cmCoupon/toAddClub";
  716. var title = '';
  717. title = "选择机构";
  718. top.$.jBox("iframe:" + url, {
  719. iframeScrolling: 'yes',
  720. width: $(top.document).width() - 400,
  721. height: $(top.document).height() - 160,
  722. persistent: true,
  723. title: title,
  724. buttons: {"确定": '1', "取消": '-1'},
  725. submit: function (v, h, f) {
  726. //确定
  727. var $jboxFrame = top.$('#jbox-iframe');
  728. var $mainFrame = top.$('#mainFrame');
  729. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  730. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  731. console.log(items);
  732. insertHtmlClub(items);
  733. }
  734. return true;
  735. }
  736. });
  737. }
  738. function appendShopOrderHead(data) {
  739. var html = '<tr>' +
  740. '<td>' +
  741. data.name +
  742. '</td>' +
  743. '<td>' +
  744. data.sname +
  745. '</td>' +
  746. '<td>' +
  747. data.linkMan +
  748. '</td>' +
  749. '<td>' +
  750. data.contractMobile +
  751. '</td>' +
  752. '<td>' +
  753. '<a href="javascript:;" onclick="delectShop()">删除</a>' +
  754. '</td>' +
  755. '</tr>';
  756. $("#hotSearchShop").html(html);
  757. $("#chooseShop").hide();
  758. $('#contentTableShop').show();
  759. $("#shopId").val(data.shopId);
  760. }
  761. function changeCondition(flag, name) {
  762. var obj = $("#" + flag);
  763. var val = obj.val();
  764. if (val === '1') {
  765. obj.val(0);
  766. val = '0';
  767. } else {
  768. obj.val(1);
  769. val = '1';
  770. }
  771. var inputObj = $("#" + name);
  772. // 临时数据
  773. var tempObj = $("#" + name + "Temp");
  774. if (name.indexOf("Time") !== -1) {
  775. //修改时间
  776. if (val === '1') {
  777. inputObj.attr('onclick', '');
  778. inputObj.removeClass('required');
  779. } else {
  780. inputObj.attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
  781. inputObj.addClass('required');
  782. }
  783. }else {
  784. if (val === '1') {
  785. inputObj.attr('readonly', true);
  786. inputObj.attr('required', false);
  787. } else {
  788. inputObj.attr('readonly', false);
  789. inputObj.attr('required', true);
  790. }
  791. }
  792. if (val === '1') {
  793. tempObj.val(inputObj.val());
  794. inputObj.val('');
  795. } else {
  796. inputObj.val(tempObj.val());
  797. tempObj.val('');
  798. }
  799. }
  800. function changeCondition(flag, name) {
  801. var obj = $("#" + flag);
  802. var val = obj.val();
  803. if (val === '1') {
  804. obj.val(0);
  805. val = '0';
  806. } else {
  807. obj.val(1);
  808. val = '1';
  809. }
  810. var inputObj = $("#" + name);
  811. // 临时数据
  812. var tempObj = $("#" + name + "Temp");
  813. if (name.indexOf("Time") !== -1) {
  814. //修改时间
  815. if (val === '1') {
  816. inputObj.attr('onclick', '');
  817. inputObj.removeClass('required');
  818. } else {
  819. inputObj.attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
  820. inputObj.addClass('required');
  821. }
  822. }else {
  823. if (val === '1') {
  824. inputObj.attr('readonly', true);
  825. inputObj.attr('required', false);
  826. } else {
  827. inputObj.attr('readonly', false);
  828. inputObj.attr('required', true);
  829. }
  830. }
  831. if (val === '1') {
  832. tempObj.val(inputObj.val());
  833. inputObj.val('');
  834. } else {
  835. inputObj.val(tempObj.val());
  836. tempObj.val('');
  837. }
  838. }
  839. //点击添加
  840. function showSelectShop() {
  841. var url = "${ctx}/coupon/cmCoupon/toAddShop";
  842. var title = '';
  843. title = "选择供应商";
  844. top.$.jBox("iframe:" + url, {
  845. iframeScrolling: 'yes',
  846. width: $(top.document).width() - 400,
  847. height: $(top.document).height() - 160,
  848. persistent: true,
  849. title: title,
  850. buttons: {"确定": '1', "取消": '-1'},
  851. submit: function (v, h, f) {
  852. //确定
  853. var $jboxFrame = top.$('#jbox-iframe');
  854. var $mainFrame = top.$('#mainFrame');
  855. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  856. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  857. console.log(items);
  858. appendShopOrderHead(items);
  859. }
  860. return true;
  861. }
  862. });
  863. }
  864. /**
  865. * 删除操作
  866. */
  867. function delectShop() {
  868. return confirmx("确定删除吗?", function () {
  869. $("#chooseShop").show();
  870. $('#contentTableShop').hide();
  871. $("#shopId").val("");
  872. });
  873. }
  874. function couponShow() {
  875. var couponType = $("input[name='couponType']:checked").val();
  876. var moneyCouponType = $("input[name='moneyCouponType']:checked").val();
  877. if(moneyCouponType == 2){
  878. $("#couponType1").attr("checked",true);
  879. return;
  880. }
  881. if (couponType == 0) {
  882. $("#eventVoucher").show();
  883. $("#couponCategory").hide();
  884. $("#couponClub").hide();
  885. $("#couponShop").hide();
  886. } else if (couponType == 1) {
  887. $("#eventVoucher").hide();
  888. $("#couponCategory").show();
  889. $("#couponClub").hide();
  890. $("#couponShop").hide();
  891. $(".productData").hide();
  892. } else if (couponType == 2) {
  893. $("#eventVoucher").hide();
  894. $("#couponCategory").hide();
  895. $("#couponClub").show();
  896. $("#couponShop").hide();
  897. $(".productData").hide();
  898. } else if (couponType == 3) {
  899. $("#eventVoucher").hide();
  900. $("#couponCategory").hide();
  901. $("#couponClub").hide();
  902. $("#couponShop").show();
  903. $(".productData").hide();
  904. } else {
  905. $("#eventVoucher").hide();
  906. $("#couponCategory").hide();
  907. $("#couponClub").hide();
  908. $("#couponShop").hide();
  909. $(".productData").hide();
  910. }
  911. }
  912. function moneyCouponShow() {
  913. var couponType = $("input[name='moneyCouponType']:checked").val();
  914. if (couponType == 1) {
  915. $("#zxq").show();
  916. $("#plq").show();
  917. $("#dpq").show();
  918. $("#qsc").show();
  919. $("#qsc").attr("checked",true);
  920. $("#couponType1").attr("checked",true);
  921. $("#yxq").show();
  922. $("#dxq").hide();
  923. $("#couponCategory").hide();
  924. $("#eventVoucher").show();
  925. $(".productData").hide();
  926. $("#couponClub").hide();
  927. $("#couponShop").hide();
  928. document.querySelector('[for="qsc"]').style.display='';
  929. document.querySelector('[for="zxq"]').style.display='';
  930. document.querySelector('[for="plq"]').style.display='';
  931. document.querySelector('[for="dpq"]').style.display='';
  932. }
  933. if(couponType == 2) {
  934. $("#couponType1").attr("checked",true);
  935. $("#productType1").attr("checked",true);
  936. $("#eventVoucher").show();
  937. $(".productData").show();
  938. $("#couponClub").hide();
  939. $("#couponShop").hide();
  940. document.querySelector('[for="qsc"]').style.display='none';
  941. document.querySelector('[for="zxq"]').style.display='none';
  942. document.querySelector('[for="plq"]').style.display='none';
  943. document.querySelector('[for="dpq"]').style.display='none';
  944. $("#qsc").hide();
  945. $("#zxq").hide();
  946. $("#plq").hide();
  947. $("#dpq").hide();
  948. }
  949. }
  950. </script>
  951. </body>
  952. </html>