2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<div class='my-ztree' shiro:hasPermission="res:catalog:edit" xmlns:shiro="http://www.w3.org/1999/xhtml">
    <ul id='zytree' class='ztree'></ul>
</div>
<script>
    jQuery(function () {
        initTree(0);
    });
 
    function initTree(status) {
        /**
         * zTree配置
         */
        var setting = {
            view: {
                selectedMulti: false
            },
            check: {
                enable: false
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback: {
                //点击节点
                onClick: onClick,
                //展开节点
                //onExpand: onExpand,
                //拖动结束之前
                beforeDrop: beforeDrop,
                //拖动结束
                onDrop: onDrop,
                //创建节点后
                onNodeCreated: onNodeCreated
            },
            async: {
                enable: true,
                url: '/res/OnemapCatalog/selectmulu',
                autoParam: ["id"],
                otherParam:{
                    type:type,
                    themeid:themeid
                }
            },
            edit: {
                enable: true,
                showRemoveBtn: false,
                showRenameBtn: false,
                drag: {
                    autoExpandTrigger: true,
                    isCopy: false,
                    isMove: true,
                    prev: true,
                    next: true,
                    inner: true,
                    borderMax: 20,
                    borderMin: -10,
                    minMoveSize: 10,
                    maxShowNodeNum: 10,
                    autoOpenTime: 10
                }
            }
        };
 
        var zNodes = {id: 0, name: "资源目录", pId: -1, isParent: true,iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'};
        $.fn.zTree.init($("#zytree"), setting, zNodes); //初始化zTree
        if(status == 1) {
            onClick(null,0,zNodes,null);
            $("#btnAddSon").css("display","");
        }
    }
 
    function onNodeCreated(event, treeId, treeNode) {
        var treeObj = $.fn.zTree.getZTreeObj(treeId);
        if (treeNode.id == 0) {
            treeObj.expandNode(treeNode, true, false, false, true);
        }
    }
 
    function onClick(event, treeId, treeNode, clickFlag) {
        if(treeNode != null && treeNode.id != null && (typeof treeNode.id)=="number") {
            $("#divTabs2").css("display", "none");
            $("#divTabs").css("display", "");
            $("#btnMerge").css("display", "none");
            $("#btnDelete").css("display", "");
            $("#btnAddSon").css("display", "");
            $("#tabSort").css("display", "");
            $("#ZiYuanSort").css("display", "");
            $("#btnEdit").css("display", "");
            $("#paixu").css("display", "");
            $("#zypaixu").css("display", "");
            $("#btnReturn").css("display", "none");
            $("#tabContent").show();
            $("#tabContent1").css("display", "none");
            $("#btnSelectZY").css("display", "");
            if (treeNode.id == 0) {
                $("#btnDelete").css("display", "none");
                $("#btnEdit").css("display", "none");
                $("#zypaixu").css("display", "none");
                $("#ZiYuanSort").css("display", "none");
                $("#btnSelectZY").css("display", "none");
            }
            $("#tabContent2").css("display", "none");
            $("#tabContent3").css("display", "none");
            $("#tabBasicInfo").html("查看");
            f_node.setId(treeNode.id);
            $("#tabBasicInfo").click();
            //备注:暂只做两级目录
            if (treeNode.pId != 0 && treeNode.pId != null) {
                $("#btnAddSon").css("display", "none");
            }
            if (treeNode.id == 0) {
                $("#btnEdit").css("display", "none");
                $("#btnAddBrother").css("display", "none");
            }
            $("#btnMerge").css("display", "none");
            $.ajax({
                url: '/res/OnemapCatalog/getcataloginfo',
                type: 'post',
                data: {id: treeNode.id},
                success: function (data) {
                    var json = eval("(" + data + ")");
                    if (json.success)
                        $("#muluid").val(json.id);
                    $("#bianma").val(json.no);
                    $("#mingzi").val(json.name);
                    $("#shuoming").val(json.index);
                    if (json.beizhu != "null") {
                        $("#beizhu").val(json.beizhu);
                    }
                    if (json.icon != "null" && json.icon != "") {
                        $("#iconImg").attr("src", "/uploadPath/" + json.icon);
                    } else {
                        $("#iconImg").attr("src", "");
                    }
 
                },
                error: function (e) {
                    alert(e);
                }
            })
        }
    }
 
    function onDrop(event, treeId, treeNodes, targetNode, moveType, isCopy) {
        var treeObj = $.fn.zTree.getZTreeObj(treeId);
        var rpId = treeNodes[0].pId;
        var pId = targetNode == null ? rpId : targetNode.pId;
        var target = targetNode == null ? treeNodes[0].getParentNode() : targetNode;
        if (moveType == "inner")
            pId = targetNode == null ? rpId : targetNode.id;
        $.ajax({
            url: '/res/manage/catalog//changebianmu',
            type: 'post',
            data: {id: treeNodes[0].id, newfid: pId},
            success: function (data) {
                alert(data);
                treeObj.reAsyncChildNodes(target, "refresh", true);
            }
        })
    }
 
    function isDrop(treeNodes, targetNode, moveType) {
        var flag = true;
 
        var target = targetNode.getParentNode() == null ? "资源目录"
            : targetNode.getParentNode().name;
        if (moveType == "inner") {
            target = targetNode.name;
        }
        var r = confirm("确定将目录【" + treeNodes[0].name + "】移到目录【" + target + "】?");
        if (!r)
            flag = false;
        return flag;
    }
 
    function beforeDrop(treeId, treeNodes, targetNode, moveType, isCopy) {
        return isDrop(treeNodes, targetNode, moveType);
    }
</script>