layui.use(function(){
	var tree = layui.tree;
	$.ajax({
		type: 'post',
		url: ctxPath + '/announcement/tree',//数据接口
		dataType: 'json', // 服务器返回数据类型
		async: true,
		data: {},
		success: function (data) {
			personType = '0';
			var result = [];
			for (let i = 0; i < data.length; i++) {
				if (data[i].level == '0') {
					data[i].spread = true
					result.push(data[i])
				}
			}
			for (let i = 0; i < result.length; i++) {
				result[i].children = []
				for (let j = 0; j < data.length; j++) {
					if (result[i].id == data[j].parentId) {
						data[j].spread = true
						result[i].children.push(data[j])
					}
				}
			}
			for (let i = 0; i < result.length; i++) {
				//root
				for (let k = 0; k < result[i].children.length; k++) {
					//parent = 0
					result[i].children[k].children = []
					for (let j = 0; j < data.length; j++) {
						if (result[i].children[k].id == data[j].parentId) {
							data[j].spread = true
							result[i].children[k].children.push(data[j])
						}
					}
				}
			}
			tree.render({
				elem: '#orgTree'
				, data: result
				, spread: true
				, showLine: false  // 是否开启连接线
				, accordion: true
			});
		},
		error: function (err) {
			console.log("获取工程下拉列表出错：", err);
		}
	});

});