tree
//初始化选择树
function initTrees(type, selectIds, keyWord) {
/**
* selectId 选中的id
* type 1 部门人员 2 角色人员 4 群组人员 5 搜索
*/
qytx.app.tree.userCheckOrRadio({
id : "groupUserTree",
type : checkType,
defaultSelectId : selectIds,
showType : $("#showType").val(),
dataParam : {
"type" : type,
"searchName" : keyWord,
"showType" : $("#showType").val()
},
click : function(data, treeNode) {
if (type == 5 && checkType != "radio") {//搜索人员时
if (treeNode) {
var obj = {};
obj.id = treeNode.id.substr(4);
obj.name = treeNode.name;
if (!treeNode.checked) {
removeObj(_result, obj);
} else {
addObj(_result, obj);//返回值
_selectId = _selectId + ","
+ treeNode.id.substr(4);
}
}
return;
}
_result = [];
_selectId = "";
if (data && data.length > 0) {
var str = "";
for (var i = 0; i < data.length; i++) {
var node = data[i];
if (showType == 3) {//选择人员
if (node.id) {
if (node.id.substr(0, 4) == "uid_") {
str += node.id.substr(4) + ",";
var obj = {};
obj.id = node.id.substr(4);
obj.name = node.name;
addObj(_result, obj);//返回值
}
}
}else if (showType == 1) {
if (node.id.substr(0, 4) == "gid_"
&& node.id != "gid_0") {
str += node.id.substr(4) + ",";
var obj = {};
obj.id = node.id.substr(4);
obj.name = node.name;
addObj(_result, obj);//返回值
}
} else if (showType == 2) {
if (node.id.substr(0, 4) == "rid_") {
str += node.id.substr(4) + ",";
var obj = {};
obj.id = node.id.substr(4);
obj.name = node.name;
addObj(_result, obj);//返回值
}
}
}
if (str.length > 0) {
_selectId = str.substr(0, str.length - 1);//修改全局选中的人员的id
}
}
art.dialog.data("result", _result);
},
loadComplete : function() {
if (type != 5) {
_result = [];
if ("" != _selectId) {
var ids = _selectId.split(",");
var treeObj = $.fn.zTree
.getZTreeObj("groupUserTree");
var showType = $("#showType").val();
for (var i = 0; i < ids.length; i++) {
var node = null;
if (showType == 1) {
node = treeObj.getNodeByParam("id", "gid_"
+ ids[i], null);
if (null != node) {
var obj = {};
obj.id = node.id.substr(4);
obj.name = node.name;
addObj(_result, obj);//返回值
}
} else if (showType == 2) {
node = treeObj.getNodeByParam("id", "rid_"
+ ids[i], null);
if (null != node) {
var obj = {};
obj.id = node.id.substr(4);
obj.name = node.name;
addObj(_result, obj);//返回值
}
} else if (showType == 3) {
node = treeObj.getNodesByParam("id", "uid_"
+ ids[i], null);
for ( var j in node) {
if (node[j].id) {
var obj = {};
obj.id = node[j].id.substr(4);
obj.name = node[j].name;
addObj(_result, obj);//返回值
}
}
}
}
}
art.dialog.data("result", _result);
}
}
});
}