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
<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 () {
        /**
         * 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/manage/catalog/selectmulu',
                autoParam: ["id"]
            },
            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
    });
 
    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) {
        $("#divTabs2").css("display", "none");
        $("#divTabs").css("display", "");
        $("#btnMerge").css("display", "");
        $("#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");
        if (treeNode.id == 0) {
            $("#btnDelete").css("display", "none");
            $("#btnEdit").css("display", "none");
            $("#zypaixu").css("display", "none");
            $("#ZiYuanSort").css("display", "none");
        }
        $("#tabContent2").css("display", "none");
        $("#tabContent3").css("display", "none");
        $("#tabBasicInfo").html("查看");
        f_node.setId(treeNode.id);
        $("#tabBasicInfo").click();
        $.ajax({
            url: '/res/manage/catalog/getcataloginfo',
            type: 'post',
            data: {id: treeNode.id},
            success: function (data) {
                var json = data.result;
                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!="" && json.icon != null){
                    $("#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>