knuGit Moumi
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.
 
 
 
 
 
 

396 lines
19 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");
System.out.println("rootID >>>>>> " + rootId );
String userYN = request.getParameter("userYN");
String selfDeptYn = request.getParameter("selfDeptYn");
if (userYN == null || userYN == "") {
userYN = "N";
} else {
userYN = "Y";
}
//System.out.println("newTreeUserShare.jsp===============================");
//System.out.println("rootId="+rootId);
//System.out.println("userYN="+userYN);
//System.out.println("selfDeptYn="+selfDeptYn);
//System.out.println("===================================================");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<script type="text/javascript" src="/totsys/common/js/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="/totsys/common/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/totsys/common/js/jquery.hotkeys.js"></script>
<script type="text/javascript" src="/totsys/common/js/jquery.jstree.js"></script>
<script type="text/javascript" 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 type="text/javascript" class="source">
var gSearchGubun = "USER"; //default=USER
var gblSearched = false;
$(function() {
var iChkCnt = 0;
$("#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": '<%=rootId%>'}
}
],
"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
},
"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.word;
// data.startId = encodeURIComponent('<%=rootId%>');
// data.gubun = str.type;
data.keyWord = str;
data.startId = encodeURIComponent('<%=rootId%>');
data.gubun = gSearchGubun;
return data;
},
//"async": false,
"async": true,
"success": function(data) {
alert("rootID == " + '<%=rootId%>');
if(data.length == 0 || data == "#" || data == ('#'+'<%=rootId%>')) {
alert('<%=Moumi.getMessageBundle().getString("moumi.message.popup.notSearchUserDept")%>'); //검색된 사용자/부서명이 없습니다.
gblSearched = false;
} else {
gblSearched = true;
}
//데이터로딩이 늦어서 에러가 발생하므로 사용하기 어려움.
//$("#moveType").text("down");
//$("#focusMove").click();
//$("#newTree").bind("search.jstree", function (e, data) { 을 사용한다.
},
"beforeSend" : function() {
$.customIndicator.show(window.parent);
},
"complete" : function() {
$.customIndicator.hide(window.parent);
}
}
},
"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'] }
});
//더블클릭 : 사용자 리스트로 추가된다.
$("#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();
});
//로드시 부서 ID가 있는 경우에는 전체 펼치기
$("#newTree").bind("loaded.jstree", function(event, data) {
<% if("Y".equals(selfDeptYn)) { %>
$("#newTree").jstree("open_all");
<% } %>
});
$("#newTree").bind("check_node.jstree", function(e, data) {
data.inst.open_node(data.rslt.obj, false, true);
});
$("#search").click(function() {
//2014.09.03 Update by KWON,HAN : 찾은 문자열이 이탤리체, 아쿠아색으로 변경되지 않음을 해결
// var str = {};
// str.word = $('#searchWord').text();
// str.type = $('#searchType').text();
// //alert("str.word = " + str.word );
// //alert("str.word = " + str.type );
// $("#newTree").jstree("search", str);
gblSearched = false;
gSearchGubun = $('#searchType').text(); //USER,DEPT
var searchResult = $("#newTree").jstree("search", $('#searchWord').text());
//alert("searchResult=" + searchResult);
//### 검색을 종료한 후에 실행된다.
//$("#newTree").bind("search.jstree", function (e, data) {
});
//### 검색을 종료한 후에 실행된다. : 검색된 것이 있으면 최초로 포커스를 이동시킨다.
$("#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);
}
}
});
//찾은 것이 있다면 ...
if(gblSearched == true) {
$("#moveType").text("down");
$("#focusMove").click();
}
}
//alert("Found " + data.rslt.nodes.length + " nodes matching '" + data.rslt.str + "'.");
});
$("#searchClear").click(function() {
$("#newTree").jstree("clear_search");
$("#searchResult").empty();
});
//체크된것이 추가버튼을 클릭하면 사용자 리스트로 추가된다.
$("#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("select_node.jstree", function (event, data) {
// //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;
// }
// //data.inst._fix_scroll(data.rslt.obj)
// });
});
//다운,업 버튼 클릭 시 : 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>