cmHeheImageForm.jsp 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
  3. <html>
  4. <head>
  5. <title>呵呵轮播图管理</title>
  6. <meta name="decorator" content="default"/>
  7. <style>
  8. .iconBox{
  9. font-size: 0;
  10. }
  11. .controls .conList{
  12. display: inline-block;
  13. margin-right: 15px;
  14. }
  15. .conList .btn:nth-of-type(1){
  16. margin-left: 25px;
  17. }
  18. .upload-content {
  19. margin-top: -70px;
  20. }
  21. .upload-content .conList .btn:nth-of-type(1) {
  22. width: 90px;
  23. height: 100px;
  24. border: 2px solid #eee;
  25. background: #fff;
  26. position: relative;
  27. }
  28. .upload-content .conList .btn:nth-of-type(1)>div {
  29. position: absolute;
  30. top: 50%;
  31. left: 50%;
  32. transform: translate(-50%, -50%);
  33. color: #666;
  34. }
  35. .upload-content .conList .btn:nth-of-type(1) span {
  36. font-size: 35px;
  37. }
  38. .upload-content .conList .btn:nth-of-type(1) h5 {
  39. color: #666;
  40. }
  41. .cancel-upload {
  42. background: transparent;
  43. border: none;
  44. box-shadow: none;
  45. position: relative;
  46. top: -38px;
  47. left: -25px;
  48. cursor: pointer;
  49. z-index: 100;
  50. }
  51. .upload-content .conList ol li {
  52. width: 114px;
  53. min-height: 80px;
  54. text-align: center;
  55. background: #fff;
  56. position: relative;
  57. top: 120px;
  58. margin-left: 2px;
  59. }
  60. .hide-pic {
  61. display: none !important;
  62. }
  63. </style>
  64. <script type="text/javascript">
  65. $(document).ready(function() {
  66. //$("#name").focus();
  67. $("#inputForm").validate({
  68. submitHandler: function(form){
  69. var image = $("#image").val();
  70. if (image == '') {
  71. alertx("请上传轮播图");
  72. return false;
  73. }
  74. var jumpType = $("input[name='jumpType']:checked").val();
  75. if (3 == jumpType) {
  76. var jumpImage = $("#jumpImage").val();
  77. if (jumpImage == '') {
  78. alertx("请上传跳转图片");
  79. return false;
  80. }
  81. }
  82. loading('正在提交,请稍等...');
  83. form.submit();
  84. },
  85. errorContainer: "#messageBox",
  86. errorPlacement: function(error, element) {
  87. $("#messageBox").text("输入有误,请先更正。");
  88. if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
  89. error.appendTo(element.parent().parent());
  90. } else {
  91. error.insertAfter(element);
  92. }
  93. }
  94. });
  95. });
  96. </script>
  97. </head>
  98. <body>
  99. <ul class="nav nav-tabs">
  100. <li><a href="${ctx}/hehe/cmHeheImage/">轮播图列表</a></li>
  101. <li class="active"><a href="${ctx}/hehe/cmHeheImage/form?id=${cmHeheImage.id}">${not empty cmHeheImage.id?'编辑':'添加'}</a></li>
  102. </ul><br/>
  103. <form:form id="inputForm" modelAttribute="cmHeheImage" action="${ctx}/hehe/cmHeheImage/save" method="post" class="form-horizontal">
  104. <form:hidden path="id"/>
  105. <sys:message content="${message}"/>
  106. <div class="control-group">
  107. <label class="control-label"><font color="red">*</font>主题:</label>
  108. <div class="controls">
  109. <form:input path="topic" htmlEscape="false" placeholder="最多输入30个汉字" style="position:relative" maxlength="30" class="input-xlarge required"/>
  110. </div>
  111. </div>
  112. <div class="control-group iconBox">
  113. <label class="control-label"><font color="red">*</font>图片:</label>
  114. <div class="controls upload-content" id="imageBox">
  115. <div class="conList">
  116. <form:hidden id="image" path="image" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
  117. <sys:ckfinder input="image" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  118. <br>
  119. <label style="margin-left: 20px">建议图片分辨率750px*366px</label>
  120. </div>
  121. </div>
  122. </div>
  123. <div class="control-group">
  124. <label class="control-label">跳转方式:</label>
  125. <div class="controls">
  126. <input type="radio" name="jumpType" value="1" onchange="changeJumpType()" ${(cmHeheImage.jumpType eq null || cmHeheImage.jumpType eq 1 )? "checked" : ""} />链接:
  127. <form:input path="jumpLink" htmlEscape="false" class="input-xxlarge"/>
  128. </div>
  129. <div class="controls" style="margin-top: 10px">
  130. <input type="radio" name="jumpType" value="2" onchange="changeJumpType()" ${cmHeheImage.jumpType eq 2 ? "checked" : ""} />产品:
  131. <form:select path="jumpProductId" class="select-ele input-xlarge">
  132. <form:option value="" label="请选择"/>
  133. <form:options items="${productList}" itemLabel="name" itemValue="productId"
  134. htmlEscape="false"/>
  135. </form:select>
  136. </div>
  137. <div class="controls upload-content" id="jumpImageBox">
  138. <input type="radio" name="jumpType" value="3" onchange="changeJumpType()" ${cmHeheImage.jumpType eq 3 ? "checked" : ""} />图片:
  139. <div class="conList iconBox">
  140. <form:hidden id="jumpImage" path="jumpImage" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
  141. <sys:ckfinder input="jumpImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  142. <br>
  143. <label style="margin-left: 20px">建议图片分辨率750px*1624px</label>
  144. </div>
  145. </div>
  146. </div>
  147. <div class="control-group">
  148. <label class="control-label"><font color="red">*</font>排序:</label>
  149. <div class="controls">
  150. <form:input path="sort" onkeyup="onlynum(this)" htmlEscape="false" class="input-xlarge required"/>
  151. </div>
  152. </div>
  153. <div class="control-group">
  154. <label class="control-label"><font color="red">*</font>状态:</label>
  155. <div class="controls">
  156. <form:select path="status" class="input-xlarge required">
  157. <form:option value="1" label="启用"/>
  158. <form:option value="2" label="停用"/>
  159. </form:select>
  160. </div>
  161. </div>
  162. <div class="form-actions">
  163. <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
  164. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  165. </div>
  166. </form:form>
  167. <script>
  168. $(function () {
  169. $('.upload-content .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
  170. $('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
  171. $('.upload-content .conList').find('.cancel-upload').hide();
  172. var observeEle = document.getElementsByClassName('upload-content')[0];
  173. var observeEle1 = document.getElementsByClassName('upload-content')[1];
  174. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
  175. var MutationObserverConfig = {
  176. childList: true,
  177. subtree: true,
  178. characterData: true
  179. };
  180. var observer = new MutationObserver(function (mutations) {
  181. $.each(mutations, function (index, item) {
  182. if (item.type === 'childList') {
  183. // 在创建新的 element 时调用
  184. var target = $(item.target),
  185. thisWrapper = target.closest('.conList'),
  186. nextEle = thisWrapper.next();
  187. thisWrapper.find('li').css('z-index', 99);
  188. thisWrapper.find('.cancel-upload').show();
  189. if (nextEle.hasClass('hide-pic')) {
  190. nextEle.removeClass('hide-pic');
  191. }
  192. }
  193. })
  194. });
  195. observer.observe(observeEle, MutationObserverConfig);
  196. observer.observe(observeEle1, MutationObserverConfig);
  197. $('body').on('click', '.cancel-upload', function () {
  198. var wrapper = $(this).closest('.conList');
  199. wrapper.find('li').css('z-index', '-1');
  200. wrapper.find('input').val('');
  201. $(this).hide();
  202. wrapper.removeClass("hide-pic");
  203. wrapper.parent().append(wrapper.clone());
  204. wrapper.remove();
  205. $(".conList").each(function (i, ele) {
  206. if ($(ele).find("input.input-xlarge").val()) {
  207. $(ele).next().removeClass("hide-pic")
  208. }
  209. })
  210. });
  211. $(window).on("load", function () {
  212. setTimeout(function () {
  213. $("#imageBox").find("input.input-xlarge").each(function (i, ele) {
  214. if ($(ele).val()) {
  215. $(ele).next().find("li").css("z-index", "99");
  216. $(ele).parents(".conList").find(".cancel-upload").show();
  217. $(ele).parents(".conList").next().removeClass("hide-pic")
  218. }
  219. })
  220. $("#jumpImageBox").find("input.input-xlarge").each(function (i, ele) {
  221. if ($(ele).val()) {
  222. $(ele).next().find("li").css("z-index", "99");
  223. $(ele).parents(".conList").find(".cancel-upload").show();
  224. $(ele).parents(".conList").next().removeClass("hide-pic")
  225. }
  226. })
  227. }, 200);
  228. });
  229. changeJumpType();
  230. });
  231. /**
  232. * @param obj
  233. * jquery控制input只能输入数字
  234. */
  235. function onlynum(obj) {
  236. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  237. }
  238. function changeJumpType() {
  239. var jumpType = $("input[name='jumpType']:checked").val();
  240. var jumpLink = $("#jumpLink");
  241. var jumpProductId = $("#jumpProductId");
  242. if (1 == jumpType) {
  243. jumpLink.addClass("required");
  244. jumpProductId.removeClass("required");
  245. }else if (2 == jumpType) {
  246. jumpProductId.addClass("required");
  247. jumpLink.removeClass("required");
  248. } else {
  249. jumpProductId.removeClass("required");
  250. jumpLink.removeClass("required");
  251. }
  252. }
  253. </script>
  254. </body>
  255. </html>