/*2017-07-31 add by yb
 * describe:服务包信息管理
 * 
 */
var zTreeObj = null;
var organizationTree=null;
var setting = {
	view : {
		dblClickExpand : false,
		showLine : false,
		showIcon: false
	},
	check : {
		enable : true
	},
	data : {
		simpleData : {
			enable : true
		}
	},
	callback : {
	}
};



//初始化组织树
function initOrganizationTree(){
	var contextPath=$("#contextPath").val();
	var organizationId=$("#organizationId").val();
	$.ajax({
		url :contextPath+"/service/type/projectOrganizationTree",
		type : "POST",
		data : {organizationId:organizationId},
		dataType:"json",
		success : function(data) {
			$.fn.zTree.init($("#organizationTree"), setting, data);
			organizationTree=$.fn.zTree.getZTreeObj("organizationTree");
			organizationTree.expandAll(true);
		},
		error : function(data) {
		}
	});
}

$(function() {
	//初始化组织树
	initOrganizationTree();
	
	//编辑提交
	$("#btn-save").bind("click", function() {
		//管辖的组织
		var organizationNodes=organizationTree.getCheckedNodes(true);
		var organizationIds="";
		$.each(organizationNodes,function(index,organizationNode){
			if(organizationNode.level=="1"){
				organizationIds+=organizationNode.id+";";
			}
		});
		if($.trim(organizationIds)==""){
			alert("请在右侧选择项目");
			return;
		}
		var r=confirm("您确定要覆盖此项目之前的所有服务？");
		if(r==true){
			$("#organizationIds").val(organizationIds);
			showBlock();
			$("#conditionform").submit();
		}
	});
	
});
