toAddCollageProduct.jsp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. <style type="text/css">
  9. .table td i{margin:0 2px;}
  10. </style>
  11. <script type="text/javascript">
  12. $(document).ready(function() {
  13. //弹出框去滚动条
  14. top.$('#jbox-content').css("overflow-y","hidden");
  15. show_title(30);
  16. // 反选
  17. $('body').on('click','input[name="info"]',function() {
  18. var allInputLength = $('input[name="info"]').length - $('input[name="info"]:disabled').length,
  19. allInputCheckedLength = $('input[name="info"]:checked').length,
  20. checkAllEle= $('.check-all');
  21. // 判断选中长度和总长度,如果相等就是全选否则取消全选
  22. if(allInputLength === allInputCheckedLength) {
  23. checkAllEle.attr('checked', true);
  24. } else {
  25. checkAllEle.attr('checked', false);
  26. }
  27. })
  28. });
  29. function page(n,s){
  30. $("#pageNo").val(n);
  31. $("#pageSize").val(s);
  32. $("#searchForm").submit();
  33. return false;
  34. }
  35. function getCheckedItems(){
  36. var items = [];
  37. var $items = $('.check-item:checked');
  38. $items.each(function(){
  39. var product = JSON.parse($(this).val());
  40. items.push({
  41. "id": "",
  42. "productId": product.productID,
  43. "image": product.mainImage,
  44. "productName": product.name,
  45. "shopName": product.shopName,
  46. "sort": 1,
  47. "status": "1",
  48. "addTime": ""
  49. })
  50. });
  51. return items;
  52. }
  53. function allCkbfun(ckb){
  54. var isChecked = ckb.checked;
  55. $(".check-item").each2(function () {
  56. var attr = $(this).attr("disabled");
  57. if (attr != 'disabled') {
  58. $(this).attr('checked', isChecked);
  59. }
  60. });
  61. }
  62. /**
  63. * @param obj
  64. * jquery控制input只能输入数字
  65. */
  66. function onlynum(obj) {
  67. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  68. }
  69. /**
  70. * @param obj
  71. * jquery控制input只能输入数字和两位小数(金额)
  72. */
  73. function num(obj) {
  74. obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
  75. obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
  76. obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
  77. obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  78. obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
  79. }
  80. </script>
  81. </head>
  82. <body>
  83. <form:form id="searchForm" modelAttribute="product" action="${ctx}/hehe/cmHeheCollageProduct/toAddProduct?productIds=${productIds}" method="post" class="breadcrumb form-search">
  84. <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
  85. <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
  86. <div class="ul-form">
  87. <label>商品ID:</label>
  88. <form:input path="productID" htmlEscape="false" maxlength="8" class="input-mini" onchange="onlynum(this)"/>
  89. <label>商品名称:</label>
  90. <form:input path="name" htmlEscape="false" class="input-medium" maxlength="20"/>
  91. <label>供应商:</label>
  92. <form:input path="shopName" htmlEscape="false" class="input-medium" maxlength="20"/>
  93. &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
  94. <div class="clearfix"></div>
  95. </div>
  96. </form:form>
  97. <sys:message content="${message}"/>
  98. <table class="table table-striped table-bordered table-condensed table-hover">
  99. <tr>
  100. <th style="width:20px;"></th>
  101. <th>商品ID</th>
  102. <th>商品图片</th>
  103. <th>商品名称</th>
  104. <th>供应商</th>
  105. </tr>
  106. <tbody>
  107. <c:if test="${not empty page.list}">
  108. <c:forEach items="${page.list}" var="item">
  109. <tr id="${item.productID}" class="itemtr">
  110. <%--已过滤添加过的商品和未上架的商品--%>
  111. <th>
  112. <input class="check-item" type="radio" name="info" value='${fns:toJson(item)}'/>
  113. </th>
  114. <td>${item.productID}</td>
  115. <td><img src="${item.mainImage}" width="50px" height="50px"></td>
  116. <td>${item.name}</td>
  117. <td>${item.shopName}</td>
  118. </tr>
  119. </c:forEach>
  120. </c:if>
  121. </tbody>
  122. </table>
  123. <c:if test="${empty page.list}">
  124. <p style="text-align: center;"><font color="#1e90ff">暂无数据……</font></p>
  125. </c:if>
  126. <div class="pagination">${page}</div>
  127. </body>
  128. </html>