toAddDiscountProduct.jsp 5.3 KB

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