    var setting = {
        view: {expandSpeed: "",
            dblClickExpand: true,
            showLine: true,
            showTitle: false,
            addHoverDom: addHoverDom,
            removeHoverDom: removeHoverDom,
            selectedMulti: false,
            fontCss: set_font_css
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        edit: {
            enable: true,
            showRenameBtn: false,
            showRemoveBtn: false,
            drag: {
                isCopy: false,
                isMove: true,
                prev: true,
                next: true,
                inner: true
            }
        },
        callback: {
            onClick: onClickzTree,
            beforeDrop: beforeDrop,
            onDrop: onDrop
        }
    };

    function onClickzTree(e, treeId, treeNode, clickFlag) {
        var urlReQuery = indexpage;
        window.location.href = urlReQuery + '/' + treeNode.id;
        return true;
    }

    function addHoverDom(treeId, treeNode) {
        var sObj = $("#" + treeNode.tId + "_span");
        if ($("#addBtn_" + treeNode.id).length > 0)
            return;
        var addStr = "<span class='button add' id='addBtn_" + treeNode.id + "' title='\u589e\u52a0' onfocus='this.blur();'></span>";
        sObj.append(addStr);
        var btn = $("#addBtn_" + treeNode.id);
        if (btn)
            btn.bind("click", function() {
                var urlReQuery = addpage;
                $.ajax({
                    type: "get",
                    url: urlReQuery + '/' + treeNode.id,
                    success: function(data, textStatus) {
                        var dataArray = $.parseJSON(data);
                        for (var key in dataArray) {
                            if (dataArray[key].name == 'ok') {
                                var zTree = $.fn.zTree.getZTreeObj(treeId);
                                zTree.addNodes(treeNode, {id: (dataArray[key].value), pId: treeNode.id, name: "New tree"});
                            } else {
                                $.modaldialog.error('发生错误，请联系管理员.' + dataArray[key].value);
                            }
                        }
                    },
                    error: function() {
                        alert('发生错误，请联系管理员');
                    }
                });
                return false;
            });
    }
    ;

    function removeHoverDom(treeId, treeNode) {
        $("#addBtn_" + treeNode.id).unbind().remove();
    }
    ;

    //节点移动规则
    function beforeDrop(treeId, treeNodes, targetNode, moveType) {
        var move_type_title;
        if (moveType == 'inner') {
            move_type_title = ' 之中，成为子节点';
        } else if (moveType == 'prev') {
            move_type_title = ' 之前';
        } else if (moveType == 'next') {
            move_type_title = ' 之后';
        }
        //是否把子节点移到根节点
        if (targetNode.getParentNode() == null) {
            if (moveType == 'inner') { //只允许放到根节点之内
                if (confirm('是否把 ' + treeNodes[0].name + ' 移到 ' + targetNode.name + move_type_title)) {
                    return true;
                }
            }
        } else {
            if (treeNodes[0].getParentNode().tId != targetNode.getParentNode().tId || moveType == 'inner') {
                if (confirm('是否把 ' + treeNodes[0].name + ' 移到 ' + targetNode.name + move_type_title)) {
                    return true;
                }
            } else {
                return true;
            }
        }
        return false;
    }

    function onDrop(event, treeId, treeNodes, targetNode, moveType) {
        var idStr = '';
        if (targetNode != null && treeNodes[0].getParentNode() != null) {
            var childNodes = treeNodes[0].getParentNode().children;
            for (var i = 0; i < childNodes.length; i++) {
                idStr = idStr + childNodes[i].id + ',';
            }
            var urlReQuery = movepage;
            $.ajax({
                type: "post",
                url: urlReQuery,
                data: {'pid': treeNodes[0].getParentNode().id, 'ids': idStr},
                success: function(data, textStatus) {
                    return true;
                },
                error: function() {
                    $.modaldialog.error('发生错误，请联系管理员');
                    return false;
                }
            });
        }
    }

    //设置样式
    function set_font_css(treeId, treeNode) {
        var nodeColor = '';
        if (treeNode.status !== 1) {
            nodeColor = 'red';
        }
        return treeNode.level == 1 ? {'font-weight': 'bold', 'color': nodeColor} : {'color': nodeColor};
    }
    //删除结构和信息
    function deleteInfo() {
        if (confirm('是否删除?')) {
            var urlReQuery = deletepage;
            var datas=$("#"+form_id).serialize();
            $.ajax({
                type: "post",
                data: datas,
                url: urlReQuery,
                success: function(data, textStatus) {
                    var dataArray = $.parseJSON(data);
                    for (var key in dataArray) {
                        if (dataArray[key].name == 'ok') {
                            if (typeof(eval(show_tips)) == "function") {
                                show_tips('ok', '删除成功!，程序正在刷新...');
                            }else{
                                $.modaldialog.success('删除成功!，程序正在刷新...');
                            }
                            setTimeout(function() {
                                window.location.href = dataArray[key].value;
                            }, 500);
                            return true;
                        } else if (dataArray[key].name == 'no') {
                            if (typeof(eval(show_tips)) == "function") {
                                show_tips('no', dataArray[key].value);
                            }else{
                                $.modaldialog.error(dataArray[key].value);
                            }
                            return false;
                        }
                    }
                },
                error: function() {
                    $.modaldialog.error('发生错误，请联系管理员');
                    return false;
                }
            });
        }
    }
    //初始化树形菜单
    $(document).ready(function() {
        $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        var zTree = $.fn.zTree.getZTreeObj('treeDemo');
        var nodes = zTree.getNodes();
        //是否自动展开节点
        if (nodes.length > 0) {
            zTree.expandNode(nodes[0], true, false, true);
        }
        //选择节点
        var node = zTree.getNodeByParam("id",current_node);
        zTree.selectNode(node);
        if ($("#treeDemo").attr('data-expandAll')==1) {
            zTree.expandAll(true);
        };
    });