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.
 
 
 
 
 
 

286 lines
13 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 dtID = HttpSSOLogin.getDeptID(request);
String rootId = request.getParameter("rootID");
String userYN = request.getParameter("userYN");
if (userYN == null) {
userYN = "N";
} else {
userYN = "Y";
}
//System.out.println("rootId="+rootId+"::::userYN="+userYN);
%>
<!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>
<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 type="text/javascript" class="source">
var gSearchGubun = "USER"; //default=USER
//@@@ var gblSearching = false;
$(function() {
$("#newTree").jstree({
"plugins": ["themes", "json_data", "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":'<%=rootId%>' }
"attr": {"id": "ROOT", "rel": '<%=dtID%>', "rootid": '<%=rootId%>'}
}
],
"ajax": {
"type": "POST",
"url": "/servlet/kr.co.kihyun.tree.Tree3",
"data": function(n) {
var data = {};
data.id = n.attr("id");
//Çʿ信 ÀÇÇØ Ãß°¡
data.rel = n.attr("rel");
data.rootId = n.attr("rootId");
data.gubun = "ORGAN";
//data.userYN='<%=userYN%>';
data.userYN = 'Y';
return data;
}
},
"progressive_render": true
},
"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,
"success": function(data) {
//alert("data = " + data);
if(data.length == 0 || data == "#" || data == ('#'+'<%=rootId%>')) {
alert('<%=Moumi.getMessageBundle().getString("moumi.message.popup.notSearchUserDept")%>'); //°Ë»öµÈ »ç¿ëÀÚ/ºÎ¼­¸íÀÌ ¾ø½À´Ï´Ù.
return;
}
}
}
},
"types": {
"valid_children": ["ROOT", "DEPT", "USER"],
"types": {
"ROOT": {
"icon": {"image": "/totsys/common/images/pc-user.gif"}
},
"USER": {
"icon": {"image": "/totsys/common/images/person.png"}
}
}
},
"core": {'initially_open': ['ROOT', '<%=rootId%>']}
});
$("#searchClear").click(function() {
$("#newTree").jstree("clear_search");
$("#searchResult").empty();
});
$("#search").click(function() {
//@@@ gblSearching = true;
gSearchGubun = $('#searchType').text(); //USER,DEPT
//alert("gSearchGubun = " + gSearchGubun);
$("#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");
if(gSearchGubun !== tmpRel) {
//alert("rel = " + tmpRel );
try {
$(this).removeClass("jstree-search");
} catch(e) {
alert(e);
}
}
});
$("#moveType").text("down");
$("#focusMove").click();
}
//@@@ gblSearching = false;
//alert("Found " + data.rslt.nodes.length + " nodes matching '" + data.rslt.str + "'.");
});
//¼±ÅÃµÈ ´ã´çÀÚ¸¦ È£ÃâµÈ ºÎ¸ðâ¿¡ ¼³Á¤ÇÑ´Ù.
$("#newTree").bind("select_node.jstree", function(e, data) {
//@@@ if(gblSearching) { return; }
//alert(data.inst.get_text(data.rslt.obj) + " - " + data.rslt.obj.attr("id")); // id - Text
//alert(data.inst.get_text(data.rslt.obj) + " - " + data.rslt.obj.attr("name")); // name - Text
//alert(data.inst.get_text(data.rslt.obj) + " - " + data.rslt.obj.attr("rel")); // rel - Text
//ºÎ¼­¸íÀ¸·Î °Ë»öÇÑ °æ¿ì¿¡ ¼±ÅÃÀÌ µÇÁö ¾ÊÀ¸´Ï±î ¾Æ·¡,À§·Î Æ÷Ä¿½º¸¦ À̵¿½Ãų ¼ö ¾ø´Ù.
/*
if(data.rslt.obj.attr("rel") !== "USER") {
//alert('<%=Moumi.getMessageBundle().getString("moumi.message.popup.selectUser")%>'); //»ç¿ëÀÚ¸¦ ¼±ÅÃÇϼ¼¿ä!
$('#newTree').jstree('deselect_all');
//return;
}
*/
parent.putNodeType(data.rslt.obj.attr("rel"), data.rslt.obj.attr("id"), data.rslt.obj.attr("deptname"), data.inst.get_text(data.rslt.obj));
});
//Á¶Á÷µµ¿¡¼­ °Ë»öµÈ ³ëµå·Î Æ÷Ä¿½º¸¦ À̵¿½ÃŲ´Ù. 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);
var verticalCenterPosition = $("html").height() / 2;
//// Áï½ÃÀ̵¿
//$("html").scrollTop(elementOffset.top - verticalCenterPosition);
// ºÎµå·´°Ô À̵¿(500ms)
$("html").animate({
scrollTop: elementOffset.top - verticalCenterPosition
}, 500);
} catch(e) {
alert(e);
}
});
});
//´Ù¿î,¾÷ ¹öư Ŭ¸¯ ½Ã : 2.ÇöÀç currentOffsetTop º¸´Ù Å« °ª¿¡ Á¸ÀçÇÏ´Â id¸¦ ã¾Æ¼­ ¸®ÅÏÇÑ´Ù.
function getDeptUserId(strId, intTop, strType) {
//xxx 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) {
//xxx 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>