feedInventory.jsp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <%@ page contentType="text/html; charset=utf-8" session="false" %>
  2. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
  4. <head>
  5. <title>我的工作台</title>
  6. <%@ include file="../common/header.jsp" %>
  7. <script type="text/javascript" src="${contextPath }/js/calendar/WdatePicker.js"></script>
  8. <script type="text/javascript" language="javascript" src="${contextPath}/js/highslide.js"></script>
  9. <script type="text/javascript">
  10. var type = "link",operCount=0;
  11. $(document).ready( function() {
  12. $("input.datebox").bind("click", function() {WdatePicker();});
  13. setNowDate();
  14. queryDate();
  15. });
  16. $(window).resize(function(){
  17. $("#list").jqGrid("setGridHeight",$(window).height() - 130);
  18. $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
  19. });
  20. //初始化日期
  21. function setNowDate(){
  22. var myDate = new Date();
  23. var year = myDate.getFullYear();
  24. var month = myDate.getMonth()+1;
  25. if(month<10){
  26. month="0"+month;
  27. }
  28. var day = myDate.getDate();
  29. if(day<10){
  30. day="0"+day;
  31. }
  32. //var bdate = year + "-" + month + "-01";
  33. var nowdate = year + "-" + month + "-" + day;
  34. var bdate = checkDate(nowdate);//当前日期减30天
  35. $("#beginDate").val(bdate);
  36. $("#endDate").val(nowdate);
  37. }
  38. //当前日期减30天
  39. function checkDate(date){
  40. var bdate = date.split("-");
  41. var cd = bdate[1]+"/"+bdate[2]+"/"+bdate[0];
  42. var nd = new Date(cd);
  43. nd = nd.valueOf();
  44. nd = nd - 24 * 60 * 60 * 1000 * 30; // * 167 是天数
  45. nd = new Date(nd);
  46. var y = nd.getFullYear();
  47. var m = nd.getMonth() + 1;
  48. if(m<10){
  49. m="0"+m;
  50. }
  51. var d = nd.getDate();
  52. if(d<10){
  53. d="0"+d;
  54. }
  55. var newdate = y+"-"+m+"-"+d;
  56. return newdate;
  57. }
  58. //查询数据
  59. function queryDate(){
  60. var beginDate = $("#beginDate").val();
  61. var endDate = $("#endDate").val();
  62. if(beginDate==""){
  63. alert("请选择开始日期");
  64. $("#beginDate").focus();
  65. }else if(endDate==""){
  66. alert("请选择结束日期");
  67. $("#endDate").focus();
  68. }else{
  69. if(type == "link"){
  70. loadList(); //第一次加载jqgrid
  71. type = "query";
  72. }else{
  73. //重新加载json类型
  74. jQuery("#list").jqGrid("setGridParam",{
  75. url:"${contextPath }/admin/feedstorage/feedInventoryList.html",
  76. postData:{"beginDate":beginDate,"endDate":endDate}
  77. }
  78. ).trigger("reloadGrid");
  79. }
  80. }
  81. $("#list").jqGrid("setGridHeight",$(window).height() - 135);
  82. $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
  83. }
  84. //jqgrid初始化
  85. function loadList(){
  86. var beginDate = $("#beginDate").val();
  87. var endDate = $("#endDate").val();
  88. jQuery("#list").jqGrid({
  89. url: "${contextPath }/admin/feedstorage/feedInventoryList.html?beginDate="+beginDate+"&endDate="+endDate,
  90. datatype: "json", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
  91. colNames:["主键","盘点日期","盘点人","备注"], //列名
  92. colModel:[
  93. {name: "invid",index: "invid",align: "center",hidden: true},
  94. {name: "inventorydate",index: "inventorydate",width:"100px", align: "center",sortable:false},
  95. {name: "createuser",index: "createuser", align: "center",sortable:false},
  96. {name: "remark",index: "remark", align: "center",sortable:false},
  97. ],
  98. caption: "库存量", //标题
  99. pager: "#page", //#page分页控件绑定的位置对象
  100. rowNum: 15, //每页显示条数
  101. rowList: [15,30,50], //分页下拉选项内容
  102. viewrecords: true, //是否显示总条数
  103. emptyrecords: "无数据", //服务器返回空列表时显示的内容
  104. autowidth: true, //自动调节宽度
  105. toolbar: [true,"top"],
  106. jsonReader: {
  107. root: "rows", //数据行
  108. page: "page", // 当前页
  109. total: "total", // 总页数
  110. records: "records", //总共有几条记录
  111. repeatitems: false, // 设置成false,在后台设置值的时候,可以乱序。且并非每个值都得设
  112. cell: "cell",
  113. id: "FeedStorageId"
  114. }
  115. });
  116. if(operCount == 0){
  117. $("#page_left").append("<input type='button' value='新增盘点单' onClick='toSavefeedInventory(this,\"add\")' style='height:30px;width:70px;font-size:12px;' /> ");
  118. $("#page_left").append("<input type='button' value='打开盘点单' onClick='toSavefeedInventory(this,\"open\")' style='height:30px;width:70px;font-size:12px;' /> ");
  119. operCount++;
  120. }
  121. }
  122. //自定义添加方法
  123. function toSavefeedInventory(e,type){
  124. if(type == "open"){
  125. var selId = $("#list").jqGrid("getGridParam","selrow"); //获取当前选中行号
  126. if(selId!=null){
  127. var rowData = $("#list").jqGrid("getRowData",selId); //获取当前选中行真实对象
  128. iframeBox(e, {
  129. src:"${contextPath}/admin/feedstorage/addFeedInventory.html?type="+type+"&invid="+rowData.invid,
  130. width:1000,
  131. height:600
  132. });
  133. }else{
  134. alert("请选择要查看的记录");
  135. }
  136. }else{
  137. iframeBox(e, {
  138. src:"${contextPath}/admin/feedstorage/addFeedInventory.html?type="+type+"&invid=",
  139. width:1000,
  140. height:600
  141. });
  142. }
  143. }
  144. function hsClose(){
  145. closeBox();
  146. alert("保存成功");
  147. queryDate();
  148. }
  149. hs.Expander.prototype.onAfterClose = function(htmlExpand) {
  150. //window.location.reload();
  151. };
  152. </script>
  153. <body style="background-color: #E0E0E0">
  154. <div>
  155. <div class="navfrm">
  156. <span>当前位置:</span>
  157. <span><a href="${contextPath }/admin/welcome.html">首页</a></span>
  158. <span>&nbsp;>>&nbsp;</span>
  159. <span>盘点单</span>
  160. </div>
  161. 日期范围:<input id="beginDate" name="beginDate" style="width:100px;" class="datebox" value=""/> -
  162. <input id="endDate" name="endDate" style="width:100px;" class="datebox" value=""/>
  163. <input type="button" value="查询" onclick="queryDate()" class="sysub" />
  164. <table id="list"></table>
  165. <div id="page" style="height:30px;"></div>
  166. </div>
  167. </body>
  168. </html>