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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
/********************************************
 *             后台管理 - 资源编目            *
 *******************************************/
 
//控制器:ResCatalogController
 
//-----------------------------------------
//F0 标签窗口初始化
//F1.排序界面初始化
//F2.资源排序界面初始化
//F3.新增子集界面
//F4.编目调整方法
//F5.页面初始化
//F6.删除方法
//F7.新增同级方法
//F8.修改界面方法
//F9.提交面目修改方法
//F10.目录新增方法
//F11.资源调整,子树初始化方法
//F12.资源位置调整界面
//F13.资源位置调整方法
//F14 初始化资源排序列表
//------------------------------------------
 
 
//F0 标签窗口初始化
var f_node_def = function () {
    var div = $("#tabContent");
    var actionkeep = "BasicInfo";
    var _VIEW = 0, _EDIT = 1, _AddBrother = 2, _AddSon = 3;
    var mode = _VIEW;
    this.setId = function (id) {//设置区域ID,点击树节点时触发
        muluid = id;
        this.onTab();
    };
    //切换页签的方法
    this.onTab = function (action, params) {
        isTop();
        var url = "";
        var myaction = actionkeep;
        if (action != null) {
            actionkeep = action;
        }
        if (mode == _EDIT) {
            myaction = actionkeep + "_Editor";
        } else if (mode == _AddBrother) {
            myaction = actionkeep + "_AddBrother";
        } else if (mode == _AddSon) {
            myaction = actionkeep + "_AddSon";
        } else {
            myaction = actionkeep;
        }
        if (action == "Sort") {
            var id = document.getElementById("muluid").value;
            initPaiXu();
            $("#tabContent2").show();
            $("#tabContent").css("display", "none");
            $("#tabContent3").css("display", "none");
        }
        if (action == "BasicInfo") {
            $("#tabContent").show();
            $("#tabContent2").css("display", "none");
            $("#tabContent3").css("display", "none");
        }
        if (action == "ZiYuanSort") {
            var id = document.getElementById("muluid").value;
            initZyPaiXu();
            $("#tabContent3").show();
            $("#tabContent").css("display", "none");
            $("#tabContent2").css("display", "none");
        }
    };
    //返回按钮绑定事件
    this.forView = function (id) {
        $("#btnAddBrother").css("display", "");
        $("#btnAddSon").css("display", "");
        $("#btnEdit").css("display", "");
        $("#btnReturn").css("display", "none");
        $("#btnDelete").css("display", "none");
        $("#divTabs2").css("display", "none");
        $("#divTabs").css("display", "");
        $("#tabSort").css("display", "");
        $("#ZiYuanSort").css("display", "");
        $("#tabRight").css("display", "");
        $("#tabOther").css("display", "");
        $("#btnMerge").css("display", "");
        $("#tabBasicInfo").html("查看");
        $("#tabContent").show();
        $("#tabContent1").css("display", "none");
        if (id != null) {
            muluid = id;
        }
        mode = _VIEW;
        this.onTab();
    };
 
    //判断是否根目录
    function isTop() {
        if (mode != _VIEW) return;
        if ($("muluid").val() == "" || $("muluid").val() == "0") {
            $("#btnAddBrother").css("display", "none");
            $("#btnEdit").css("display", "none");
        } else {
            $("#btnAddBrother").css("display", "");
            $("#btnEdit").css("display", "");
        }
    }
};
//对象初始化
var f_node = new f_node_def();
 
 
//F1 排序界面初始化
function initPaiXu() {
    var Tree = document.getElementById("OrderTree");
    var id = document.getElementById("muluid").value;
    Tree.innerHTML = "";
    $.ajax({
        type: 'post',
        url: 'initsort',
        data: {id: id},
        success: function (data) {
            var json = data;
            Tree.size = json.count;
            var List = json.children;
            for (i = 0; i < List.length; i++) {
                Tree.innerHTML+="<li onclick='SetZiYuanSelect(this);' resourceid='" + List[i].id + "'>"
                    + "<a href='javascript:void(0);' style='color:black;'>"
                    + "<span style='padding-left:9px;'>" + List[i].name + "</span>"
                    + "</a>";
            }
        },
        error: function (data) {
            alert("未知错误");
            window.location = window.location;
        }
    });
}
 
//F2 资源排序界面初始化
function initZyPaiXu() {
    var Tree = document.getElementById("ZyOrderTree");
    var id = document.getElementById("muluid").value;
    Tree.innerHTML = "";
    $.ajax({
        type: 'post',
        url: 'initzysort',
        data: {id: id},
        success: function (data) {
            var json = data;
            Tree.size = json.count;
            var List = json.children;
            for (i = 0; i < List.length; i++) {
                Tree.innerHTML += "<li onclick='SetSelect(this);' resourceid='" + List[i].id + "'>"
                    + "<a href='javascript:void(0);' style='color:black;'>"
                    + "<span style='padding-left:9px;'>" + List[i].name + "</span>"
                    + "</a>";
            }
        },
        error: function (data) {
            alert("未知错误");
            window.location = window.location;
        }
    });
}
 
//F3 新增子集界面
function Add() {
    $("#tabBasicInfo").click()
    $("#btnAddBrother").css("display", "none");
    $("#btnAddSon").css("display", "none");
    $("#btnEdit").css("display", "none");
    $("#btnReturn").css("display", "");
    $("#btnDelete").css("display", "none");
    $("#tabSort").css("display", "none");
    $("#ZiYuanSort").css("display", "none");
    $("#tabRight").css("display", "none");
    $("#tabOther").css("display", "none");
    $("#tabBasicInfo").html("增加");
    $("#tabContent1").show();
    $("#tabContent").css("display", "none");
    $("#butSave").css("display", "");
    $("#butEdit").css("display", "none");
    var id = $("#muluid").val();
    if (id == "")
        id = 0;
    $.ajax({
        type: 'post',
        url: 'addchildren',
        data: {id: id},
        success: function (data) {
            var json = eval("(" + data + ")");
            $("#afname").val(json.name);
            $("#afid").val(json.id);
            $("#abianma").val(json.oId);
            $("#amingzi").val("");
            $("#firstZM").val("");
            $("#ashuoming").val("");
            $("#abeizhu").val("");
            $("#aicon").val("");
        },
        error: function (data) {
            alert("请选择目标父级");
            window.location = window.location;
        }
    });
}
 
//F4 编目调整方法
function Sort() {
    var id = "";
    var list = $("#OrderTree li");
    for (var i = 0; i < list.length; i++) {
        if (i > 0) id += "|";
        id += list[i].getAttribute("resourceid");
    }
    var Tree = document.getElementById("OrderTree");
    var pid = document.getElementById("muluid").value;
    $.ajax({
        type: 'post',
        url: 'sort',
        data: {id: id, pid: pid},
        success: function (data) {
            var json = data;
            Tree.innerHTML = "";
            Tree.size = json.count;
            var List = json.children;
            for (i = 0; i < List.length; i++) {
                Tree.innerHTML += "<li onclick='SetSelect(this);' resourceid='" + List[i].id + "'>"
                    + "<a href='javascript:void(0);' style='color:black;'>"
                    + "<span style='padding-left:9px;'>" + List[i].name + "</span>"
                    + "</a>";
            }
            alert("排序成功!");
        },
        error: function (data) {
            alert("未知错误");
            window.location = window.location;
        }
    });
}
 
//F5 资源调整方法
function ZySort() {
    var ids = "";
    var list = $("#ZyOrderTree li");
    for (var i = 0; i < list.length; i++) {
        if (i > 0) ids += "|";
        ids += list[i].getAttribute("resourceid");
    }
    var Tree = document.getElementById("ZyOrderTree");
    var pid = document.getElementById("muluid").value;
    $.ajax({
        type: 'post',
        url: 'zysort',
        data: {ids: ids, pid: pid},
        success: function (data) {
            var json = data;
            Tree.innerHTML = "";
            //Tree.size = json.count;
            var List = json.children;
            for (i = 0; i < List.length; i++) {
                Tree.innerHTML += "<li onclick='SetSelect(this);' resourceid='" + List[i].id + "'>"
                    + "<a href='javascript:void(0);' style='color:black;'>"
                    + "<span style='padding-left:9px;'>" + List[i].name + "</span>"
                    + "</a>";
            }
            alert("排序成功!");
        },
        error: function (data) {
            alert("未知错误");
            window.location = window.location;
        }
    });
}
 
//F6 删除方法
function Delete() {
    var id = $("#muluid").val();
    $.ajax({
        type: 'post',
        url: 'isDelete',
        data: {id: id},
        success: function (data) {
            if(data == "-1") {
                if(confirm("该目录下存在资源,删除该目录将会删除该目录下的资源,是否确定删除?")) {
                    $.ajax({
                        type: 'post',
                        url: 'delete',
                        data: {id: id},
                        success: function (data) {
                            alert(data);
                            window.location = window.location;
                        }
                    })
                }
            }
            else {
                alert(data);
                window.location = window.location;
            }
        }
    })
}
 
//F7 新增同级方法
function AddBrother() {
    $("#tabBasicInfo").click()
    $("#btnAddBrother").css("display", "none");
    $("#btnAddSon").css("display", "none");
    $("#btnEdit").css("display", "none");
    $("#btnReturn").css("display", "");
    $("#btnDelete").css("display", "none");
    $("#tabSort").css("display", "none");
    $("#ZiYuanSort").css("display", "none");
    $("#tabRight").css("display", "none");
    $("#tabOther").css("display", "none");
    $("#tabBasicInfo").html("增加");
    $("#tabContent1").show();
    $("#tabContent").css("display", "none");
    $("#butSave").css("display", "");
    $("#butEdit").css("display", "none");
    var id = $("#muluid").val();
    if (id == "")
        id = 0;
    $.ajax({
        type: 'post',
        url: 'addbrother',
        data: {id: id},
        success: function (data) {
            var json = eval("(" + data + ")");
            $("#afname").val(json.name);
            $("#afid").val(json.pId);
            $("#abianma").val(json.oId);
            $("#amingzi").val("");
            $("#firstZM").val("");
            $("#ashuoming").val("");
            $("#abeizhu").val("");
            $("#aicon").val("");
        },
        error: function (data) {
            alert("请选择目标父级");
            window.location = window.location;
        }
    });
}
 
//F8 修改界面方法
function Edit() {
    var div = $("#tabContent");
    $("#tabBasicInfo").click()
    $("#btnAddBrother").css("display", "none");
    $("#btnAddSon").css("display", "none");
    $("#btnEdit").css("display", "none");
    $("#btnReturn").css("display", "");
    $("#btnDelete").css("display", "none");
    $("#tabSort").css("display", "none");
    $("#ZiYuanSort").css("display", "none");
    $("#tabRight").css("display", "none");
    $("#tabOther").css("display", "none");
    $("#tabBasicInfo").html("修改");
    $("#tabContent1").show();
    $("#tabContent").css("display", "none");
    $("#butSave").css("display", "none");
    $("#butEdit").css("display", "");
    var id = $("#muluid").val();
    $.ajax({
        type: 'post',
        url: 'edit',
        data: {id: id},
        dataType: 'json',
        success: function (data) {
            // var json = eval("(" + data + ")");
            var json = data.result;
            $("#afname").val(json.fname);
            $("#aid").val(json.id);
            $("#afid").val(json.Pid);
            $("#abianma").val(json.oId);
            $("#amingzi").val(json.name);
            $("#firstZM").val(json.firstPY);
            $("#ashuoming").val(json.descrip);
            if (json.remark != "null") {
                $("#abeizhu").val(json.remark);
            }
            if (json.icon != "null"&&json.icon!="") {
                $("#aicon").val(json.icon);
                $("#photo").attr("src","/uploadPath/"+json.icon);
            }
        },
        error: function (data) {
            //alert("error");
            alert(data);
        }
    });
}
 
//F9 提交面目修改方法
function Editpost() {
    if (form2.valid()) {
        var image = $('#uploadInput')[0].files[0];
        if (image != null) {
            var formdata = new FormData();
            formdata.append('myFile', $('#uploadInput')[0].files[0]);
            $.ajax({
                url: "/res/testuploadimg",
                type: "POST",
                data: formdata,
                cache: false,
                async: false,
                processData: false,  // 告诉jQuery不要去处理发送的数据
                contentType: false,  // 告诉jQuery不要去设置Content-Type请求头
                success: function (data) {
                    if (data == -1) {
                        alert("文件格式不正确,请重新上传!");
                    } else if (data == 0) {
                        alert("上传图片失败");
                    } else {
                        $("#aicon").val(data);
                        jQuery('#formBasicInfo').ajaxSubmit({
                            url: 'saveedit',
                            type: 'post',
                            success: function (data) {
                                alert(data);
                                window.location = window.location;
                            }
                        })
                    }
                }
            })
        }
        else{
            jQuery('#formBasicInfo').ajaxSubmit({
                url: 'saveedit',
                type: 'post',
                success: function (data) {
                    alert(data);
                    window.location = window.location;
                }
            })
        }
 
    }
}
 
//F10 目录新增方法
function Insert() {
    if (form2.valid()) {
        var image = $('#uploadInput')[0].files[0];
        if (image != null) {
            var formdata = new FormData();
            formdata.append('myFile', $('#uploadInput')[0].files[0]);
            $.ajax({
                url: "/res/testuploadimg",
                type: "POST",
                data: formdata,
                cache: false,
                async: false,
                processData: false,  // 告诉jQuery不要去处理发送的数据
                contentType: false,  // 告诉jQuery不要去设置Content-Type请求头
                success: function (data) {
                    if (data == -1) {
                        alert("文件格式不正确,请重新上传!");
                    } else if (data == 0) {
                        alert("上传图片失败");
                    } else {
                        $("#aicon").val(data);
                        jQuery('#formBasicInfo').ajaxSubmit({
                            url: 'insert',
                            type: 'post',
                            success: function (data) {
                                alert(data);
                                window.location = window.location;
                            }
                        });
                    }
                }
            })
        }
        else{
            jQuery('#formBasicInfo').ajaxSubmit({
                url: 'insert',
                type: 'post',
                success: function (data) {
                    alert(data);
                    window.location = window.location;
                }
            });
        }
 
    }
}
 
//F11 资源调整,子树初始化方法
function initSonTree() {
    var setting1 = {
        view: {
            selectedMulti: false
        },
        check: {
            enable: true
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            //点击节点
            //onClick: onClick,
            //展开节点
            //onExpand: onExpand,
            //拖动结束之前
            //beforeDrop: beforeDrop,
            //拖动结束
            //onDrop: onDrop
        },
        async: {
            enable: true,
            url: 'selectmuluandziyuan',
            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 zNodes1 = {id: 0, name: "原目录", pId: -1, isParent: true, "nocheck": true,iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'};
    var setting = {
        view: {
            selectedMulti: false
        },
        check: {
            enable: true,
            chkboxType: {"Y": "s", "N": "s"}
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            //点击节点
            //onClick: onClick,
            //展开节点
            //onExpand: onExpand,
            //拖动结束之前
            //beforeDrop: beforeDrop,
            //拖动结束
            //onDrop: onDrop
 
        },
        async: {
            enable: true,
            url: '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, "nocheck": true,iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'};
    $.fn.zTree.init($("#zytreesonl"), setting1, zNodes1); //初始化zTree
    $.fn.zTree.init($("#zytreesonr"), setting, zNodes);
}
 
//F12 资源位置调整界面
function Merge() {
    $("#divTabs").css("display", "none");
    $("#divTabs2").css("display", "");
    $("#btnReturn").css("display", "");
    $("#btnAddSon").css("display", "none");
    $("#btnMerge").css("display", "none");
    $("#btnDelete").css("display", "none");
    $("#btnEdit").css("display", "none");
    initSonTree();
 
}
 
//F13 资源位置调整方法
function GetCheckedAll() {
    var ids = "";
    var treeObj = $.fn.zTree.getZTreeObj("zytreesonl");
    var nodes = treeObj.getCheckedNodes(true);
    if (nodes.length < 1) {
        alert("请选择要调整的资源")
        return;
    }
    for (var i = 0; i < nodes.length; i++) {
        if(nodes[i].isParent) {
            continue;
        }
        ids = ids + nodes[i].id + ";";
    }
    var treeObj2 = $.fn.zTree.getZTreeObj("zytreesonr");
    var nodes2 = treeObj2.getCheckedNodes(true);
    if (nodes2.length > 1) {
        alert("目标目录只能是一个");
        return;
    }
    if (nodes2 < 1) {
        alert("请选择目标目录");
        return;
    }
    var fid = nodes2[0].id;
    $.ajax({
        type: 'post',
        url: '/res/OnemapCatalog/manage/catalog/merge',
        data: {ids: ids, fid: fid},
        success: function (data) {
            alert(data);
            window.location = window.location;
        }
    });
}
 
//F14 初始化资源排序列表
function initZyPaiXu() {
    var Tree = document.getElementById("ZyOrderTree");
    var id = document.getElementById("muluid").value;
 
    Tree.innerHTML = "";
    $.ajax({
        type: 'post',
        url: 'initzysort',
        data: {id: id},
        success: function (data) {
            var json = data;
            Tree.size = json.count;
            var List = json.children;
            for (i = 0; i < List.length; i++) {
                Tree.innerHTML += "<li onclick='SetSelect(this);' resourceid='" + List[i].id + "'>"
                    + "<a href='javascript:void(0);' style='color:black;'>"
                    + "<span style='padding-left:9px;'>" + List[i].name + "</span>"
                    + "</a>";
            }
        },
        error: function (data) {
            alert("未知错误");
            window.location = window.location;
        }
    });
}