/**
 * Created by Tony on 2017/5/12.
 */
zTreeHelper = {
    createTree: function(sourceData, setting, containerId, caller){
        let me = this, treeArr = tree_Data_Helper.buildTreeNodeDirectly(sourceData);
        me.createTreeDirectly(treeArr, setting, containerId, caller);
    },
    createTreeDirectly: function (treeArr, setting, containerId, caller) {
        let private_build_parentNodeIds = function(pNodeId, nodesArr){
            let rst = [];
            for (let i = 0; i < nodesArr.length; i++) {
                if (nodesArr[i].items.length > 0) {
                    rst = rst.concat(private_build_parentNodeIds(nodesArr[i].ID, nodesArr[i].items));
                } else {
                    rst.push(nodesArr[i].ID);
                }
            }
            if (pNodeId && rst.length > 0) {
                caller.parentNodeIds["_pNodeId_" + pNodeId] = rst;
            }
            return rst;
        };
        if (caller.parentNodeIds) {
            private_build_parentNodeIds(null, treeArr);
        }
        caller.treeObj = $.fn.zTree.init($("#" + containerId), setting, treeArr);
        caller.treeObj.expandAll(true);
    }
};