TreeShow.jsp 15.3 KB
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 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ include file="/systeminfo/init_wev8.jsp" %>
<%@ page import="weaver.conn.*"%>
<%@ page import="weaver.hrm.company.*"%>
<%@ page import="weaver.hrm.resource.*"%>
<jsp:useBean id="ResourceComInfo" class="weaver.hrm.resource.ResourceComInfo" scope="page" />
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<link type="text/css" href="/workrelate/js/jit/base.css" rel="stylesheet" />
<link type="text/css" href="/workrelate/js/jit/Spacetree.css" rel="stylesheet" />
<style type="text/css">
	html,body{background: #fff;}
	#center-container{cursor: move;}
	#right-container{width: 70px;height: auto;border-right: 1px #EFEFEF solid;border-bottom: 1px #EFEFEF solid;overflow: hidden;
		top: 0px;left: 0px;right: auto;bottom: auto;}
	.root,.box{width: 140px;height: 60px;text-align: left;font-size: 12px;background: url(/workrelate/images/trans.png) repeat;}
	.root{text-align: center;line-height: 60px;}
	.datatable{width: 100%;table-layout: fixed;margin: 0px;}
	.info1,.info{line-height: 20px;empty-cells: show;word-break: keep-all;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;
		padding-left: 4px;padding-right: 4px;color: #333333;}
	.info1{text-align: right;color: #838383;}	
	
	.info3 a{float: right;}
</style>
<%
	String condtype = Util.null2String(request.getParameter("condtype"));
	String hrmid = Util.null2String(request.getParameter("hrmid"));
	if(hrmid.equals("") || hrmid.equals("0")) hrmid = user.getUID()+"";
	boolean showall = false;
	String rootname = "";
	if(condtype.equals("2")){
		rootname = "公司目标";//泛微目标总纲
		if(user.getUID()==2){
			showall = true;
		}else{
			rs.executeSql("select goalmaint,iscgoal from GM_BaseSetting");
			if(rs.next()){
				String goalmaint = Util.null2String(rs.getString("goalmaint"));
				int iscgoal = Util.getIntValue(rs.getString("iscgoal"),0);
				if(goalmaint.indexOf(","+user.getUID()+",")>-1){
					showall = true;
				}else if(iscgoal==1){
					showall = true;
				}
			}
			hrmid = "";
			rs.executeSql("select hrmid from GM_RightSetting where orgid=1 and type=1");
			while(rs.next()){
				hrmid += "," + Util.null2String(rs.getString(1));
			}
			if(!hrmid.equals("")) hrmid = hrmid.substring(1);
		}
	}else{
		showall = true;
		rootname = ResourceComInfo.getLastname(hrmid)+"的目标";
	}

	int status = Util.getIntValue(request.getParameter("status"),1);
	int period = Util.getIntValue(request.getParameter("period"),3);
	int periody = Util.getIntValue(request.getParameter("periody"),Integer.parseInt(TimeUtil.getCurrentDateString().substring(0,4)));
	int periodm = Util.getIntValue(request.getParameter("periodm"),Integer.parseInt(TimeUtil.getCurrentDateString().substring(5,7)));
	int periods = Util.getIntValue(request.getParameter("periods"),Integer.parseInt(TimeUtil.getCurrentSeason()));
	String datefrom = "";
	String dateto = "";
	if(period==1){//月度
		datefrom = TimeUtil.getYearMonthFirstDay(periody,periodm);
		dateto = TimeUtil.getYearMonthEndDay(periody,periodm);
	}else if(period==2){//季度
		if(periods==1){
			datefrom = TimeUtil.getYearMonthFirstDay(periody,1);
			dateto = TimeUtil.getYearMonthEndDay(periody,3);
		}else if(periods==2){
			datefrom = TimeUtil.getYearMonthFirstDay(periody,4);
			dateto = TimeUtil.getYearMonthEndDay(periody,6);
		}else if(periods==3){
			datefrom = TimeUtil.getYearMonthFirstDay(periody,7);
			dateto = TimeUtil.getYearMonthEndDay(periody,9);
		}else if(periods==4){
			datefrom = TimeUtil.getYearMonthFirstDay(periody,10);
			dateto = TimeUtil.getYearMonthEndDay(periody,12);
		}
	}else if(period==3){//年度
		datefrom = TimeUtil.getYearMonthFirstDay(periody,1);
		dateto = TimeUtil.getYearMonthEndDay(periody,12);
	}else if(period==4){//三年
		
	}else if(period==5){//五年
		
	}
	String  str = "";
	if(showall){
		str = (String)staticobj.getRecordFromObj("GM_GOALSHOW","GM_GOAL_"+hrmid+"_"+period+"_"+datefrom+"_"+dateto+"_"+showall+"_"+condtype);
	}
	//str = null;
	//System.out.println("str:"+str);
	if(str==null || "".equals(str)){
		str = "var json = {";
	    str += "id: '-1',";
	    str += "name: '"+"<div class=\"root\">"+rootname+""+"</div>"+"',";
	    str += "data: {},";
	    if(showall){
	    	str += "children: [";
		    str += this.getInfo(hrmid,period,datefrom,dateto,showall);
		    str += "]";
	    }
	    str += "};";
	    
	    staticobj.putRecordToObj("GM_GOALSHOW","GM_GOAL_"+hrmid+"_"+period+"_"+datefrom+"_"+dateto+"_"+showall+"_"+condtype,str);
	}
	
%>
<%@ include file="/secondwev/common/head.jsp" %>
	</head>
<body onload="init(json);">
	<script type="text/javascript">
		<%=str%>

		var show = "#F5D8B6";//"#DFA46A";//展开颜色
		var showinfo1 = "#b67434";
		var showinfo2 = "#fbeee0";
		var showinfo3 = "#ffffff";
		var showinfo33 = "#d69a60";
		
		var hassub = "#D1E3F7";//"#91B6DF";//含下级颜色
		var hassubinfo1 = "#668bb5";
		var hassubinfo2 = "#ffffff";
		var hassubinfo3 = "#ffffff";
		var hassubinfo33 = "#6196D1";
		
		var nosub = "#F2F2F2";//"#F9F9F9";//不含下级颜色
		var nosubinfo1 = "#9d9d9d";
		var nosubinfo2 = "#333333";
		var nosubinfo3 = "#E84C4C";
		var nosubinfo33 = "#f2f2f2";

		var cinit = 1;
		<%if(condtype.equals("2")){%>cinit = 1;<%}%>
	</script>
	<script language="javascript" type="text/javascript" src="/workrelate/js/jit/jit.js"></script>
	<script language="javascript" type="text/javascript" src="/workrelate/js/jit/excanvas.js"></script>
	<script language="javascript" type="text/javascript" src="/workrelate/js/jit/spacetree.js"></script>
	<div id="center-container">
    <div id="infovis"></div>
	</div>
	<div id="right-container" style="">
	
	<table class="tableStyle">
	    <tr>
	        <td>
	        <div id="log"></div>
	        </td>
	    </tr>
	</table>
	
	<div style="width: 100%;line-height: 40px;height: 40px;font-size: 14px;color: #23A4FF;text-align: center;">展现方向</div>
	<table style="">
	    <tr>
	         <td>
	            <label for="r-top"></label>
	         </td>
	         <td>
	            <input type="radio" id="r-top" name="orientation"  value="top" />
	         </td>
	    </tr>
	    <tr>
	         <td>
	            <label for="r-bottom"></label>
	          </td>
	          <td>
	            <input type="radio" id="r-bottom" name="orientation" value="bottom" />
	          </td>
	    </tr>
	    <tr>
	        <td>
	            <label for="r-left"></label>
	        </td>
	        <td>
	            <input type="radio" id="r-left" name="orientation" checked="checked" value="left" />
	        </td>
	    </tr>
	    <tr>
	          <td>
	            <label for="r-right"></label>
	          </td> 
	          <td> 
	           <input type="radio" id="r-right" name="orientation" value="right" />
	          </td>
	    </tr>
	    <tr>
	    </tr>
	</table>
</div>
<div id="bg" style='display:none;z-index:10000;width:100%;height:100%;position: absolute;top: 0px;bottom: 0px;left: 0px;right: 0px;background: url(/workrelate/images/bg_ahp.png) repeat;' align='center'>
</div>
<div id="detail" style="width: 540px;height: auto;position: absolute;z-index: 10001;display: none;border: 1px #F2F2F2 solid;
border-radius: 4px;-moz-border-radius: 4px;-webkit-border-radius: 4px;">
	<div id="" style="width: 100%;height: 40px;position: relative;background: #F2F2F2;border-bottom: 1px #E8E8E8 solid;display: none;">
		<div style="position: absolute;left: 0px;line-height: 40px;margin-left: 5px;font-weight: bold;">目标明细</div>
		<div style="width: 30px;height: 40px;background: url('../images/btn_close.png') center no-repeat;cursor: pointer;
			position: absolute;right: 0px;" title="关闭" onclick="closeDetail()"></div>
	</div>
	<div style="width: 30px;height: 40px;background: url('../images/btn_close.png') center no-repeat;cursor: pointer;
			position: absolute;right: 2px;" title="关闭" onclick="closeDetail()"></div>
<iframe id="detailframe" style="width:100%;height:100%;" frameborder="0"></iframe>
</div>
<script type="text/javascript">
$(document).ready(function(){
 $(".jNiceRadio").click(function(){
    changeOperation($(this).parent().find("input[type='radio']"));
 });
});
	function showDetail(dataid){
		var goalid = $("#box"+dataid).attr("_goalid");
		//openOperateWindow("Main.jsp?showdetail=1&goalid="+goalid);
		
		
		var width = $(window).width();
		var height = $(window).height();
		
		
		var w = Math.round(width*0.6);
		var h = Math.round(height*0.8);
		var left = (width-w)/2;
		var top = (height-h)/2;
		
		//alert(height+"_"+h+"_"+top);
		
		$("#bg").show();
		$("#detailframe").height(h).attr("src","Main.jsp?showdetail=1&goalid="+goalid);
		$("#detail").css({"width":w,"height":h,"top":top,"left":left}).fadeIn(500);
	}
	function closeDetail(){
		
		$("#detail").fadeOut(500,function(){
			$("#bg").hide();
			$("#detailframe").attr("src","");
		});
	}
	
	function openOperateWindow(url){
		//openFullWindowHaveBar(url);
		
		  var redirectUrl = url ;
		  var width = screen.width ;
		  var height = screen.height ;
		  var top = height/2 - 260;
		  //alert(height+'-'+top);
		  var left = width/2 - 455;
		  var width = 910 ;
		  var height = 500 ;
		  var szFeatures = "" ;
		  szFeatures +="top="+top+"," ; 
		  szFeatures +="left="+left+"," ;
		  szFeatures +="width="+width+"," ;
		  szFeatures +="height="+height+"," ;
		  //szFeatures +="directories=no," ;
		  szFeatures +="status=yes,toolbar=no,location=no," ;
		  //szFeatures +="menubar=no," ;
		  szFeatures +="scrollbars=yes," ;
		  szFeatures +="resizable=yes" ; 
		  window.open(redirectUrl,"",szFeatures) ;
		  
	}
</script>
</body>
</html>
<%!
	private String getInfo(String userid,int period,String datefrom,String dateto,boolean showall) throws Exception{
		if(userid.equals("")) return "";
		StringBuffer nowNode = new StringBuffer();
		RecordSet rs = new RecordSet();
		StringBuffer sql = new StringBuffer();
		sql.append("select t1.id,t1.name,t1.status,t1.creater,t1.principalid,t1.attribute,t1.target,t1.tunit,t2.orgId,t2.type"
				+" from GM_GoalInfo t1 left join GM_RightSetting t2 on t1.principalid=t2.hrmId"
				+" where (t1.deleted=0 or t1.deleted is null) and t1.principalid in ("+userid+")"
				+" and not exists(select 1 from GM_GoalInfo t3 where t1.parentid=t3.id and t3.principalid in ("+userid+"))"
		);
		
		if(period!=0){
			sql.append(" and t1.period="+period);
		}
		if(!datefrom.equals("")){
			sql.append(" and t1.enddate>='"+datefrom+"'");
		}
		if(!dateto.equals("")){
			sql.append(" and t1.enddate<='"+dateto+"'");
		}
		sql.append(" order by t1.showorder,t1.id");
		String goalname = "";
		double target = 0;
		String tunit = "";
		String orgid = "";
		int type = 0;
		rs.executeSql(sql.toString());
		String dataid = "";
		String goalid = "";
		while(rs.next()){
			goalname = Util.null2String(rs.getString("name")); 
			target = Util.getDoubleValue(rs.getString("target"),0);
			tunit = Util.null2String(rs.getString("tunit")); 
			orgid = Util.null2String(rs.getString("orgId")); 
			type = Util.getIntValue(rs.getString("type"),0);
			dataid = String.valueOf(UUID.randomUUID());
			goalid = Util.null2String(rs.getString("id")); 
			nowNode.append("{");
			nowNode.append("id: '" + dataid + "',");
			nowNode.append("name: '<div id=\"box"+dataid+"\" class=\"box\"_goalid=\""+goalid+"\">" + this.getGoalTitle(userid,goalname,target,tunit,orgid,type,dataid) + "</div>',");
			nowNode.append("data: {},");
			if(showall){
				nowNode.append("children: [" + this.getTree(Util.null2String(rs.getString("id")),period,datefrom,dateto) + "]");
			}
			nowNode.append("},");
			
		}
		String jsonstr = nowNode.toString();
	    if (jsonstr.lastIndexOf(",") != -1) {
	      return jsonstr.substring(0, jsonstr.length() - 1);
	    }
	    return jsonstr;
	}
	private String getTree(String supid,int period,String datefrom,String dateto) throws Exception{
		StringBuffer nowNode = new StringBuffer();
		RecordSet rs = new RecordSet();
		StringBuffer sql = new StringBuffer();
		sql.append("select t1.id,t1.name,t1.status,t1.creater,t1.principalid,t1.attribute,t1.target,t1.tunit,t2.orgId,t2.type"
				+" from GM_GoalInfo t1 left join GM_RightSetting t2 on t1.principalid=t2.hrmId"
				+" where (t1.deleted=0 or t1.deleted is null) and t1.id<>"+supid+" and t1.parentid="+supid);
		if(period!=0){
			sql.append(" and t1.period="+period);
		}
		if(!datefrom.equals("")){
			sql.append(" and t1.enddate>='"+datefrom+"'");
		}
		if(!dateto.equals("")){
			sql.append(" and t1.enddate<='"+dateto+"'");
		}
		sql.append(" order by t1.showorder,t1.id");
		String userid = "";
		String goalname = "";
		double target = 0;
		String tunit = "";
		String orgid = "";
		int type = 0;
		rs.executeSql(sql.toString());
		String dataid = "";
		String goalid = "";
		while(rs.next()){
			userid = Util.null2String(rs.getString("principalid"));
			goalname = Util.null2String(rs.getString("name")); 
			target = Util.getDoubleValue(rs.getString("target"),0);
			tunit = Util.null2String(rs.getString("tunit")); 
			orgid = Util.null2String(rs.getString("orgId")); 
			type = Util.getIntValue(rs.getString("type"),0);
			dataid = String.valueOf(UUID.randomUUID());
			goalid = Util.null2String(rs.getString("id")); 
			nowNode.append("{");
			nowNode.append("id: '" + dataid + "',");
			nowNode.append("name: '<div id=\"box"+dataid+"\" class=\"box\" _goalid=\""+goalid+"\">" + this.getGoalTitle(userid,goalname,target,tunit,orgid,type,dataid) + "</div>',");
			nowNode.append("data: {},");
			nowNode.append("children: [" + this.getTree(Util.null2String(rs.getString("id")),period,datefrom,dateto) + "]");
			nowNode.append("},");
		}
		String jsonstr = nowNode.toString();
	    if (jsonstr.lastIndexOf(",") != -1) {
	      return jsonstr.substring(0, jsonstr.length() - 1);
	    }
	    return jsonstr;
	}

	private String getGoalTitle(String userid,String goalname,double target,String tunit,String orgid,int type,String dataid) throws Exception{
		StringBuffer title = new StringBuffer();
		String orgname = "";
		String titleinfo = "";
		ResourceComInfo ResourceComInfo = new ResourceComInfo();
		if(!orgid.equals("")){
			if(type==1){
				CompanyComInfo CompanyComInfo = new CompanyComInfo();
				orgname = CompanyComInfo.getCompanyname(orgid);
			}else if(type==2){
				SubCompanyComInfo SubCompanyComInfo = new SubCompanyComInfo();
				orgname = SubCompanyComInfo.getSubCompanyname(orgid);
			}else if(type==3){
				DepartmentComInfo DepartmentComInfo = new DepartmentComInfo();
				orgname = DepartmentComInfo.getDepartmentname(orgid);
			}
			titleinfo = orgname+"["+ResourceComInfo.getLastname(userid)+"]\\n";
		}else{
			orgname = ResourceComInfo.getLastname(userid);
			titleinfo = orgname + "\\n";
		}
		titleinfo += goalname;
		if(target!=0){
			titleinfo += "\\n"+target;
			if(!tunit.equals("")){
				titleinfo += " "+tunit;
			}
		}
		title.append("<table class=\"datatable\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" title=\""+titleinfo+"\">");
		title.append("<tr><td class=\"info1\">"+orgname+"</a></td></tr>");
		title.append("<tr><td class=\"info info2\" >"+goalname+"</td></tr>");
		
		title.append("<tr><td class=\"info info3\">");
		if(target!=0){	
			title.append(target);
			if(!tunit.equals("")){
				title.append(" "+tunit);
			}
		}
		title.append("<a href=javascript:showDetail(\""+dataid+"\")>查看</a>");
		title.append("</td></tr>");
		
		title.append("</table>");
		return title.toString();
	}
%>