redemptionCodeCouponForm.jsp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  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/codeCouponList">兑换码优惠券</a></li>
  110. <li class="active"><a href="${ctx}/coupon/cmCoupon/codeCouponForm?id=${cmCoupon.id}">${not empty cmCoupon.id?'编辑':'添加'}</a></li>
  111. </ul><br/>
  112. <form:form id="inputForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/codeCouponSave" 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. <input name="startDate" id="startDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
  138. value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd 00:00:00"/>"
  139. onclick="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00',isShowClear:false});" onblur="dateShow()"/>
  140. </div>
  141. </div>
  142. <div class="control-group">
  143. <label class="control-label"><font color="red">*</font>结束时间:</label>
  144. <div class="controls">
  145. <input name="endDate" id="endDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
  146. value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd 23:59:59"/>"
  147. onclick="WdatePicker({dateFmt:'yyyy-MM-dd 23:59:59',isShowClear:false});" onblur="dateShow()"/>
  148. </div>
  149. </div>
  150. <div class="control-group">
  151. <label class="control-label"><font color="red">*</font>优惠状态:</label>
  152. <div class="controls">
  153. <label id="initializeShow">
  154. <c:if test="${empty cmCoupon.status || cmCoupon.status eq 0}">
  155. <font color="#800080">未生效</font>
  156. </c:if>
  157. <c:if test="${cmCoupon.status eq 1}">
  158. <font color="#00CC66">已生效</font>
  159. </c:if>
  160. <c:if test="${cmCoupon.status eq 2}">
  161. <font color="red">已关闭</font>
  162. </c:if>
  163. <c:if test="${cmCoupon.status eq 3}">
  164. <font color="#FF6600">已失效</font>
  165. </c:if>
  166. </label>
  167. <label id="closeShow" style="display: none">
  168. <font color="red">已关闭</font>
  169. </label>
  170. <input type="hidden" id="hiddenStatus" name="status" value="">
  171. <input type="checkbox" id="status" name="status" value="2" ${cmCoupon.status eq "2" ? "checked" : ""} onclick="statusShow()" />关闭
  172. </div>
  173. </div>
  174. <div class="control-group">
  175. <label class="control-label"><font color="red">*</font>兑换码数量:</label>
  176. <div class="controls">
  177. <input type="number" name="codeNum" value="${cmCoupon.codeNum}" min="${empty cmCoupon.codeNum ? 0:cmCoupon.codeNum}" required>
  178. &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="showSelect(${cmCoupon.id})">查看兑换码</a>
  179. </div>
  180. </div>
  181. <div class="control-group">
  182. <label class="control-label"><font color="red">*</font>优惠券类型:</label>
  183. <div class="controls">
  184. <form:radiobutton path="couponType" value="0" label="活动券" class="required" onclick="couponShow()"/>
  185. <form:radiobutton path="couponType" value="1" label="品类券" class="required" onclick="couponShow()"/>
  186. <form:radiobutton path="couponType" value="2" label="用户专享券" class="required" onclick="couponShow()"/>
  187. <form:radiobutton path="couponType" value="3" label="店铺券" class="required" onclick="couponShow()"/>
  188. <form:radiobutton path="couponType" value="4" label="新用户券" class="required" onclick="couponShow()"/>
  189. </div>
  190. </div>
  191. <div id="eventVoucher" hidden="hidden">
  192. <div class="control-group">
  193. <label class="control-label"><font color="red">*</font>优惠商品:</label>
  194. <div class="controls">
  195. <form:radiobutton path="productType" value="1" label="全商城商品" onclick="productShow()" checked ="${empty cmCoupon.productType ? true:false}"/>
  196. <form:radiobutton path="productType" value="2" label="指定商品" onclick="productShow()"/>
  197. </div>
  198. </div>
  199. <div class="productData" hidden="hidden">
  200. <div class="control-group">
  201. <label class="control-label"><font color="red">*</font>网站活动页banner:</label>
  202. <div class="controls upload-content-image iconBox">
  203. <div class="conList">
  204. <form:hidden id="pcBanner" path="pcBanner" htmlEscape="false" maxlength="255" class="input-xlarge"/>
  205. <sys:ckfinder input="pcBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  206. <br>
  207. </div>
  208. </div>
  209. </div>
  210. <div class="control-group">
  211. <label class="control-label"><font color="red">*</font>小程序活动页banner:</label>
  212. <div class="controls upload-content-image iconBox">
  213. <div class="conList">
  214. <form:hidden id="appletsBanner" path="appletsBanner" htmlEscape="false" maxlength="255" class="input-xlarge"/>
  215. <sys:ckfinder input="appletsBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  216. <br>
  217. </div>
  218. </div>
  219. </div>
  220. <div class="control-group">
  221. <input class="btn" id="del" style="width: 50px" onclick="batchDeletion()" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
  222. <input class="btn btn-primary" style="width: 70px" onclick="batchSaveSort()" value="一键排序"/>&nbsp;&nbsp;&nbsp;&nbsp;
  223. <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct()" value="添加"/>
  224. <br><br>
  225. <table id="contentTableProduct" class="table table-striped table-bordered table-condensed" hidden="hidden">
  226. <thead>
  227. <tr>
  228. <th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this)"/> 全选
  229. </th>
  230. <th>商品图片</th>
  231. <th>商品名称</th>
  232. <th>供应商</th>
  233. <th>网站状态</th>
  234. <th>小程序状态</th>
  235. <th>排序</th>
  236. <th>添加时间</th>
  237. <th>操作</th>
  238. </tr>
  239. </thead>
  240. <tbody id="hotSearchProduct"></tbody>
  241. </table>
  242. </div>
  243. </div>
  244. </div>
  245. <div class="control-group" id="couponCategory" hidden="hidden">
  246. <label class="control-label"><font color="red">*</font>优惠品类:</label>
  247. <div class="controls">
  248. <form:radiobutton path="categoryType" value="1" label="产品" checked ="${empty cmCoupon.categoryType ? true:false}"/>
  249. <form:radiobutton path="categoryType" value="2" label="仪器"/>
  250. </div>
  251. </div>
  252. <div class="control-group" id="couponClub" hidden="hidden">
  253. <label class="control-label"><font color="red">*</font>机构:</label>
  254. <div class="controls">
  255. <a href="javascript:void(0);" onclick="showSelectClub()" id="chooseClub">请选择机构</a>
  256. <input type="hidden" name="userId" id="userId" value="${cmCoupon.userId}">
  257. <table id="contentTableClub" class="table table-striped table-bordered table-condensed" hidden="hidden">
  258. <thead>
  259. <tr>
  260. <th>机构名称</th>
  261. <th>机构简称</th>
  262. <th>联系人</th>
  263. <th>手机号</th>
  264. <th>操作</th>
  265. </tr>
  266. </thead>
  267. <tbody id="hotSearchClub"></tbody>
  268. </table>
  269. </div>
  270. </div>
  271. <div class="control-group" id="couponShop" hidden="hidden">
  272. <label class="control-label"><font color="red">*</font>供应商:</label>
  273. <div class="controls">
  274. <a href="javascript:void(0);" onclick="showSelectShop()" id="chooseShop">请选择供应商</a>
  275. <form:hidden path="shopId" id="shopId"/>
  276. <table id="contentTableShop" class="table table-striped table-bordered table-condensed" hidden="hidden">
  277. <thead>
  278. <tr>
  279. <th>机构名称</th>
  280. <th>机构简称</th>
  281. <th>联系人</th>
  282. <th>手机号</th>
  283. <th>操作</th>
  284. </tr>
  285. </thead>
  286. <tbody id="hotSearchShop"></tbody>
  287. </table>
  288. </div>
  289. </div>
  290. <div class="form-actions">
  291. <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
  292. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  293. </div>
  294. </form:form>
  295. <script>
  296. //图片初始化
  297. $(function () {
  298. $('.upload-content-image .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
  299. $('.upload-content-image .conList .btn:nth-of-type(2)').after('<img class="cancel-upload-image" src="/static/images/close-btn1.png">').remove();
  300. $('.upload-content-image .conList').find('.cancel-upload-image').hide();
  301. var observeEleImage = document.getElementsByClassName('upload-content-image')[0];
  302. var observeEleImage1 = document.getElementsByClassName('upload-content-image')[1];
  303. var MutationObserverImage = window.MutationObserver || window.WebKitMutationObserver;
  304. var MutationObserverConfigImage = {
  305. childList: true,
  306. subtree: true,
  307. characterData: true
  308. };
  309. var observerImage = new MutationObserverImage(function (mutations) {
  310. $.each(mutations, function (index, item) {
  311. if (item.type === 'childList') {
  312. // 在创建新的 element 时调用
  313. var target = $(item.target),
  314. thisWrapper = target.closest('.conList'),
  315. nextEle = thisWrapper.next();
  316. thisWrapper.find('li').css('z-index', 99);
  317. thisWrapper.find('.cancel-upload-image').show();
  318. if (nextEle.hasClass('hide-pic-image')) {
  319. nextEle.removeClass('hide-pic-image');
  320. }
  321. }
  322. })
  323. });
  324. observerImage.observe(observeEleImage, MutationObserverConfigImage);
  325. observerImage.observe(observeEleImage1, MutationObserverConfigImage);
  326. $('body').on('click', '.upload-content-image li', function () {
  327. var index = $(this).closest('.conList').index() + 1,
  328. str = 'remarkImage' + index + 'FinderOpen';
  329. eval(str + '()');
  330. });
  331. $('body').on('click', '.cancel-upload-image', function () {
  332. var wrapper = $(this).closest('.conList');
  333. wrapper.find('li').css('z-index', '-1');
  334. wrapper.find('input').val('');
  335. $(this).hide();
  336. wrapper.removeClass("hide-pic-image");
  337. wrapper.parent().append(wrapper.clone());
  338. wrapper.remove();
  339. $(".conList").each(function (i, ele) {
  340. if ($(ele).find("input.input-xlarge").val()) {
  341. $(ele).next().removeClass("hide-pic-image")
  342. }
  343. })
  344. });
  345. $(window).on("load", function () {
  346. setTimeout(function () {
  347. var input = $("#pcBanner");
  348. if (input.val()) {
  349. input.next().find("li").css("z-index", "99");
  350. input.parents(".conList").find(".cancel-upload-image").show();
  351. input.parents(".conList").next().removeClass("hide-pic-image")
  352. }
  353. input = $("#appletsBanner");
  354. if (input.val()) {
  355. input.next().find("li").css("z-index", "99");
  356. input.parents(".conList").find(".cancel-upload-image").show();
  357. input.parents(".conList").next().removeClass("hide-pic-image")
  358. }
  359. }, 500);
  360. });
  361. productShow()
  362. });
  363. var productIds = '';
  364. var imageList = [];
  365. $(function () {
  366. //活动券商品回显
  367. <c:forEach items="${associateList}" var="associate" varStatus="index">
  368. imageList.push({
  369. id: "${associate.id}",
  370. productId: "${empty associate.productId ? "":associate.productId}",
  371. image: "${associate.image}",
  372. productName: "${associate.productName}",
  373. shopName: "${associate.shopName}",
  374. sort: "${associate.sort}",
  375. pcStatus: "${associate.pcStatus}",
  376. appletsStatus: "${associate.appletsStatus}",
  377. addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
  378. });
  379. </c:forEach>
  380. if (imageList.length > 0) {
  381. $('#contentTableProduct').show();
  382. batchSaveSort();
  383. }
  384. //用户专享券机构回显
  385. if (${not empty cmUser}){
  386. var items = {
  387. "userID": "${cmUser.userID}",
  388. "name": "${cmUser.name}",
  389. "shortName": "${cmUser.shortName}",
  390. "linkMan": "${empty cmUser.userName ? '':cmUser.userName}",
  391. "contractMobile": "${empty cmUser.bindMobile ? '':cmUser.bindMobile}"
  392. };
  393. insertHtmlClub(items);
  394. }
  395. //店铺券供应商回显
  396. if (${not empty cmCoupon.shop}) {
  397. var shop = {
  398. "shopId": "${cmCoupon.shop.shopID}",
  399. "name": "${cmCoupon.shop.name}",
  400. "sname": "${cmCoupon.shop.sname}",
  401. "linkMan": "${cmCoupon.shop.linkMan}",
  402. "contractMobile": "${cmCoupon.shop.contractMobile}"
  403. }
  404. appendShopOrderHead(shop);
  405. }
  406. couponShow();
  407. });
  408. //点击添加商品
  409. function showSelectProduct() {
  410. var url = "${ctx}/coupon/cmCoupon/toAddProduct?productIds=" + productIds;
  411. var title = '';
  412. title = "选择商品";
  413. top.$.jBox("iframe:" + url, {
  414. iframeScrolling: 'yes',
  415. width: $(top.document).width() - 400,
  416. height: $(top.document).height() - 160,
  417. persistent: true,
  418. title: title,
  419. buttons: {"确定": '1', "取消": '-1'},
  420. submit: function (v, h, f) {
  421. //确定
  422. var $jboxFrame = top.$('#jbox-iframe');
  423. var $mainFrame = top.$('#mainFrame');
  424. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  425. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  426. console.log(items);
  427. console.log(items[0]);
  428. for (var i = 0; i < items.length; i++) {
  429. console.log(items[i]);
  430. imageList.push(items[i]);
  431. $('#contentTableProduct').show();
  432. $("#del").removeAttr("disabled");
  433. batchSaveSort();
  434. };
  435. }
  436. return true;
  437. }
  438. });
  439. }
  440. /**
  441. * 一键排序
  442. */
  443. function batchSaveSort() {
  444. imageList.sort(sort);
  445. insertHtmlProduct(imageList);
  446. }
  447. //根据sort值 从小到大排序
  448. function sort(a, b) {
  449. return a.sort - b.sort;
  450. }
  451. //相关图片列表数据
  452. function appendProductOrderHead(data, index) {
  453. var html = '<tr id ="ai' + index + '">' +
  454. '<td>' +
  455. '<input class="check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
  456. '</td>' +
  457. '<td>' +
  458. '<img src="' + data.image + '" width="60px" border="none" title="启用">' +
  459. '</td>' +
  460. '<td>' +
  461. data.productName +
  462. '</td>' +
  463. '<td>' +
  464. data.shopName +
  465. '</td>' +
  466. '<td>' +
  467. (data.pcStatus == 1 ? (
  468. '<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
  469. '<a href="javascript:void(0);" onclick="updatePcStatus(0,' + index + ');" >' +
  470. '停用</a>'
  471. ) : (
  472. '<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
  473. '<a href="javascript:void(0)" onclick="updatePcStatus(1,' + index + ');">' +
  474. '启用</a>'
  475. )) +
  476. '</td>' +
  477. '<td>' +
  478. (data.appletsStatus == 1 ? (
  479. '<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
  480. '<a href="javascript:void(0);" onclick="updateAppletsStatus(0,' + index + ');" >' +
  481. '停用</a>'
  482. ) : (
  483. '<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
  484. '<a href="javascript:void(0)" onclick="updateAppletsStatus(1,' + index + ');">' +
  485. '启用</a>'
  486. )) +
  487. '</td>' +
  488. '<td>' +
  489. '<input name="sort" style="width:50px;" value="' + data.sort + '" onkeyup="onlynum(this)" onchange="changeSort(' + index + ',this)"></td>' +
  490. '</td>' +
  491. '<td>' +
  492. (data.addTime == '' ? (
  493. '<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
  494. ) : (
  495. data.addTime
  496. )) +
  497. '</td>' +
  498. '<td>' +
  499. '<a href="javascript:;" onclick="delect(' + index + ')">删除</a>' +
  500. '</td>' +
  501. '</tr>';
  502. return html;
  503. }
  504. function insertHtmlProduct(list) {
  505. var html = '';
  506. productIds = '';
  507. list.forEach(function (item, index) {
  508. html += appendProductOrderHead(item, index);
  509. productIds += "," + item.productId;
  510. });
  511. $("#hotSearchProduct").html(html);
  512. }
  513. function changeSort(index, sortThis) {
  514. var sort = sortThis.value;
  515. if (sort <= 0) {
  516. }
  517. var image = imageList[index];
  518. image.sort = sort;
  519. }
  520. function updatePcStatus(status, index) {
  521. var image = imageList[index];
  522. confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
  523. image.pcStatus = status;
  524. batchSaveSort();
  525. })
  526. }
  527. function updateAppletsStatus(status, index) {
  528. var image = imageList[index];
  529. confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
  530. image.appletsStatus = status;
  531. batchSaveSort();
  532. })
  533. }
  534. function clickAllSelect(ckb) {
  535. var isChecked = ckb.checked;
  536. $(".check-item").attr('checked', isChecked);
  537. }
  538. /**
  539. * 删除操作
  540. */
  541. function delect(index) {
  542. return confirmx("确定删除吗?", function () {
  543. var image = imageList[index];
  544. if (image.productId != '') {
  545. productIds = productIds.replace(image.productId,"");
  546. }
  547. imageList.splice(index, 1);
  548. insertHtmlProduct(imageList);
  549. if (imageList.length == 0) {
  550. $('#contentTableProduct').hide();
  551. $("#del").attr("disabled", "disabled");
  552. }
  553. });
  554. }
  555. /**
  556. * 批量删除
  557. */
  558. function batchDeletion() {
  559. var index = -1;
  560. var i = 1;
  561. return confirmx("确定删除吗?", function () {
  562. $('input[name="info"]:checked').each(function () {
  563. var thisIndex = $(this).val();
  564. if (index >= 0 && index < thisIndex) {
  565. thisIndex = thisIndex - i;
  566. i++;
  567. } else {
  568. index = thisIndex;
  569. }
  570. var image = imageList[thisIndex];
  571. if (image.productId != '') {
  572. productIds = productIds.replace(image.productId, "");
  573. }
  574. imageList.splice(thisIndex, 1);
  575. insertHtmlProduct(imageList);
  576. if (imageList.length == 0) {
  577. $('#contentTableProduct').hide();
  578. $("#del").attr("disabled", "disabled");
  579. }
  580. });
  581. });
  582. }
  583. function productShow() {
  584. var productType = $("input[name='productType']:checked").val();
  585. if (productType == 2){
  586. $(".productData").show();
  587. }else {
  588. $(".productData").hide();
  589. }
  590. }
  591. function insertHtmlClub(data) {
  592. var html = '<tr>' +
  593. '<td>' +
  594. data.name +
  595. '</td>' +
  596. '<td>' +
  597. data.shortName +
  598. '</td>' +
  599. '<td>' +
  600. data.linkMan +
  601. '</td>' +
  602. '<td>' +
  603. data.contractMobile +
  604. '</td>' +
  605. '<td>' +
  606. '<a href="javascript:;" onclick="deleteClub()">删除</a>' +
  607. '</td>' +
  608. '</tr>';
  609. $("#contentTableClub").show();
  610. $("#chooseClub").hide();
  611. $("#hotSearchClub").html(html);
  612. $("#userId").val(data.userID);
  613. }
  614. function deleteClub() {
  615. $("#hotSearchClub").html("");
  616. $("#contentTableClub").hide();
  617. $("#chooseClub").show();
  618. $("#userId").val("");
  619. }
  620. function statusShow() {
  621. var status = $("input[name='status']:checked").val();
  622. if (status == 2) {
  623. $("#initializeShow").hide();
  624. $("#closeShow").show();
  625. } else {
  626. $("#initializeShow").show();
  627. $("#closeShow").hide();
  628. $("#hiddenStatus").val(0);
  629. }
  630. }
  631. function dateShow() {
  632. var startDate = $("#startDate").val();
  633. var startMs = new Date(startDate).getTime();
  634. var endDate = $("#endDate").val();
  635. var endMs = new Date(endDate).getTime();
  636. var nowMs = new Date().getTime();
  637. if (nowMs < startMs) {
  638. $("#initializeShow").html("<font color=\"#800080\">未生效</font>");
  639. } else if (nowMs > endMs) {
  640. $("#initializeShow").html("<font color=\"#FF6600\">已失效</font>");
  641. } else {
  642. $("#initializeShow").html("<font color=\"#00CC66\">已生效</font>");
  643. }
  644. }
  645. function showSelect(couponId) {
  646. if (couponId == null){
  647. alertx("暂未生成兑换码");
  648. return false;
  649. }
  650. var url = "${ctx}/coupon/cmCoupon/redemptionCode?couponId=" + couponId;
  651. var title = '';
  652. title = "查看兑换码";
  653. top.$.jBox("iframe:" + url, {
  654. iframeScrolling: 'yes',
  655. width: $(top.document).width() - 750,
  656. height: $(top.document).height() - 300,
  657. persistent: true,
  658. title: title,
  659. buttons: {"确定": '1'}
  660. });
  661. }
  662. /**
  663. * @param obj
  664. * jquery控制input只能输入数字
  665. */
  666. function onlynum(obj) {
  667. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  668. }
  669. //点击添加机构
  670. function showSelectClub() {
  671. var url = "${ctx}/coupon/cmCoupon/toAddClub";
  672. var title = '';
  673. title = "选择机构";
  674. top.$.jBox("iframe:" + url, {
  675. iframeScrolling: 'yes',
  676. width: $(top.document).width() - 400,
  677. height: $(top.document).height() - 160,
  678. persistent: true,
  679. title: title,
  680. buttons: {"确定": '1', "取消": '-1'},
  681. submit: function (v, h, f) {
  682. //确定
  683. var $jboxFrame = top.$('#jbox-iframe');
  684. var $mainFrame = top.$('#mainFrame');
  685. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  686. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  687. console.log(items);
  688. insertHtmlClub(items);
  689. }
  690. return true;
  691. }
  692. });
  693. }
  694. function appendShopOrderHead(data) {
  695. var html = '<tr>' +
  696. '<td>' +
  697. data.name +
  698. '</td>' +
  699. '<td>' +
  700. data.sname +
  701. '</td>' +
  702. '<td>' +
  703. data.linkMan +
  704. '</td>' +
  705. '<td>' +
  706. data.contractMobile +
  707. '</td>' +
  708. '<td>' +
  709. '<a href="javascript:;" onclick="delectShop()">删除</a>' +
  710. '</td>' +
  711. '</tr>';
  712. $("#hotSearchShop").html(html);
  713. $("#chooseShop").hide();
  714. $('#contentTableShop').show();
  715. $("#shopId").val(data.shopId);
  716. }
  717. //点击添加
  718. function showSelectShop() {
  719. var url = "${ctx}/coupon/cmCoupon/toAddShop";
  720. var title = '';
  721. title = "选择供应商";
  722. top.$.jBox("iframe:" + url, {
  723. iframeScrolling: 'yes',
  724. width: $(top.document).width() - 400,
  725. height: $(top.document).height() - 160,
  726. persistent: true,
  727. title: title,
  728. buttons: {"确定": '1', "取消": '-1'},
  729. submit: function (v, h, f) {
  730. //确定
  731. var $jboxFrame = top.$('#jbox-iframe');
  732. var $mainFrame = top.$('#mainFrame');
  733. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  734. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  735. console.log(items);
  736. appendShopOrderHead(items);
  737. }
  738. return true;
  739. }
  740. });
  741. }
  742. /**
  743. * 删除操作
  744. */
  745. function delectShop() {
  746. return confirmx("确定删除吗?", function () {
  747. $("#chooseShop").show();
  748. $('#contentTableShop').hide();
  749. $("#shopId").val("");
  750. });
  751. }
  752. function couponShow() {
  753. var couponType = $("input[name='couponType']:checked").val();
  754. if (couponType == 0) {
  755. $("#eventVoucher").show();
  756. $("#couponCategory").hide();
  757. $("#couponClub").hide();
  758. $("#couponShop").hide();
  759. } else if (couponType == 1) {
  760. $("#eventVoucher").hide();
  761. $("#couponCategory").show();
  762. $("#couponClub").hide();
  763. $("#couponShop").hide();
  764. } else if (couponType == 2) {
  765. $("#eventVoucher").hide();
  766. $("#couponCategory").hide();
  767. $("#couponClub").show();
  768. $("#couponShop").hide();
  769. } else if (couponType == 3) {
  770. $("#eventVoucher").hide();
  771. $("#couponCategory").hide();
  772. $("#couponClub").hide();
  773. $("#couponShop").show();
  774. } else {
  775. $("#eventVoucher").hide();
  776. $("#couponCategory").hide();
  777. $("#couponClub").hide();
  778. $("#couponShop").hide();
  779. }
  780. }
  781. </script>
  782. </body>
  783. </html>