123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <%@ page contentType="text/html; charset=utf-8" session="false" %>
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
- <head>
- <title>我的工作台</title>
- <%@ include file="../common/header.jsp" %>
- <script type="text/javascript" src="${contextPath }/js/calendar/WdatePicker.js"></script>
- <script type="text/javascript">
- var mydata,operCount=0,lastrow,lastcell;
- $(document).ready( function() {
- loadList(); //加载jqgrid
- $("input.datebox").bind("click", function() {WdatePicker();});
- $("#list").jqGrid("setGridHeight",$(window).height() - 105);
- $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
- });
- $(window).resize(function(){
- $("#list").jqGrid("setGridHeight",$(window).height() - 105);
- $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
- });
-
- //jqgrid初始化
- function loadList(){
-
- jQuery("#list").jqGrid({
- datatype: "local", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
- height: "60%", //高度
- colNames:["主键","舍栏名称","转投剩料量(kg)","转投舍栏ID","转投舍栏"], //列名
- colModel:[
- {name: "ID",index: "ID",width: 1,align: "center",sorttype: "string",hidden: true},
- {name: "BNAME",index: "BNAME",align: "center",sorttype: "String",editable: false},
- {name: "Remain",index: "Remain",align: "center",sorttype: "number",editable: true,editrules: {number: true},formatter:"number"},
- {name: "ztFeedpId",index: "ztFeedpId",width: 1,align: "center",sorttype: "string",hidden: true},
- {
- name: "ztFeedpName",
- index: "ztFeedpName",
- align: "center",
- sorttype: "int",
- editable: true,
- edittype: "select",
- editoptions:{
- dataUrl: "${contextPath }/admin/produce/produceselect.html",
- dataEvents: [{
- type: 'change', //下拉选择的时候
- fn: function(e){
- var currentValue = this.value;
- var ztFeedpId = currentValue.substring(0,currentValue.indexOf(","));
- var row = $("#list").jqGrid("getGridParam","selrow");
- if(ztFeedpId == ""){
- $("#list").setCell(row,"ztFeedpId",null);
- }else{
- $("#list").setCell(row,"ztFeedpId",ztFeedpId);
- }
- }
- }]
- }
- }
- ],
- cellEdit: true,
- cellsubmit: "clientArray", //当单元格发生变化后不直接发送请求、"remote"默认直接发送请求
-
- beforeEditCell:function(rowid,cellname,v,iRow,iCol){
- lastrow = iRow;
- lastcell = iCol;
- },
-
- rowNum: 1000, //每页显示条数
- /**
- * 设置水平滚动条 begin
- **/
- shrinkToFit:false,
- autoScroll: true,
- autowidth: true, //自动调节宽度
- /**
- * 设置水平滚动条 end
- **/
- altRows: true, //设置表格是否允许行交替变色值
- altclass:"tdbgmouseover", //自定义隔行变色的样式
-
- toolbar: [true,"top"],
- caption: "栏舍剩料量" //标题
-
- });
-
- if(operCount == 0){
- $("#t_list").append("<input id='beginDate' name='beginDate' style='width:100px;font-size:12px;' class='datebox' value=''/> ");
- $("#t_list").append("<input type='button' value='<' onclick='leftDate();' /><input type='button' value='>' onclick='rightDate();' /> ");
- $("#t_list").append("<input type='button' class='sysub' value='查询' onclick='queryDate()' /> ");
- $("#t_list").append("<input type='button' value='确认保存' onClick='saveLpplan()' class='sysub' /> ");
- operCount++;
- }
-
- //获取数据集
- mydata = getLists();
-
- if(mydata!=null){
- for(var i=0;i<=mydata.length;i++){
- jQuery("#list").jqGrid('addRowData',i+1,mydata[i]);
- }
- jQuery("#list").jqGrid().trigger("reloadGrid"); //添加完数据后客户端自动刷新一次、实现客户端数据与服务器数据的完全分离
- }
-
- }
-
- //获取服务器数据
- function getLists(){
- var beginDate = $("#beginDate").val();
- if(beginDate==""){
- setNowDate();
- beginDate = $("#beginDate").val();
- }
- $.ajax({
- async: false,
- type: 'POST',
- dataType:'json', //返回类型json
- url: "${contextPath }/admin/produce/surpluslist.html?beginDate="+beginDate,
- error: function(){alert("系统错误");},
- success: function(json){
- mydata = json;
- }
- });
- return mydata;
- }
- //确认保存
- function saveLpplan(){
- $("#list").jqGrid("saveCell",lastrow,lastcell);
- var beginDate = $("#beginDate").val();
- var milkStr = "";
- var ids = $("#list").jqGrid("getDataIDs");
- for ( var i = 0; i < ids.length; i++) {
- var rowData = $("#list").jqGrid("getRowData",ids[i]);
-
- var ID = rowData.ID;
- var BNAME = $.trim(rowData.BNAME);
- var Remain = rowData.Remain;
- var ztFeedpId = rowData.ztFeedpId;
- var ztFeedpName = rowData.ztFeedpName;
-
- if(milkStr == ""){
- milkStr = "ID:"+ID+",BNAME:"+BNAME+",Remain:"+Remain+",ztFeedpId:"+ztFeedpId+",ztFeedpName:"+ztFeedpName;
- }else{
- milkStr += ";" + "ID:"+ID+",BNAME:"+BNAME+",Remain:"+Remain+",ztFeedpId:"+ztFeedpId+",ztFeedpName:"+ztFeedpName;
- }
- }
-
- $.ajax({
- async: false,
- type: 'POST',
- data: "milkStr="+milkStr+"&beginDate="+beginDate,
- dataType: 'json',
- url: "${contextPath}/admin/produce/surplusallupdate.html",
- error: function(){alert("系统错误");},
- success: function(json){
- if(json.status == "success"){
- $("#list").clearGridData(); //清空原grid数据
- loadList();
- }
- }
- });
- }
- //初始化日期
- function setNowDate(){
- var myDate = new Date();
- var year = myDate.getFullYear();
- var month = myDate.getMonth()+1;
- var day = myDate.getDate();
- var nowdate = year + "-" + month + "-" + day;
- $("#beginDate").val(nowdate);
- }
-
- //查询数据
- function queryDate(){
- //清空主表数据重新加载一次
- $("#list").clearGridData();
- loadList();
- }
- function leftDate(){
- var beginDate = $("#beginDate").val();
- var newbDate = checkDate(beginDate,"left");
- $("#beginDate").val(newbDate);
- queryDate();
- }
- function rightDate(){
- var beginDate = $("#beginDate").val();
- var newbDate = checkDate(beginDate,"");
- $("#beginDate").val(newbDate);
- queryDate();
- }
- </script>
- </head>
- <body>
- <div>
- <div class="navfrm">
- <span>当前位置:</span>
- <span><a href="${contextPath }/admin/welcome.html">首页</a></span>
- <span> >> </span>
- <span>栏舍剩料量</span>
- </div>
- <table id="list"></table>
- </div>
- </body>
- </html>
|