<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@include file="/pages/includes/taglibs.jsp" %>
<head>
		<script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/jquery-1.8.3.js"></script>
 <script type="text/ecmascript" src="<%=request.getContextPath() %>/resource/plugin/jqgrid/js/jquery.jqGrid.min.js"></script>
 <script type="text/ecmascript" src="<%=request.getContextPath() %>/resource/plugin/jqgrid/js/i18n/grid.locale-cn.js"></script>
 
<script type="text/ecmascript" src="<%=request.getContextPath()%>/pages/apdata/jqgridDatas.js"></script>
<script src="<%=request.getContextPath()%>/resource/js/datePicker/WdatePicker.js" type="text/javascript"></script>
 <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/resource/plugin/jqueryui/css/custom-theme/jquery-ui-1.9.2.custom.css" />
 <link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath() %>/resource/plugin/jqgrid/css/ui.jqgrid.css" />
<style type="text/css">

a{      /* 统一设置所以样式 */
     font-family:Arial;
     font-size:12px;
     text-align:center;
     margin:3px;
}
a:link,a:visited{  /* 超链接正常状态、被访问过的样式 */
    color:#000000;
    padding:4px 10px 4px 10px;
    background-color:#f1f1f1;
    text-decoration:none;
 
    border-top:1px solid #EEEEEE; /* 边框实现阴影效果 */
    border-left:1px solid #EEEEEE;
    border-bottom:1px solid #717171;
    border-right:1px solid #717171;
}
a:hover{       /* 鼠标指针经过时的超链接 */
    color:#821818;     /* 改变文字颜色 */
    padding:5px 8px 3px 12px;  /* 改变文字位置 */
    background-color:#e2c4c9;  /* 改变背景色 */
    border-top:1px solid #717171; /* 边框变换,实现“按下去”的效果 */
    border-left:1px solid #717171;
    border-bottom:1px solid #EEEEEE;
    border-right:1px solid #EEEEEE;
}

fieldset legend {  
    color:#302A2A;  
    font: bold 16px/2 Verdana, Geneva, sans-serif;  
    font-weight: bold;  
    text-align: left;  
    text-shadow: 2px 2px 2px rgb(88, 126, 156);  
}  
</style>
<script type="text/javascript">
	
	var fcId = '<s:property value="wfId"/>';
	var projectid = '<s:property value="projectid"/>';
	
	function thisPage(){
		$("#f1").attr("action","planIndex.action").submit();
	}
	function addData(){
	
		$("#f1").attr("action","editDatas.action").submit();
	}
	function editData(id){
		var year=$("#year").val();
		
		$("#f1").attr("action","editDatas.action?vo.projectid="+id).submit();
	}
	function queryData(){
		var year = $("#year").val();
		var wfId = $("#wfId").val();
		var projectid=$("#projectid").val();
		
		var temp="queryData.action?year="+year
										//+"&month="+endDate
										+"&wfId="+wfId
										+"&projectid="+projectid;
		var url= encodeURI(encodeURI(temp)); 
			$("#gridTable").setGridParam({url:url}).trigger("reloadGrid"); 
		
	}
	
		function toExcel() {
			  	var beginDate = $("#year").val();
				var wfId = $("#wfId").val();
				var projectid=$("#projectid").val();
				
				var temp="projectPlanExcel.action?year="+beginDate
												//+"&month="+endDate
												+"&wfId="+wfId
												
												+"&projectid="+projectid;
				var url= encodeURI(encodeURI(temp)); 
					$('#toexcel').attr('href',url); 
				
		}	
		
		function changeFc(fcId){
		if(fcId!='' && fcId!=null )
		{
			var url = "changeWindpowerAjax.action?wfId="+fcId;
   		
		$.ajax({
			type:"post",
			url:url,
			dataType:"json",
			success: function(data){
				if(data.length != 0){
					eval(data);
					$("#projectid").empty();
					$("#projectid").append("<option value=''>请选择</option>"); 
				
					for(var i=0; i<data.length; i++){
						$("#projectid").append("<option value='"+data[i].id+"'>"+data[i].name+"</option>"); 
					}
					
				}else{
					$("#projectid").empty();
					$("#projectid").append("<option value=''>请选择</option>"); 
				}
				
				
	  		}		
		});
		
		}
   		
		queryData();
		
	}
$(document).ready(function () {

showJqGrid();

});
function showJqGrid() {
		var year = $("#year").val();
		var wfId = $("#wfId").val();
		var projectid=$("#projectid").val();
		
		var temp="queryData.action?year="+year
										//+"&month="+endDate
										+"&wfId="+wfId
										+"&projectid="+projectid;
		var url= encodeURI(encodeURI(temp)); 
var id = 'gridTable';


var datatype = 'json';

var colNames = ['编号','名称', '年', '1月','2月','3月','4月', '5月','6月','7月','8月', '9月','10月','11月','12月','合计'];

var colModel = [
{ name: 'id', index: 'id', width: 150, align: 'center', hidden:true,  frozen : true},
{ name: 'projectName', index: 'projectName', width: 150, align: 'center',  frozen : true},
{ name: 'year', index: 'year', width: 150, align: 'center'},
{ name: 'gc01', index: 'gc01', width: 150, align: 'center'},
{ name: 'gc02', index: 'gc02', width: 150, align: 'center'},
{ name: 'gc03', index: 'gc03', width: 150, align: 'center'},
{ name: 'gc04', index: 'gc04', width: 150, align: 'center'},
{ name: 'gc05', index: 'gc05', width: 150, align: 'center'},
{ name: 'gc06', index: 'gc06', width: 150, align: 'center'},
{ name: 'gc07', index: 'gc07', width: 150, align: 'center'},
{ name: 'gc08', index: 'gc08', width: 150, align: 'center'},
{ name: 'gc09', index: 'gc09', width: 150, align: 'center'},
{ name: 'gc10', index: 'gc10', width: 150, align: 'center'},
{ name: 'gc11', index: 'gc11', width: 150, align: 'center'},
{ name: 'gc12', index: 'gc12', width: 150, align: 'center'},
{ name: 'generatingcapacity', index: 'generatingcapacity', width: 150, align: 'center'}

];

var caption = '计划发电量列表';


var sortname = 'projectName';

var gridPagerID ='gridPager';

var sortorder='desc';

var height='auto';

var width='1500';


var rownumbers=true;

var multiselect=false;

myJqGrid(id, url, datatype, colNames, colModel, caption,  sortname, gridPagerID,sortorder,height,width,
multiselect,rownumbers);
$("#gridTable").jqGrid('setFrozenColumns');
}
</script>
<style type="text/css">


fieldset legend {  
    color:#302A2A;  
    font: bold 16px/2 Verdana, Geneva, sans-serif;  
    font-weight: bold;  
    text-align: left;  
    text-shadow: 2px 2px 2px rgb(88, 126, 156);  
}  
</style>
</head>
<body>

<form action="fittingtopindex.action" method="post" id="f1">

<fieldset style="height: 60px" id="fst">
    <legend class="item_Name">查询条件</legend>
  <table  class="item_Name">
	<tr>
		<th  width="10%">
			风场:
		</th>
		<td width="20%" >
			 <s:select list="windpowers" cssStyle="width:90%" listKey="id" listValue="name" id="wfId" name="wfId" headerKey="" headerValue="请选择" onchange="javascript:changeFc(this.value);" ></s:select>

		</td>
		<th  width="10%">
			项目:
		</th>
		<td width="20%">
		<select name="projectid" id="projectid" style="width:90%" onchange="javascript:queryData();">
				<option value="">请选择</option>
			</select> 
			</td>
		<th width="5%">
			年:
		</th>
		<td width="20%" style="text-align: left">
			<s:textfield cssClass="Wdate" onFocus="WdatePicker({dateFmt:'yyyy',isShowWeek:true,readOnly:true})" 
			id="year" name="year" title="年"  onchange="javascript:queryData();"/>
		</td>
		<td width="200px" style="text-align: right">
			<a href="#" id="test" onclick="javascript:queryData();"  >查询</a>
			<a href="#" id="test" onclick="javascript:addData();"  >新增</a> 
			<a href="#" onclick="javascript:toExcel();" id="toexcel">导出</a>	
		</td>
	</tr>
</table>
  </fieldset>

<br/>

<table id='gridTable' height="100%">

</table>

<div id='gridPager'></div>
</form>

</body>