| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <%@ 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" %>
- <link type="text/css" rel="stylesheet" href="${contextPath}/css/style.css" />
- <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("setGridWidth",document.body.clientWidth - 5);
- });
-
- $(window).resize(function(){
- });
-
- //jqgrid初始化
- function loadList(){
-
- jQuery("#list").jqGrid({
- datatype: "local", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
- height: "50%", //高度
- colNames:["主键","车次","TMR","配方模板","描述","总量","每车重量"], //列名
- colModel:[
- {name: "ID",index: "ID",width: 1,align: "center",sorttype: "string",hidden: true},
- {name: "SORT",index: "SORT",width: 50,align: "center",sorttype: "int",editable: true,editrules: {integer: true}},
- {name: "tmrId",index: "tmrId",width: 70,align: "center",sorttype: "int",editable: true,edittype: "select",
- editoptions:{
- dataUrl: "${contextPath }/admin/recipeplan/tmrselect.html"
- }
- },
- {name: "feedtempletId",index: "feedtempletId",width: 70,align: "center",sorttype: "int",editable: true,edittype: "select",
- editoptions:{
- dataUrl: "${contextPath }/admin/recipeplan/plpplanselect.html"
- }
- },
- {name: "remark",index: "remark",width: 70,align: "center",sorttype: "string",editable: true},
- {name: "sumWeight",index: "sumWeight",width: 70,align: "center",sorttype: "string",editable: true,editrules: {number: true}},
- {name: "sortWeight",index: "sortWeight",width: 70,align: "center",sorttype: "string",editable: true,editrules: {number: true}}
- ],
- cellEdit: true,
- cellsubmit: "clientArray", //当单元格发生变化后不直接发送请求、"remote"默认直接发送请求
- autowidth: true, //自动调节宽度
- rowNum: 1000, //每页显示条数
- /**
- * 设置水平滚动条 end
- **/
-
- toolbar: [true,"top"],
-
- beforeEditCell:function(rowid,cellname,v,iRow,iCol){
- lastrow = iRow;
- lastcell = iCol;
- }
-
- });
-
- 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 class='sysub' type='button' value='新增车次' onClick='addLpplan()' style='font-size:-2'/> ");
- $("#t_list").append("<input class='sysub' type='button' value='删除车次' onClick='delLpplan()' style='font-size:-2'/> ");
- $("#t_list").append("<input class='sysub' type='button' value='确认保存' onClick='saveLpplan()' 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"); //添加完数据后客户端自动刷新一次、实现客户端数据与服务器数据的完全分离
- }
-
- }
-
- //获取服务器数据
- function getLists(){
- var beginDate = $("#beginDate").val();
- if(beginDate==""){
- setNowDate();
- beginDate = $("#beginDate").val();
- }
- $.ajax({
- async: false,
- type: 'POST',
- dataType:'json', //返回类型json
- url: "${contextPath }/admin/recipeplan/plpplanlist.html?beginDate="+beginDate,
- error: function(){alert("系统错误");},
- success: function(json){
- mydata = json;
- }
- });
- return mydata;
- }
-
- //自定义添加方法
- function addLpplan(){
- var beginDate = $("#beginDate").val();
- var ids = $("#list").jqGrid("getDataIDs");
- $("#list").jqGrid("addRowData",ids.length+1,{},"first");
- $.ajax({
- async: false,
- type: "POST",
- dataType:"json", //返回类型jsond
- data: "oper=add&selId=&beginDate="+beginDate,
- url: "${contextPath }/admin/recipeplan/plupdate.html",
- error: function(){alert("系统错误");},
- success: function(json){
- $("#list").clearGridData(); //清空原grid数据
- loadList(); //重新载入服务器数据
- }
- });
- }
-
- //自定义删除方法
- function delLpplan(){
- var beginDate = $("#beginDate").val();
- var row = $("#list").jqGrid("getGridParam","selrow");
- if(row!=null){
- var flag = confirm("您确定要删除吗?");
- if(flag){
- var selRow = $("#list").jqGrid("getRowData",row);
- $.ajax({
- async: false,
- type: "POST",
- dataType:"json", //返回类型jsond
- data: "oper=del&selId="+selRow.ID+"&beginDate="+beginDate,
- url: "${contextPath }/admin/recipeplan/plupdate.html",
- error: function(){alert("系统错误");},
- success: function(json){
- $("#list").clearGridData(); //清空原grid数据
- loadList(); //重新载入服务器数据
- }
- });
- }
- }else{
- alert("请选择记录");
- }
- }
-
- //确认保存
- function saveLpplan(){
- $("#list").jqGrid("saveCell",lastrow,lastcell);
- //编辑后按过回车状态、可以保存
-
- var beginDate = $("#beginDate").val();
- var lpplanStr = "";
- 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 tmrId = $.trim(rowData.tmrId);
- var feedtempletId = $.trim(rowData.feedtempletId);
- var remark = rowData.remark;
- var SORT = rowData.SORT;
- var sumWeight = rowData.sumWeight;
- var sortWeight = rowData.sortWeight;
- if(lpplanStr == ""){
- lpplanStr = "ID:"+ID+",tmrId:"+tmrId+",SORT:"+SORT+",feedtempletId:"+feedtempletId+",remark:"+remark+",sumWeight:"+sumWeight+",sortWeight:"+sortWeight;
- }else{
- lpplanStr += ";" + "ID:"+ID+",tmrId:"+tmrId+",SORT:"+SORT+",feedtempletId:"+feedtempletId+",remark:"+remark+",sumWeight:"+sumWeight+",sortWeight:"+sortWeight;
- }
- }
-
- $.ajax({
- async: false,
- type: 'POST',
- data: "lpplanStr="+lpplanStr+"&beginDate="+beginDate,
- dataType: 'json',
- url: "${contextPath}/admin/recipeplan/updateallProduce.html",
- error: function(){alert("系统错误");},
- success: function(json){
- if(json.status == "success"){
- $("#list").clearGridData(); //清空原grid数据
- //window.location.reload();
- 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 style="background-color: #E0E0E0">
- <div>
- <table id="list"></table>
- </div>
- </body>
- </html>
|