svipAddProduct.jsp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <%@ include file="/WEB-INF/views/include/taglib.jsp" %>
  3. <html>
  4. <head>
  5. <title>选择商品</title>
  6. <meta name="decorator" content="default"/>
  7. <style type="text/css">
  8. .table td i {
  9. margin: 0 2px;
  10. }
  11. .discount{
  12. display: inline;
  13. }
  14. </style>
  15. <script type="text/javascript">
  16. $(document).ready(function () {
  17. $("#searchForm").validate({
  18. submitHandler: function (form) {
  19. var isSubMitFlag = true;
  20. var productID = $("#productID").val();
  21. if (isNaN(productID) || productID.indexOf('0') == 0 ) {
  22. alertx("请输入正确的商品ID");
  23. isSubMitFlag = false;
  24. return false;
  25. }
  26. if (isSubMitFlag) {
  27. form.submit();
  28. }
  29. }
  30. })
  31. });
  32. </script>
  33. </head>
  34. <body>
  35. <form:form id="searchForm" modelAttribute="product" action="${ctx}/svip/cmSvipProduct/findProductPage" method="post"
  36. class="breadcrumb form-search">
  37. <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
  38. <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
  39. <form:hidden path="ids"/>
  40. <div class="ul-form">
  41. <label>商品ID:</label>
  42. <form:input path="productID" id="productID" htmlEscape="false" maxlength="8" class="input-mini" onkeyup="onlynum(this)"/>
  43. <label>商品名称:</label>
  44. <form:input path="name" htmlEscape="false" class="input-medium" maxlength="20"/>
  45. <label>供应商名称:</label>
  46. <form:input path="shopName" htmlEscape="false" class="input-medium" maxlength="20"/>
  47. &nbsp;&nbsp; <input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
  48. <div class="clearfix"></div>
  49. </div>
  50. </form:form>
  51. <sys:message content="${message}"/>
  52. <table class="table table-striped table-bordered table-condensed table-hover">
  53. <tr>
  54. <th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this)"/> 全选</th>
  55. <th>商品ID</th>
  56. <th>商品图片</th>
  57. <th>商品名称</th>
  58. <th>供应商</th>
  59. <th>机构价</th>
  60. <th style="width: 140px !important;">会员折扣</th>
  61. <th style="width: 140px !important;">会员价</th>
  62. </tr>
  63. <tbody>
  64. <c:if test="${not empty page.list}">
  65. <c:forEach items="${page.list}" var="item">
  66. <tr id="${item.productID}" class="itemtr">
  67. <th>
  68. <input class="check-item" type="checkbox" name="info" ${item.existsFlag eq 1?'disabled':''} value='${item.productID}'/>
  69. </th>
  70. <td>${item.productID}</td>
  71. <td><img class="mainImage" src="${item.mainImage}" width="50px" height="50px"></td>
  72. <td class="productName">${item.name}</td>
  73. <td>${item.shopName}</td>
  74. <td>¥${item.price1}</td>
  75. <td><input class="discount" id="discount${item.productID}" onchange="changeDiscount(${item.productID},1)" type="number" maxlength="11" style="width: 100px"> %</td>
  76. <td><input class="discountPrice" id="discountPrice${item.productID}" onchange="changeDiscount(${item.productID},2)" type="number" maxlength="11" style="width: 100px"></td>
  77. </tr>
  78. </c:forEach>
  79. </c:if>
  80. </tbody>
  81. </table>
  82. <c:if test="${empty page.list}">
  83. <p style="text-align: center;"><font color="#1e90ff">暂无数据……</font></p>
  84. </c:if>
  85. <div class="pagination">${page}</div>
  86. <script type="text/javascript">
  87. $(document).ready(function () {
  88. //弹出框去滚动条
  89. top.$('#jbox-content').css("overflow-y", "hidden");
  90. show_title(30);
  91. });
  92. function page(n, s) {
  93. $("#pageNo").val(n);
  94. $("#pageSize").val(s);
  95. $("#searchForm").submit();
  96. return false;
  97. }
  98. function getCheckedItems() {
  99. debugger
  100. var items = new Array();
  101. var $items = $('.check-item:checked');
  102. var error = 0;
  103. $items.each(function () {
  104. let discount = $(this).parents(".itemtr").find(".discount").val();
  105. let discountPrice = $(this).parents(".itemtr").find(".discountPrice").val();
  106. if (discount == '' && discountPrice == '') {
  107. error = -1;
  108. }
  109. items.push({
  110. productId: $(this).val(),
  111. discount: discount,
  112. discountPrice: discountPrice
  113. });
  114. });
  115. return error == -1 ? error : items;
  116. }
  117. function clickAllSelect(ckb) {
  118. var isChecked = ckb.checked;
  119. var $items = $('.check-item');
  120. $items.each(function(){
  121. var disabled = $(this).attr('disabled');
  122. if (disabled != 'disabled') {
  123. $(this).attr('checked', isChecked)
  124. }
  125. });
  126. }
  127. /**
  128. * @param obj
  129. * jquery控制input只能输入数字
  130. */
  131. function onlynum(obj) {
  132. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  133. }
  134. /**
  135. * 更改折扣/折扣价
  136. */
  137. function changeDiscount(productId,priceType) {
  138. debugger
  139. if (priceType == 1) {
  140. var val = $("#discount" + productId).val();
  141. if (val > 100 || val <0) {
  142. $.jBox.tip("请输入0-100之间的数字", 'info');
  143. val = '';
  144. $("#discount" + productId).val('');
  145. }else {
  146. val = Number(val).toFixed(2);
  147. $("#discount" + productId).val(val);
  148. }
  149. if (val != '' && val != undefined) {
  150. $("#discountPrice"+productId).attr('readonly', 'readonly');
  151. } else {
  152. $("#discountPrice"+productId).removeAttr('readonly');
  153. }
  154. } else {
  155. var val = $("#discountPrice" + productId).val();
  156. if (val != '' && val != undefined) {
  157. val = Number(val).toFixed(2);
  158. $("#discountPrice" + productId).val(val);
  159. $("#discount"+productId).attr('readonly', 'readonly');
  160. } else {
  161. $("#discount" + productId).removeAttr('readonly');
  162. }
  163. }
  164. }
  165. </script>
  166. </body>
  167. </html>