You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
344 lines
15 KiB
344 lines
15 KiB
<%@ |
|
page contentType="text/html; charset=UTF-8" |
|
import="kr.co.kihyun.beans.user.HttpSSOLogin" |
|
import="kr.co.kihyun.moumi.Moumi" |
|
import="kr.co.kihyun.lang.MString" |
|
import="kr.co.kihyun.lang.MLong" |
|
import="kr.co.kihyun.beans.user.Dept" |
|
import="kr.co.kihyun.beans.user.PartList" |
|
%> |
|
|
|
<% |
|
String rootId = request.getParameter("rootID"); |
|
String usID = HttpSSOLogin.getLoginID(request); |
|
String deptID = HttpSSOLogin.getDeptID(request); |
|
System.out.println("rootId = " + rootId); |
|
String userYN = "Y"; |
|
%> |
|
|
|
<!DOCTYPE html> |
|
<html lang="ko"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<title>트리메뉴</title> |
|
<script src="/totsys/common/js/jquery-1.12.4.min.js"></script> |
|
<script src="/totsys/common/js/jquery.cookie.js"></script> |
|
<script src="/totsys/common/js/jquery.hotkeys.js"></script> |
|
<script src="/totsys/common/js/jquery.jstree.js"></script> |
|
<script src="/totsys/common/js/jquery.custom.indicator.js"></script> |
|
<style> |
|
#newTree { text-align: justify; font-size:9pt; vertical-align:middle; } |
|
</style> |
|
</head> |
|
<body> |
|
<input type="button" class="button" value="Search" id="search" style="display:none" /> |
|
<input type="button" class="button" value="Search clear" id="searchClear" style="display:none" /> |
|
<input type="button" class="button" value="checked Id" id="checkbtn" style="display:none" /> |
|
<input type="button" class="button" value="focus Move" id="focusMove" style="display:none" /> |
|
<div id="searchType" style="display:none"></div> |
|
<div id="searchWord" style="display:none"></div> |
|
<div id="moveType" style="display:none"></div> |
|
<div id="newTree" class="newTree"></div> |
|
|
|
<script class="source"> |
|
var gSearchGubun = "USER"; //default=DEPT |
|
var gblSearched = false; |
|
|
|
$(function() { |
|
$("#newTree").jstree({ |
|
"plugins": ["themes", "json_data", "checkbox", "search", "types", "ui", "core"], |
|
"themes": { |
|
"theme": "classic", |
|
"dots": true, |
|
"icons": true, |
|
"url": "/totsys/common/js/themes/classic/style.css" |
|
}, |
|
"json_data": { |
|
"data": [ |
|
{ |
|
"data": "조직도", |
|
"state": "closed", |
|
"attr": {"id": "ROOT", "rel": "ROOT", "rootid": '<%=deptID%>'} |
|
} |
|
], |
|
"ajax": { |
|
"type": "POST", |
|
"url": "/servlet/kr.co.kihyun.tree.Tree", |
|
"data": function(n) { |
|
var data = {}; |
|
data.id = n.attr("id"); |
|
data.rootId = n.attr("rootId"); |
|
data.gubun = "ORGAN"; |
|
data.userYN = '<%=userYN%>'; |
|
return data; |
|
} |
|
}, |
|
"progressive_render": true |
|
}, |
|
"types": { |
|
"valid_children": ["ROOT", "DEPT", "USER"], |
|
"types": { |
|
"ROOT": { |
|
"icon": {"image": "/totsys/common/images/pc-user.gif"} |
|
}, |
|
"USER": { |
|
"icon": {"image": "/totsys/common/images/person.png"} |
|
} |
|
} |
|
}, |
|
"checkbox": {state_type: "three-state"}, |
|
"search": { |
|
"case_insensitive": true, |
|
"ajax": { |
|
"type": "POST", |
|
"url": "/servlet/kr.co.kihyun.tree.TreeSearch", |
|
"data": function(str) { |
|
var data = {}; |
|
data.keyWord = str; |
|
data.startId = encodeURIComponent('<%=rootId%>'); |
|
data.gubun = gSearchGubun; |
|
return data; |
|
}, |
|
//"async": false, |
|
"async": true, |
|
"success": function(data) { |
|
//alert("data = " + data); |
|
if (data.length == 0 || data == "#" || data == ('#' + '<%=rootId%>')) { |
|
alert('<%=Moumi.getMessageBundle().getString("moumi.message.popup.notSearchGroupDept")%>'); //검색된 그룹명/부서명이 없습니다. |
|
gblSearched = false; |
|
} else { |
|
gblSearched = true; |
|
} |
|
}, |
|
"beforeSend" : function() { |
|
$.customIndicator.show(window.parent); |
|
}, |
|
"complete" : function() { |
|
$.customIndicator.hide(window.parent); |
|
} |
|
} |
|
}, |
|
"core": {'initially_open': ['ROOT']} |
|
}); |
|
|
|
$("#searchClear").click(function() { |
|
$("#newTree").jstree("clear_search"); |
|
$("#searchResult").empty(); |
|
}); |
|
|
|
$("#search").click(function() { |
|
gblSearched = false; |
|
gSearchGubun = "USER"; |
|
$("#newTree").jstree("search", $('#searchWord').text()); |
|
}); |
|
|
|
//### 검색을 종료한 후에 실행된다. : 검색된 것이 있으면 최초로 포커스를 이동시킨다. |
|
$("#newTree").bind("search.jstree", function(e, data) { |
|
if (data.rslt.nodes.length > 0) { |
|
//1.이전에 선택된 모든 노드를 해제한다. |
|
$('#newTree').jstree('deselect_all'); |
|
|
|
//2.검색유형과 다른 것은 style를 제거한다. |
|
var tmpRel = ""; |
|
$("#newTree").find(".jstree-search").each(function() { |
|
tmpRel = $(this).parent("li").attr("rel"); |
|
//alert("rel = " + tmpRel ); |
|
if (gSearchGubun !== tmpRel) { |
|
try { |
|
$(this).removeClass("jstree-search"); |
|
} catch (e) { |
|
alert(e); |
|
} |
|
} |
|
}); |
|
|
|
//찾은 것이 있다면 ... |
|
if (gblSearched == true) { |
|
$("#moveType").text("down"); |
|
$("#focusMove").click(); |
|
} |
|
} |
|
|
|
//@@@ gblSearching = false; |
|
//alert("Found " + data.rslt.nodes.length + " nodes matching '" + data.rslt.str + "'."); |
|
}); |
|
|
|
|
|
$("#newTree").bind("check_node.jstree", function(e, data) { |
|
data.inst.open_node(data.rslt.obj, false, true); |
|
}); |
|
|
|
//체크된것이 추가버튼을 클릭하면 사용자 리스트로 추가된다. |
|
$("#checkbtn").click(function() { |
|
iChkCnt = 0 |
|
|
|
$("#newTree").jstree("get_checked", null, true).each(function() { |
|
//alert(" this.id = " + this.id); |
|
//alert(" this.rel = " + this.rel); |
|
//alert(" this.SYSAUTH = " + this.SYSAUTH); |
|
//alert(" this.name = " + this.name); |
|
//alert(" this.deptid = " + this.deptid); |
|
//alert(" this.deptname = " + this.deptname); |
|
if (this.id == "ROOT" || this.rel == "ROOT" || this.rel == "DEPT") { |
|
return; |
|
} |
|
iChkCnt = iChkCnt + 1; |
|
//parent.putSelId(this.id, this.name, this.deptname); |
|
//ie10,11 호환성 수정 undefined 수정, 부서추가 막음 |
|
var name=$(this).attr('name'); |
|
if(!name||name==''){ |
|
//name=$(this).attr('deptname'); |
|
return; |
|
}else{ |
|
|
|
} |
|
parent.putSelId(this.id,name,$(this).attr('deptname')); |
|
}); |
|
|
|
if (iChkCnt == 0) { |
|
alert('<%=Moumi.getMessageBundle().getString("moumi.message.popup.selectUser")%>'); //사용자를 선택하세요! |
|
} else { |
|
//오른쪽의 사용자 리스트에 표시된다. |
|
parent.document.list.submit(); |
|
} |
|
}); |
|
|
|
//조직도에서 검색된 노드로 포커스를 이동시킨다. strType : down, up |
|
$("#focusMove").click(function() { |
|
var moveType = $("#moveType").text(); //down,up |
|
//alert("moveType = " + moveType); |
|
|
|
//1.현재 선택된 object의 offset.top를 구한다. |
|
var NODE = $.jstree._focused().get_selected(); |
|
var nodeId = $(NODE).attr("id"); |
|
if (nodeId == undefined) { |
|
nodeId = ""; |
|
} |
|
|
|
var currentObj = $('#' + nodeId); |
|
var currentOffset = currentObj.offset(); |
|
var currentOffsetTop = -1; |
|
if (currentOffset != null) { |
|
currentOffsetTop = currentOffset.top; |
|
} |
|
|
|
//2.현재 currentOffsetTop 보다 큰 값에 존재하는 id를 찾아서 리턴한다. |
|
var currentNodeId = ""; |
|
currentNodeId = getDeptUserId(nodeId, currentOffsetTop, moveType); |
|
|
|
//3.리턴된 id가 없다면 메세지를 띄우고 리턴한다. |
|
if (currentNodeId === null || currentNodeId === "") { |
|
alert("더 이상 찾을 수 없습니다."); |
|
return; |
|
} |
|
|
|
//4.이전에 선택된 모든 노드를 해제한다. |
|
$('#newTree').jstree('deselect_all'); |
|
|
|
//5.리턴된 id로 노드를 선택한다. |
|
$("#newTree").jstree("select_node", '#' + currentNodeId); //591 |
|
|
|
try { |
|
var selectedObj = $('#' + currentNodeId); |
|
var elementOffset = selectedObj.offset(); |
|
//alert("[offset.top] : " + elementOffset.top + "\n[offset.left] : " + elementOffset.left); |
|
//ie10,11 및 호환성 보기 까지 전부 동작하도록 수정 |
|
var verticalCenterPosition = $(window).height() / 2; |
|
//// 즉시이동 |
|
//$("html").scrollTop(elementOffset.top - verticalCenterPosition); |
|
|
|
// 부드럽게 이동(500ms) |
|
$("html").animate({ |
|
scrollTop: elementOffset.top - verticalCenterPosition |
|
}, 500); |
|
|
|
} catch (e) { |
|
alert(e); |
|
} |
|
}); |
|
|
|
//더블클릭 : 사용자 리스트로 추가된다. |
|
$("#newTree").bind("dblclick.jstree", function(e, data) { |
|
var NODE = $.jstree._focused().get_selected(); |
|
nodeId = $(NODE).attr("id"); |
|
nodeRel = $(NODE).attr("rel"); |
|
nodeName = $(NODE).attr("name"); |
|
nodeDeptId = $(NODE).attr("deptid"); |
|
nodeDeptName = $(NODE).attr("deptname"); |
|
//alert(" nodeId = " + nodeId); |
|
//alert(" nodeRel = " + nodeRel); |
|
//alert(" nodeName = " + nodeName); |
|
//alert(" nodeDeptId = " + nodeDeptId); |
|
//alert(" nodeDeptName = " + nodeDeptName); |
|
|
|
if (nodeId == undefined) { |
|
return; |
|
} |
|
if (nodeId == "ROOT" || nodeRel == "ROOT" || nodeRel == "DEPT") { |
|
alert('<%=Moumi.getMessageBundle().getString("moumi.message.popup.selectUser")%>'); //사용자를 선택하세요! |
|
return; |
|
} |
|
|
|
parent.putSelId(nodeId, nodeName, nodeDeptName); |
|
|
|
//오른쪽의 사용자 리스트에 표시된다. |
|
parent.document.list.submit(); |
|
}); |
|
|
|
}); |
|
|
|
|
|
//다운,업 버튼 클릭 시 : 2.현재 currentOffsetTop 보다 큰 값에 존재하는 id를 찾아서 리턴한다. |
|
function getDeptUserId(strId, intTop, strType) { |
|
//alert("strId = " + strId + ", intTop = " + intTop + ", strType = " + strType); |
|
var id = ""; |
|
var idArray = new Array(); |
|
var returnId = ""; |
|
var blSearchOk = false; |
|
|
|
if (strType === "down") { |
|
$("#newTree").find(".jstree-search").each(function() { |
|
id = $(this).parent("li").attr("id"); |
|
|
|
if (blSearchOk === false && strId !== id) { |
|
var selectedObj = $('#' + id); |
|
var elementOffset = selectedObj.offset(); |
|
|
|
if (elementOffset.top > intTop) { |
|
//alert("[offset.top] : " + elementOffset.top + "\n[offset.left] : " + elementOffset.left); |
|
returnId = id |
|
blSearchOk = true; |
|
} |
|
|
|
} |
|
}); |
|
} |
|
|
|
if (strType === "up") { |
|
$("#newTree").find(".jstree-search").each(function() { |
|
idArray.push($(this).parent("li").attr("id")); |
|
}); |
|
idArray.reverse(); |
|
|
|
for (var i = 0; i < idArray.length; i++) { |
|
id = idArray[i].toString(); |
|
|
|
if (blSearchOk === false && strId !== id) { |
|
var selectedObj = $('#' + id); |
|
var elementOffset = selectedObj.offset(); |
|
|
|
if (elementOffset.top < intTop) { |
|
//alert("[offset.top] : " + elementOffset.top + "\n[offset.left] : " + elementOffset.left); |
|
returnId = id |
|
blSearchOk = true; |
|
} |
|
} |
|
} |
|
} |
|
|
|
return returnId; |
|
} |
|
</script> |
|
|
|
</body> |
|
</html>
|
|
|