feedstoragein.jsp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. $("#list").jqGrid("setGridHeight",$(window).height() - 130);
  16. $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
  17. });
  18. $(window).resize(function(){
  19. $("#list").jqGrid("setGridHeight",$(window).height() - 130);
  20. $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
  21. });
  22. //初始化日期
  23. function setNowDate(){
  24. var myDate = new Date();
  25. var year = myDate.getFullYear();
  26. var month = myDate.getMonth()+1;
  27. var day = myDate.getDate();
  28. var nowdate = year + "-" + month + "-" + day;
  29. $("#endDate").val(nowdate);
  30. var lastmonth = myDate.getMonth();
  31. var lastdate = year + "-" + lastmonth + "-" + day;
  32. $("#beginDate").val(lastdate);
  33. }
  34. function leftDate(){
  35. var beginDate = $("#beginDate").val();
  36. var endDate = $("#endDate").val();
  37. var newbDate = checkDate(beginDate,"left");
  38. var neweDate = checkDate(endDate,"left");
  39. $("#beginDate").val(newbDate);
  40. $("#endDate").val(neweDate);
  41. queryDate();
  42. }
  43. function rightDate(){
  44. var beginDate = $("#beginDate").val();
  45. var endDate = $("#endDate").val();
  46. var newbDate = checkDate(beginDate,"");
  47. var neweDate = checkDate(endDate,"");
  48. $("#beginDate").val(newbDate);
  49. $("#endDate").val(neweDate);
  50. queryDate();
  51. }
  52. //查询数据
  53. function queryDate(){
  54. var beginDate = $("#beginDate").val();
  55. var endDate = $("#endDate").val();
  56. var feedId = $("#feedId").val();
  57. if(beginDate==""){
  58. alert("请选择开始日期");
  59. $("#beginDate").focus();
  60. }else if(endDate==""){
  61. alert("请选择结束日期");
  62. $("#endDate").focus();
  63. }else{
  64. if(type == "link"){
  65. loadList(); //第一次加载jqgrid
  66. type = "query";
  67. }else{
  68. //重新加载json类型
  69. jQuery("#list").jqGrid("setGridParam",{
  70. url:"${contextPath }/admin/feedstorage/feedstorageinlist.html",
  71. postData:{"beginDate":beginDate,"endDate":endDate,"feedId":feedId}
  72. }
  73. ).trigger("reloadGrid");
  74. }
  75. }
  76. $("#list").jqGrid("setGridHeight",$(window).height() - 135);
  77. $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
  78. }
  79. //jqgrid初始化
  80. function loadList(){
  81. var beginDate = $("#beginDate").val();
  82. var endDate = $("#endDate").val();
  83. var feedId = $("#feedId").val();
  84. jQuery("#list").jqGrid({
  85. url: "${contextPath }/admin/feedstorage/feedstorageinlist.html?beginDate="+beginDate+"&endDate="+endDate+"&feedId="+feedId,
  86. datatype: "json", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
  87. colNames:["主键","饲料ID","入库日期","饲料名称","操作重量","批号","金额","备注","创建日期","创建人"], //列名
  88. colModel:[
  89. {name: "FeedStorageId",index: "FeedStorageId",align: "center",hidden: true},
  90. {name: "FeedId",index: "FeedId", align: "center",hidden: true},
  91. {name:"BusinessDate",index: "BusinessDate", align: "center",sortable:false},
  92. {name: "FeedName",index: "FeedName", align: "center",sortable:false},
  93. {name: "OperateWeight",index: "OperateWeight", align: "center",sortable:false},
  94. {name:"PCpde",index: "PCpde", align: "center",sortable:false},
  95. {name:"TPrice",index: "TPrice", align: "center",sortable:false},
  96. {name: "Remark",index: "Remark", align: "center",sortable:false},
  97. {name: "CreateDate",index: "CreateDate",width:"100px", align: "center",sortable:false},
  98. {name: "CreateBy",index: "CreateBy", align: "center",sortable:false},
  99. ],
  100. caption: "入库信息", //标题
  101. pager: "#page", //#page分页控件绑定的位置对象
  102. rowNum: 15, //每页显示条数
  103. rowList: [15,30,50], //分页下拉选项内容
  104. viewrecords: true, //是否显示总条数
  105. emptyrecords: "无数据", //服务器返回空列表时显示的内容
  106. autowidth: true, //自动调节宽度
  107. toolbar: [true,"top"],
  108. jsonReader: {
  109. root: "rows", //数据行
  110. page: "page", // 当前页
  111. total: "total", // 总页数
  112. records: "records", //总共有几条记录
  113. repeatitems: false, // 设置成false,在后台设置值的时候,可以乱序。且并非每个值都得设
  114. cell: "cell",
  115. id: "FeedStorageId"
  116. }
  117. });
  118. if(operCount == 0){
  119. $("#page_left").append("<input type='button' value='新增' onClick='addRow(this,\"add\")' style='height:30px;width:70px;font-size:12px;' /> ");
  120. operCount++;
  121. }
  122. }
  123. //自定义添加方法
  124. function addRow(e,type){
  125. iframeBox(e, {
  126. src:"${contextPath}/admin/feedstorage/addfeedstoragein.html?type="+type+"&feedStorageId=",
  127. width:470,
  128. height:400
  129. });
  130. }
  131. function hsClose(){
  132. closeBox();
  133. alert("保存成功");
  134. queryDate();
  135. }
  136. hs.Expander.prototype.onAfterClose = function(htmlExpand) {
  137. //window.location.reload();
  138. };
  139. </script>
  140. <body style="background-color: #E0E0E0">
  141. <div>
  142. <div class="navfrm">
  143. <span>当前位置:</span>
  144. <span><a href="${contextPath }/admin/welcome.html">首页</a></span>
  145. <span>&nbsp;>>&nbsp;</span>
  146. <span>库存量</span>
  147. </div>
  148. <input id="beginDate" name="beginDate" style="width:100px;" class="datebox" value=""/> -
  149. <input id="endDate" name="endDate" style="width:100px;" class="datebox" value=""/>
  150. <input type="button" value="<" onclick="leftDate();" /><input type="button" value=">" onclick="rightDate();" />
  151. 饲料:
  152. <select id="feedId">
  153. <option value="">全部</option>
  154. <c:forEach items="${feeds }" var="feed">
  155. <option value="${feed.ID }">
  156. <c:out value="${feed.FNAME }" />
  157. </option>
  158. </c:forEach>
  159. </select>
  160. <input type="button" value="查询" onclick="queryDate()" class="sysub" />
  161. <table id="list"></table>
  162. <div id="page" style="height:30px;"></div>
  163. </div>
  164. </body>
  165. </html>