var treeObj = null;
        var setting = {
        		check : {
        			enable : true,
        			chkDisabledInherit : true
        		},
                data: {
                    simpleData: {
                        enable: true
                    }
                },
                view: {
                    fontCss: setHighlight // 高亮一定要设置，setHighlight是自定义方法
                },
            	callback : {
            		beforeCheck : beforeCheck,
            		onCheck : onCheck,
            		onClick: zTreeOnClick
            	}
        };
        
// tree节点选中之前进行判断
var className = "dark";
function beforeCheck(treeId, treeNode) {
	className = (className === "dark" ? "" : "dark");
	return (treeNode.doCheck !== false);
}

//计算tree选中的节点，for循环去除计算父节点在内
var treecheck = [];
function onCheck() {
	var checkCount = 1, totalcount = 4;
	var zTree = jQuery.fn.zTree.getZTreeObj("tree");
	if (zTree != null) {
		checkCount = zTree.getCheckedNodes(true).length;
		var nodes = zTree.getCheckedNodes(true);
		totalcount = checkCount;
		treecheck = [];

		for ( var i = 0; i < totalcount; i++) {
			if (nodes[i].id > 4000) {
				treecheck.push(nodes[i].id);
				/*********************************
				 * 设置加载实时数据界面 add by yexb -----start
				 *********************************/
				//实时谐波频谱，实时数据列表，实时矢量图
				if(blrealharmonic){
					window.main_right.refreshRealHarmoinc();
					blrealharmonic=false;
				}
				else if(blrealdatalist){
					window.main_right.refreshRealDatalist();
					blrealdatalist=false;
				}
				else if(blrealvector){
					window.main_right.refreshRealVector();
					blrealvector=false;
				}
			} else {
				checkCount--;
			}
		}

		if (number != 0) {
			if (checkCount >= number) {
				disabledNode(true);
			} else {
				disabledNode(false);
			}
		}
	}
}

function zTreeOnClick() {
    var zTree = $.fn.zTree.getZTreeObj("tree");
    
    if (zTree != null) {
        var nodes = zTree.getSelectedNodes();   //获取树控件选中对象集合
        
        // 关闭所有节点的高亮
        var allNodes = treeObj.transformToArray(treeObj.getNodes());
        for (var i = 0; i < allNodes.length; i ++) {
            allNodes[i].highlight = false;
            treeObj.updateNode(allNodes[i]);
        }
        
        // 高亮并展开搜索到的节点
        for (var i = 0; i < nodes.length; i ++) {
            nodes[i].highlight = true;
            treeObj.updateNode(nodes[i]); // 更新节点，让高亮生效
        }
        
        var index = nodes[0].nodeIndex;
        
        queryInfo(index);
        
    }
}

        function getTree() {
        	jQuery.ajax({
        		type : 'POST',
        		dataType : "json",
        		url : '/pqs9200/permission/getTree',
        		data : {},
        		async:false,
        		error : function() {
        			console.log("获取终端树请求发送失败！");
        		},
        		success : function(data) {
        			var datalist = [];
        			for ( var i = 0; i < data.length; i++) {
        				var str = '';

        				str += '{' + "id:" + data[i].id;
        				str += ',' + "name:'" + data[i].name + "'";
        				str += ',' + "nodeIndex:" + data[i].nodeIndex;
        				str += ',' + "nodeType:" + data[i].nodeType;
        				str += ',' + "ppId:" + data[i].ppId;
        				if(data[i].nodeType == "0"){
        					str += ',' + "open:" + true;
        				}else{
        					str += ',' + "open:" + false;
        				}
        				str += ',' + "describe:" + data[i].describe;
        				str += ',' + "rd_Index:'" + data[i].rdIndex + "'";
        				str += ',' + "pId:" + data[i].pId + '}';
        				datalist.push(str);
        			}
        			datalist = eval('[' + datalist + ']');// string->json数组

        			var zNodes = datalist;
        			
        			treeObj = $.fn.zTree.init($("#tree"), setting, zNodes);
        			var treeObj1 = $.fn.zTree.getZTreeObj("tree"); 
        			treeObj1.expandAll(true);
        		}
        	});
        	
//
//            $(document).ready(function(){
//                treeObj = $.fn.zTree.init($("#tree"), setting, zNodes);
//            });
        }


        $(document).ready(function(){
        	getTree();
        });
        
        // 设置高亮字体
        function setHighlight(treeId, treeNode) {
            return (!!treeNode.highlight) ? {color:"#000000", "font-weight":"bold"} : {color:"#666", "font-weight":"normal"};
        }
        
        function queryInfo(index){
        	jQuery.ajax({
        		type : 'POST',
        		dataType : "json",
        		url : '/pqs9200/permission/getInfo',
        		data : {
        			index:index
        		},
        		beforeSend: function () {  
                    i = ityzl_SHOW_LOAD_LAYER();  
                },
        		async:false,
        		success : function(data) {
	        			var heightTemp=screen.height;
	        			var length;
	        			if(heightTemp===768){
	        				length=10;
	        			}else if (heightTemp===1024){
	        		        length=20;
	        			}else if (heightTemp===960){
	        		        length=15;
	        		    }else if (heightTemp===1050){
	        		        length=18;
	        		    }else{
	        		        length=12;
	        			}
    					var oTable=$('#vdlist').DataTable({
    						scrollX : true,
    						lengthChange : false,
    						bDestroy : true,
    						ordering : false,
    						columnDefs : [ {
    							targets : [ ],
    							visible : false
    						} ],
    						data : data.body,
    						destroy : true,
    						pageLength:length,
    						language : {
    							url:'/pqs9200/json/chine.json'
    						},
    						'fnDrawCallback': function(oTable) {    
    						    $("#vdlist_paginate").append("<div style='float:right;padding-top:4px;padding-left:10px;'><font style='font-size: 12px'>到第 <input type='text' id='changePage' class='input-text' style='width:50px;height:28px;'> 页  <button class='btn btn-primary' id='dataTable-btn'>确定</button></font></div>");    
    						    var table = $("#vdlist").dataTable();    
    						    $('#dataTable-btn').click(function(e) {
    						        if($("#changePage").val() && $("#changePage").val() > 0) {    
    						            var redirectpage = $("#changePage").val() - 1;    
    						        } else {    
    						            var redirectpage = 0;    
    						        }    
    						        table.fnPageChange(redirectpage);
    						    });    
    						}
    					});
    				//***********关闭loading
    	        	ityzl_CLOSE_LOAD_LAYER(i); 
        		}
        	});
        }