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.
 
 
 
 
 
 

365 lines
16 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 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 = "DEPT"; //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": '<%=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
},
"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%>');
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;
$("#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.deptname = " + this.deptname);
//alert(" this.organdeptname = " + this.organdeptname);
//alert(" this.upperdeptname = " + this.upperdeptname);
var testID = this.id;
testID = testID.substring(1, 2);
testID = testID.replace(" ", "");
if (testID == "9") {
//alert("추가할 수 없습니다.");
} else {
iChkCnt = iChkCnt + 1;
//parent.putSelId(this.id);
//ie10,11 에서 undefined 문제 해결
var upperdeptname=$(this).attr('upperdeptname');
if(!upperdeptname)upperdeptname='';
parent.putSelId2(this.id,
$(this).attr('deptname'),
$(this).attr('organdeptname'),
upperdeptname);
}
//parent.putSelId(this.id);
});
if (iChkCnt == 0) {
alert('<%=Moumi.getMessageBundle().getString("moumi.message.doc.SubmitDevision")%>'); //제출부서를 선택해주세요.
} else {
try {
$.customIndicator.show(window.parent); // 2014.10.08 by youngjun cho. (loading indicator 추가)
} catch(e) {
alert(e);
}
//오른쪽의 부서 리스트에 표시된다.
parent.document.list.submit();
try {
$.customIndicator.hide(window.parent); // 2014.10.08 by youngjun cho. (loading indicator 추가)
} catch(e) {
alert(e);
}
}
});
//조직도에서 검색된 노드로 포커스를 이동시킨다. 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) {
iChkCnt = 0
var NODE = $.jstree._focused().get_selected();
var nodeId = $(NODE).attr("id");
var deptname = $(NODE).attr("deptname");
var organdeptname = $(NODE).attr("organdeptname");
var upperdeptname = $(NODE).attr("upperdeptname");
if (deptname == undefined) { deptname = ""; }
if (organdeptname == undefined) { organdeptname = ""; }
if (upperdeptname == undefined) { upperdeptname = ""; }
//alert(" nodeId = " + nodeId);
//alert(" deptname = " + deptname);
//alert(" organdeptname = " + organdeptname);
//alert(" upperdeptname = " + upperdeptname);
if (nodeId == undefined) {
return;
}
if (nodeId.length > 10 || nodeId == 'ROOT') { // this.id == 'ROOT')
return;
}
var testID = nodeId;
testID = testID.substring(1, 2);
testID = testID.replace(" ", "");
if (testID == "9") {
} else {
iChkCnt = iChkCnt + 1;
//parent.putSelId(nodeId);
parent.putSelId2(nodeId, deptname, organdeptname, upperdeptname);
}
//parent.putSelId(nodeId);
if (iChkCnt == 0) {
alert('<%=Moumi.getMessageBundle().getString("moumi.message.doc.SubmitDevision")%>'); //제출부서를 선택해주세요.
} else {
//오른쪽의 부서 리스트에 표시된다.
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>