cmCouponForm.jsp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  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. if (imageList.length > 0) {
  14. var productInfo = JSON.stringify(imageList);
  15. $('#productInfo').val(productInfo);
  16. }
  17. var productType = $("input[name='productType']:checked").val();
  18. if (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?couponType=0">活动券</a></li>
  110. <li class="active"><a href="${ctx}/coupon/cmCoupon/form?couponType=0&id=${cmCoupon.id}">${not empty cmCoupon.id?'编辑':'添加'}</a></li>
  111. </ul><br/>
  112. <font style="color: red;margin-left: 20px">活动券适合在某些节日或者主题活动时创建,并且适用于全部客户以及商城全部商品或指定商品(不包括二手商品)。</font><br><br>
  113. <form:form id="inputForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/save" method="post" class="form-horizontal">
  114. <form:hidden path="id"/>
  115. <form:hidden path="productInfo" id="productInfo"/>
  116. <input type="hidden" name="couponType" value="0"/>
  117. <sys:message content="${message}"/>
  118. <form:hidden path="receiveFlag"/>
  119. <div class="control-group">
  120. <label class="control-label"><font color="red">*</font>活动主题:</label>
  121. <div class="controls">
  122. <form:input path="name" htmlEscape="false" maxlength="30" placeholder="30个汉字以内" class="input-xlarge required"/>
  123. </div>
  124. </div>
  125. <div class="control-group">
  126. <label class="control-label"><font color="red">*</font>优惠券金额:</label>
  127. <div class="controls">
  128. <input type="number" id="couponAmount" name="couponAmount" value="${cmCoupon.couponAmount}" min="0" required>
  129. </div>
  130. </div>
  131. <div class="control-group">
  132. <label class="control-label"><font color="red">*</font>优惠条件:</label>
  133. <div class="controls">
  134. 订单商品总额满&nbsp;&nbsp;&nbsp;&nbsp;<input type="number" name="touchPrice" id="touchPrice" value="${cmCoupon.touchPrice}" min="0" required>
  135. </div>
  136. </div>
  137. <div class="control-group">
  138. <label class="control-label"><font color="red">*</font>开始时间:</label>
  139. <div class="controls">
  140. <input name="startDate" id="startDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
  141. value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM-dd 00:00:00"/>"
  142. onclick="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00',isShowClear:false});" onblur="dateShow()">
  143. </div>
  144. </div>
  145. <div class="control-group">
  146. <label class="control-label"><font color="red">*</font>结束时间:</label>
  147. <div class="controls">
  148. <input name="endDate" id="endDate" type="text" required readonly="readonly" maxlength="20" class="input-medium Wdate "
  149. value="<fmt:formatDate value="${cmCoupon.endDate}" pattern="yyyy-MM-dd 23:59:59"/>"
  150. onclick="WdatePicker({dateFmt:'yyyy-MM-dd 23:59:59',isShowClear:false});" onblur="dateShow()"/>
  151. </div>
  152. </div>
  153. <div class="control-group">
  154. <label class="control-label"><font color="red">*</font>领取期限:</label>
  155. <div class="controls">
  156. <input type="number" id="receivePeriod" name="receivePeriod" onkeyup="onlynum(this)" value="${cmCoupon.receivePeriod}" min="1" required> 天
  157. <input type="checkbox" id="receiveFlag" name="receiveFlag" style="margin-left:20px !important" value="${cmCoupon.receiveFlag eq 1?1:0}"
  158. ${cmCoupon.receiveFlag eq 1 ? "checked" : ""} onclick="changeCondition('receiveFlag','receivePeriod')" />同活动开始-结束时间
  159. <input id="receivePeriodTemp" type="hidden" value="${cmCoupon.receivePeriod}">
  160. </div>
  161. </div>
  162. <div class="control-group">
  163. <label class="control-label"><font color="red">*</font>使用期限:</label>
  164. <div class="controls">
  165. <input type="number" id="usePeriod" name="usePeriod" value="${cmCoupon.usePeriod}" min="1" required> 天
  166. </div>
  167. </div>
  168. <div class="control-group">
  169. <label class="control-label"><font color="red">*</font>优惠状态:</label>
  170. <div class="controls">
  171. <label id="initializeShow">
  172. <c:if test="${empty cmCoupon.status || cmCoupon.status eq 0}">
  173. <font color="#800080">未生效</font>
  174. </c:if>
  175. <c:if test="${cmCoupon.status eq 1}">
  176. <font color="#00CC66">已生效</font>
  177. </c:if>
  178. <c:if test="${cmCoupon.status eq 2}">
  179. <font color="red">已关闭</font>
  180. </c:if>
  181. <c:if test="${cmCoupon.status eq 3}">
  182. <font color="#FF6600">已失效</font>
  183. </c:if>
  184. </label>
  185. <label id="closeShow" style="display: none">
  186. <font color="red">已关闭</font>
  187. </label>
  188. <input type="hidden" id="hiddenStatus" name="status" value="">
  189. <input type="checkbox" id="status" name="status" value="2" ${cmCoupon.status eq "2" ? "checked" : ""} onclick="statusShow()" />关闭
  190. </div>
  191. </div>
  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="showSelect()" value="添加"/>
  224. <br><br>
  225. <table id="contentTable" 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="hotSearch"></tbody>
  241. </table>
  242. </div>
  243. </div>
  244. <div class="form-actions">
  245. <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
  246. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  247. </div>
  248. </form:form>
  249. <script>
  250. //图片初始化
  251. $(function () {
  252. $('.upload-content-image .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
  253. $('.upload-content-image .conList .btn:nth-of-type(2)').after('<img class="cancel-upload-image" src="/static/images/close-btn1.png">').remove();
  254. $('.upload-content-image .conList').find('.cancel-upload-image').hide();
  255. var observeEleImage = document.getElementsByClassName('upload-content-image')[0];
  256. var observeEleImage1 = document.getElementsByClassName('upload-content-image')[1];
  257. var MutationObserverImage = window.MutationObserver || window.WebKitMutationObserver;
  258. var MutationObserverConfigImage = {
  259. childList: true,
  260. subtree: true,
  261. characterData: true
  262. };
  263. var observerImage = new MutationObserverImage(function (mutations) {
  264. $.each(mutations, function (index, item) {
  265. if (item.type === 'childList') {
  266. // 在创建新的 element 时调用
  267. var target = $(item.target),
  268. thisWrapper = target.closest('.conList'),
  269. nextEle = thisWrapper.next();
  270. thisWrapper.find('li').css('z-index', 99);
  271. thisWrapper.find('.cancel-upload-image').show();
  272. if (nextEle.hasClass('hide-pic-image')) {
  273. nextEle.removeClass('hide-pic-image');
  274. }
  275. }
  276. })
  277. });
  278. observerImage.observe(observeEleImage, MutationObserverConfigImage);
  279. observerImage.observe(observeEleImage1, MutationObserverConfigImage);
  280. $('body').on('click', '.upload-content-image li', function () {
  281. var index = $(this).closest('.conList').index() + 1,
  282. str = 'remarkImage' + index + 'FinderOpen';
  283. eval(str + '()');
  284. });
  285. $('body').on('click', '.cancel-upload-image', function () {
  286. var wrapper = $(this).closest('.conList');
  287. wrapper.find('li').css('z-index', '-1');
  288. wrapper.find('input').val('');
  289. $(this).hide();
  290. wrapper.removeClass("hide-pic-image");
  291. wrapper.parent().append(wrapper.clone());
  292. wrapper.remove();
  293. $(".conList").each(function (i, ele) {
  294. if ($(ele).find("input.input-xlarge").val()) {
  295. $(ele).next().removeClass("hide-pic-image")
  296. }
  297. })
  298. });
  299. $(window).on("load", function () {
  300. setTimeout(function () {
  301. var input = $("#pcBanner");
  302. if (input.val()) {
  303. input.next().find("li").css("z-index", "99");
  304. input.parents(".conList").find(".cancel-upload-image").show();
  305. input.parents(".conList").next().removeClass("hide-pic-image")
  306. }
  307. input = $("#appletsBanner");
  308. if (input.val()) {
  309. input.next().find("li").css("z-index", "99");
  310. input.parents(".conList").find(".cancel-upload-image").show();
  311. input.parents(".conList").next().removeClass("hide-pic-image")
  312. }
  313. }, 500);
  314. });
  315. productShow();
  316. initInputDisplay();
  317. });
  318. var productIds = '';
  319. var imageList = [];
  320. $(function () {
  321. <c:forEach items="${associateList}" var="associate" varStatus="index">
  322. imageList.push({
  323. id: "${associate.id}",
  324. productId: "${empty associate.productId ? "":associate.productId}",
  325. image: "${associate.image}",
  326. productName: "${associate.productName}",
  327. shopName: "${associate.shopName}",
  328. sort: "${associate.sort}",
  329. pcStatus: "${associate.pcStatus}",
  330. appletsStatus: "${associate.appletsStatus}",
  331. addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
  332. });
  333. </c:forEach>
  334. if (imageList.length > 0) {
  335. $('#contentTable').show();
  336. batchSaveSort();
  337. }
  338. });
  339. //点击添加
  340. function showSelect() {
  341. var url = "${ctx}/coupon/cmCoupon/toAddProduct?productIds=" + productIds;
  342. var title = '';
  343. title = "选择商品";
  344. top.$.jBox("iframe:" + url, {
  345. iframeScrolling: 'yes',
  346. width: $(top.document).width() - 400,
  347. height: $(top.document).height() - 160,
  348. persistent: true,
  349. title: title,
  350. buttons: {"确定": '1', "取消": '-1'},
  351. submit: function (v, h, f) {
  352. //确定
  353. var $jboxFrame = top.$('#jbox-iframe');
  354. var $mainFrame = top.$('#mainFrame');
  355. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  356. var items = $jboxFrame[0].contentWindow.getCheckedItems();
  357. console.log(items);
  358. console.log(items[0]);
  359. for (var i = 0; i < items.length; i++) {
  360. console.log(items[i]);
  361. imageList.push(items[i]);
  362. $('#contentTable').show();
  363. $("#del").removeAttr("disabled");
  364. batchSaveSort();
  365. };
  366. }
  367. return true;
  368. }
  369. });
  370. }
  371. /**
  372. * 一键排序
  373. */
  374. function batchSaveSort() {
  375. imageList.sort(sort);
  376. insertHtml(imageList);
  377. }
  378. //根据sort值 从小到大排序
  379. function sort(a, b) {
  380. return a.sort - b.sort;
  381. }
  382. //相关图片列表数据
  383. function appendShopOrderHead(data, index) {
  384. var html = '<tr id ="ai' + index + '">' +
  385. '<td>' +
  386. '<input class="check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
  387. '</td>' +
  388. '<td>' +
  389. '<img src="' + data.image + '" width="60px" border="none" title="启用">' +
  390. '</td>' +
  391. '<td>' +
  392. data.productName +
  393. '</td>' +
  394. '<td>' +
  395. data.shopName +
  396. '</td>' +
  397. '<td>' +
  398. (data.pcStatus == 1 ? (
  399. '<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
  400. '<a href="javascript:void(0);" onclick="updatePcStatus(0,' + index + ');" >' +
  401. '停用</a>'
  402. ) : (
  403. '<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
  404. '<a href="javascript:void(0)" onclick="updatePcStatus(1,' + index + ');">' +
  405. '启用</a>'
  406. )) +
  407. '</td>' +
  408. '<td>' +
  409. (data.appletsStatus == 1 ? (
  410. '<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
  411. '<a href="javascript:void(0);" onclick="updateAppletsStatus(0,' + index + ');" >' +
  412. '停用</a>'
  413. ) : (
  414. '<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
  415. '<a href="javascript:void(0)" onclick="updateAppletsStatus(1,' + index + ');">' +
  416. '启用</a>'
  417. )) +
  418. '</td>' +
  419. '<td>' +
  420. '<input name="sort" style="width:50px;" value="' + data.sort + '" onkeyup="onlynum(this)" onchange="changeSort(' + index + ',this)"></td>' +
  421. '</td>' +
  422. '<td>' +
  423. (data.addTime == '' ? (
  424. '<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
  425. ) : (
  426. data.addTime
  427. )) +
  428. '</td>' +
  429. '<td>' +
  430. '<a href="javascript:;" onclick="delect(' + index + ')">删除</a>' +
  431. '</td>' +
  432. '</tr>';
  433. return html;
  434. }
  435. function insertHtml(list) {
  436. var html = '';
  437. productIds = '';
  438. list.forEach(function (item, index) {
  439. html += appendShopOrderHead(item, index);
  440. productIds += "," + item.productId;
  441. });
  442. $("#hotSearch").html(html);
  443. }
  444. function changeSort(index, sortThis) {
  445. var sort = sortThis.value;
  446. if (sort <= 0) {
  447. }
  448. var image = imageList[index];
  449. image.sort = sort;
  450. }
  451. function updatePcStatus(status, index) {
  452. var image = imageList[index];
  453. confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
  454. image.pcStatus = status;
  455. batchSaveSort();
  456. })
  457. }
  458. function updateAppletsStatus(status, index) {
  459. var image = imageList[index];
  460. confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
  461. image.appletsStatus = status;
  462. batchSaveSort();
  463. })
  464. }
  465. function clickAllSelect(ckb) {
  466. var isChecked = ckb.checked;
  467. $(".check-item").attr('checked', isChecked);
  468. }
  469. /**
  470. * 删除操作
  471. */
  472. function delect(index) {
  473. return confirmx("确定删除吗?", function () {
  474. var image = imageList[index];
  475. if (image.productId != '') {
  476. productIds = productIds.replace(image.productId,"");
  477. }
  478. imageList.splice(index, 1);
  479. insertHtml(imageList);
  480. if (imageList.length == 0) {
  481. $('#contentTable').hide();
  482. $("#del").attr("disabled", "disabled");
  483. }
  484. });
  485. }
  486. /**
  487. * 批量删除
  488. */
  489. function batchDeletion() {
  490. var index = -1;
  491. var i = 1;
  492. return confirmx("确定删除吗?", function () {
  493. $('input[name="info"]:checked').each(function () {
  494. var thisIndex = $(this).val();
  495. if (index >= 0 && index < thisIndex) {
  496. thisIndex = thisIndex - i;
  497. i++;
  498. } else {
  499. index = thisIndex;
  500. }
  501. var image = imageList[thisIndex];
  502. if (image.productId != '') {
  503. productIds = productIds.replace(image.productId, "");
  504. }
  505. imageList.splice(thisIndex, 1);
  506. insertHtml(imageList);
  507. if (imageList.length == 0) {
  508. $('#contentTable').hide();
  509. $("#del").attr("disabled", "disabled");
  510. }
  511. });
  512. });
  513. }
  514. function productShow() {
  515. var productType = $("input[name='productType']:checked").val();
  516. if (productType == 2){
  517. $(".productData").show();
  518. }else {
  519. $(".productData").hide();
  520. }
  521. }
  522. function statusShow() {
  523. var status = $("input[name='status']:checked").val();
  524. if (status == 2) {
  525. $("#initializeShow").hide();
  526. $("#closeShow").show();
  527. } else {
  528. $("#initializeShow").show();
  529. $("#closeShow").hide();
  530. $("#hiddenStatus").val(0);
  531. }
  532. }
  533. function dateShow() {
  534. var startDate = $("#startDate").val();
  535. var startMs = new Date(startDate).getTime();
  536. var endDate = $("#endDate").val();
  537. var endMs = new Date(endDate).getTime();
  538. var nowMs = new Date().getTime();
  539. if (nowMs < startMs) {
  540. $("#initializeShow").html("<font color=\"#800080\">未生效</font>");
  541. } else if (nowMs > endMs) {
  542. $("#initializeShow").html("<font color=\"#FF6600\">已失效</font>");
  543. } else {
  544. $("#initializeShow").html("<font color=\"#00CC66\">已生效</font>");
  545. }
  546. }
  547. /**
  548. * @param obj
  549. * jquery控制input只能输入数字
  550. */
  551. function onlynum(obj) {
  552. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  553. }
  554. function changeCondition(flag, name) {
  555. var obj = $("#" + flag);
  556. var val = obj.val();
  557. if (val === '1') {
  558. obj.val(0);
  559. val = '0';
  560. } else {
  561. obj.val(1);
  562. val = '1';
  563. }
  564. var inputObj = $("#" + name);
  565. // 临时数据
  566. var tempObj = $("#" + name + "Temp");
  567. if (name.indexOf("Time") !== -1) {
  568. //修改时间
  569. if (val === '1') {
  570. inputObj.attr('onclick', '');
  571. inputObj.removeClass('required');
  572. } else {
  573. inputObj.attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
  574. inputObj.addClass('required');
  575. }
  576. }else {
  577. if (val === '1') {
  578. inputObj.attr('readonly', true);
  579. inputObj.attr('required', false);
  580. } else {
  581. inputObj.attr('readonly', false);
  582. inputObj.attr('required', true);
  583. }
  584. }
  585. if (val === '1') {
  586. tempObj.val(inputObj.val());
  587. inputObj.val('');
  588. } else {
  589. inputObj.val(tempObj.val());
  590. tempObj.val('');
  591. }
  592. }
  593. function initInputDisplay() {
  594. var receiveFlag = $("#receiveFlag").val();
  595. if (receiveFlag === '1') {
  596. $("#receivePeriod").attr('readonly', true);
  597. $("#receivePeriod").attr('required', false);
  598. } else {
  599. $("#receivePeriod").attr('readonly', false);
  600. $("#receivePeriod").attr('required', true);
  601. }
  602. }
  603. </script>
  604. </body>
  605. </html>