123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- <%@ 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,currentId="",isEnableSupplyFeed=0,isMorningPart=0,isNoonPart=0,isNightPart=0,selCurrentId=0,
- colName,Calculation = 0,northType=0,southType=1,isSelTr = 0,Reserved6 = 0,Reserved7 = 0,isLocking = 0,oldUpdateValue = 0,operCount=0,lastrow,lastcell;
-
- $(document).ready( function() {
- getDefaultConfig();//获取系统默认参数是否启用补料模版,各班比例
- queryDate(); //加载jqgrid
- $("#list").jqGrid("setGridWidth",document.body.clientWidth - 10);
- $("#list").jqGrid("setGridHeight",pageHeight() - 50);
- $("input.datebox").bind("click", function() {WdatePicker();});
-
- });
-
- $(window).resize(function(){
- $("#list").jqGrid("setGridWidth",document.body.clientWidth - 10);
- $("#list").jqGrid("setGridHeight",pageHeight() - 50);
- });
-
- function pageHeight(){
- if($.browser.msie){
- return document.compatMode == "CSS1Compat"? document.documentElement.clientHeight :
- document.body.clientHeight;
- }else{
- return self.innerHeight;
- }
- }
-
- //jqgrid初始化
- function loadList(){
- jQuery("#list").jqGrid({
- datatype: "local", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
- height: 170, //高度
- colNames: ["主键","栏舍名称","早班1量", "早班2量", "中班1量", "中班2量", "晚班1量", "晚班2量", "sel1", "sel2", "sel3", "sel4", "sel5", "sel6"],
- colModel:[
- {
- name: "ID",
- index: "ID",
- align: "center",
- sorttype: "string",
- editable: true,
- hidden: true
- //editoptions:{readonly:true} 如果要显示该列可以设置只读
- },
- {
- name: "BNAME",
- index: "BNAME",
- align: "center",
- sorttype: "string",
- editable: false
- },
- {
- name: "Rtime1",
- index: "Rtime1",
- align: "center",
- sorttype: "int",
- editable: true,
- editrules: {number: true}
- },
- {
- name: "Rtime2",
- index: "Rtime2",
- align: "center",
- sorttype: "int",
- editable: true,
- editrules: {number: true},hidden: true
- },
- {
- name: "Rtime3",
- index: "Rtime3",
- align: "center",
- sorttype: "int",
- editable: true,
- editrules: {number: true}
- },
- {
- name: "Rtime4",
- index: "Rtime4",
- align: "center",
- sorttype: "int",
- editable: true,
- editrules: {number: true},hidden: true
- },
- {
- name: "Rtime5",
- index: "Rtime5",
- align: "center",
- sorttype: "int",
- editable: true,
- editrules: {number: true}
- },
- {
- name: "Rtime6",
- index: "Rtime6",
- align: "center",
- sorttype: "int",
- editable: true,
- editrules: {number: true},hidden: true
- },
- {name: "sel1",index: "sel1",align: "center",sorttype: "int",editrules: {number: true},hidden: true},
- {name: "sel2",index: "sel2",align: "center",sorttype: "int",editrules: {number: true},hidden: true},
- {name: "sel3",index: "sel3",align: "center",sorttype: "int",editrules: {number: true},hidden: true},
- {name: "sel4",index: "sel4",align: "center",sorttype: "int",editrules: {number: true},hidden: true},
- {name: "sel5",index: "sel5",align: "center",sorttype: "int",editrules: {number: true},hidden: true},
- {name: "sel6",index: "sel6",align: "center",sorttype: "int",editrules: {number: true},hidden: true}
- ],
-
- beforeEditCell:function(rowid,cellname,v,iRow,iCol){
- lastrow = iRow;
- lastcell = iCol;
- },
-
- afterSaveCell: function(rowid,name,val,iRow,iCol){
- var beginDate = $("#beginDate").val();
- var rowData = $("#list").jqGrid("getRowData",rowid);
- $.ajax({
- async: false,
- type: 'POST',
- dataType:'json', //返回类型jsond
- data: "ID="+rowData.ID+"&colName="+name+"&colValue="+val+"&beginDate="+beginDate,
- url: "${contextPath }/admin/recipeplan/amountUpdate.html",
- error: function(){alert("系统错误");},
- success: function(json){
- if(json.status == "success"){
- //清空主表数据重新加载一次
- $("#list").clearGridData();
- loadList();
- }
- }
- });
- },
-
- cellEdit: true,
- cellsubmit: "clientArray", //当单元格发生变化后不直接发送请求、"remote"默认直接发送请求
- /**
- * 设置水平滚动条 begin
- **/
- toolbar: [true,"top"],
- shrinkToFit: false,
- autoScroll: true,
- pager: "#page", //#page分页控件绑定的位置对象
- pginput: false, //不显示分页文本框
- pgbuttons: false, //不显示翻页按钮
- rowNum: 1000, //每页显示条数
- //autowidth: true, //自动调节宽度
- sortname: 'SORT' //按SORT进行排序 默认asc
- });
-
- 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 id='addFeedpBtn' class='sysub' type='button' value='生成栏舍' onClick='addFeedp()' style='font-size:-2'/> ");
- $("#t_list").append("<input id='' class='sysub' type='button' value='全部清0' onClick='clearFeedp()' style='font-size:-2'/> ");
- 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"); //添加完数据后客户端自动刷新一次、实现客户端数据与服务器数据的完全分离
- }
-
- if(isMorningPart == 1){
- $("#list").jqGrid("showCol","Rtime2");
- }
- if(isNoonPart == 1){
- $("#list").jqGrid("showCol","Rtime4");
- }
- if(isNightPart == 1){
- $("#list").jqGrid("showCol","Rtime6");
- }
-
- if(isSelTr>0){
- $("#list").jqGrid("setSelection",isSelTr);
- }
-
- //根据栏舍发料班次为班次比例添加背景色
- var ids = $("#list").jqGrid("getDataIDs");
- for ( var i = 0; i < ids.length; i++) {
- var rowData = $("#list").jqGrid("getRowData",ids[i]);
- if(rowData.sel1 == 1){
- $("#list").setCell(ids[i],"Rtime1","",{background:'#CCEC9D'});
- }
- if(rowData.sel2 == 1){
- $("#list").setCell(ids[i],"Rtime2","",{background:'#CCEC9D'});
- }
- if(rowData.sel3 == 1){
- $("#list").setCell(ids[i],"Rtime3","",{background:'#CCEC9D'});
- }
- if(rowData.sel4 == 1){
- $("#list").setCell(ids[i],"Rtime4","",{background:'#CCEC9D'});
- }
- if(rowData.sel5 == 1){
- $("#list").setCell(ids[i],"Rtime5","",{background:'#CCEC9D'});
- }
- if(rowData.sel6 == 1){
- $("#list").setCell(ids[i],"Rtime6","",{background:'#CCEC9D'});
- }
- }
-
- }
-
- //获取服务器数据
- function getLists(){
- var beginDate = $("#beginDate").val();
- if(beginDate==""){
- setNowDate();
- beginDate = $("#beginDate").val();
- }
- $.ajax({
- async: false,
- type: 'POST',
- data: "beginDate="+beginDate,
- dataType:'json', //返回类型json
- url: "${contextPath }/admin/recipeplan/feedpamountlist.html",
- error: function(){alert("系统错误");},
- success: function(json){
- mydata = json;
- }
- });
- return mydata;
- }
-
- //获取系统默认参数是否启用补料模版,各班比例
- function getDefaultConfig(){
- $.ajax({
- async: false,
- type: 'POST',
- dataType:'json', //返回类型json
- url: "${contextPath }/admin/basicdata/getdefaultconfig.html",
- error: function(){alert("系统错误");},
- success: function(json){
- if(json.status == "success"){
- if(json.isEnableSupplyFeed){
- isEnableSupplyFeed = 1;
- }
- if(json.isMorningPart){
- isMorningPart = 1;
- }
- if(json.isNoonPart){
- isNoonPart = 1;
- }
- if(json.isNightPart){
- isNightPart = 1;
- }
- }
- }
- });
- }
-
- //自定义添加方法
- function addFeedp(){
- var beginDate = $("#beginDate").val();
- $.ajax({
- async: false,
- type: "POST",
- data: "beginDate="+beginDate,
- dataType:"json", //返回类型jsond
- url: "${contextPath }/admin/recipeplan/addfeedpamount.html",
- error: function(){alert("系统错误");},
- success: function(json){
- $("#list").clearGridData(); //清空原grid数据
- loadList(); //重新载入服务器数据
- }
- });
- }
-
- //自定义添加方法
- function clearFeedp(){
- var beginDate = $("#beginDate").val();
- $.ajax({
- async: false,
- type: "POST",
- data: "beginDate="+beginDate,
- dataType:"json", //返回类型jsond
- url: "${contextPath }/admin/recipeplan/clearfeedp.html",
- error: function(){alert("系统错误");},
- success: function(json){
- $("#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 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();
- }
-
- //查询数据
- function queryDate(){
- //清空主表数据重新加载一次
- $("#list").clearGridData();
- loadList();
- var ids = $("#list").jqGrid("getDataIDs");
- if(ids.length > 0){
- $("#addFeedpBtn").hide();
- }else{
- $("#addFeedpBtn").show();
- }
- }
-
- </script>
- </head>
- <body>
- <table id="list"></table>
- </body>
- </html>
|