cmCouponForm.jsp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. <%@ page import="java.util.Date" %>
  2. <%@ page contentType="text/html;charset=UTF-8" %>
  3. <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
  4. <html>
  5. <head>
  6. <title>优惠券管理</title>
  7. <meta name="decorator" content="default"/>
  8. <script type="text/javascript">
  9. $(document).ready(function() {
  10. //$("#name").focus();
  11. $("#inputForm").validate({
  12. submitHandler: function(form){
  13. $("#receiveFlag").removeAttr('disabled');
  14. if (imageList.length > 0) {
  15. var productInfo = JSON.stringify(imageList);
  16. $('#productInfo').val(productInfo);
  17. }
  18. var productType = $("input[name='productType']:checked").val();
  19. var couponAmount = $("#couponAmount").val()*1;
  20. var touchPrice = $("#touchPrice").val()*1;
  21. if (couponAmount >= touchPrice) {
  22. alertx("优惠券金额必须小于优惠条件金额");
  23. return false;
  24. }
  25. var startDate = $("#startDate").val();
  26. var endDate = $("#endDate").val();
  27. if (startDate >= endDate) {
  28. alertx("结束时间不能早于开始时间");
  29. return false;
  30. }
  31. loading('正在提交,请稍等...');
  32. form.submit();
  33. },
  34. errorContainer: "#messageBox",
  35. errorPlacement: function(error, element) {
  36. $("#messageBox").text("输入有误,请先更正。");
  37. if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
  38. error.appendTo(element.parent().parent());
  39. } else {
  40. error.insertAfter(element);
  41. }
  42. }
  43. });
  44. });
  45. </script>
  46. <style>
  47. .iconBox {
  48. font-size: 0;
  49. }
  50. .conList .btn:nth-of-type(1){
  51. margin-left: 25px;
  52. }
  53. .upload-content-image {
  54. margin-top: -70px;
  55. }
  56. .upload-content-image .conList .btn:nth-of-type(1) {
  57. width: 90px;
  58. height: 100px;
  59. border: 2px solid #eee;
  60. background: #fff;
  61. position: relative;
  62. }
  63. .upload-content-image .conList .btn:nth-of-type(1) > div {
  64. position: absolute;
  65. top: 50%;
  66. left: 50%;
  67. transform: translate(-50%, -50%);
  68. color: #666;
  69. }
  70. .upload-content-image .conList .btn:nth-of-type(1) span {
  71. font-size: 35px;
  72. }
  73. .upload-content-image .conList .btn:nth-of-type(1) h5 {
  74. color: #666;
  75. }
  76. .upload-content-image .conList ol li {
  77. width: 114px;
  78. min-height: 80px;
  79. text-align: center;
  80. background: #fff;
  81. position: relative;
  82. top: 120px;
  83. margin-left: 2px;
  84. }
  85. .cancel-upload-image {
  86. background: transparent;
  87. border: none;
  88. box-shadow: none;
  89. position: relative;
  90. top: -38px;
  91. left: -25px;
  92. cursor: pointer;
  93. z-index: 100;
  94. }
  95. .hide-pic-image {
  96. display: none !important;
  97. }
  98. </style>
  99. </head>
  100. <body>
  101. <ul class="nav nav-tabs">
  102. <li><a href="${ctx}/coupon/cmCoupon/list?couponType=0&&moneyCouponFlag=2">活动券</a></li>
  103. <li class="active"><a href="${ctx}/coupon/cmCoupon/form?couponType=0&id=${cmCoupon.id}">${not empty cmCoupon.id?'编辑':'添加'}</a></li>
  104. </ul><br/>
  105. <font style="color: red;margin-left: 20px">活动券适合在某些节日或者主题活动时创建,并且适用于全部客户以及商城全部商品或指定商品(不包括二手商品)。</font><br><br>
  106. <form:form id="inputForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/save" method="post" class="form-horizontal">
  107. <form:hidden path="id"/>
  108. <form:hidden path="productInfo" id="productInfo"/>
  109. <input type="hidden" name="couponType" value="0"/>
  110. <sys:message content="${message}"/>
  111. <form:hidden path="receiveFlag"/>
  112. <div class="control-group">
  113. <label class="control-label"><font color="red">*</font>活动主题:</label>
  114. <div class="controls">
  115. <form:input path="name" htmlEscape="false" maxlength="30" placeholder="30个汉字以内" class="input-xlarge required"/>
  116. </div>
  117. </div>
  118. <div class="control-group">
  119. <label class="control-label"><font color="red">*</font>优惠券金额:</label>
  120. <div class="controls">
  121. <input type="number" id="couponAmount" name="couponAmount" value="${cmCoupon.couponAmount}" min="0" required>
  122. </div>
  123. </div>
  124. <div class="control-group">
  125. <label class="control-label"><font color="red">*</font>优惠条件:</label>
  126. <div class="controls">
  127. 订单商品总额满&nbsp;&nbsp;&nbsp;&nbsp;<input type="number" name="touchPrice" id="touchPrice" value="${cmCoupon.touchPrice}" min="0" required>
  128. </div>
  129. </div>
  130. <div class="control-group">
  131. <label class="control-label"><font color="red">*</font>折扣方式:</label>
  132. <div class="controls">
  133. <form:radiobutton path="couponTextFlag" value="1" label="满减" class="required" onclick="textChange(1)"/>
  134. <form:radiobutton path="couponTextFlag" value="2" label="打折" class="required" onclick="textChange(2)"/>
  135. </div>
  136. </div>
  137. <div class="control-group" id="texts" hidden="hidden">
  138. <label class="control-label"><font color="red">*</font>折扣文案:</label>
  139. <div class="controls">
  140. <input type="text" id="couponText" name="couponText" value="${cmCoupon.couponText}" min="0" required>
  141. </div>
  142. </div>
  143. <div class="control-group">
  144. <label class="control-label"><font color="red">*</font>上架时间:</label>
  145. <div class="controls">
  146. <input name="startDate" id="startDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
  147. value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd 00:00:00"/>"
  148. onclick="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00',isShowClear:false});" onblur="dateShow()">
  149. </div>
  150. </div>
  151. <div class="control-group">
  152. <label class="control-label"><font color="red">*</font>下架时间:</label>
  153. <div class="controls">
  154. <input name="endDate" id="endDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
  155. value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd 23:59:59"/>"
  156. onclick="WdatePicker({dateFmt:'yyyy-MM-dd 23:59:59',isShowClear:false});" onblur="dateShow()"/>
  157. </div>
  158. </div>
  159. <div class="control-group">
  160. <label class="control-label"><font color="red">*</font>领取期限:</label>
  161. <div class="controls">
  162. <input type="number" id="receivePeriod" name="receivePeriod" onkeyup="onlynum(this)" value="${cmCoupon.receivePeriod}" min="1" required> 天
  163. <input type="checkbox" id="receiveFlag" name="receiveFlag" style="margin-left:20px !important" value="${cmCoupon.receiveFlag eq 1?1:0}"
  164. ${cmCoupon.receiveFlag eq 1 ? "checked" : ""} onclick="changeCondition('receiveFlag','receivePeriod')" />同上下架时间
  165. <input id="receivePeriodTemp" type="hidden" value="${cmCoupon.receivePeriod}">
  166. <input id="receiveFlagTemp" type="hidden" value="${cmCoupon.receiveFlag}">
  167. </div>
  168. </div>
  169. <div class="control-group">
  170. <label class="control-label"><font color="red">*</font>使用期限:</label>
  171. <div class="controls">
  172. <input type="number" id="usePeriod" name="usePeriod" value="${cmCoupon.usePeriod}" min="1" required> 天
  173. <input type="checkbox" id="useTimeFlag" name="useTimeFlag" style="margin-left:20px !important" value="${cmCoupon.useTimeFlag eq 1?1:0}"
  174. ${cmCoupon.useTimeFlag eq 1 ? "checked" : ""} onclick="changeUseTime('useTimeFlag')"/>同上下架时间
  175. <input id="usePeriodTemp" type="hidden" value="${cmCoupon.usePeriod}">
  176. </div>
  177. </div>
  178. <div class="control-group">
  179. <label class="control-label">分享优惠券标题:</label>
  180. <div class="controls">
  181. <form:input path="shareCouponTopic" htmlEscape="false" maxlength="30" placeholder="30个汉字以内" class="input-xlarge"/>
  182. </div>
  183. </div>
  184. <div class="control-group">
  185. <label class="control-label">分享优惠券封面:</label>
  186. <div class="controls upload-content-image iconBox">
  187. <div class="conList">
  188. <form:hidden id="shareCouponImage" path="shareCouponImage" htmlEscape="false" maxlength="255" class="input-xlarge"/>
  189. <sys:ckfinder input="shareCouponImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  190. <br>
  191. </div>
  192. </div>
  193. </div>
  194. <div class="control-group">
  195. <label class="control-label"><font color="red">*</font>状态:</label>
  196. <div class="controls">
  197. <label id="initializeShow">
  198. <c:if test="${empty cmCoupon.status || cmCoupon.status eq 0}">
  199. <font color="#800080">未生效</font>
  200. </c:if>
  201. <c:if test="${cmCoupon.status eq 1}">
  202. <font color="#00CC66">已生效</font>
  203. </c:if>
  204. <c:if test="${cmCoupon.status eq 2}">
  205. <font color="red">已关闭</font>
  206. </c:if>
  207. <c:if test="${cmCoupon.status eq 3}">
  208. <font color="#FF6600">已失效</font>
  209. </c:if>
  210. </label>
  211. <label id="closeShow" style="display: none">
  212. <font color="red">已关闭</font>
  213. </label>
  214. <input type="hidden" id="hiddenStatus" name="status" value="">
  215. <input type="checkbox" id="status" name="status" value="2" ${cmCoupon.status eq "2" ? "checked" : ""} onclick="statusShow()" />关闭
  216. </div>
  217. </div>
  218. <div class="control-group">
  219. <label class="control-label"><font color="red">*</font>优惠商品:</label>
  220. <div class="controls">
  221. <%-- <form:radiobutton path="productType" value="1" label="全商城商品" onclick="productShow()" checked ="${empty cmCoupon.productType ? true:false}"/>--%>
  222. <form:radiobutton path="productType" value="2" label="指定商品" onclick="productShow()"/>
  223. </div>
  224. </div>
  225. <div class="productData" hidden="hidden">
  226. <div class="control-group">
  227. <label class="control-label">网站活动页banner:</label>
  228. <div class="controls upload-content-image iconBox">
  229. <div class="conList">
  230. <form:hidden id="pcBanner" path="pcBanner" htmlEscape="false" maxlength="255" class="input-xlarge"/>
  231. <sys:ckfinder input="pcBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  232. <br>
  233. </div>
  234. </div>
  235. </div>
  236. <div class="control-group">
  237. <label class="control-label">小程序活动页banner:</label>
  238. <div class="controls upload-content-image iconBox">
  239. <div class="conList">
  240. <form:hidden id="appletsBanner" path="appletsBanner" htmlEscape="false" maxlength="255" class="input-xlarge"/>
  241. <sys:ckfinder input="appletsBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  242. <br>
  243. </div>
  244. </div>
  245. </div>
  246. <div class="control-group">
  247. <input class="btn" id="del" style="width: 50px" onclick="batchDeletion()" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
  248. <input class="btn btn-primary" style="width: 70px" onclick="batchSaveSort()" value="一键排序"/>&nbsp;&nbsp;&nbsp;&nbsp;
  249. <input class="btn btn-primary" style="width: 50px" onclick="showSelect()" value="添加"/>
  250. <br><br>
  251. <table id="contentTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
  252. <thead>
  253. <tr>
  254. <th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this)"/> 全选
  255. </th>
  256. <th>商品图片</th>
  257. <th>商品名称</th>
  258. <th>供应商</th>
  259. <th>网站状态</th>
  260. <th>小程序状态</th>
  261. <th>排序</th>
  262. <th>添加时间</th>
  263. <th>操作</th>
  264. </tr>
  265. </thead>
  266. <tbody id="hotSearch"></tbody>
  267. </table>
  268. </div>
  269. </div>
  270. <div class="form-actions">
  271. <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
  272. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  273. </div>
  274. </form:form>
  275. <script>
  276. //图片初始化
  277. $(function () {
  278. $('.upload-content-image .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
  279. $('.upload-content-image .conList .btn:nth-of-type(2)').after('<img class="cancel-upload-image" src="/static/images/close-btn1.png">').remove();
  280. $('.upload-content-image .conList').find('.cancel-upload-image').hide();
  281. var observeEleImage = document.getElementsByClassName('upload-content-image')[0];
  282. var observeEleImage1 = document.getElementsByClassName('upload-content-image')[1];
  283. var MutationObserverImage = window.MutationObserver || window.WebKitMutationObserver;
  284. var MutationObserverConfigImage = {
  285. childList: true,
  286. subtree: true,
  287. characterData: true
  288. };
  289. var observerImage = new MutationObserverImage(function (mutations) {
  290. $.each(mutations, function (index, item) {
  291. if (item.type === 'childList') {
  292. // 在创建新的 element 时调用
  293. var target = $(item.target),
  294. thisWrapper = target.closest('.conList'),
  295. nextEle = thisWrapper.next();
  296. thisWrapper.find('li').css('z-index', 99);
  297. thisWrapper.find('.cancel-upload-image').show();
  298. if (nextEle.hasClass('hide-pic-image')) {
  299. nextEle.removeClass('hide-pic-image');
  300. }
  301. }
  302. })
  303. });
  304. observerImage.observe(observeEleImage, MutationObserverConfigImage);
  305. observerImage.observe(observeEleImage1, MutationObserverConfigImage);
  306. $('body').on('click', '.upload-content-image li', function () {
  307. var index = $(this).closest('.conList').index() + 1,
  308. str = 'remarkImage' + index + 'FinderOpen';
  309. eval(str + '()');
  310. });
  311. $('body').on('click', '.cancel-upload-image', function () {
  312. var wrapper = $(this).closest('.conList');
  313. wrapper.find('li').css('z-index', '-1');
  314. wrapper.find('input').val('');
  315. $(this).hide();
  316. wrapper.removeClass("hide-pic-image");
  317. wrapper.parent().append(wrapper.clone());
  318. wrapper.remove();
  319. $(".conList").each(function (i, ele) {
  320. if ($(ele).find("input.input-xlarge").val()) {
  321. $(ele).next().removeClass("hide-pic-image")
  322. }
  323. })
  324. });
  325. $(window).on("load", function () {
  326. setTimeout(function () {
  327. var input = $("#pcBanner");
  328. if (input.val()) {
  329. input.next().find("li").css("z-index", "99");
  330. input.parents(".conList").find(".cancel-upload-image").show();
  331. input.parents(".conList").next().removeClass("hide-pic-image")
  332. }
  333. input = $("#shareCouponImage");
  334. if (input.val()) {
  335. input.next().find("li").css("z-index", "99");
  336. input.parents(".conList").find(".cancel-upload-image").show();
  337. input.parents(".conList").next().removeClass("hide-pic-image")
  338. }
  339. input = $("#appletsBanner");
  340. if (input.val()) {
  341. input.next().find("li").css("z-index", "99");
  342. input.parents(".conList").find(".cancel-upload-image").show();
  343. input.parents(".conList").next().removeClass("hide-pic-image")
  344. }
  345. }, 500);
  346. });
  347. productShow();
  348. initInputDisplay();
  349. initUseTimeFlag();
  350. if(${cmCoupon.couponTextFlag eq 2}){
  351. $("#texts").show();
  352. }
  353. });
  354. function textChange(val) {
  355. if (2 === val) {
  356. $("#texts").show();
  357. }else{
  358. $("#texts").hide();
  359. }
  360. }
  361. var productIds = '';
  362. var imageList = [];
  363. $(function () {
  364. <c:forEach items="${associateList}" var="associate" varStatus="index">
  365. imageList.push({
  366. id: "${associate.id}",
  367. productId: "${empty associate.productId ? "":associate.productId}",
  368. image: "${associate.image}",
  369. productName: "${associate.productName}",
  370. shopName: "${associate.shopName}",
  371. sort: "${associate.sort}",
  372. pcStatus: "${associate.pcStatus}",
  373. appletsStatus: "${associate.appletsStatus}",
  374. addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
  375. });
  376. </c:forEach>
  377. if (imageList.length > 0) {
  378. $('#contentTable').show();
  379. batchSaveSort();
  380. }
  381. });
  382. //点击添加
  383. function showSelect() {
  384. var url = "${ctx}/coupon/cmCoupon/toAddProduct?productIds=" + productIds;
  385. var title = '';
  386. title = "选择商品";
  387. top.$.jBox("iframe:" + url, {
  388. iframeScrolling: 'yes',
  389. width: $(top.document).width() - 400,
  390. height: $(top.document).height() - 160,
  391. persistent: true,
  392. title: title,
  393. buttons: {"确定": '1', "取消": '-1'},
  394. submit: function (v, h, f) {
  395. //确定
  396. var $jboxFrame = top.$('#jbox-iframe');
  397. var $mainFrame = top.$('#mainFrame');
  398. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  399. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  400. console.log(items);
  401. console.log(items[0]);
  402. for (var i = 0; i < items.length; i++) {
  403. console.log(items[i]);
  404. imageList.push(items[i]);
  405. $('#contentTable').show();
  406. $("#del").removeAttr("disabled");
  407. batchSaveSort();
  408. };
  409. }
  410. return true;
  411. }
  412. });
  413. }
  414. /**
  415. * 一键排序
  416. */
  417. function batchSaveSort() {
  418. imageList.sort(sort);
  419. insertHtml(imageList);
  420. }
  421. //根据sort值 从小到大排序
  422. function sort(a, b) {
  423. return a.sort - b.sort;
  424. }
  425. //相关图片列表数据
  426. function appendShopOrderHead(data, index) {
  427. var html = '<tr id ="ai' + index + '">' +
  428. '<td>' +
  429. '<input class="check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
  430. '</td>' +
  431. '<td>' +
  432. '<img src="' + data.image + '" width="60px" border="none" title="启用">' +
  433. '</td>' +
  434. '<td>' +
  435. data.productName +
  436. '</td>' +
  437. '<td>' +
  438. data.shopName +
  439. '</td>' +
  440. '<td>' +
  441. (data.pcStatus == 1 ? (
  442. '<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
  443. '<a href="javascript:void(0);" onclick="updatePcStatus(0,' + index + ');" >' +
  444. '停用</a>'
  445. ) : (
  446. '<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
  447. '<a href="javascript:void(0)" onclick="updatePcStatus(1,' + index + ');">' +
  448. '启用</a>'
  449. )) +
  450. '</td>' +
  451. '<td>' +
  452. (data.appletsStatus == 1 ? (
  453. '<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
  454. '<a href="javascript:void(0);" onclick="updateAppletsStatus(0,' + index + ');" >' +
  455. '停用</a>'
  456. ) : (
  457. '<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
  458. '<a href="javascript:void(0)" onclick="updateAppletsStatus(1,' + index + ');">' +
  459. '启用</a>'
  460. )) +
  461. '</td>' +
  462. '<td>' +
  463. '<input name="sort" style="width:50px;" value="' + data.sort + '" onkeyup="onlynum(this)" onchange="changeSort(' + index + ',this)"></td>' +
  464. '</td>' +
  465. '<td>' +
  466. (data.addTime == '' ? (
  467. '<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
  468. ) : (
  469. data.addTime
  470. )) +
  471. '</td>' +
  472. '<td>' +
  473. '<a href="javascript:;" onclick="delect(' + index + ')">删除</a>' +
  474. '</td>' +
  475. '</tr>';
  476. return html;
  477. }
  478. function insertHtml(list) {
  479. var html = '';
  480. productIds = '';
  481. list.forEach(function (item, index) {
  482. html += appendShopOrderHead(item, index);
  483. productIds += "," + item.productId;
  484. });
  485. $("#hotSearch").html(html);
  486. }
  487. function changeSort(index, sortThis) {
  488. var sort = sortThis.value;
  489. if (sort <= 0) {
  490. }
  491. var image = imageList[index];
  492. image.sort = sort;
  493. }
  494. function updatePcStatus(status, index) {
  495. var image = imageList[index];
  496. confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
  497. image.pcStatus = status;
  498. batchSaveSort();
  499. })
  500. }
  501. function updateAppletsStatus(status, index) {
  502. var image = imageList[index];
  503. confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
  504. image.appletsStatus = status;
  505. batchSaveSort();
  506. })
  507. }
  508. function clickAllSelect(ckb) {
  509. var isChecked = ckb.checked;
  510. $(".check-item").attr('checked', isChecked);
  511. }
  512. /**
  513. * 删除操作
  514. */
  515. function delect(index) {
  516. return confirmx("确定删除吗?", function () {
  517. var image = imageList[index];
  518. if (image.productId != '') {
  519. productIds = productIds.replace(image.productId,"");
  520. }
  521. imageList.splice(index, 1);
  522. insertHtml(imageList);
  523. if (imageList.length == 0) {
  524. $('#contentTable').hide();
  525. $("#del").attr("disabled", "disabled");
  526. }
  527. });
  528. }
  529. /**
  530. * 批量删除
  531. */
  532. function batchDeletion() {
  533. var index = -1;
  534. var i = 1;
  535. return confirmx("确定删除吗?", function () {
  536. $('input[name="info"]:checked').each(function () {
  537. var thisIndex = $(this).val();
  538. if (index >= 0 && index < thisIndex) {
  539. thisIndex = thisIndex - i;
  540. i++;
  541. } else {
  542. index = thisIndex;
  543. }
  544. var image = imageList[thisIndex];
  545. if (image.productId != '') {
  546. productIds = productIds.replace(image.productId, "");
  547. }
  548. imageList.splice(thisIndex, 1);
  549. insertHtml(imageList);
  550. if (imageList.length == 0) {
  551. $('#contentTable').hide();
  552. $("#del").attr("disabled", "disabled");
  553. }
  554. });
  555. });
  556. }
  557. function productShow() {
  558. var productType = $("input[name='productType']:checked").val();
  559. if (productType == 2){
  560. $(".productData").show();
  561. }else {
  562. $(".productData").hide();
  563. }
  564. }
  565. function statusShow() {
  566. var status = $("input[name='status']:checked").val();
  567. if (status == 2) {
  568. $("#initializeShow").hide();
  569. $("#closeShow").show();
  570. } else {
  571. $("#initializeShow").show();
  572. $("#closeShow").hide();
  573. $("#hiddenStatus").val(0);
  574. }
  575. }
  576. function dateShow() {
  577. var startDate = $("#startDate").val();
  578. var startMs = new Date(startDate).getTime();
  579. var endDate = $("#endDate").val();
  580. var endMs = new Date(endDate).getTime();
  581. var nowMs = new Date().getTime();
  582. if (nowMs < startMs) {
  583. $("#initializeShow").html("<font color=\"#800080\">未生效</font>");
  584. } else if (nowMs > endMs) {
  585. $("#initializeShow").html("<font color=\"#FF6600\">已失效</font>");
  586. } else {
  587. $("#initializeShow").html("<font color=\"#00CC66\">已生效</font>");
  588. }
  589. }
  590. /**
  591. * @param obj
  592. * jquery控制input只能输入数字
  593. */
  594. function onlynum(obj) {
  595. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  596. }
  597. function changeCondition(flag, name) {
  598. var obj = $("#" + flag);
  599. var val = obj.val();
  600. if (val === '1') {
  601. obj.val(0);
  602. val = '0';
  603. } else {
  604. obj.val(1);
  605. val = '1';
  606. }
  607. var inputObj = $("#" + name);
  608. // 临时数据
  609. var tempObj = $("#" + name + "Temp");
  610. if (name.indexOf("Time") !== -1) {
  611. //修改时间
  612. if (val === '1') {
  613. inputObj.attr('onclick', '');
  614. inputObj.removeClass('required');
  615. } else {
  616. inputObj.attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
  617. inputObj.addClass('required');
  618. }
  619. }else {
  620. if (val === '1') {
  621. inputObj.attr('readonly', true);
  622. inputObj.attr('required', false);
  623. } else {
  624. inputObj.attr('readonly', false);
  625. inputObj.attr('required', true);
  626. }
  627. }
  628. if (val === '1') {
  629. tempObj.val(inputObj.val());
  630. inputObj.val('');
  631. } else {
  632. inputObj.val(tempObj.val());
  633. tempObj.val('');
  634. }
  635. }
  636. function initInputDisplay() {
  637. var receiveFlag = $("#receiveFlag").val();
  638. if (receiveFlag === '1') {
  639. $("#receivePeriod").attr('readonly', true);
  640. $("#receivePeriod").attr('required', false);
  641. } else {
  642. $("#receivePeriod").attr('readonly', false);
  643. $("#receivePeriod").attr('required', true);
  644. }
  645. }
  646. function changeUseTime(flag) {
  647. var obj = $("#" + flag);
  648. var val = obj.val();
  649. if (val === '1') {
  650. obj.val(0);
  651. val = '0';
  652. } else {
  653. obj.val(1);
  654. val = '1';
  655. }
  656. var temp = $("#usePeriodTemp").val();
  657. var use = $("#usePeriod").val();
  658. var receive = $("#receivePeriod").val();
  659. var receiveTemp = $("#receivePeriodTemp").val();
  660. var receiveFlag = $("#receiveFlag").val();
  661. if (val === '1') {
  662. $("#usePeriod").attr('readonly', true);
  663. $("#usePeriod").attr('required', false);
  664. $("#receivePeriodTemp").val(receive);
  665. $("#usePeriodTemp").val(use);
  666. $("#usePeriod").val('');
  667. $("#receivePeriod").val('');
  668. $("#receivePeriod").attr('readonly', true);
  669. $('[name="receiveFlag"]').attr('checked', true);
  670. $('[name="receiveFlag"]').attr('disabled', true);
  671. $("#receivePeriod").removeAttr('required');
  672. $('[name="receiveFlag"]').val(1);
  673. } else {
  674. $("#usePeriod").attr('readonly', false);
  675. $("#usePeriod").attr('required', true);
  676. $('[name="receiveFlag"]').attr('disabled', false);
  677. if (receive > 0) {
  678. $("#receivePeriod").attr('readonly', true);
  679. $('[name="receiveFlag"]').attr('checked', true);
  680. } else {
  681. $("#receivePeriod").attr('readonly', false);
  682. $('[name="receiveFlag"]').attr('checked', false);
  683. }
  684. if (receiveTemp > 0) {
  685. $("#receivePeriod").val(receiveTemp);
  686. $('[name="receiveFlag"]').val(0);
  687. }else{
  688. $('[name="receiveFlag"]').attr('checked', true);
  689. $("#receivePeriod").attr('readonly', true);
  690. }
  691. $("#usePeriod").val(temp);
  692. }
  693. }
  694. function initUseTimeFlag() {
  695. var receiveFlag = $("#useTimeFlag").val();
  696. if (receiveFlag === '1') {
  697. $("#usePeriod").attr('readonly', true);
  698. $("#usePeriod").attr('required', false);
  699. $("#receivePeriod").attr('readonly', true);
  700. $('[name="receiveFlag"]').attr('disabled', 'disabled');
  701. $('[name="receiveFlag"]').attr('checked', true);
  702. $('[name="receiveFlag"]').val(1);
  703. $("#receivePeriod").removeAttr('required');
  704. } else {
  705. $('[name="receiveFlag"]').attr('disabled', false);
  706. $("#usePeriod").attr('readonly', false);
  707. $("#usePeriod").attr('required', true);
  708. }
  709. }
  710. </script>
  711. </body>
  712. </html>