123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- <%@ 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,type = "link";
- $(document).ready( function() {
- $("input.datebox").bind("click", function() {WdatePicker();});
- setNowDate();
- loadList(); //第一次加载jqgrid
- $("#list").jqGrid("setGridHeight",$(window).height() - 130);
- $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
-
- if(mydata!=null){
- if(mydata.length > 0){
- for(var i=0;i<=mydata.length;i++){
- if(mydata[i].CheckStatus == "已审核"){
- $("#checkStatusBtn").hide();
- break;
- }else{
- $("#checkStatusBtn").show();
- break;
- }
- }
- }else{
- $("#checkStatusBtn").show();
- }
- }else{
- $("#checkStatusBtn").show();
- }
- });
-
- $(window).resize(function(){
- $("#list").jqGrid("setGridHeight",$(window).height() - 130);
- $("#list").jqGrid("setGridWidth",document.body.clientWidth - 5);
- });
-
- //初始化日期
- 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();
-
- if(mydata!=null){
- if(mydata.length > 0){
- for(var i=0;i<=mydata.length;i++){
- if(mydata[i].CheckStatus == "已审核"){
- $("#checkStatusBtn").hide();
- break;
- }else{
- $("#checkStatusBtn").show();
- break;
- }
- }
- }else{
- $("#checkStatusBtn").show();
- }
- }else{
- $("#checkStatusBtn").show();
- }
-
- $("#checkLabel").html("");
- }
- 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();
- }
-
- //jqgrid初始化
- function loadList(){
- jQuery("#list").jqGrid({
- datatype: "local", //从服务器端返回的数据类型,(表格期望接收的数据类型)。可选类型:xml,xmlstring,json,local,function
- colNames:["审核状态","主键","业务日期","牲畜类别","饲料名称","计划重量","实际重量","操作重量","备注","是否审核"], //列名
- colModel:[
- {name: "CheckStatus",index: "CheckStatus",align: "center",hidden: true},
- {name: "FeedStorageId",index: "FeedStorageId",align: "center",hidden: true},
- {name: "BusinessDate",index: "BusinessDate", align: "center",sortable:false},
- {name: "CLASSNAME",index: "CLASSNAME", align: "center",sortable:false},
- {name: "FeedName",index: "FeedName", align: "center",sortable:false},
- {name: "PlanWeight",index: "PlanWeight", align: "center",sortable:false},
- {name: "ActualWeight",index: "ActualWeight", align: "center",sortable:false},
- {name: "OperateWeight",index: "OperateWeight", align: "center",sortable:false,editable: true},
- {name: "Remark",index: "Remark", align: "center",sortable:false,editable: true},
- {name: "CheckStatus",index: "CheckStatus", align: "center",sortable:false},
- ],
-
- cellEdit: true,
- cellsubmit: "clientArray", //当单元格发生变化后不直接发送请求、"remote"默认直接发送请求
-
- afterSaveCell: function(rowid,name,val,iRow,iCol) {
- var rowData = $("#list").jqGrid("getRowData",rowid);
- $.ajax({
- async: false,
- type: 'POST',
- dataType:'json', //返回类型jsond
- data: "ID="+rowData.FeedStorageId+"&colName="+name+"&colValue="+val,
- url: "${contextPath }/admin/feedstorage/feedstoragesystemoutupdate.html",
- error: function(){alert("系统错误");},
- success: function(json){
- }
- });
- },
-
- afterInsertRow: function(rowid,rowdata,rowelem){
- if(rowdata.CheckStatus == "已审核"){
- $("#list").setCell(rowid,7,"",{background: "#e4dee6"});
- $("#list").setColProp("OperateWeight",{editable: false});
- }else{
- $("#list").setColProp("OperateWeight",{editable: true});
- }
- },
-
- caption: "系统用量", //标题
- pager: "#page", //#page分页控件绑定的位置对象
- pginput: false, //不显示分页文本框
- pgbuttons: false, //不显示翻页按钮
- rowNum: 1000, //每页显示条数
- autowidth: true //自动调节宽度
-
- });
-
- //获取数据集
- mydata = getLists();
-
- if(mydata!=null){
- for(var i=0;i<=mydata.length;i++){
- jQuery("#list").jqGrid('addRowData',i+1,mydata[i]);
- }
- }
-
-
- }
-
- //获取服务器数据
- function getLists(){
-
- var beginDate = $("#beginDate").val();
- //var feedId = $("#feedId").val();
-
- if(beginDate==""){
- alert("请选择开始日期");
- $("#beginDate").focus();
- }
-
- $.ajax({
- async: false,
- type: 'POST',
- dataType:'json', //返回类型json
- url: "${contextPath }/admin/feedstorage/feedstoragesystemoutlist.html?beginDate="+beginDate+"&feedId=",
- error: function(){alert("系统错误");},
- success: function(json){
- mydata = json;
- }
- });
- return mydata;
- }
-
- function checkData(){
- var beginDate = $("#beginDate").val();
-
- $.ajax({
- async: false,
- type: "POST",
- dataType:"json", //返回类型jsond
- data: "beginDate="+beginDate,
- url: "${contextPath }/admin/feedstorage/feedstoragesystemoutcheckvalid.html",
- error: function(){alert("系统错误");},
- success: function(json){
- if(json.status == "success"){
- if(json.checkLabel != ""){
- var checkLabel = "<font color='red'>" + json.checkLabel + "</font>";
- $("#checkLabel").html(checkLabel);
- }else{
- $.ajax({
- async: false,
- type: "POST",
- dataType:"json", //返回类型jsond
- data: "beginDate="+beginDate,
- url: "${contextPath }/admin/feedstorage/feedstoragesystemoutcheck.html",
- error: function(){alert("系统错误");},
- success: function(json){
- if(json.status == "fail"){
- alert(json.msg);
- }else{
- $("#list").clearGridData(); //清空原grid数据
- loadList(); //重新载入服务器数据
- }
- }
- });
- }
- }
- }
- });
- }
-
- </script>
- <body style="background-color: #E0E0E0">
- <div>
- <div class="navfrm">
- <span>当前位置:</span>
- <span><a href="${contextPath }/admin/welcome.html">首页</a></span>
- <span> >> </span>
- <span>系统用量</span>
- </div>
- <input id="beginDate" name="beginDate" style="width:100px;" class="datebox" value=""/>
- <input type="button" value="<" onclick="leftDate();" /><input type="button" value=">" onclick="rightDate();" />
- <input type="button" value="系统用料单" onclick="queryDate()" class="sysub" />
- <input id="checkStatusBtn" type="button" value="审核" onclick="checkData()" class="sysub" />
- <label id="checkLabel"></label>
- <table id="list"></table>
- <div id="page" style="height:30px;"></div>
- </div>
- </body>
- </html>
|