var treeObj = null;
var treeAllData;
var setting = {
	check : {
		enable : true,
		chkDisabledInherit : true
	},
	data : {
		simpleData : {
			enable : true
		}
	},
	view : {
		fontCss : setHighlight, // 高亮一定要设置，setHighlight是自定义方法
		addDiyDom : addDiyDom
	},
	callback : {
		beforeCheck : beforeCheck,
		onCheck : onCheck,
		onClick : zTreeOnClick
	}
};

function addDiyDom(treeId, treeNode) {
	if (treeNode.level != 4) {
		return;
	}
	var powerType = treeNode.powerType;
	if (powerType == 0) {
		var aObj = $("#" + treeNode.tId + "_a");
		var editStr = "<input type='image' src='../images/img/gw.png'></input>";
		aObj.before(editStr);
	} else if (powerType == 1) {
		var aObj = $("#" + treeNode.tId + "_a");
		var editStr = "<input type='image' src='../images/img/fgw.png'></input>";
		aObj.before(editStr);
	} else if (powerType == 2) {
		var aObj = $("#" + treeNode.tId + "_a");
		var editStr = "<input type='image' src='../images/img/newgw.png'></input>";
		aObj.before(editStr);
	} else if (powerType == 3) {
		var aObj = $("#" + treeNode.tId + "_a");
		var editStr = "<input type='image' src='../images/img/newfgw.png'></input>";
		aObj.before(editStr);
	} else if (powerType == 4) {
		var aObj = $("#" + treeNode.tId + "_a");
		var editStr = "<input type='image' src='../images/img/ss.png'></input>";
		aObj.before(editStr);
	} else {
		var aObj = $("#" + treeNode.tId + "_a");
		var editStr = "<input type='image' src='../images/img/pcc.png'></input>";
		aObj.before(editStr);
	}
}
// 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]); // 更新节点，让高亮生效
		}

		if (nodes[0].level == 4) { // 如果选中监测点信息则进行处理，其他信息不处理
		// var point = new BMap.Point(nodes[0].lon, nodes[0].lat);
		// map.panTo(point, false);
		// obj.lon = nodes[0].lon;
		// obj.lat = nodes[0].lat;
		// obj.state = nodes[0].state;
		// obj.name = nodes[0].name;

			// 修改选中监测点的信息展示
			var devname = nodes[0].getParentNode();
			var bdname = nodes[0].getParentNode().getParentNode();
			var gdname = nodes[0].getParentNode().getParentNode().getParentNode();
			$('#pointInfo').text(
					gdname.name + '->' + bdname.name + '->' + nodes[0].name);

			var line_index = nodes[0].nodeIndex;
			$("#lineIndex").val(line_index);
			$("#lineName").val(nodes[0].name);

			var status = nodes[0].status;
			var state = nodes[0].state;
			if (state == 2) {
				$("#image").val("gray");
			} else if (state == 1) {
				$("#image").val("yellow");
			} else {
				if (status == 0) {
					$("#image").val("red");
				} else {
					$("#image").val("green");
				}
			}

			// 传递参数给相应界面
			var tjsrc = "tongji?line_index=" + line_index;
			var fxsrc = "analyze?line_index=" + line_index;
			var sbsrc = "manage?line_index=" + line_index;
			$("#tjsrc").val(tjsrc);
			$("#fxsrc").val(fxsrc);
			$("#sbsrc").val(sbsrc);
			$("#tjclick").val('on');
			$("#fxclick").val('on');
			$("#sbclick").val('on');
			// document.getElementById("tj").src = tjsrc;
			// document.getElementById("fx").src = fxsrc;
			// document.getElementById("sb").src = sbsrc;

			var endTime = getEndTime();
			var startTime = getStartTime("年份", endTime);
			// getEventDensity(line_index,startTime,endTime);
			// getEventTime(line_index,startTime,endTime);
			// getEventData(line_index,startTime,endTime);
			// getEventType(line_index,startTime,endTime);
			// getEventCause(line_index,startTime,endTime);

			pantoPoint(line_index);

			// 画之前先清空地图覆盖物
			/*
			 * pointmap.clearOverlays(); drawPoint(pointmap, nodes[0].lon,
			 * nodes[0].lat, nodes[0].state, nodes[0].name);
			 * pointmap.addEventListener("tilesloaded", function () {
			 * //div开始隐藏，导致中心点加载不出来，地图加载完成后设置地图中心点 pointmap.setCenter(point);
			 * });
			 */
		}
	}
}

function zTreeOnAsyncSuccess(pastIndex) {
	var zTree = $.fn.zTree.getZTreeObj("tree");

	var nodes = zTree.getNodes();
	zTree.expandNode(nodes[0], true);

	var childNodes = zTree.transformToArray(nodes[0]);

	var nowIndex;
	if (pastIndex.length == 0) {
		var i = 0;
		for (i = 0; i < childNodes.length; i++) {
			var type = childNodes[i].level;
			if (type == 4) {
				var devname = childNodes[i].getParentNode();
				var bdname = childNodes[i].getParentNode().getParentNode();
				var gdname = childNodes[i].getParentNode().getParentNode()
						.getParentNode();

				zTree.expandNode(gdname, true);
				zTree.expandNode(bdname, true);
				zTree.expandNode(devname, true);
				zTree.expandNode(childNodes[i], true);

				$('#pointInfo').text(
						gdname.name + '->' + bdname.name + '->' +  childNodes[i].name);

				var line_index = childNodes[i].nodeIndex;
				nowIndex = line_index;
				$("#lineIndex").val(line_index);
				$("#lineName").val(childNodes[i].name);

				var status = childNodes[i].status;
				var state = childNodes[i].state;
				if (state == 2) {
					$("#image").val("gray");
				} else if (state == 1) {
					$("#image").val("yellow");
				} else {
					if (status == 0) {
						$("#image").val("red");
					} else {
						$("#image").val("green");
					}
				}

				// 传递参数给相应界面
				var tjsrc = "tongji?line_index=" + line_index;
				var fxsrc = "analyze?line_index=" + line_index;
				var sbsrc = "manage?line_index=" + line_index;
				$("#tjsrc").val(tjsrc);
				$("#fxsrc").val(fxsrc);
				$("#sbsrc").val(sbsrc);
				// document.getElementById("tj").src = tjsrc;
				// document.getElementById("fx").src = fxsrc;
				// document.getElementById("sb").src = sbsrc;

				var endTime = getEndTime();
				var startTime = getStartTime("年份", endTime);
				// getEventDensity(line_index,startTime,endTime);
				// getEventTime(line_index,startTime,endTime);
				// getEventData(line_index,startTime,endTime);
				// getEventType(line_index,startTime,endTime);
				// getEventCause(line_index,startTime,endTime);
				// 关闭所有节点的高亮
				var allNodes = treeObj.transformToArray(treeObj.getNodes());
				for (var n = 0; n < allNodes.length; n++) {
					allNodes[n].highlight = false;
					treeObj.updateNode(allNodes[n]);
				}

				// 高亮并展开搜索到的节点
				childNodes[i].highlight = true;
				treeObj.updateNode(childNodes[i]); // 更新节点，让高亮生效

				break;
			}
		}
	} else {
		nowIndex = pastIndex;
		var i = 0;
		for (i = 0; i < childNodes.length; i++) {
			var index = childNodes[i].nodeIndex;
			if (index == pastIndex && childNodes[i].level == 4) {
				var devname = childNodes[i].getParentNode();
				var bdname = childNodes[i].getParentNode().getParentNode();
				var gdname = childNodes[i].getParentNode().getParentNode()
						.getParentNode();

				zTree.expandNode(gdname, true);
				zTree.expandNode(bdname, true);
				zTree.expandNode(devname, true);
				zTree.expandNode(childNodes[i], true);

				$('#pointInfo').text(
						gdname.name + '->' + bdname.name + '->' + childNodes[i].name);

				var line_index = childNodes[i].nodeIndex;
				$("#lineIndex").val(line_index);
				$("#lineName").val(childNodes[i].name);

				var status = childNodes[i].status;
				var state = childNodes[i].state;
				if (state == 2) {
					$("#image").val("gray");
				} else if (state == 1) {
					$("#image").val("yellow");
				} else {
					if (status == 0) {
						$("#image").val("red");
					} else {
						$("#image").val("green");
					}
				}

				// 传递参数给相应界面
				var tjsrc = "tongji?line_index=" + line_index;
				var fxsrc = "analyze?line_index=" + line_index;
				var sbsrc = "manage?line_index=" + line_index;
				$("#tjsrc").val(tjsrc);
				$("#fxsrc").val(fxsrc);
				$("#sbsrc").val(sbsrc);
				// document.getElementById("tj").src = tjsrc;
				// document.getElementById("fx").src = fxsrc;
				// document.getElementById("sb").src = sbsrc;

				var endTime = getEndTime();
				var startTime = getStartTime("年份", endTime);
				// getEventDensity(line_index,startTime,endTime);
				// getEventTime(line_index,startTime,endTime);
				// getEventData(line_index,startTime,endTime);
				// getEventType(line_index,startTime,endTime);
				// getEventCause(line_index,startTime,endTime);
				// 关闭所有节点的高亮
				var allNodes = treeObj.transformToArray(treeObj.getNodes());
				for (var n = 0; n < allNodes.length; n++) {
					allNodes[n].highlight = false;
					treeObj.updateNode(allNodes[n]);
				}

				// 高亮并展开搜索到的节点
				childNodes[i].highlight = true;
				treeObj.updateNode(childNodes[i]); // 更新节点，让高亮生效

				break;
			}
		}
	}

	pantoPoint(nowIndex);
}

function getTree(pastIndex) {
	var endTime = getEndTime();
	var startTime = getStartTime("月份", endTime);
	jQuery.ajax({
		type : 'POST',
		dataType : "json",
		url : '/pqs9200/device/tree',
		data : {
			startTime : startTime,
			endTime : endTime
		},
        beforeSend: function () {
            i = ityzl_SHOW_LOAD_LAYER();
        },
		async : true,
		error : function() {
			console.log("获取终端树请求发送失败！");
		},
		success : function(data) {
			if (data.code == 500 || data.body == null) {
				console.error("获取终端树请求异常.");
				layer.msg("获取终端树内容失败.");
			} else {
				treeAllData = data.body;
				var treedata = data.body;
				initTree(treedata);
				zTreeOnAsyncSuccess(pastIndex);
			}

            ityzl_CLOSE_LOAD_LAYER(i);
		}
	});

}

$(document).ready(function() {
	var pastIndex = $("#lineIndex").val();
	pastIndex=filterXSS(pastIndex);
	getTree(pastIndex);

});

// 模糊搜索name满足条件的节点
function searchNode(value) {
	if (value == "")
		return;
//
//	// 获取搜索的节点
//	var nodes = treeObj.getNodesByParamFuzzy("name", value);
//	// 关闭所有节点的高亮
//	var allNodes = treeObj.transformToArray(treeObj.getNodes());
//	for (var i = 0; i < allNodes.length; i++) {
//		allNodes[i].highlight = false;
//		treeObj.updateNode(allNodes[i]);
//	}
//	// 展开第一层节点
//	treeObj.expandAll(false);
//	treeObj.expandNode(treeObj.getNodes()[0], true);
//	// 高亮并展开搜索到的节点
//	for (var i = 0; i < nodes.length; i++) {
//		nodes[i].highlight = true;
//		treeObj.updateNode(nodes[i]); // 更新节点，让高亮生效
//		treeObj.expandNode(nodes[i].getParentNode(), true);
//	}

    var hiddenNodes = [];
    var ztreeObj = $.fn.zTree.getZTreeObj("tree");
    var keyword=$("#search_value").val();
    //显示上次搜索后隐藏的结点，注意：使用hideNodes（）方法时需要引包jquery.ztree.exhide-3.5.min.js
    //ztreeObj.showNodes(hiddenNodes);
    //获取不符合条件的子父结点
    hiddenNodes=ztreeObj.getNodesByFilter(filterFunc);
    //隐藏不符合条件的子父结点，注意：使用hideNodes（）方法时需要引包jquery.ztree.exhide-3.5.min.js
    ztreeObj.hideNodes(hiddenNodes);

	var treeObj = $.fn.zTree.getZTreeObj("tree");
	var nodes = treeObj.getNodesByParamFuzzy("name", value);// 获取搜索的节点

	closeHigh();

	treeObj.expandAll(false);// 展开第一层节点
	treeObj.expandNode(treeObj.getNodes()[0], true);

	// 高亮并展开搜索到的节点
	for (var i = 0; i < nodes.length; i++) {
		nodes[i].highlight = true;
		treeObj.updateNode(nodes[i]); // 更新节点，让高亮生效
		treeObj.expandNode(nodes[i].getParentNode(), true);
	}

    $("#serchB").css("display", "none");
    $("#resetB").css("display", "");
}

function valueChange(value) {
	if (value == '') {
		closeHigh();
	}
}

//查找不符合条件的结点
//返回true表示需要隐藏，返回false表示不需要隐藏 。
function filterFunc(node){
    var keyword=$("#search_value").val();
   //如果当前结点或其子节点匹配模糊查询的关键字，则该结点不隐藏
   if(node.name.indexOf(keyword)!=-1){
     return false;
   }
   if(node.isParent){
     var b=searchChildren(node,keyword);
     if(!b){
         return b;
     }
   }
   if(node.getParentNode() !=null){
     var b=searchParent(node,keyword);
     if(!b){
         return b;
     }
   }
     return true;
}
/**
 * 查找子结点，如果匹配模糊查询的关键字则返回false，否则返回true
 */
function searchChildren(pNode,keyword){
    var childs=pNode.children;
    var isexit=true;

    for(var i = 0;i < childs.length;i++){
    	if(childs[i].name.indexOf(keyword)!=-1){
    		return false;
    	}
    }
    for(var i = 0;i < childs.length;i++){
      if(childs[i].isParent){
         isexit=searchChildren(childs[i],keyword);
             if(!isexit){
                 return isexit;
             }
       }else{
         if(childs[i].name.indexOf(keyword)!=-1){
             return false;
             }
        }
      }
    return isexit;
}

function searchParent(pNode,keyword){
    var parent=pNode.getParentNode();
    var isexit=true;
    if(parent.name.indexOf(keyword)!=-1){
		return false;
	}

	if(parent.getParentNode()){
        isexit=searchParent(parent,keyword);
            if(!isexit){
                return isexit;
            }
      }else{
         if(parent.name.indexOf(keyword)!=-1){
             return false;
         }
      }
    return isexit;
}

// 设置高亮字体
function setHighlight(treeId, treeNode) {
	return (!!treeNode.highlight) ? {
		color : "#000000",
		"font-weight" : "bold"
	} : {
		color : "#666",
		"font-weight" : "normal"
	};
}
//关闭所有高亮节点
function closeHigh() {
	var treeObj = $.fn.zTree.getZTreeObj("tree");
	var allNodes = treeObj.transformToArray(treeObj.getNodes());// 关闭所有节点的高亮

	for (var i = 0; i < allNodes.length; i++) {
		allNodes[i].highlight = false;
		treeObj.updateNode(allNodes[i]);
	}
}
// 延时搜索，用于输入框的按键事件，如果不延时，树就会不断的跳动
var timeoutId = null;
function searchNodeLazy(value) {
	if (timeoutId) {
		clearTimeout(timeoutId);
	}
	timeoutId = setTimeout(function() {
		searchNode(value);
	}, 500);
}

// 根据传入的json对象，更新终端图表
function updateIcon(json) {
	var lineIndex = $("#lineIndex").val();

	var jsonArr = [];
	for (var i = 0; i < json.length; i++) {
		jsonArr[i] = json[i];
	}

	var zTree = $.fn.zTree.getZTreeObj("tree");

	var nodes = zTree.getNodes();
	var childNodes = zTree.transformToArray(nodes[0]);

	for (var i = 0; i < childNodes.length; i++) {
		var type = childNodes[i].level;
		if (type == 4) {
			for (var n = 0; n < jsonArr.length; n++) {
				var status = jsonArr[n].status;
				var devFlag = jsonArr[n].devflag;

				if (jsonArr[n].lineid == childNodes[i].nodeIndex) {
					if (jsonArr[n].lineid == lineIndex) {
						if (devFlag == 2) {
							childNodes[i].icon = "../images/img/gray.png";
							$("#image").val("gray");
						} else if (devFlag == 1) {
							childNodes[i].icon = "../images/img/yellow.png";
							$("#image").val("yellow");
						} else {
							if (status == 0) {
								childNodes[i].icon = "../images/img/red.png";
								$("#image").val("red");
							} else {
								childNodes[i].icon = "../images/img/green.png";
								$("#image").val("green");
							}
						}

						zTree.updateNode(childNodes[i]);
					} else {
						if (devFlag == 2) {
							childNodes[i].icon = "../images/img/gray.png";
						} else if (devFlag == 1) {
							childNodes[i].icon = "../images/img/yellow.png";
						} else {
							if (status == 0) {
								childNodes[i].icon = "../images/img/red.png";
							} else {
								childNodes[i].icon = "../images/img/green.png";
							}
						}

						zTree.updateNode(childNodes[i]);
					}
				}
			}
		}
	}
}

//获取装置类型设备树
$("#datatype").on("change",function() {
	var i;
	var endTime = getEndTime();
	var startTime = getStartTime("月份", endTime);

	if($("option:selected",this).val() == 0){
		getTree("");
		zTreeOnAsyncSuccess("");
	}else if($("option:selected",this).val() == 1){
		getmancTree();
	}else if($("option:selected",this).val() == 2){
		getscaleTree();
	}else if($("option:selected",this).val() == 3){
		getloadTypeTree();
	}else if($("option:selected",this).val() == 4){
		getmonitorTree();
	}
})

//数据库获取厂家终端树数据
function getmancTree() {
	var endTime = getEndTime();
	var startTime = getStartTime("月份", endTime);

	$.ajax({
		url : "/pqs9200/device/mancTree",
		type : "post",
		async : true,
		dataType : "json",
        beforeSend: function () {
            i = ityzl_SHOW_LOAD_LAYER();
        },
		data : {
			startTime : startTime,
			endTime : endTime
		},
		success : function(data) {
			if (data.code == 500 || data.body == null) {
				console.error("获取终端树请求异常.");
				layer.msg("获取终端树内容失败.");
			} else {
				treeAllData = data.body;
				initTree(data.body);
				zTreeOnAsyncSuccess("");
			}

            ityzl_CLOSE_LOAD_LAYER(i);
		}
	});
}

//数据库获取电压等级终端树数据
function getscaleTree() {
	var endTime = getEndTime();
	var startTime = getStartTime("月份", endTime);

	$.ajax({
		url : "/pqs9200/device/scaleTree",
		type : "post",
		async : true,
		dataType : "json",
        beforeSend: function () {
            i = ityzl_SHOW_LOAD_LAYER();
        },
		data : {
			startTime : startTime,
			endTime : endTime
		},
		success : function(data) {
			if (data.code == 500 || data.body == null) {
				console.error("获取终端树请求异常.");
				layer.msg("获取终端树内容失败.");
			} else {
				treeAllData = data.body;
				initTree(data.body);
				zTreeOnAsyncSuccess("");

			}

            ityzl_CLOSE_LOAD_LAYER(i);
		}
	});
}

//数据库获取干扰源类型终端树数据
function getloadTypeTree() {
	var endTime = getEndTime();
	var startTime = getStartTime("月份", endTime);

	$.ajax({
		url : "/pqs9200/device/loadTypeTree",
		type : "post",
		async : true,
		dataType : "json",
        beforeSend: function () {
            i = ityzl_SHOW_LOAD_LAYER();
        },
		data : {
			startTime : startTime,
			endTime : endTime
		},
		success : function(data) {
			if (data.code == 500 || data.body == null) {
				console.error("获取终端树请求异常.");
				layer.msg("获取终端树内容失败.");
			} else {
				treeAllData = data.body;
				initTree(data.body);
				zTreeOnAsyncSuccess("");
			}

            ityzl_CLOSE_LOAD_LAYER(i);
		}
	});
}

//数据库获取监测点性质终端树数据
function getmonitorTree() {
	var endTime = getEndTime();
	var startTime = getStartTime("月份", endTime);

	$.ajax({
		url : "/pqs9200/device/monitorTree",
		type : "post",
		async : true,
		dataType : "json",
        beforeSend: function () {
            i = ityzl_SHOW_LOAD_LAYER();
        },
		data : {
			startTime : startTime,
			endTime : endTime
		},
		success : function(data) {
			if (data.code == 500 || data.body == null) {
				console.error("获取终端树请求异常.");
				layer.msg("获取终端树内容失败.");
			} else {
				treeAllData = data.body;
				initTree(data.body);
				zTreeOnAsyncSuccess("");
			}

            ityzl_CLOSE_LOAD_LAYER(i);
		}
	});
}

function initTree(treedata) {
	var datalist = [];
	for (var i = 0; i < treedata.length; i++) {
		var str = '';

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

	var zNodes = datalist;
	var k = 0;

	for (var index = 0; index < zNodes.length; index++) {
		if (zNodes[index].nodeType == 0) {
			if(loadColor == "#006565"){
				zNodes[index].icon = "../images/img/gwbase.png";
			}else{
				zNodes[index].icon = "../images/img/nwbase.png";
			}
		} else if (zNodes[index].nodeType == 1) {
			if(loadColor == "#006565"){
				zNodes[index].icon = "../images/img/gwprovince.png";
			}else{
				zNodes[index].icon = "../images/img/nwprovince.png";
			}
		} else if (zNodes[index].nodeType == 2) {
			if(loadColor == "#006565"){
				zNodes[index].icon = "../images/img/gwpower.png";
			}else{
				zNodes[index].icon = "../images/img/nwpower.png";
			}
		} else if (zNodes[index].nodeType == 3) {
			if(loadColor == "#006565"){
				zNodes[index].icon = "../images/img/gwsubstation.png";
			}else{
				zNodes[index].icon = "../images/img/nwsubstation.png";
			}
		} else
			{
			if (zNodes[index].state == 2) {
				zNodes[index].icon = "../images/img/gray.png";
			} else if (zNodes[index].state == 1) {
				zNodes[index].icon = "../images/img/yellow.png";
			} else {
				if (zNodes[index].status == 0) {
					zNodes[index].icon = "../images/img/red.png";
				} else {
					zNodes[index].icon = "../images/img/green.png";
				}
			}
		}
	}

	treeObj = $.fn.zTree.init($("#tree"), setting, zNodes);
}

function resetTree(){
	document.getElementById("search_value").value = "";
	var endTime = getEndTime();
	var startTime = getStartTime("月份", endTime);

	initTree(treeAllData);
	zTreeOnAsyncSuccess("");


    $("#serchB").css("display", "");
    $("#resetB").css("display", "none");
}
