Blame view

src/main/webapp/js/projecttask/reportDetails.js 8.17 KB
caiyongsong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
var finereportPath = "";
var currentPage=1;//当前页
var totalpage=0;//总页数
var pageNum = 5;//最多显示页数
var setupLayerData=['建设单位','证号','办理状态','结束时间','项目编号','登记时间','建设地址'];
var searchLayerDate=[];
var curserver
$(function(){
	curserver = CONF_BACK_SERVERURL;
	initializeComponent();
	jdate();
});

function jdate(){
	var start = {
			dateCell:"#inpstart",
	        format: 'YYYY-MM-DD',
	        festival:false,
	    };
		 var end = {
			dateCell:"#inpend",
			format: 'YYYY-MM-DD',
			festival:false,
		 };
		 jeDate(start);
		 jeDate(end);	 
}


function initializeComponent(){
	var reportid = $("#reportid").val();
    $.ajax({
		type: "POST",
		url: curserver + global.modelctls.reports.detail,
		headers:{
    		"token":$.cookie('ftoken')
		},
		data:{id:reportid},
		dataType: 'json',
		success:function(result){
			 currentReport = result;
			 $('#reportname').text(currentReport.name);
			 $('#reportmo').text(currentReport.remark);
			 var time = new Date(currentReport.createdt);
			 $("#reportTime").text(time.format("yyyy-MM-dd hh:mm"));
			 revisionid = currentReport.revisionid
			 $.ajax({
					type: "POST",
					url: curserver + global.modelctls.reports.revision.content.get,
					headers:{
			    		"token":$.cookie('ftoken')
					},
					data:{ id: revisionid },
					success:function(result){
						 var obj = result ? JSON.parse(result) : { path: '', args: [] };
						 finereportPath = obj.path
					}
			 });
		}
	});	
    
}

function searchReport(){
	var condition="";
	var sqlWhere = "where 1=1"
	var sdStr="";
	var inpstart = $('#inpstart').val();
	var inpend = $('#inpend').val();
	var buildunit = $('#buildunit').val();
	var status = isundefined($('#status').val());
	var buildaddress = isundefined($('#buildaddress').val());
	var projectcode = isundefined($('#projectcode').val());
	if(inpstart!=""&&inpend!="")
		condition += " and TRUNC(sp.starttime) >= TO_DATE('"+inpstart+"', 'yyyy-mm-dd')  and TRUNC(sp.starttime) <= TO_DATE('"+inpend+"', 'yyyy-mm-dd')";
	if(buildunit!="")
		condition += "and buildunit like '%25"+buildunit+"%25'";
	if(status!="")
		condition += " and status like '%25"+status+"%25'";
	if(buildaddress!="")
		condition += " and buildaddress like '%25"+buildaddress+"%25'";
	if(projectcode!="")
		condition += "and projectcode like '%25"+projectcode+"%25'";

	if(setupLayerData.length>0){
		sdStr=setupLayerData.join(","); 
	}
	var conditionStr = sqlWhere + condition;
	if(finereportPath!=""){
		var path = finereportPath.substring(finereportPath.indexOf('/')+1);
		var reportURL = cjkEncode(curserver+"/ReportServer?reportlet="+path+"&pare="+conditionStr+"&SD="+sdStr+"&__showtoolbar__=false");
	    document.paraForm.action = reportURL;   
	    document.paraForm.submit(); 
		$('#reportHead').css("display",'');
		$('#pageZero').css("display",'');

	}
}

function isundefined(val){
	var data = "";
	if(val==undefined)
		return data;
	else
		return val;
}

function cjkEncode(text) {                                                                            
    if (text == null) {         
      return "";         
    }         
    var newText = "";         
    for (var i = 0; i < text.length; i++) {         
      var code = text.charCodeAt (i);          
      if (code >= 128 || code == 91 || code == 93) {  //91 is "[", 93 is "]".         
        newText += "[" + code.toString(16) + "]";         
      } else {         
        newText += text.charAt(i);         
      }         
    }         
    return newText;         
  }     


function dynamicPage(totalre, totalpa,currentPage){
	$("#total_records").html(totalre);
	$("#total_page").html(totalpa);	
	var pageStart = "";
	var pageEnd = "";
	if(currentPage<=Math.round(pageNum/2)+1){
		pageStart = 1;
		pageEnd = pageNum;
	}
	if(currentPage>Math.round(pageNum/2)+1){   
		pageStart = currentPage-Math.round(pageNum/2); 
		pageEnd = currentPage+Math.round(pageNum/2)-2;
	}
	if(pageEnd>totalpa){
		pageEnd = totalpa;
	}
	var ulcontent = $(".pagination");
	ulcontent.children().filter('li').remove();
	ulcontent.append("<li> <a onclick=\"jumpPage(0)\" aria-label=\"Previous\">" +
	"<span aria-hidden=\"true\">上一页</span></a></li> ");
	for(var i=pageStart;i<=pageEnd;i++){
		if(i==currentPage){
			ulcontent.append("<li class=\"active\"><a onclick=\"gotopage("+i+")\">"+i+"</a></li>");
		}else{
			ulcontent.append("<li><a onclick=\"gotopage("+i+")\">"+i+"</a></li>");
		}
	}
	ulcontent.append("<li> <a onclick=\"jumpPage(1)\" aria-label=\"Next\">" +
			"<span aria-hidden=\"true\">下一页</span></a></li> ");
	pagging.modifyPagging(totalre, totalpa,currentPage);
}

pagging.config.list=gotopage;


/**
 * 报表自定义翻页
 * @param index
 */
function jumpPage(index){
	if(index==0){//上一页
		document.getElementById('iframeFinereport').contentWindow.contentPane.gotoPreviousPage(); 
	}else {
		document.getElementById('iframeFinereport').contentWindow.contentPane.gotoNextPage();
	}
}

function gotopage(index){
	var contentpane= document.getElementById('iframeFinereport').contentWindow.contentPane;       
    var page = index;       
    if(page >= contentpane.reportTotalPage) {       
      contentpane.gotoLastPage();       
    }        
    contentpane.gotoPage(parseInt(page));
}

function exportReportToPDF(){
	var contentpane= document.getElementById('iframeFinereport').contentWindow.contentPane; 
	if(contentpane!=undefined)
		contentpane.exportReportToPDF();
}

function exportReportToWord(){
	var contentpane= document.getElementById('iframeFinereport').contentWindow.contentPane; 
	if(contentpane!=undefined)
		contentpane.exportReportToWord();
}
function exportReportToExcel(type){
	var contentpane= document.getElementById('iframeFinereport').contentWindow.contentPane; 
	if(contentpane!=undefined)
		contentpane.exportReportToExcel(type);
}


function opensearchLayer(){
	parent.layer.open({
		  type: 2,
		  title: '<img src="../../image/projecttask/type.png" style=\"width:25px;height:25px;\"/><span>选择条件</span>',
		  shadeClose: true,
		  shade: 0.3,
		  offset:['50px'],
		  area: ['600px', '320px'],
		  btn: ['确认', '取消'],
		  content: 'reportLayer/searchLayer.jsp', //iframe的url
		  yes: function(index,layero){			
			  var iframeWin = window[layero.find('iframe')[0]['name']];
			  searchLayerDate = [];
			  searchLayerDate = iframeWin.checkboxitem();
			  var searchList =$("#searchHtml");
			  var strid = "";
			  searchList.children().remove();
			  if(searchLayerDate.length>0){
				  for(var i=0;i<searchLayerDate.length;i++){
					  if(searchLayerDate[i]=="办理状态")
						  strid = "status"
					  if(searchLayerDate[i]=="建设地址") 	  
						  strid = "buildaddress"
					  if(searchLayerDate[i]=="项目编号")	
						  strid = "projectcode"
					  var strHtml = "<div style=\"color: black;\">"+searchLayerDate[i]+":</div>"+
					  				"<div><input id=\""+strid+"\" type=\"text\" placeholder=\""+searchLayerDate[i]+"\" style=\"width: 520px;padding-left: 10px;\"><div>"
					 searchList.append(strHtml);
				  }
			  }
			  layer.closeAll();
			} 
		});  
	
}

function openLayer(){
	parent.layer.open({
		  type: 2,
		  title: '<img src="../../image/projecttask/type.png" style=\"width:25px;height:25px;\"/><span>字段显示设置</span>',
		  shadeClose: true,
		  shade: 0.3,
		  offset:['50px'],
		  area: ['600px', '520px'],
		  btn: ['确认', '取消'],
		  content: 'reportLayer/setupLayer.jsp', //iframe的url
		  yes: function(index,layero){			
			  var iframeWin = window[layero.find('iframe')[0]['name']];
			  setupLayerData = [];
			  setupLayerData = iframeWin.checkboxitem();
			  layer.closeAll();
			} 
		});  
}


Date.prototype.format = function(format){ 
	var o = { 
	"M+" : this.getMonth()+1, //month 
	"d+" : this.getDate(), //day 
	"h+" : this.getHours(), //hour 
	"m+" : this.getMinutes(), //minute 
	"s+" : this.getSeconds(), //second 
	"q+" : Math.floor((this.getMonth()+3)/3), //quarter 
	"S" : this.getMilliseconds() //millisecond 
	} 
	 if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return format;
}