<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>
|