toAddProduct.jsp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. "pcStatus": "1",
  48. "appletsStatus": "1",
  49. "addTime": ""
  50. })
  51. });
  52. return items;
  53. }
  54. function allCkbfun(ckb){
  55. var isChecked = ckb.checked;
  56. $(".check-item").attr('checked', isChecked);
  57. }
  58. /**
  59. * @param obj
  60. * jquery控制input只能输入数字
  61. */
  62. function onlynum(obj) {
  63. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  64. }
  65. /**
  66. * @param obj
  67. * jquery控制input只能输入数字和两位小数(金额)
  68. */
  69. function num(obj) {
  70. obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
  71. obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
  72. obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
  73. obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  74. obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
  75. }
  76. </script>
  77. </head>
  78. <body>
  79. <form:form id="searchForm" modelAttribute="product" action="${ctx}/coupon/cmCoupon/toAddProduct?productIds=${productIds}" method="post" class="breadcrumb form-search">
  80. <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
  81. <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
  82. <div class="ul-form">
  83. <label>商品ID:</label>
  84. <form:input path="productID" htmlEscape="false" maxlength="10" class="input-mini" onchange="onlynum(this)"/>
  85. <label>商品名称:</label>
  86. <form:input path="name" htmlEscape="false" class="input-medium" maxlength="20"/>
  87. <label>供应商:</label>
  88. <form:input path="shopName" htmlEscape="false" class="input-medium" maxlength="20"/>
  89. &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
  90. <div class="clearfix"></div>
  91. </div>
  92. </form:form>
  93. <sys:message content="${message}"/>
  94. <table class="table table-striped table-bordered table-condensed table-hover">
  95. <tr>
  96. <th style="width:20px;"><input class="check-all" type="checkbox" onclick="allCkbfun(this);"/></th>
  97. <th>商品ID</th>
  98. <th>商品图片</th>
  99. <th>商品名称</th>
  100. <th>供应商</th>
  101. </tr>
  102. <tbody>
  103. <c:if test="${not empty page.list}">
  104. <c:forEach items="${page.list}" var="item">
  105. <tr id="${item.productID}" class="itemtr">
  106. <%--已过滤添加过的商品和未上架的商品--%>
  107. <th>
  108. <input class="check-item" ${item.storeStatus ? "disabled" : ""} type="checkbox" name="info" value='${fns:toJson(item)}'/>
  109. </th>
  110. <td>${item.productID}</td>
  111. <td><img src="${item.mainImage}" width="50px" height="50px"></td>
  112. <td>${item.name}</td>
  113. <td>${item.shopName}</td>
  114. </tr>
  115. </c:forEach>
  116. </c:if>
  117. </tbody>
  118. </table>
  119. <c:if test="${empty page.list}">
  120. <p style="text-align: center;"><font color="#1e90ff">暂无数据……</font></p>
  121. </c:if>
  122. <div class="pagination">${page}</div>
  123. </body>
  124. </html>