feedpamount.jsp 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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,currentId="",isEnableSupplyFeed=0,isMorningPart=0,isNoonPart=0,isNightPart=0,selCurrentId=0,
  10. colName,Calculation = 0,northType=0,southType=1,isSelTr = 0,Reserved6 = 0,Reserved7 = 0,isLocking = 0,oldUpdateValue = 0,operCount=0,lastrow,lastcell;
  11. $(document).ready( function() {
  12. getDefaultConfig();//获取系统默认参数是否启用补料模版,各班比例
  13. queryDate(); //加载jqgrid
  14. $("#list").jqGrid("setGridWidth",document.body.clientWidth - 10);
  15. $("#list").jqGrid("setGridHeight",pageHeight() - 50);
  16. $("input.datebox").bind("click", function() {WdatePicker();});
  17. });
  18. $(window).resize(function(){
  19. $("#list").jqGrid("setGridWidth",document.body.clientWidth - 10);
  20. $("#list").jqGrid("setGridHeight",pageHeight() - 50);
  21. });
  22. function pageHeight(){
  23. if($.browser.msie){
  24. return document.compatMode == "CSS1Compat"? document.documentElement.clientHeight :
  25. document.body.clientHeight;
  26. }else{
  27. return self.innerHeight;
  28. }
  29. }
  30. //jqgrid初始化
  31. function loadList(){
  32. jQuery("#list").jqGrid({
  33. datatype: "local", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
  34. height: 170, //高度
  35. colNames: ["主键","栏舍名称","早班1量", "早班2量", "中班1量", "中班2量", "晚班1量", "晚班2量", "sel1", "sel2", "sel3", "sel4", "sel5", "sel6"],
  36. colModel:[
  37. {
  38. name: "ID",
  39. index: "ID",
  40. align: "center",
  41. sorttype: "string",
  42. editable: true,
  43. hidden: true
  44. //editoptions:{readonly:true} 如果要显示该列可以设置只读
  45. },
  46. {
  47. name: "BNAME",
  48. index: "BNAME",
  49. align: "center",
  50. sorttype: "string",
  51. editable: false
  52. },
  53. {
  54. name: "Rtime1",
  55. index: "Rtime1",
  56. align: "center",
  57. sorttype: "int",
  58. editable: true,
  59. editrules: {number: true}
  60. },
  61. {
  62. name: "Rtime2",
  63. index: "Rtime2",
  64. align: "center",
  65. sorttype: "int",
  66. editable: true,
  67. editrules: {number: true},hidden: true
  68. },
  69. {
  70. name: "Rtime3",
  71. index: "Rtime3",
  72. align: "center",
  73. sorttype: "int",
  74. editable: true,
  75. editrules: {number: true}
  76. },
  77. {
  78. name: "Rtime4",
  79. index: "Rtime4",
  80. align: "center",
  81. sorttype: "int",
  82. editable: true,
  83. editrules: {number: true},hidden: true
  84. },
  85. {
  86. name: "Rtime5",
  87. index: "Rtime5",
  88. align: "center",
  89. sorttype: "int",
  90. editable: true,
  91. editrules: {number: true}
  92. },
  93. {
  94. name: "Rtime6",
  95. index: "Rtime6",
  96. align: "center",
  97. sorttype: "int",
  98. editable: true,
  99. editrules: {number: true},hidden: true
  100. },
  101. {name: "sel1",index: "sel1",align: "center",sorttype: "int",editrules: {number: true},hidden: true},
  102. {name: "sel2",index: "sel2",align: "center",sorttype: "int",editrules: {number: true},hidden: true},
  103. {name: "sel3",index: "sel3",align: "center",sorttype: "int",editrules: {number: true},hidden: true},
  104. {name: "sel4",index: "sel4",align: "center",sorttype: "int",editrules: {number: true},hidden: true},
  105. {name: "sel5",index: "sel5",align: "center",sorttype: "int",editrules: {number: true},hidden: true},
  106. {name: "sel6",index: "sel6",align: "center",sorttype: "int",editrules: {number: true},hidden: true}
  107. ],
  108. beforeEditCell:function(rowid,cellname,v,iRow,iCol){
  109. lastrow = iRow;
  110. lastcell = iCol;
  111. },
  112. afterSaveCell: function(rowid,name,val,iRow,iCol){
  113. var beginDate = $("#beginDate").val();
  114. var rowData = $("#list").jqGrid("getRowData",rowid);
  115. $.ajax({
  116. async: false,
  117. type: 'POST',
  118. dataType:'json', //返回类型jsond
  119. data: "ID="+rowData.ID+"&colName="+name+"&colValue="+val+"&beginDate="+beginDate,
  120. url: "${contextPath }/admin/recipeplan/amountUpdate.html",
  121. error: function(){alert("系统错误");},
  122. success: function(json){
  123. if(json.status == "success"){
  124. //清空主表数据重新加载一次
  125. $("#list").clearGridData();
  126. loadList();
  127. }
  128. }
  129. });
  130. },
  131. cellEdit: true,
  132. cellsubmit: "clientArray", //当单元格发生变化后不直接发送请求、"remote"默认直接发送请求
  133. /**
  134. * 设置水平滚动条 begin
  135. **/
  136. toolbar: [true,"top"],
  137. shrinkToFit: false,
  138. autoScroll: true,
  139. pager: "#page", //#page分页控件绑定的位置对象
  140. pginput: false, //不显示分页文本框
  141. pgbuttons: false, //不显示翻页按钮
  142. rowNum: 1000, //每页显示条数
  143. //autowidth: true, //自动调节宽度
  144. sortname: 'SORT' //按SORT进行排序 默认asc
  145. });
  146. if(operCount == 0){
  147. $("#t_list").append("<input id='beginDate' name='beginDate' style='width:100px;font-size:12px;' class='datebox' value=''/>&nbsp;&nbsp;");
  148. $("#t_list").append("<input type='button' value='<' onclick='leftDate();' /><input type='button' value='>' onclick='rightDate();' />&nbsp;&nbsp;");
  149. $("#t_list").append("<input id='addFeedpBtn' class='sysub' type='button' value='生成栏舍' onClick='addFeedp()' style='font-size:-2'/> ");
  150. $("#t_list").append("<input id='' class='sysub' type='button' value='全部清0' onClick='clearFeedp()' style='font-size:-2'/> ");
  151. operCount++;
  152. }
  153. //获取数据集
  154. mydata = getLists();
  155. if(mydata!=null){
  156. for(var i=0;i<=mydata.length;i++){
  157. jQuery("#list").jqGrid('addRowData',i+1,mydata[i]);
  158. }
  159. jQuery("#list").jqGrid().trigger("reloadGrid"); //添加完数据后客户端自动刷新一次、实现客户端数据与服务器数据的完全分离
  160. }
  161. if(isMorningPart == 1){
  162. $("#list").jqGrid("showCol","Rtime2");
  163. }
  164. if(isNoonPart == 1){
  165. $("#list").jqGrid("showCol","Rtime4");
  166. }
  167. if(isNightPart == 1){
  168. $("#list").jqGrid("showCol","Rtime6");
  169. }
  170. if(isSelTr>0){
  171. $("#list").jqGrid("setSelection",isSelTr);
  172. }
  173. //根据栏舍发料班次为班次比例添加背景色
  174. var ids = $("#list").jqGrid("getDataIDs");
  175. for ( var i = 0; i < ids.length; i++) {
  176. var rowData = $("#list").jqGrid("getRowData",ids[i]);
  177. if(rowData.sel1 == 1){
  178. $("#list").setCell(ids[i],"Rtime1","",{background:'#CCEC9D'});
  179. }
  180. if(rowData.sel2 == 1){
  181. $("#list").setCell(ids[i],"Rtime2","",{background:'#CCEC9D'});
  182. }
  183. if(rowData.sel3 == 1){
  184. $("#list").setCell(ids[i],"Rtime3","",{background:'#CCEC9D'});
  185. }
  186. if(rowData.sel4 == 1){
  187. $("#list").setCell(ids[i],"Rtime4","",{background:'#CCEC9D'});
  188. }
  189. if(rowData.sel5 == 1){
  190. $("#list").setCell(ids[i],"Rtime5","",{background:'#CCEC9D'});
  191. }
  192. if(rowData.sel6 == 1){
  193. $("#list").setCell(ids[i],"Rtime6","",{background:'#CCEC9D'});
  194. }
  195. }
  196. }
  197. //获取服务器数据
  198. function getLists(){
  199. var beginDate = $("#beginDate").val();
  200. if(beginDate==""){
  201. setNowDate();
  202. beginDate = $("#beginDate").val();
  203. }
  204. $.ajax({
  205. async: false,
  206. type: 'POST',
  207. data: "beginDate="+beginDate,
  208. dataType:'json', //返回类型json
  209. url: "${contextPath }/admin/recipeplan/feedpamountlist.html",
  210. error: function(){alert("系统错误");},
  211. success: function(json){
  212. mydata = json;
  213. }
  214. });
  215. return mydata;
  216. }
  217. //获取系统默认参数是否启用补料模版,各班比例
  218. function getDefaultConfig(){
  219. $.ajax({
  220. async: false,
  221. type: 'POST',
  222. dataType:'json', //返回类型json
  223. url: "${contextPath }/admin/basicdata/getdefaultconfig.html",
  224. error: function(){alert("系统错误");},
  225. success: function(json){
  226. if(json.status == "success"){
  227. if(json.isEnableSupplyFeed){
  228. isEnableSupplyFeed = 1;
  229. }
  230. if(json.isMorningPart){
  231. isMorningPart = 1;
  232. }
  233. if(json.isNoonPart){
  234. isNoonPart = 1;
  235. }
  236. if(json.isNightPart){
  237. isNightPart = 1;
  238. }
  239. }
  240. }
  241. });
  242. }
  243. //自定义添加方法
  244. function addFeedp(){
  245. var beginDate = $("#beginDate").val();
  246. $.ajax({
  247. async: false,
  248. type: "POST",
  249. data: "beginDate="+beginDate,
  250. dataType:"json", //返回类型jsond
  251. url: "${contextPath }/admin/recipeplan/addfeedpamount.html",
  252. error: function(){alert("系统错误");},
  253. success: function(json){
  254. $("#list").clearGridData(); //清空原grid数据
  255. loadList(); //重新载入服务器数据
  256. }
  257. });
  258. }
  259. //自定义添加方法
  260. function clearFeedp(){
  261. var beginDate = $("#beginDate").val();
  262. $.ajax({
  263. async: false,
  264. type: "POST",
  265. data: "beginDate="+beginDate,
  266. dataType:"json", //返回类型jsond
  267. url: "${contextPath }/admin/recipeplan/clearfeedp.html",
  268. error: function(){alert("系统错误");},
  269. success: function(json){
  270. $("#list").clearGridData(); //清空原grid数据
  271. loadList(); //重新载入服务器数据
  272. }
  273. });
  274. }
  275. //初始化日期
  276. function setNowDate(){
  277. var myDate = new Date();
  278. var year = myDate.getFullYear();
  279. var month = myDate.getMonth()+1;
  280. var day = myDate.getDate();
  281. var nowdate = year + "-" + month + "-" + day;
  282. $("#beginDate").val(nowdate);
  283. }
  284. function leftDate(){
  285. var beginDate = $("#beginDate").val();
  286. var newbDate = checkDate(beginDate,"left");
  287. $("#beginDate").val(newbDate);
  288. queryDate();
  289. }
  290. function rightDate(){
  291. var beginDate = $("#beginDate").val();
  292. var newbDate = checkDate(beginDate,"");
  293. $("#beginDate").val(newbDate);
  294. queryDate();
  295. }
  296. //查询数据
  297. function queryDate(){
  298. //清空主表数据重新加载一次
  299. $("#list").clearGridData();
  300. loadList();
  301. var ids = $("#list").jqGrid("getDataIDs");
  302. if(ids.length > 0){
  303. $("#addFeedpBtn").hide();
  304. }else{
  305. $("#addFeedpBtn").show();
  306. }
  307. }
  308. </script>
  309. </head>
  310. <body>
  311. <table id="list"></table>
  312. </body>
  313. </html>