feedstoragesystemout.jsp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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">
  9. var mydata,type = "link";
  10. $(document).ready( function() {
  11. $("input.datebox").bind("click", function() {WdatePicker();});
  12. setNowDate();
  13. loadList(); //第一次加载jqgrid
  14. $("#list").jqGrid("setGridHeight",$(window).height() - 130);
  15. $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
  16. if(mydata!=null){
  17. if(mydata.length > 0){
  18. for(var i=0;i<=mydata.length;i++){
  19. if(mydata[i].CheckStatus == "已审核"){
  20. $("#checkStatusBtn").hide();
  21. break;
  22. }else{
  23. $("#checkStatusBtn").show();
  24. break;
  25. }
  26. }
  27. }else{
  28. $("#checkStatusBtn").show();
  29. }
  30. }else{
  31. $("#checkStatusBtn").show();
  32. }
  33. });
  34. $(window).resize(function(){
  35. $("#list").jqGrid("setGridHeight",$(window).height() - 130);
  36. $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
  37. });
  38. //初始化日期
  39. function setNowDate(){
  40. var myDate = new Date();
  41. var year = myDate.getFullYear();
  42. var month = myDate.getMonth()+1;
  43. var day = myDate.getDate();
  44. var nowdate = year + "-" + month + "-" + day;
  45. $("#beginDate").val(nowdate);
  46. }
  47. //查询数据
  48. function queryDate(){
  49. //清空主表数据重新加载一次
  50. $("#list").clearGridData();
  51. loadList();
  52. if(mydata!=null){
  53. if(mydata.length > 0){
  54. for(var i=0;i<=mydata.length;i++){
  55. if(mydata[i].CheckStatus == "已审核"){
  56. $("#checkStatusBtn").hide();
  57. break;
  58. }else{
  59. $("#checkStatusBtn").show();
  60. break;
  61. }
  62. }
  63. }else{
  64. $("#checkStatusBtn").show();
  65. }
  66. }else{
  67. $("#checkStatusBtn").show();
  68. }
  69. $("#checkLabel").html("");
  70. }
  71. function leftDate(){
  72. var beginDate = $("#beginDate").val();
  73. var newbDate = checkDate(beginDate,"left");
  74. $("#beginDate").val(newbDate);
  75. queryDate();
  76. }
  77. function rightDate(){
  78. var beginDate = $("#beginDate").val();
  79. var newbDate = checkDate(beginDate,"");
  80. $("#beginDate").val(newbDate);
  81. queryDate();
  82. }
  83. //jqgrid初始化
  84. function loadList(){
  85. jQuery("#list").jqGrid({
  86. datatype: "local", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
  87. colNames:["审核状态","主键","业务日期","牲畜类别","饲料名称","计划重量","实际重量","操作重量","备注","是否审核"], //列名
  88. colModel:[
  89. {name: "CheckStatus",index: "CheckStatus",align: "center",hidden: true},
  90. {name: "FeedStorageId",index: "FeedStorageId",align: "center",hidden: true},
  91. {name: "BusinessDate",index: "BusinessDate", align: "center",sortable:false},
  92. {name: "CLASSNAME",index: "CLASSNAME", align: "center",sortable:false},
  93. {name: "FeedName",index: "FeedName", align: "center",sortable:false},
  94. {name: "PlanWeight",index: "PlanWeight", align: "center",sortable:false},
  95. {name: "ActualWeight",index: "ActualWeight", align: "center",sortable:false},
  96. {name: "OperateWeight",index: "OperateWeight", align: "center",sortable:false,editable: true},
  97. {name: "Remark",index: "Remark", align: "center",sortable:false,editable: true},
  98. {name: "CheckStatus",index: "CheckStatus", align: "center",sortable:false},
  99. ],
  100. cellEdit: true,
  101. cellsubmit: "clientArray", //当单元格发生变化后不直接发送请求、"remote"默认直接发送请求
  102. afterSaveCell: function(rowid,name,val,iRow,iCol) {
  103. var rowData = $("#list").jqGrid("getRowData",rowid);
  104. $.ajax({
  105. async: false,
  106. type: 'POST',
  107. dataType:'json', //返回类型jsond
  108. data: "ID="+rowData.FeedStorageId+"&colName="+name+"&colValue="+val,
  109. url: "${contextPath }/admin/feedstorage/feedstoragesystemoutupdate.html",
  110. error: function(){alert("系统错误");},
  111. success: function(json){
  112. }
  113. });
  114. },
  115. afterInsertRow: function(rowid,rowdata,rowelem){
  116. if(rowdata.CheckStatus == "已审核"){
  117. $("#list").setCell(rowid,7,"",{background: "#e4dee6"});
  118. $("#list").setColProp("OperateWeight",{editable: false});
  119. }else{
  120. $("#list").setColProp("OperateWeight",{editable: true});
  121. }
  122. },
  123. caption: "系统用量", //标题
  124. pager: "#page", //#page分页控件绑定的位置对象
  125. pginput: false, //不显示分页文本框
  126. pgbuttons: false, //不显示翻页按钮
  127. rowNum: 1000, //每页显示条数
  128. autowidth: true //自动调节宽度
  129. });
  130. //获取数据集
  131. mydata = getLists();
  132. if(mydata!=null){
  133. for(var i=0;i<=mydata.length;i++){
  134. jQuery("#list").jqGrid('addRowData',i+1,mydata[i]);
  135. }
  136. }
  137. }
  138. //获取服务器数据
  139. function getLists(){
  140. var beginDate = $("#beginDate").val();
  141. //var feedId = $("#feedId").val();
  142. if(beginDate==""){
  143. alert("请选择开始日期");
  144. $("#beginDate").focus();
  145. }
  146. $.ajax({
  147. async: false,
  148. type: 'POST',
  149. dataType:'json', //返回类型json
  150. url: "${contextPath }/admin/feedstorage/feedstoragesystemoutlist.html?beginDate="+beginDate+"&feedId=",
  151. error: function(){alert("系统错误");},
  152. success: function(json){
  153. mydata = json;
  154. }
  155. });
  156. return mydata;
  157. }
  158. function checkData(){
  159. var beginDate = $("#beginDate").val();
  160. $.ajax({
  161. async: false,
  162. type: "POST",
  163. dataType:"json", //返回类型jsond
  164. data: "beginDate="+beginDate,
  165. url: "${contextPath }/admin/feedstorage/feedstoragesystemoutcheckvalid.html",
  166. error: function(){alert("系统错误");},
  167. success: function(json){
  168. if(json.status == "success"){
  169. if(json.checkLabel != ""){
  170. var checkLabel = "<font color='red'>" + json.checkLabel + "</font>";
  171. $("#checkLabel").html(checkLabel);
  172. }else{
  173. $.ajax({
  174. async: false,
  175. type: "POST",
  176. dataType:"json", //返回类型jsond
  177. data: "beginDate="+beginDate,
  178. url: "${contextPath }/admin/feedstorage/feedstoragesystemoutcheck.html",
  179. error: function(){alert("系统错误");},
  180. success: function(json){
  181. if(json.status == "fail"){
  182. alert(json.msg);
  183. }else{
  184. $("#list").clearGridData(); //清空原grid数据
  185. loadList(); //重新载入服务器数据
  186. }
  187. }
  188. });
  189. }
  190. }
  191. }
  192. });
  193. }
  194. </script>
  195. <body style="background-color: #E0E0E0">
  196. <div>
  197. <div class="navfrm">
  198. <span>当前位置:</span>
  199. <span><a href="${contextPath }/admin/welcome.html">首页</a></span>
  200. <span>&nbsp;>>&nbsp;</span>
  201. <span>系统用量</span>
  202. </div>
  203. <input id="beginDate" name="beginDate" style="width:100px;" class="datebox" value=""/>
  204. <input type="button" value="<" onclick="leftDate();" /><input type="button" value=">" onclick="rightDate();" />
  205. <input type="button" value="系统用料单" onclick="queryDate()" class="sysub" />
  206. <input id="checkStatusBtn" type="button" value="审核" onclick="checkData()" class="sysub" />
  207. <label id="checkLabel"></label>
  208. <table id="list"></table>
  209. <div id="page" style="height:30px;"></div>
  210. </div>
  211. </body>
  212. </html>