feedstoragein.jsp 6.4 KB

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