feedstorage.jsp 7.3 KB

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