cmHeheImageForm.jsp 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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. .relative-pst{
  64. position: relative;
  65. }
  66. </style>
  67. <script type="text/javascript">
  68. $(document).ready(function() {
  69. //$("#name").focus();
  70. $("#inputForm").validate({
  71. submitHandler: function(form){
  72. var image = $("#image").val();
  73. if (image == '') {
  74. alertx("请上传轮播图");
  75. return false;
  76. }
  77. var jumpType = $("input[name='jumpType']:checked").val();
  78. if (3 == jumpType) {
  79. var jumpImage = $("#jumpImage").val();
  80. if (jumpImage == '') {
  81. alertx("请上传跳转图片");
  82. return false;
  83. }
  84. }
  85. loading('正在提交,请稍等...');
  86. form.submit();
  87. },
  88. errorContainer: "#messageBox",
  89. errorPlacement: function(error, element) {
  90. $("#messageBox").text("输入有误,请先更正。");
  91. if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
  92. error.appendTo(element.parent().parent());
  93. } else {
  94. error.insertAfter(element);
  95. }
  96. }
  97. });
  98. });
  99. </script>
  100. </head>
  101. <body>
  102. <ul class="nav nav-tabs">
  103. <li><a href="${ctx}/hehe/cmHeheImage/">轮播图列表</a></li>
  104. <li class="active"><a href="${ctx}/hehe/cmHeheImage/form?id=${cmHeheImage.id}">${not empty cmHeheImage.id?'编辑':'添加'}</a></li>
  105. </ul><br/>
  106. <form:form id="inputForm" modelAttribute="cmHeheImage" action="${ctx}/hehe/cmHeheImage/save" method="post" class="form-horizontal">
  107. <form:hidden path="id"/>
  108. <sys:message content="${message}"/>
  109. <div class="control-group">
  110. <label class="control-label"><font color="red">*</font>主题:</label>
  111. <div class="controls">
  112. <form:input path="topic" htmlEscape="false" placeholder="最多输入30个汉字" style="position:relative" maxlength="30" class="input-xlarge required"/>
  113. </div>
  114. </div>
  115. <div class="control-group iconBox">
  116. <label class="control-label"><font color="red">*</font>图片:</label>
  117. <div class="controls upload-content" id="imageBox">
  118. <div class="conList">
  119. <form:hidden id="image" path="image" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
  120. <sys:ckfinder input="image" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  121. <br>
  122. <label style="margin-left: 20px">建议图片分辨率750px*366px</label>
  123. </div>
  124. </div>
  125. </div>
  126. <div class="control-group">
  127. <label class="control-label">跳转方式:</label>
  128. <div class="controls" style="margin-top: 10px">
  129. <input type="radio" name="jumpType" value="4" class="relative-pst" onchange="changeJumpType()" ${cmHeheImage.jumpType eq 4 ? "checked" : ""} />无:
  130. </div>
  131. <div class="controls">
  132. <input type="radio" name="jumpType" value="1" class="relative-pst" onchange="changeJumpType()" ${(cmHeheImage.jumpType eq null || cmHeheImage.jumpType eq 1 )? "checked" : ""} />链接:
  133. <form:input path="jumpLink" htmlEscape="false" class="input-xxlarge relative-pst"/>
  134. </div>
  135. <div class="controls" style="margin-top: 10px">
  136. <input type="radio" name="jumpType" value="2" class="relative-pst" onchange="changeJumpType()" ${cmHeheImage.jumpType eq 2 ? "checked" : ""} />产品:
  137. <form:select path="jumpProductId" class="select-ele input-xlarge">
  138. <form:option value="" label="请选择"/>
  139. <form:options items="${productList}" itemLabel="name" itemValue="productId"
  140. htmlEscape="false"/>
  141. </form:select>
  142. </div>
  143. <div class="controls upload-content" id="jumpImageBox">
  144. <input type="radio" name="jumpType" value="3" onchange="changeJumpType()" ${cmHeheImage.jumpType eq 3 ? "checked" : ""} />图片:
  145. <div class="conList iconBox">
  146. <form:hidden id="jumpImage" path="jumpImage" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
  147. <sys:ckfinder input="jumpImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  148. <br>
  149. <label style="margin-left: 20px">建议图片分辨率750px*1624px</label>
  150. </div>
  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:input path="sort" onkeyup="onlynum(this)" htmlEscape="false" class="input-xlarge required"/>
  157. </div>
  158. </div>
  159. <div class="control-group">
  160. <label class="control-label"><font color="red">*</font>状态:</label>
  161. <div class="controls">
  162. <form:select path="status" class="input-xlarge required">
  163. <form:option value="1" label="启用"/>
  164. <form:option value="2" label="停用"/>
  165. </form:select>
  166. </div>
  167. </div>
  168. <div class="form-actions">
  169. <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
  170. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  171. </div>
  172. </form:form>
  173. <script>
  174. $(function () {
  175. $('.upload-content .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
  176. $('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
  177. $('.upload-content .conList').find('.cancel-upload').hide();
  178. var observeEle = document.getElementsByClassName('upload-content')[0];
  179. var observeEle1 = document.getElementsByClassName('upload-content')[1];
  180. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
  181. var MutationObserverConfig = {
  182. childList: true,
  183. subtree: true,
  184. characterData: true
  185. };
  186. var observer = new MutationObserver(function (mutations) {
  187. $.each(mutations, function (index, item) {
  188. if (item.type === 'childList') {
  189. // 在创建新的 element 时调用
  190. var target = $(item.target),
  191. thisWrapper = target.closest('.conList'),
  192. nextEle = thisWrapper.next();
  193. thisWrapper.find('li').css('z-index', 99);
  194. thisWrapper.find('.cancel-upload').show();
  195. if (nextEle.hasClass('hide-pic')) {
  196. nextEle.removeClass('hide-pic');
  197. }
  198. }
  199. })
  200. });
  201. observer.observe(observeEle, MutationObserverConfig);
  202. observer.observe(observeEle1, MutationObserverConfig);
  203. $('body').on('click', '.cancel-upload', function () {
  204. var wrapper = $(this).closest('.conList');
  205. wrapper.find('li').css('z-index', '-1');
  206. wrapper.find('input').val('');
  207. $(this).hide();
  208. wrapper.removeClass("hide-pic");
  209. wrapper.parent().append(wrapper.clone());
  210. wrapper.remove();
  211. $(".conList").each(function (i, ele) {
  212. if ($(ele).find("input.input-xlarge").val()) {
  213. $(ele).next().removeClass("hide-pic")
  214. }
  215. })
  216. });
  217. $(window).on("load", function () {
  218. setTimeout(function () {
  219. $("#imageBox").find("input.input-xlarge").each(function (i, ele) {
  220. if ($(ele).val()) {
  221. $(ele).next().find("li").css("z-index", "99");
  222. $(ele).parents(".conList").find(".cancel-upload").show();
  223. $(ele).parents(".conList").next().removeClass("hide-pic")
  224. }
  225. })
  226. $("#jumpImageBox").find("input.input-xlarge").each(function (i, ele) {
  227. if ($(ele).val()) {
  228. $(ele).next().find("li").css("z-index", "99");
  229. $(ele).parents(".conList").find(".cancel-upload").show();
  230. $(ele).parents(".conList").next().removeClass("hide-pic")
  231. }
  232. })
  233. }, 200);
  234. });
  235. changeJumpType();
  236. });
  237. /**
  238. * @param obj
  239. * jquery控制input只能输入数字
  240. */
  241. function onlynum(obj) {
  242. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  243. }
  244. function changeJumpType() {
  245. var jumpType = $("input[name='jumpType']:checked").val();
  246. var jumpLink = $("#jumpLink");
  247. var jumpProductId = $("#jumpProductId");
  248. if (1 == jumpType) {
  249. jumpLink.addClass("required");
  250. jumpProductId.removeClass("required");
  251. }else if (2 == jumpType) {
  252. jumpProductId.addClass("required");
  253. jumpLink.removeClass("required");
  254. } else {
  255. jumpProductId.removeClass("required");
  256. jumpLink.removeClass("required");
  257. }
  258. }
  259. </script>
  260. </body>
  261. </html>