realtime1.jsp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <%@ page contentType="text/html; charset=utf-8" session="false" %>
  2. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  3. <script type="text/javascript">
  4. var mydataP1;
  5. $(document).ready( function() {
  6. loadR1List(); //加载jqgrid
  7. panelS = $("body").layout("panel","south").panel();
  8. panelCHeight = $(window).height() - panelS.height();
  9. $("#list").jqGrid("setGridHeight",panelCHeight-110);
  10. $("#p1list").jqGrid("setGridHeight",panelCHeight-130);
  11. $("#p2list").jqGrid("setGridHeight",panelCHeight-130);
  12. $("#list").jqGrid("setGridWidth",$(window).width()*0.33);
  13. $("#p1list").jqGrid("setGridWidth",$(window).width()*0.32);
  14. $("#p2list").jqGrid("setGridWidth",$(window).width()*0.32);
  15. });
  16. //jqgrid初始化
  17. function loadR1List(){
  18. $("#p1list").jqGrid({
  19. datatype: "local", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
  20. height: 130, //高度
  21. colNames:["主键","操作编号","设计重量","实际重量", "主要成分", "完成时间","方式", "开始读数重量", "最后读数重量","wc"], //列名
  22. colModel:[
  23. {
  24. name: "ID",
  25. index: "ID",
  26. align: "center",
  27. sorttype: "string",
  28. hidden: true
  29. },
  30. {
  31. name: "SORT",
  32. index: "SORT",
  33. align: "center",
  34. sorttype: "string"
  35. },
  36. {
  37. name: "LWEIGHT",
  38. index: "LWEIGHT",
  39. align: "center",
  40. sorttype: "string"
  41. },
  42. {
  43. name: "ActualWeightMinus",
  44. index: "ActualWeightMinus",
  45. align: "center",
  46. sorttype: "string"
  47. },
  48. {
  49. name: "FNAME",
  50. index: "FNAME",
  51. align: "center",
  52. sorttype: "string"
  53. },
  54. {
  55. name: "InTime",
  56. index: "InTime",
  57. align: "center",
  58. sorttype: "string"
  59. },
  60. {
  61. name: "ButtonType",
  62. index: "ButtonType",
  63. align: "center",
  64. sorttype: "string"
  65. },
  66. {
  67. name: "LastActualWeight",
  68. index: "LastActualWeight",
  69. align: "center",
  70. sorttype: "string",
  71. hidden: true
  72. },
  73. {
  74. name: "ActualWeight",
  75. index: "ActualWeight",
  76. align: "center",
  77. sorttype: "string",
  78. hidden: true
  79. },
  80. {
  81. name: "isWc",
  82. index: "isWc",
  83. align: "center",
  84. sorttype: "string",
  85. hidden: true
  86. }
  87. ],
  88. afterInsertRow: function(rowid,rowdata,rowelem){
  89. if(rowdata.isWc == 1){
  90. $("#p1list").setCell(rowid,1,"",{background:'#FFE66F'});
  91. $("#p1list").setCell(rowid,2,"",{background:'#FFE66F'});
  92. $("#p1list").setCell(rowid,3,"",{background:'#FFE66F'});
  93. $("#p1list").setCell(rowid,4,"",{background:'#FFE66F'});
  94. $("#p1list").setCell(rowid,5,"",{background:'#FFE66F'});
  95. $("#p1list").setCell(rowid,6,"",{background:'#FFE66F'});
  96. }
  97. },
  98. footerrow: true, //统计运算的功能
  99. gridComplete: completeMethod,
  100. /**
  101. * 设置水平滚动条 begin
  102. **/
  103. autowidth: true, //自动调节宽度
  104. rowNum: 1000, //每页显示条数
  105. /**
  106. * 设置水平滚动条 end
  107. **/
  108. altRows: true, //设置表格是否允许行交替变色值
  109. altclass:"tdbgmouseover" //自定义隔行变色的样式
  110. });
  111. //获取数据集
  112. mydataP1 = getR1Lists();
  113. if(mydataP1!=null){
  114. for(var i=0;i<=mydataP1.length;i++){
  115. $("#p1list").jqGrid('addRowData',i+1,mydataP1[i]);
  116. }
  117. }
  118. }
  119. //获取服务器数据
  120. function getR1Lists(){
  121. var currentpId = $("#currentpId").val();
  122. $.ajax({
  123. async: false,
  124. type: 'POST',
  125. dataType:'json', //返回类型json
  126. url: "${contextPath }/admin/statistics/realtime1list.html?currentpId="+currentpId,
  127. error: function(){alert("系统错误");},
  128. success: function(json){
  129. mydataP1 = json;
  130. }
  131. });
  132. return mydataP1;
  133. }
  134. //页脚统计
  135. function completeMethod(){
  136. var sum_lweight=$("#p1list").getCol("LWEIGHT",false,"sum");
  137. var sum_awm=$("#p1list").getCol("ActualWeightMinus",false,"sum");
  138. $("#p1list").footerData("set", {SORT:"合计:", LWEIGHT: sum_lweight});
  139. $("#p1list").footerData("set", {ActualWeightMinus: sum_awm});
  140. }
  141. </script>
  142. <table id="p1list"></table>