addProductImage.jsp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <%--
  2. Created by IntelliJ IDEA.
  3. User: Administrator
  4. Date: 2020/4/9
  5. Time: 19:54
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" %>
  9. <%@ include file="/WEB-INF/views/include/taglib.jsp" %>
  10. <html>
  11. <head>
  12. <title>选择商品图片</title>
  13. <meta name="decorator" content="default"/>
  14. <style type="text/css">
  15. .table td i {
  16. margin: 0 2px;
  17. }
  18. </style>
  19. <script type="text/javascript">
  20. $(document).ready(function () {
  21. $("#searchForm").validate({
  22. submitHandler: function (form) {
  23. var isSubMitFlag = true;
  24. var productID = $("#productID").val();
  25. if (isNaN(productID) || productID.indexOf('0') == 0) {
  26. alertx("请输入正确的商品ID");
  27. isSubMitFlag = false;
  28. return false;
  29. }
  30. if (isSubMitFlag) {
  31. form.submit();
  32. }
  33. }
  34. })
  35. });
  36. </script>
  37. </head>
  38. <body>
  39. <ul class="nav nav-tabs">
  40. <li class="${productCategory eq 1 ? 'active':''}"><a
  41. href="${ctx}/newhome/newPageFloor/addProductImage?productCategory=1">添加商品</a></li>
  42. <li class="${productCategory eq 2 ? 'active':''}"><a
  43. href="${ctx}/newhome/newPageFloor/addProductImage?productCategory=2&productIds=${productIds}">添加二手商品</a>
  44. </li>
  45. <li><a href="${ctx}/newhome/newPageFloor/addOtherImage">添加其他图片</a></li>
  46. </ul>
  47. <br/>
  48. <form:form id="searchForm" modelAttribute="product" action="" method="post" class="breadcrumb form-search">
  49. <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
  50. <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
  51. <form:hidden path="productIds"/>
  52. <div class="ul-form">
  53. <label>商品ID:</label>
  54. <form:input path="productID" id="productID" htmlEscape="false" maxlength="8" class="input-mini"
  55. onkeyup="onlynum(this)"/>
  56. <label>商品名称:</label>
  57. <form:input path="name" htmlEscape="false" class="input-medium" maxlength="20"/>
  58. <c:if test="${productCategory eq 1}">
  59. <label>供应商名称:</label>
  60. <form:input path="shopName" htmlEscape="false" class="input-medium" maxlength="20"/>
  61. </c:if>
  62. &nbsp;&nbsp; <input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
  63. <div class="clearfix"></div>
  64. </div>
  65. </form:form>
  66. <sys:message content="${message}"/>
  67. <table class="table table-striped table-bordered table-condensed table-hover">
  68. <tr>
  69. <th style="width:20px;"><input class="check-all" type="checkbox" onclick="handleClickAllSelect()"/> 全选 </th>
  70. <th>商品ID</th>
  71. <th>商品图片</th>
  72. <th>商品名称</th>
  73. <c:if test="${productCategory eq 1}">
  74. <th>供应商名称</th>
  75. </c:if>
  76. </tr>
  77. <tbody>
  78. <c:if test="${not empty page.list}">
  79. <c:forEach items="${page.list}" var="item">
  80. <tr id="${item.productID}" class="itemtr">
  81. <th>
  82. <input class="check-item" type="checkbox" name="info" value='${fns:toJson(item)}' onclick="ClickSelect()"/>
  83. </th>
  84. <td>${item.productID}</td>
  85. <td><img src="${item.mainImage}" width="50px" height="50px"></td>
  86. <td>${item.name}</td>
  87. <c:if test="${productCategory eq 1}">
  88. <td>${item.shopName}</td>
  89. </c:if>
  90. </tr>
  91. </c:forEach>
  92. </c:if>
  93. </tbody>
  94. </table>
  95. <c:if test="${empty page.list}">
  96. <p style="text-align: center;"><font color="#1e90ff">暂无数据……</font></p>
  97. </c:if>
  98. <div class="pagination">${page}</div>
  99. <script type="text/javascript">
  100. var isCheckedAll = false;
  101. $(document).ready(function () {
  102. //弹出框去滚动条
  103. top.$('#jbox-content').css("overflow-y", "hidden");
  104. show_title(30);
  105. });
  106. function page(n, s) {
  107. $("#pageNo").val(n);
  108. $("#pageSize").val(s);
  109. $("#searchForm").submit();
  110. return false;
  111. }
  112. function getCheckedItems() {
  113. var item = $('.check-item:checked').val();
  114. if(!item){
  115. alertx("请勾选商品~");
  116. return;
  117. }
  118. var imageArray = [];
  119. $(".check-item:checked").each(function (index,el) {
  120. var item = $(this).val();
  121. var product = JSON.parse(item);
  122. var link = '';
  123. if (${productCategory eq 1}) {
  124. link = "${fns:getConfig('wwwServer')}product-" + product.productID + ".html";
  125. } else {
  126. link = "${fns:getConfig('wwwServer')}flea-market-" + product.productID + ".html";
  127. }
  128. var items = {
  129. "id": "",
  130. "productId": product.productID,
  131. "validFlag": product.validFlag,
  132. "image": product.mainImage,
  133. "name": product.name,
  134. "link": link,
  135. "sort": 1,
  136. "pcStatus": "1",
  137. "appletsStatus": "1",
  138. "label": "",
  139. "createDate": ""
  140. };
  141. imageArray.push(items);
  142. })
  143. return imageArray;
  144. }
  145. function handleClickAllSelect() {
  146. var inputIsCheckedAll = $('.check-all').attr('checked');
  147. var imageArray = [];
  148. if(inputIsCheckedAll){
  149. isCheckedAll = 'true';
  150. $(".check-item").attr('checked', true);
  151. $(".check-item").each(function (index,el) {
  152. var item = $(this).val();
  153. var product = JSON.parse(item);
  154. var link ='';
  155. if (${productCategory eq 1}) {
  156. link = "${fns:getConfig('wwwServer')}product-" + product.productID + ".html";
  157. } else {
  158. link = "${fns:getConfig('wwwServer')}flea-market-" + product.productID + ".html";
  159. }
  160. var items = {
  161. "id": "",
  162. "productId": product.productID,
  163. "validFlag": product.validFlag,
  164. "image": product.mainImage,
  165. "name": product.name,
  166. "link": link,
  167. "sort": 1,
  168. "pcStatus": "1",
  169. "appletsStatus": "1",
  170. "label": "",
  171. "createDate": ""
  172. };
  173. imageArray.push(items);
  174. })
  175. }else{
  176. isCheckedAll = 'false';
  177. $(".check-item").attr('checked', false);
  178. imageArray = [];
  179. }
  180. return imageArray;
  181. }
  182. function ClickSelect(){
  183. isCheckedAll = 'checkedData';
  184. $(".check-all").attr('checked', false);
  185. var imageArray = [];
  186. $(".check-item:checked").each(function (index,el) {
  187. // console.log('*****');
  188. var item = $(this).val();
  189. var product = JSON.parse(item);
  190. var link ='';
  191. if (${productCategory eq 1}) {
  192. link = "${fns:getConfig('wwwServer')}product-" + product.productID + ".html";
  193. } else {
  194. link = "${fns:getConfig('wwwServer')}flea-market-" + product.productID + ".html";
  195. }
  196. var items = {
  197. "id": "",
  198. "productId": product.productID,
  199. "validFlag": product.validFlag,
  200. "image": product.mainImage,
  201. "name": product.name,
  202. "link": link,
  203. "sort": 1,
  204. "pcStatus": "1",
  205. "appletsStatus": "1",
  206. "label": "",
  207. "createDate": ""
  208. };
  209. imageArray.push(items);
  210. })
  211. // console.log(imageArray);
  212. return imageArray;
  213. }
  214. function handleCheckedAll() {
  215. return isCheckedAll;
  216. }
  217. /**
  218. /**
  219. * @param obj
  220. * jquery控制input只能输入数字
  221. */
  222. function onlynum(obj) {
  223. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  224. }
  225. </script>
  226. </body>
  227. </html>