cmBaikeBannerForm.jsp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
  3. <html>
  4. <head>
  5. <title>banner管理</title>
  6. <meta name="decorator" content="default"/>
  7. <style>
  8. .jumpType{
  9. margin-left: 20px;
  10. width: 400px;
  11. }
  12. </style>
  13. <style>
  14. .iconBox {
  15. font-size: 0;
  16. }
  17. .controls .conList {
  18. display: inline-block;
  19. margin-right: 15px;
  20. }
  21. .conList .btn:nth-of-type(1) {
  22. margin-left: 25px;
  23. }
  24. .upload-content {
  25. margin-top: -70px;
  26. }
  27. .upload-content .conList .btn:nth-of-type(1) {
  28. width: 90px;
  29. height: 100px;
  30. border: 2px solid #eee;
  31. background: #fff;
  32. position: relative;
  33. }
  34. .upload-content .conList .btn:nth-of-type(1) > div {
  35. position: absolute;
  36. top: 50%;
  37. left: 50%;
  38. transform: translate(-50%, -50%);
  39. color: #666;
  40. }
  41. .upload-content .conList .btn:nth-of-type(1) span {
  42. font-size: 35px;
  43. }
  44. .upload-content .conList .btn:nth-of-type(1) h5 {
  45. color: #666;
  46. }
  47. .cancel-upload {
  48. background: transparent;
  49. border: none;
  50. box-shadow: none;
  51. position: relative;
  52. top: -38px;
  53. left: -25px;
  54. cursor: pointer;
  55. z-index: 100;
  56. }
  57. .upload-content .conList ol li {
  58. width: 114px;
  59. min-height: 80px;
  60. text-align: center;
  61. background: #fff;
  62. position: relative;
  63. top: 120px;
  64. margin-left: 2px;
  65. }
  66. .hide-pic {
  67. display: none !important;
  68. }
  69. .paramRow {
  70. margin-top: 10px;
  71. }
  72. </style>
  73. <script type="text/javascript">
  74. $(document).ready(function() {
  75. //$("#name").focus();
  76. $("#inputForm").validate({
  77. submitHandler: function(form){
  78. var bannerType = ${cmBaikeBanner.bannerType};
  79. var productPcBanner = $("#productPcBanner").val();
  80. var productAppBanner = $("#productAppBanner").val();
  81. var instrumentPcBanner = $("#instrumentPcBanner").val();
  82. var instrumentAppBanner = $("#instrumentAppBanner").val();
  83. if (bannerType == 1) {
  84. if (productPcBanner === '') {
  85. alertx("请上传pc端banner");
  86. return false;
  87. }
  88. if (productAppBanner === '') {
  89. alertx("请上传移动端banner");
  90. return false;
  91. }
  92. } else {
  93. if (instrumentPcBanner === '') {
  94. alertx("请上传pc端banner");
  95. return false;
  96. }
  97. if (instrumentAppBanner === '') {
  98. alertx("请上传移动端banner");
  99. return false;
  100. }
  101. }
  102. loading('正在提交,请稍等...');
  103. form.submit();
  104. },
  105. errorContainer: "#messageBox",
  106. errorPlacement: function(error, element) {
  107. $("#messageBox").text("输入有误,请先更正。");
  108. if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
  109. error.appendTo(element.parent().parent());
  110. } else {
  111. error.insertAfter(element);
  112. }
  113. }
  114. });
  115. });
  116. </script>
  117. </head>
  118. <body>
  119. <ul class="nav nav-tabs">
  120. <li class="${cmBaikeBanner.bannerType eq 1?'active':''}">
  121. <a href="${ctx}/baike/cmBaikeHotSearch/bannerForm?bannerType=1">产品banner</a>
  122. </li>
  123. <li class="${cmBaikeBanner.bannerType eq 2?'active':''}">
  124. <a href="${ctx}/baike/cmBaikeHotSearch/bannerForm?bannerType=2">仪器banner</a>
  125. </li>
  126. </ul><br/>
  127. <form:form id="inputForm" modelAttribute="cmBaikeBanner" action="${ctx}/baike/cmBaikeHotSearch/saveBanner" method="post" class="form-horizontal">
  128. <form:hidden path="id"/>
  129. <form:hidden path="bannerType" />
  130. <sys:message content="${message}"/>
  131. <div id="pcBanner" style="${cmBaikeBanner.bannerType eq 1?'':'display:none'}">
  132. <div class="control-group iconBox">
  133. <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>PC端banner:</label>
  134. <div class="controls upload-content" id="bannerBox1">
  135. <div class="conList">
  136. <form:hidden id="productPcBanner" path="productPcBanner" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
  137. <sys:ckfinder input="productPcBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"
  138. maxHeight="100"/>
  139. <br>
  140. <label style="margin-left: 150px">建议图片分辨率1920px*510px</label>
  141. </div>
  142. </div>
  143. </div>
  144. <div class="control-group iconBox">
  145. <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>移动端banner:</label>
  146. <div class="controls upload-content" id="bannerBox2">
  147. <div class="conList">
  148. <form:hidden id="productAppBanner" path="productAppBanner" htmlEscape="false" maxlength="255"
  149. class="input-xlarge required"/>
  150. <sys:ckfinder input="productAppBanner" type="images" uploadPath="/photo" selectMultiple="false"
  151. maxWidth="100" maxHeight="100"/>
  152. <br>
  153. <label style="margin-left: 150px">建议图片分辨率750px*366px</label>
  154. </div>
  155. </div>
  156. </div>
  157. <div class="control-group">
  158. <label class="control-label">banner跳转链接:</label>
  159. <div class="controls">
  160. <form:input path="productLink" htmlEscape="false" placeholder="输入URL地址"
  161. class="input-xlarge"/>
  162. </div>
  163. </div>
  164. <div class="control-group">
  165. <label class="control-label">状态:</label>
  166. <div class="controls">
  167. <form:select path="productStatus" class="input-xlarge required">
  168. <form:option value="1" label="启用"/>
  169. <form:option value="0" label="停用"/>
  170. </form:select>
  171. </div>
  172. </div>
  173. </div>
  174. <div id="appBanner" style="${cmBaikeBanner.bannerType eq 2?'':'display:none'}">
  175. <div class="control-group iconBox">
  176. <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>PC端banner:</label>
  177. <div class="controls upload-content" id="bannerBox3">
  178. <div class="conList">
  179. <form:hidden id="instrumentPcBanner" path="instrumentPcBanner" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
  180. <sys:ckfinder input="instrumentPcBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"
  181. maxHeight="100"/>
  182. <br>
  183. <label style="margin-left: 150px">建议图片分辨率1920px*510px</label>
  184. </div>
  185. </div>
  186. </div>
  187. <div class="control-group iconBox">
  188. <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>移动端banner:</label>
  189. <div class="controls upload-content" id="bannerBox4">
  190. <div class="conList">
  191. <form:hidden id="instrumentAppBanner" path="instrumentAppBanner" htmlEscape="false" maxlength="255"
  192. class="input-xlarge required"/>
  193. <sys:ckfinder input="instrumentAppBanner" type="images" uploadPath="/photo" selectMultiple="false"
  194. maxWidth="100" maxHeight="100"/>
  195. <br>
  196. <label style="margin-left: 150px">建议图片分辨率750px*366px</label>
  197. </div>
  198. </div>
  199. </div>
  200. <div class="control-group">
  201. <label class="control-label">banner跳转链接:</label>
  202. <div class="controls">
  203. <form:input path="instrumentLink" htmlEscape="false" placeholder="输入URL地址"
  204. class="input-xlarge"/>
  205. </div>
  206. </div>
  207. <div class="control-group">
  208. <label class="control-label">状态:</label>
  209. <div class="controls">
  210. <form:select path="instrumentStatus" class="input-xlarge required">
  211. <form:option value="1" label="启用"/>
  212. <form:option value="0" label="停用"/>
  213. </form:select>
  214. </div>
  215. </div>
  216. </div>
  217. <div class="form-actions">
  218. <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
  219. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  220. </div>
  221. </form:form>
  222. <script>
  223. $(function () {
  224. $('.upload-content .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
  225. $('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
  226. $('.upload-content .conList').find('.cancel-upload').hide();
  227. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
  228. var MutationObserverConfig = {
  229. childList: true,
  230. subtree: true,
  231. characterData: true
  232. };
  233. var observer = new MutationObserver(function (mutations) {
  234. $.each(mutations, function (index, item) {
  235. debugger
  236. if (item.type === 'childList') {
  237. // 在创建新的 element 时调用
  238. var target = $(item.target),
  239. thisWrapper = target.closest('.conList'),
  240. nextEle = thisWrapper.next();
  241. thisWrapper.find('li').css('z-index', 99);
  242. thisWrapper.find('.cancel-upload').show();
  243. if (nextEle.hasClass('hide-pic')) {
  244. nextEle.removeClass('hide-pic');
  245. }
  246. }
  247. })
  248. });
  249. for (var i = 0; i < 4; i++) {
  250. var observeEle = document.getElementsByClassName('upload-content')[i];
  251. observer.observe(observeEle, MutationObserverConfig)
  252. }
  253. $('body').on('click', '.cancel-upload', function () {
  254. var wrapper = $(this).closest('.conList');
  255. wrapper.find('li').css('z-index', '-1');
  256. wrapper.find('input').val('');
  257. $(this).hide();
  258. wrapper.removeClass("hide-pic");
  259. wrapper.parent().append(wrapper.clone());
  260. wrapper.remove();
  261. $(".conList").each(function (i, ele) {
  262. if ($(ele).find("input.input-xlarge").val()) {
  263. $(ele).next().removeClass("hide-pic")
  264. }
  265. })
  266. });
  267. $(window).on("load", function () {
  268. setTimeout(function () {
  269. for (var i = 1;i<=4;i++) {
  270. $("#bannerBox" + i).find("input.input-xlarge").each(function (i, ele) {
  271. if ($(ele).val()) {
  272. $(ele).next().find("li").css("z-index", "99");
  273. $(ele).parents(".conList").find(".cancel-upload").show();
  274. $(ele).parents(".conList").next().removeClass("hide-pic")
  275. }
  276. });
  277. }
  278. }, 200);
  279. });
  280. });
  281. </script>
  282. </body>
  283. </html>