var objAjax=new JAjax();
function loadPage(){
	loadBodyclick();
	var tools=new toolsClass();
	tools.add("","生成Excel","runDate.runExcel()","生成Excel");
	tools.create(toolsDiv);
	if(urlPar("runType")!=null&&urlPar("runType")!=""){
		runDate.runType=urlPar("runType");
	}else{
		runDate.runType=-1;	
	}
	var signUserUrl=urlPar("signUser");
	var nowTime=urlPar("nowTime");
	if(signUserUrl!=null&&signUserUrl!=""){
		signUserUrl=signUserUrl.split(c1);
		runDate.signUser=signUserUrl;
	}
	if(nowTime!=null&&nowTime!=""){
		$("selectTime").value=nowTime;
	}else{
		 var dt=new Date();		
		 var nowDateSystem=dt.toLocaleString();
		 var index=nowDateSystem.indexOf("月");
		 var indexD=nowDateSystem.indexOf("日");
		 $("selectTime").value=nowDateSystem.substring(0,4)+"-"+(nowDateSystem.substring(5,index)-1)+"-"+nowDateSystem.substring(index+1,indexD);  
	}
	runDate.nowPage=1;
	runDate.pageSize=13;
	runDate.readDate();
	writeFettleLeft("提示:当前是显示未签收的文章列表,点击文章标题可以查看该文章"); //状态栏提示
}

function selDate(thisObj){
	var d=openSelectDate("../../");
	if(d!="" & d!=null&typeof d!="undefined"){  
		if(thisObj.type=="button"){                  
			thisObj.previousSibling.value=d;
			runDate.nowPage=1;
			runDate.readDate();
		}
	}
} 

function SingRunDate(){//初始化数据
	var runType=-1;//-1当前用户的信息 0正常+过期 1正常 2 过期 
	var nowPage=1;
	var pageSize=19;
	var pageCount=0;
	var signUser=new Array();//存放要签收的用户信息
	var selArray=new Array();
}

SingRunDate.prototype.runExcel=function(){
	if(this.selArray){
		var objResponse=new JHttpResponse();
		objResponse.write("inDate",this.selArray.join(","));	
		var out=objAjax.getText("post","signed.aspx?type=runExcel",objResponse,null);
		if(out.indexOf(".xls")>-1){
			$("runExcel").href=out;
			$("runExcel").click();
		}else{
			alert(out)
		}
	}else{
		alert("当前没有数据");	
	}
}

SingRunDate.prototype.readDate=function(){//读取数据
	var selectTime=$("selectTime");
	var signUserLst="";
	if(runDate.signUser){
		if(runDate.signUser.length>0){
			signUserLst=runDate.signUser.join(c1);	
		}
	}
	var objResponse=new JHttpResponse();
	objResponse.write("nowPage",this.nowPage);	
    objResponse.write("pageSize",this.pageSize);
	objResponse.write("selTime",selectTime.value);
	objResponse.write("runType",this.runType);
	objResponse.write("signUser",signUserLst);		
	var out=objAjax.getText("post","signed.aspx?type=readSignFor",objResponse,null);
	if(out.indexOf(c1)>-1){
		this.selArray=new Array();
		var thSplit=out.split(c3);
		var divPages=$("divPages")
		var cTable=$("bodyDiv");
		if(cTable.childNodes.length>0){
			cTable.firstChild.removeNode(true);
		}
		divPages.innerHTML="";		
		this.pageCount=thSplit[1];		
		out=thSplit[0].split(c2);
		var t=new createOurTitle();
		t.add("标题(点击查看)","left","220");
		t.add("签收用户名","center","80");
		t.add("签收发布日期","center","120");
		t.add("签收结束日期","center","120");
		t.add("签收类型","center","80");
		t.table=cTable;
		t.create();	
		var tr=null;
		this.selArray=new Array();
		var allArrayStr=thSplit[3].split(",");
		for(var k=0;k<allArrayStr.length;k++){
			if(allArrayStr[k]!=""&&allArrayStr[k]!=null){
					this.selArray.push(allArrayStr[k]);
			}
		}
		for(var i=0;i<out.length;i++){
			tr=cTable.insertRow();
			var tSplit=out[i].split(c1);
			tr.setAttribute("id",tSplit[0]);                       //类型    显示页10
 			//id,tabid,tab,mid,toUser,state,toDate,endDate,fileTitle,type,contentPage
			var createTD=tr.insertCell();			//标题
			createTD.style.cssText="text-align:left;padding-left:10px;height:23px;width:220px;";
			createTD.setAttribute("title",tSplit[8])
			var cElement=document.createElement("a");
			var href="../../"+tSplit[10]+"?menuid="+tSplit[3]+"&tab="+tSplit[2]+"&tabid="+tSplit[1];
			cElement.setAttribute("href",href);
			cElement.setAttribute("target","_blank");
			cElement.appendChild(document.createTextNode(tSplit[8]))
			createTD.appendChild(cElement);						
			createTD=tr.insertCell();//签收单位
			createTD.style.cssText="text-align:left;height:23px;width:80px;";
			createTD.appendChild(document.createTextNode(tSplit[4]));			
			createTD=tr.insertCell();//创建日期
			createTD.style.cssText="text-align:left;height:23px;width:120px;";
			createTD.appendChild(document.createTextNode(tSplit[6]));			
			createTD=tr.insertCell();//结束日期
			createTD.style.cssText="text-align:right;height:23px;width:120px;color:#ff0000;";
			createTD.appendChild(document.createTextNode(tSplit[7]));			
			createTD=tr.insertCell();//签收类型
			createTD.style.cssText="text-align:center;height:23px;width:80px;";
			createTD.appendChild(document.createTextNode(tSplit[9]));

			tr.onmouseover=function(){
				for(var i=0;i<this.childNodes.length;i++){
					this.childNodes[i].className="listTitleOption_1Other";	
				}
			}
			tr.onmouseout=function(){
				for(var i=0;i<this.childNodes.length;i++){
					this.childNodes[i].className="listBodyOptionOther";	
				}
			}
		}
		//创建分页
		var pages=parseInt(this.pageCount/this.pageSize);
		if(this.pageCount%this.pageSize>0){
			pages=pages+1;	
		}
		divPages.appendChild(document.createTextNode("一共有"+this.pageCount+"条,分"+pages+"页,第"+this.nowPage+"页"));
		
		var cPage=document.createElement("span");
		cPage.setAttribute("title","首  页");
		cPage.style.cssText="padding-left:10px;cursor:hand;";
		cPage.innerHTML="首  页";	
		if(pages>1&&this.nowPage>1){
		   cPage.onclick=function(){
			   runDate.nowPage=1;
			   runDate.readDate();
		   }
		}else{
			cPage.style.cssText="padding-left:10px;color:#C0C0C0;";
		}
		divPages.appendChild(cPage);
		
		cPage=document.createElement("span");
		cPage.setAttribute("title","下一页");
		cPage.style.cssText="padding-left:10px;cursor:hand;";
		cPage.innerHTML="下一页";
		if(pages>1&&this.nowPage<pages){
		   cPage.onclick=function(){
			   runDate.nowPage=parseInt(runDate.nowPage)+1;
			   runDate.readDate();
		   }
		}else{
			cPage.style.cssText="padding-left:10px;color:#C0C0C0;";
		}
		divPages.appendChild(cPage);
		
		cPage=document.createElement("span");
		cPage.setAttribute("title","上一页");
		cPage.style.cssText="padding-left:10px;cursor:hand;";
		cPage.innerHTML="上一页";
		if(pages>1&&this.nowPage>1){
		   cPage.onclick=function(){
			   runDate.nowPage=parseInt(runDate.nowPage)-1;
			   runDate.readDate();
		   }
		}else{
			cPage.style.cssText="padding-left:10px;color:#C0C0C0;";
		}
		divPages.appendChild(cPage)
		
		cPage=document.createElement("span");
		cPage.setAttribute("title","尾  页");
		cPage.style.cssText="padding-left:10px;cursor:hand;";
		cPage.innerHTML="尾  页";
		if(pages>1&&this.nowPage<pages){
		   cPage.onclick=function(){
			   runDate.nowPage=pages;
			   runDate.readDate();
		   }
		}else{
			cPage.style.cssText="padding-left:10px;color:#C0C0C0;";
		}
		divPages.appendChild(cPage)
		var runTime=document.createElement("span");
		runTime.style.cssText="color:#FF0000;padding-left:25px;"
		runTime.innerHTML="页面运行总时间"+thSplit[2]+"毫秒";
		divPages.appendChild(runTime);
	}else{
		var divPages=$("divPages")
		var cTable=$("bodyDiv");
		if(cTable.childNodes.length>0){
			cTable.firstChild.removeNode(true);
		}
		divPages.innerHTML="<p style='color:#FF0000;'>从"+$("selectTime").value+"到现在没有要签收的文件</p>";	
	}
}

function createOurTitle(){//创建表头
   var title=new Array();  
   this.setW=0;
   var wAll=0;
   var table=null;
   this.add=function(titleText,clickText,width){
	   var l=title.length;
	   title[l]=new Array();
	   title[l][0]= titleText;
	   title[l][1]=clickText;
	   title[l][2]=width;
   }
   this.create=function(){
		if (this.table==null){
			  return  null;
		}
		var createTR=this.table.insertRow();
		for (var i=0;i<title.length;i++){
			var createTD=createTR.insertCell();
			createTD.appendChild(document.createTextNode(title[i][0]));
			if(i==0){
			createTD.style.cssText="width:"+title[i][2]+"px;text-align:"+title[i][1]+";padding-left:10px;";
			}else{
			createTD.style.cssText="width:"+title[i][2]+"px;text-align:"+title[i][1]+";";
			}
			createTD.className="titleRow";
			createTD.onmouseover=function(){
				this.className="listTitleOption_1Other";
			}
			createTD.onmouseout=function(){
				this.className="titleRow";
			}
		}
	}
}


