| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611 | var gis = gis || {};	 gis.tree = function() {};gis.tree.autohide0Node=true;gis.tree.gqshowcbinbw=!true;/* * 用于对 Ajax 返回数据进行预处理的函数。[setting.async.enable = true 时生效] */gis.tree.filter = function(treeId, parentNode, childNodes) {	//console.log('>2>parentNode:',parentNode);	//childNodes ={"children":[{"children":[{"children":[],"iconSkin":"","id":"402881e750ef634b0150ef64cce10001","isParent":false,"name":"2","open":false,"pId":"","type":""},{"children":[],"iconSkin":"","id":"402881e750ec68340150ec68af3c0000","isParent":true,"name":"11111","open":false,"pId":"","type":""},{"children":[],"iconSkin":"","id":"402881e750eed3aa0150eed4fe510001","isParent":true,"name":"市局下","open":false,"pId":"","type":""},{"children":[],"iconSkin":"","id":"402881e750ebc9ca0150ebede1a60006","isParent":true,"name":"港口局","open":false,"pId":"","type":""},{"children":[],"iconSkin":"","id":"402881e750ef34c80150ef35d9990001","isParent":true,"name":"222","open":false,"pId":"","type":""}],"iconSkin":"","id":"402881e750dab7fa0150dabe66630002","isParent":false,"name":"市局","open":false,"pId":"","type":""},{"children":[{"children":[],"iconSkin":"","id":"402881e750ef78f80150ef7de1940001","isParent":false,"name":"2","open":false,"pId":"","type":""}],"iconSkin":"","id":"402881e750ef78f80150ef7bf30c0000","isParent":false,"name":"2","open":false,"pId":"","type":""}],"iconSkin":"","id":"01","isParent":false,"name":"行政单位信息","open":true,"pId":"","type":""};	//alert(JSON.stringify(childNodes));	//alert(childNodes);	//childNodes={"iconSkin":"","id":"01","isParent":true,"name":"行政单位信息","open":true,"pId":"","type":"","children":[{"iconSkin":"","id":"01","isParent":true,"name":"行政单位","open":false,"pId":"","type":""}]}	//childNodes=[{"iconSkin":"","id":"01","isParent":true,"name":"行政单位","open":false,"pId":"","type":""}];	/*	if(parentNode&&parentNode.treeNodeType){		if(parentNode.treeNodeType='GK_BASIC_JSJY_GK_GK'){			childNodes=[{"iconSkin":"","id":"01","isParent":true,"name":"行政单位","open":false,"pId":"","type":""}]		}	}	*/	//debugger;	/*	if(childNodes){		if(!parentNode){			alert(JSON.stringify(parentNode));		}else{			parentNode.name="xxx";			for(var ii=0;ii<childNodes.length;ii++){				childNodes[ii].name="xxx"			}		}			}*/	//console.log('>22222>gis.script.cbdataInfostatistics:',gis.script.cbdataInfostatistics);	//&&(node.treeNodeType=='GK_BASIC_JSJY_JYR'||node.treeNodeType=='GK_BASIC_JSJY_JYR_BW')	/*	if(parentNode&&parentNode.treeNodeType=="GK_BASIC_JSJY_GK_GQ"){				childNodes=gis.tree.addcbtotree(parentNode,childNodes,parentNode.treeNodeType,("V"+parentNode.code));	}	*/	return childNodes;}/* * 设置 zTree 是否显示节点的图标 */gis.tree.showIconForTree = function(treeId, treeNode) {	if(treeNode){		//alert(treeNode.iconSkin);		return !gis.script.isBlank(treeNode.iconSkin);	}	return false;	//return !treeNode.isParent;}/* * 调用父内框架的clickDrawFillMarker方法,绘画船舶 */gis.tree.parentdrawFillMarker= function(treeNode){	if(parent&&parent.gis&&parent.gis.script&&parent.gis.script.clickDrawFillMarker){		parent.gis.script.clickDrawFillMarker(treeNode);	}}/* * 调用父内框架的parentopenPop_Boat方法,取消船舶选择状态 */gis.tree.parentopenPop_Boat= function(treeNode,runPop){	if(parent&&parent.gis&&parent.gis.script&&parent.gis.script.openPop_Boat){		parent.gis.script.openPop_Boat(treeNode,runPop);	}}/* * 树节点点击事件 */gis.tree.nodeClick = function(event, treeId, treeNode, clickFlag) {	//alert(parent.gis.script.setMapCenter);return;	if(parent&&parent.gis&&parent.gis.script){		parent.gis.script.removeAllPopup();	}		var parentgisLayerinfo=gis.tree.parentgisLayerinfo();	var layerloadover=gis.tree.parentgisLayerinfo();	if(parentgisLayerinfo&&layerloadover){		if(typeof(treeNode.id)!="undefined"){			var issetCenter=false;			if(treeNode.id==0){				//map.setCenter(new SuperMap.LonLat(lon, lat), 0);				//parent.gis.script.loadcbdataService(parent.gis.script.phase.refresh);return;								var info={};				info.lon=119.66;				info.lat=32.57;				info.zoomSize=0;				gis.tree.parentsetMapCenter(info); 				issetCenter=true;			}else if(treeNode.treeNodeType&&treeNode.treeNodeType=="HS_AIS"){				if(parent&&parent.gis&&parent.gis.script&&parent.gis.script.boatrefreshInfo){					var cbobj=parent.gis.script.boatrefreshInfo[treeNode.mmsi];					if(cbobj){						if(gis.script.isNum(cbobj.lon)&&gis.script.isNum(cbobj.lat)){							var info={};							info.lon=cbobj.lon;							info.lat=cbobj.lat;							info.zoomSize=10;							gis.tree.parentsetMapCenter(info); 																	var featuredata=jQuery.extend(true, {}, treeNode);							featuredata.attributes={onID:treeNode.name,onMMSI:treeNode.mmsi};							featuredata.attributes.shipLON=cbobj.lon;							featuredata.attributes.shipLAT=cbobj.lat;							gis.tree.parentopenPop_Boat(featuredata);													}					}				}							}else if(treeNode.treeNodeType&&treeNode.treeNodeType=="HS_AIS2"){				if(gis.script.isNum(treeNode.lon)&&gis.script.isNum(treeNode.lat)){					var info={};					info.lon=treeNode.lon;					info.lat=treeNode.lat;					info.zoomSize=10;					gis.tree.parentsetMapCenter(info); 				}				//boatLayer.removeAllFeatures();				//gis.script.drawFillMarker(boatLayer,treeNode);								//gis.tree.parentdrawFillMarker(treeNode);								var featuredata=jQuery.extend(true, {}, treeNode);				featuredata.attributes={onID:treeNode.name,onMMSI:treeNode.mmsi};				//gis.tree.parentopenPop_Boat(featuredata,false);				gis.tree.parentopenPop_Boat(featuredata);			}else{				//alert(treeNode.gisinfo);				//map.zoomToScale(0.000001180591620);				//alert(treeNode.treeNodeType);				//console.log("parentgisLayerinfo--->",parentgisLayerinfo);				if(treeNode.treeNodeType&&parentgisLayerinfo[treeNode.treeNodeType]){					var objdata={}										if(!gis.script.isBlank(treeNode.gisinfo)){						var gobj=eval("("+treeNode.gisinfo+")");						//objdata.id=gobj.smid;						objdata.zoomto=gobj.zoomto;					}															if(!gis.script.isBlank(treeNode.code)){						objdata.id=treeNode.code;					}										//alert(objdata.id)					if(objdata.id){												var info=parentgisLayerinfo[treeNode.treeNodeType][objdata.id];												if(info&&typeof(info.lon)!="undefined"&&typeof(info.lat)!="undefined"){							info.zoomSize=objdata.zoomto||info.zoom||6;							gis.tree.parentsetMapCenter(info); 							issetCenter=true;						}else{							gis.tree.loadgisService(treeNode,objdata);						}					}				}								/*				if(g){					var gobj=eval("("+g+")");					if(gobj&&gobj.smid){						if(treeNode.treeNodeType&&parentgisLayerinfo[treeNode.treeNodeType]){							var info=parentgisLayerinfo[treeNode.treeNodeType][gobj.smid];							if(info&&typeof(info.lon)!="undefined"&&typeof(info.lat)!="undefined"){								map.setCenter(new SuperMap.LonLat(info.lon, info.lat),gobj.zoomto||5); 							}						}								}				}				*/			}						if(!issetCenter){				//alert("缺少关联数据,定位失败...");			}		}			}	return layerloadover;}/*gis.tree.loadgisService = function(treeNode,objdata){	//alert(treeNode.treeNodeType+"--"+objdata.id);	var dataServices=gisConfigBean.dataconfig;	if(dataServices){		gis.script.consolelog('dataServices',dataServices);		for(var n in dataServices){			var data=gisConfigBean.dataconfig[n];			if(data.gisLayerinfoKey&&treeNode.treeNodeType&&treeNode.treeNodeType==data.gisLayerinfoKey){				//alert(treeNode.treeNodeType+"--"+objdata.id);				var originaldata = gisConfigBean.dataconfig[n];								var data=jQuery.extend(true, {}, originaldata);				if(data.Model&&data.Model[gis.script.modelid]){					var model=data.Model[gis.script.modelid];					data.datasetNames=data.datasetNames.split(",");					data.fields=data.fields.split(",");					data.cachedata=model.cachedata||data.cachedata;					data.zoom=model.zoom||data.zoom;					data.attributeFilter=data.gisLayerinfoAttrKey+"="+objdata.id;					data.treelocationHighlight=model.treelocationHighlight||"false";					data.url=data.url||defdataUrl;					//alert(data.attributeFilter);					gis.tree.loadServicetreelocation(data);				}								break;			}		}	}}*/gis.tree.beforeAsync = function(treeId, treeNode){	if(treeNode){		//otherParam.ttt.xx='xxx';		//alert();	}}gis.tree.parentcbdataInfostatistics= function(){	if(parent&&parent.gis&&parent.gis.script&&parent.gis.script.cbdataInfostatistics){		return parent.gis.script.cbdataInfostatistics;	}	return {};}gis.tree.getZTreeObj = function(){	return $.fn.zTree.getZTreeObj("tree");}/* * 用于捕获异步加载正常结束的事件回调函数。如果设置了 setting.callback.beforeAsync 方法,且返回 false,将无法触发 onAsyncSuccess / onAsyncError 事件回调函数。 */gis.tree.onAsyncSuccess = function(event, treeId, treeNode, msg){	//alert(gis.tree.parentcbdataInfostatistics());	gis.script.cbdataInfostatistics=gis.tree.parentcbdataInfostatistics();	var treeObj = $.fn.zTree.getZTreeObj(treeId);	if(!treeNode){				if(treeObj){			var nodes = treeObj.getNodes();			/*			for(var i in nodes){				var node=nodes[i];				alert(node.name);				node.name="xxx";				treeObj.updateNode(node);			}			*/			//debugger;			gis.tree.updatecb(treeObj,nodes,null);		}			}else if(treeNode.treeNodeType&&treeNode.treeNodeType=="GK_BASIC_JSJY_GK_GQ"){		//gis.script.loadConfigXmlBWService("bwsjServices",{id:"759DF99526FD4F7F934EF2DEC3C6CFF3",code:'32100104'});		//alert(treeNode.name);		//gis.tree.addcbtotree(treeNode,treeNode.treeNodeType,("V"+treeNode.code));				parent.gis.script.loadConfigXmlBWService("bwsjServices",treeNode);	}	else{		gis.tree.updatecb(treeObj,treeNode.children,treeNode);	}}/* * 统计数据 */gis.tree.getcbinfo=function(info,key,code){	var s1=0;	gis.script.cbdataInfostatistics=gis.tree.parentcbdataInfostatistics();	if(info){		if(!code){			if(gis.script.cbdataInfostatistics[key]){				for(var kk in gis.script.cbdataInfostatistics[key]){					var v=gis.script.cbdataInfostatistics[key][kk];					if(v){						s1=s1+v.length;					}				}									}				}else{			if(info[key]){				var v=info[key][code];				if(v){					s1=v.length				}							}					}			}	return s1;}/* * 根据动态船舶数据,统计数据,重新绘制tree。动态添加船舶节点。 */gis.tree.updatecb = function(treeObj,nodes,pnode){	gis.script.cbdataInfostatistics=gis.tree.parentcbdataInfostatistics();	//console.log("1.gis.script.cbdataInfostatistics",gis.script.cbdataInfostatistics);	if(nodes&&nodes.length){		//debugger;		//alert(nodes.length);		for(var i in nodes){			var node=nodes[i];			//treeObj.showNode(node);			if(node.treeNodeType&&node.treeNodeType=="HS_AIS"){				continue;			}						if(node.open){				//gis.tree.updatecb(treeObj,node.children);			}			gis.tree.updatecb(treeObj,node.children);						//进出港船舶总数:系泊总数:靠泊危化品船			var newName=[];			var s1=0,s2=0,s3=0;			if(!node.treeNodeType){				s1=gis.tree.getcbinfo(gis.script.cbdataInfostatistics,"GK_BASIC_JSJY_GK_GK",null);				s2=gis.tree.getcbinfo(gis.script.cbdataInfostatistics,"GK_BASIC_JSJY_GK_GK_STATUS",null);				s3=gis.tree.getcbinfo(gis.script.cbdataInfostatistics,"GK_BASIC_JSJY_GK_GK_DANGER",null);				newName.push("进出港:");				newName.push(s1);				newName.push(",系泊:");				newName.push(s2);				newName.push(",危化品:");				newName.push(s3);			}else{				//GK_BASIC_JSJY_GK_GK_320001				var vkey="V"+node.code;				//console.log('>3>vkey:',vkey);				s1=gis.tree.getcbinfo(gis.script.cbdataInfostatistics,node.treeNodeType,vkey);				s2=gis.tree.getcbinfo(gis.script.cbdataInfostatistics,(node.treeNodeType+"_STATUS"),vkey);				s3=gis.tree.getcbinfo(gis.script.cbdataInfostatistics,(node.treeNodeType+"_DANGER"),vkey);								if(!node.oldname){					node.oldname=node.name;				}				var nodename=node.oldname;				if(gis.script.isBlank(nodename)){					nodename="";				}								newName.push(nodename);				newName.push("(");				newName.push(s1);				newName.push(",");				newName.push(s2);				newName.push(",");				newName.push(s3);				newName.push(")");							}									if(gis.tree.autohide0Node&&node.treeNodeType&&node.treeNodeType=='GK_BASIC_JSJY_GK_GQ'){				if(s1<=0){					node.isParent=false;				}else{					node.isParent=true;				}							}						if(node.treeNodeType&&node.treeNodeType=='GK_BASIC_JSJY_JYR_BW'){				//console.log('>2>node.treeNodeType:',node.treeNodeType);				//console.log('>3>vkey:',vkey);				if(s1>0){					node.isParent=true;					//node.open=false;					//node.children=gis.tree.addcbtotree(node,[],node.treeNodeType,("V"+node.code));					//alert(node.code)					//node.children.push({"iconSkin":"","id":"01","isParent":false,"name":"行政单位","open":false,"pId":"","type":""})					//treeObj.addNodes(node, {id:(100), pId:pnode.id, name:"new node"},true);					gis.tree.addcbtotreeApi(treeObj,node,node.treeNodeType,("V"+node.code));				}else{					node.isParent=false;				}				//alert(node.isParent);			}						node.name=newName.join("");												if(gis.tree.autohide0Node){				if(node.treeNodeType&&(node.treeNodeType=='GK_BASIC_JSJY_JYR'||node.treeNodeType=='GK_BASIC_JSJY_JYR_BW')){					//alert(1);										if(s1<=0){						treeObj.hideNode(node);						continue;					}else{						treeObj.showNode(node);					}									}							}									treeObj.updateNode(node);					}					}}/* * 动态添加船舶节点。 */gis.tree.addcbtotreeApi = function(treeObj,node,key,vkey){	gis.script.cbdataInfostatistics=gis.tree.parentcbdataInfostatistics();	if(gis.script.cbdataInfostatistics[key]){		var v=gis.script.cbdataInfostatistics[key][vkey];				if(v){			//var newnode={"iconSkin":"","id":"01","isParent":false,"name":"行政单位","open":false,"pId":"","type":""}			//var newnode={isParent:false,open:false,treeNodeType:"HS_AIS",pId:"",type:""};			//console.log("vvv:",v);			for(var ij=0;ij<v.length;ij++){				var vo=v[ij];				if(vo.arrt&&(!vo.arrt.cbshowinjyr||key!="GK_BASIC_JSJY_GK_GQ"||gis.tree.gqshowcbinbw)){					//alert(vo.arrt.cbshowinjyr);					var newnode=jQuery.extend(true, {isParent:false,open:false,treeNodeType:"HS_AIS",pId:"",type:""}, vo.arrt);					newnode.id="mmsi"+(ij+(vo.arrt.mmsi));					if(gis.script.isBlank(newnode.name)){						newnode.name="";						if(!gis.script.isBlank(vo.arrt.mmsi)){							newnode.name="("+vo.arrt.mmsi+")";						}					}					//console.log("newnode:",newnode);					newnode.iconSkin="";					if(newnode.danger&&newnode.danger==1							&&newnode.status&&newnode.status==5){						newnode.iconSkin="icon001"					}else if(newnode.status&&newnode.status==5){								newnode.iconSkin="icon002";					}else if(newnode.danger&&newnode.danger==1){								newnode.iconSkin="icon003";					}					//console.log("vvv:",newnode);					//gis.script.openbwjlj					//console.log("vvv:",parent.gis.script.openbwjlj[node.id]);					if(parent&&parent.gis&&parent.gis.script.openbwjlj&&parent.gis.script.openbwjlj[node.id]){						treeObj.addNodes(node, newnode,false);					}else{						treeObj.addNodes(node, newnode,true);					}														}			}							}	}}gis.tree.addcbtotree = function(node,carray,key,vkey){	var children=carray||[];	gis.script.cbdataInfostatistics=gis.tree.parentcbdataInfostatistics();	if(gis.script.cbdataInfostatistics[key]){		var v=gis.script.cbdataInfostatistics[key][vkey];		if(v){			//var newnode={"iconSkin":"","id":"01","isParent":false,"name":"行政单位","open":false,"pId":"","type":""}			//var newnode={isParent:false,open:false,treeNodeType:"HS_AIS",pId:"",type:""};			//console.log("vvv:",v);			for(var ij=0;ij<v.length;ij++){				var vo=v[ij];								if(vo.arrt){										var newnode=jQuery.extend(true, {isParent:false,open:false,treeNodeType:"HS_AIS",pId:"",type:""}, vo.arrt);					if(gis.script.isBlank(newnode.name)){						newnode.name="";					}					//console.log("newnode:",newnode);					newnode.iconSkin="";					if(newnode.danger&&newnode.danger==1							&&newnode.status&&newnode.status==5){						newnode.iconSkin="icon001"					}else if(newnode.status&&newnode.status==5){								newnode.iconSkin="icon002";					}else if(newnode.danger&&newnode.danger==1){								newnode.iconSkin="icon003";					}					/*					if(newnode.status&&newnode.status==5){								newnode.iconSkin="icon03";					}					if(newnode.danger&&newnode.danger==1){												newnode.iconSkin="icon01";					}					*/					children.push(newnode);				}			}		}	}	return children;}gis.tree.updatenodecb = function(treeObj,nodes){	}gis.tree.initcbtree = function(){		var setting = {			view: {				selectedMulti: false,				showIcon: gis.tree.showIconForTree			},			key: {				title:"title"			},			async: {				enable: true,				type: "post",				dataType:"json",				contentType: "application/json",				url: contextPath+"/zygl/treejson.html",				autoParam: ["id", "name","treeNodeType"],				otherParam: {async:'treejson',rootName:"船舶总数",isHidden:(gis.tree.autohide0Node?1:0) },				dataFilter: gis.tree.filter			},			callback: {				onDblClick: gis.tree.nodeClick,				beforeAsync: gis.tree.beforeAsync,				onAsyncSuccess: gis.tree.onAsyncSuccess,				onClick: function(event, treeId, treeNode) {					//alert(this);return;					var treeObj = $.fn.zTree.getZTreeObj(treeId);					treeObj.expandNode(treeNode,true,false,false,false);				}			}		};		$.fn.zTree.init($("#tree"), setting);	}gis.tree.parentloadcbdataService = function(){	if(parent&&parent.gis&&parent.gis.script&&parent.gis.script.loadcbdataService){		 //alert(gis.tree.phase.init);		 parent.gis.script.loadcbdataService(gis.tree.phase.init);		 return;	}	gis.script.loadcbdataService(obj);}$(document).ready(function() {	/*	var treediv=$("#treediv");	var tree=$("#tree");	//alert($.support.leadingWhitespace)	if($.support&&$.support.leadingWhitespace){		tree.css("width",treediv.width()-10);		tree.css("height",treediv.height()-10);	}	*/	//$("#othen").css("display","none");	//tree.css("height",treediv.height()-$("#othen").height());	//tree.css("height",treediv.height());	//gis.tree.initcbtree();	/*	if(gis.script.loadcbdataService){    	gis.script.loadcbdataService(gis.script.phase.init);    }    */	//alert();	gis.tree.parentloadcbdataService();});
 |