📄 structure.js
字号:
//create wholetable and init
var length;
if( this.subnode == null || this.subnode.length==0 )
length=1;
else
length=this.subnode.length;
var wholeTable = document.createElement("<table border='0' cellpadding='0' cellspacing='0' >");
var i,curRow,curCell,j;
for(i=0;i<3;i++){
if (i<=1) {
curRow = wholeTable.insertRow();
if (length == 1) {
curCell = curRow.insertCell();
curCell.noWrap = false;
} else {
curCell = curRow.insertCell();
curCell.noWrap = false;
curCell.colSpan=length-1;
curCell.style.display="none";
curCell = curRow.insertCell();
curCell.noWrap = true;
curCell = curRow.insertCell();
curCell.noWrap = false;
curCell.colSpan=length-1;
curCell.style.display="none";
}
} else {
curRow = wholeTable.insertRow();
for(j=0;j<length;j++){
curCell = curRow.insertCell();
curCell.noWrap = false;
if( j!=length-1 ){
curCell = curRow.insertCell();
curCell.noWrap = true;
if( !(length%2==0 && j==length/2-1) )
curCell.width="13";
}
}
}
}
wholeTable.rows[0].cells[0].height="20";
curRow = wholeTable.rows[2];
for(i=0;i< curRow.cells.length;i++){
curRow.cells[i].vAlign = "top";
}
//create viewNode
var viewNode = this.createViewNode(this.oid);
if (length == 1) {
initLevelViewNode(wholeTable.rows[1].cells[0] ,viewNode);
wholeTable.rows[1].cells[0].align="center";
} else {
initLevelViewNode(wholeTable.rows[1].cells[1] ,viewNode);
wholeTable.rows[1].cells[1].align="center";
}
if( needAdapt ){
adaptNodes[adaptNodes.length] = viewNode;
}
//create top line
var curImage = null ;
if( this.parent!=null ){
curRow = wholeTable.rows[0];
if( inParentIndex==0 ){
if( parentChildCount==1 ){
//insert " | "
curImage = document.createElement("<img src='" +contextPath+ "/images/orgvertical.gif' width='100' height='20'>");
if (length == 1) {
curRow.cells[0].appendChild(curImage);
curRow.cells[0].align="center";
} else {
curRow.cells[1].appendChild(curImage);
curRow.cells[1].align="center";
}
}else{
//insert " ┌──"
subTable = document.createElement("<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
subTable.insertRow();
subTable.rows[0].insertCell().width="50%";
subTable.rows[0].insertCell();
subTable.rows[0].insertCell().width="50%";
curImage = document.createElement("<img src='" +contextPath+ "/images/orgleft.gif' width='100' height='20'>");
subTable.rows[0].cells[1].appendChild(curImage);
subTable.rows[0].cells[2].background = contextPath + "/images/orghorizontal.gif";
if (length == 1) {
curRow.cells[0].appendChild(subTable);
curRow.cells[0].align="center";
} else {
curRow.cells[1].appendChild(subTable);
curRow.cells[1].align="center";
curRow.cells[2].background = contextPath + "/images/orghorizontal.gif";
}
}
}else if( parentChildCount%2==1 && inParentIndex==(parentChildCount-1)/2 ){
//insert "──┼──"
if (length == 1) {
curImage = document.createElement("<img src='" +contextPath+ "/images/orgcross.gif' width='100' height='20'>");
curRow.cells[0].appendChild(curImage);
curRow.cells[0].align="center";
curRow.cells[0].background = contextPath + "/images/orghorizontal.gif";
} else {
curImage = document.createElement("<img src='" +contextPath+ "/images/orgcross.gif' width='100' height='20'>");
curRow.cells[1].appendChild(curImage);
curRow.cells[1].align="center";
curRow.cells[0].background = contextPath + "/images/orghorizontal.gif";
curRow.cells[1].background = contextPath + "/images/orghorizontal.gif";
curRow.cells[2].background = contextPath + "/images/orghorizontal.gif";
}
}else if( inParentIndex==parentChildCount-1 ){
//insert "──┐"
subTable = document.createElement("<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
subTable.insertRow();
subTable.rows[0].insertCell().width="50%";
subTable.rows[0].insertCell();
subTable.rows[0].insertCell().width="50%";
curImage = document.createElement("<img src='" +contextPath+ "/images/orgright.gif' width='100' height='20'>");
subTable.rows[0].cells[1].appendChild(curImage);
subTable.rows[0].cells[0].background = contextPath + "/images/orghorizontal.gif";
if (length == 1) {
curRow.cells[0].appendChild(subTable);
curRow.cells[0].align="center";
} else {
curRow.cells[1].appendChild(subTable);
curRow.cells[1].align="center";
curRow.cells[0].background = contextPath + "/images/orghorizontal.gif";
}
}else{
//insert "──┬──"
if (length == 1) {
curImage = document.createElement("<img src='" +contextPath+ "/images/orgcenter.gif' width='100' height='20'>");
curRow.cells[0].appendChild(curImage);
curRow.cells[0].align="center";
curRow.cells[0].background = contextPath + "/images/orghorizontal.gif";
} else {
curImage = document.createElement("<img src='" +contextPath+ "/images/orgcenter.gif' width='100' height='20'>");
curRow.cells[1].appendChild(curImage);
curRow.cells[1].align="center";
curRow.cells[0].background = contextPath + "/images/orghorizontal.gif";
curRow.cells[1].background = contextPath + "/images/orghorizontal.gif";
curRow.cells[2].background = contextPath + "/images/orghorizontal.gif";
}
}
}
if( needAdapt ){
adaptImages[adaptImages.length] = curImage;
}
//create bottomY line
var subTable;
if( this.subnode!=null && this.subnode.length>0 ){
curRow = wholeTable.rows[2];
wholeTable.rows[2].style.display = this.open?"block":"none";
if (wholeTable.rows[0].cells.length > 1) {
wholeTable.rows[0].cells[0].style.display=this.open?"block":"none";
wholeTable.rows[0].cells[2].style.display=this.open?"block":"none";
wholeTable.rows[1].cells[0].style.display=this.open?"block":"none";
wholeTable.rows[1].cells[2].style.display=this.open?"block":"none";
}
for(i=0;i<length-1;i++){
if( length%2==0 && i==length/2-1 ){
//insert "──┴──"
subTable = document.createElement("<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
curRow.cells[i*2+1].appendChild(subTable);
subTable.insertRow();
curCell = subTable.rows[0].insertCell();
curCell.width="50%";
curCell = subTable.rows[0].insertCell();
curCell.align="center";
curCell = subTable.rows[0].insertCell();
curCell.width="50%";
subTable.rows[0].cells[0].background = contextPath + "/images/orghorizontal.gif";
curImage = document.createElement("<img src='" +contextPath+ "/images/orgtop.gif' width='100' height='20'>");
subTable.rows[0].cells[1].appendChild(curImage);
subTable.rows[0].cells[2].background = contextPath + "/images/orghorizontal.gif";
}else{
//insert "─────"
subTable = document.createElement("<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
curRow.cells[i*2+1].appendChild(subTable);
curCell = subTable.insertRow().insertCell();
curCell.height="20";
curCell.background = contextPath + "/images/orghorizontal.gif";
}
}
//call the child's createAllNode() method
if( this.open ){
var subViewNode;
for(i=0;i<length;i++){
subViewNode = this.getSubnode(i).createAllNodeH(i,length);
wholeTable.rows[2].cells[i*2].appendChild(subViewNode);
}
}
}
return wholeTable;
}
//create view Node --------------------------------------------------------------------------------------------------------
function NodeCreateViewNode(oid){
if( mode=="chart" ){
return this.createViewNodeH(oid);
}else{
return this.createViewNodeT(oid);
}
}
//show organization unit by tree model
function NodeCreateViewNodeT(oid){
var idUnitItem = "unititem" + oid;
var idItem = "item" + oid;
var aDiv = document.createElement("<div class='orgunitchartitemcell'>");
aDiv.treeNode = this;
this.viewNode = aDiv;
//create the Whole table
var wholeTable = document.createElement("<table width='100%' height='25' border='0' cellspacing='0' cellpadding='0' style='PADDING-RIGHT: 4px; PADDING-LEFT: 4px' >");
aDiv.appendChild(wholeTable);
var curRow = wholeTable.insertRow();
//create the first col
var curCell = curRow.insertCell();
curCell.height = "25";
curCell.width = "1%";
curCell.noWrap = true;
curCell.className = "subtableheader";
var clickHandle = "doEditNode(this.viewNode," + "this" + ");";
var curImage = document.createElement("<img id='" + idItem + "' onmouseover='" +clickHandle+ "' src='" +contextPath+ "/images/edit.gif' width='16' height='16' border='0' style='cursor:hand;' >");
curCell.appendChild( curImage );
curImage.viewNode = aDiv;
aDiv.editImage = curImage;
//create the second col
curCell = curRow.insertCell();
curCell.width = "50%";
curCell.height = "25";
curCell.noWrap = true;
curCell.innerText = this.name;
//create the third col
curCell = curRow.insertCell();
curCell.width = "49%";
curCell.height = "25";
curCell.noWrap = true;
return aDiv;
}
function NodeCreateViewNodeV(oid){
var idUnitItem = "unititem" + oid;
var idItem = "item" + oid;
var aDiv = document.createElement("<div class='orgunitchartitemcell'>");
aDiv.treeNode = this;
this.viewNode = aDiv;
//create the Whole table
var wholeTable = document.createElement("<table width='100%' border='0' cellspacing='0' cellpadding='0' style='PADDING-RIGHT: 2px; PADDING-LEFT: 2px' >");
aDiv.appendChild(wholeTable);
//create the first col of whole table.
var curCell = curRow.insertCell();
curCell.className = "subtableheader";
curCell.noWrap = true;
//create the subtable of first col
var subTable = document.createElement( "<table width='1' border='0' cellspacing='0' cellpadding='0'>" );
curCell.appendChild(subTable);
curRow = subTable.insertRow();
curRow.align="center";
curCell = curRow.insertCell();
curCell.height = "16";
var clickHandle = "doEditNode(this.viewNode," + "this" + ");";
var curImage = document.createElement("<img id='" + idItem + "' onmouseover='" +clickHandle+ "' src='" +contextPath+ "/images/edit.gif' width='16' height='16' border='0' style='cursor:hand;' >");
curCell.appendChild( curImage );
curImage.viewNode = aDiv;
aDiv.editImage = curImage;
curRow = subTable.insertRow();
curRow.align="center";
curCell = curRow.insertCell();
curCell.height = "16"
clickHandle = 'assignJob(this.viewNode.treeNode.oid);';
curImage = document.createElement("<img onclick='" +clickHandle + "' src='" +contextPath+ "/images/userbro.gif' width='16' height='16' border='0' style='cursor:hand;' >");
// curImage.alt = assignJobAltLabel;
curCell.appendChild( curImage );
curImage.viewNode = aDiv;
aDiv.assignJobImage = curImage;
//create the second col of whole table
curCell = wholeTable.rows[0].insertCell();
curCell.className = "subalterbar";
curCell.noWrap = true;
//create subtable of second col
subTable = document.createElement( "<table width='100' border='0' cellspacing='0' cellpadding='2'>" );
curCell.appendChild(subTable);
if( !isCompact ){
curRow = subTable.insertRow();
curCell = curRow.insertCell();
curCell.width = "1%";
curCell.align = "right";
curCell.noWrap = true;
curCell.innerText = codeKeyValue;
curCell = curRow.insertCell();
curCell.width = "100%";
curCell.noWrap = true;
curCell.innerText = this.code;
}
curRow = subTable.insertRow();
if( !isCompact ){
curCell = curRow.insertCell();
curCell.width = "1%";
curCell.align = "right";
curCell.vAlign = "top";
curCell.noWrap = true;
curCell.innerText = nameKeyValue;
}
curCell = curRow.insertCell();
curCell.width = "100%";
curCell.noWrap = true;
curCell.innerText = this.name;
if( !isCompact ){
curRow = subTable.insertRow();
curCell = curRow.insertCell();
curCell.width = "1%";
curCell.align = "right";
curCell.vAlign = "top";
curCell.noWrap = true;
curCell = curRow.insertCell();
curCell.width = "100%";
curCell.noWrap = true;
}
//create subtable of second col
subTable = document.createElement( "<table width='100' border='0' cellspacing='0' cellpadding='2'>" );
wholeTable.rows[0].cells[1].appendChild(subTable);
aDiv.chiefJobTable = subTable;
curRow = subTable.insertRow();
curCell = curRow.insertCell();
curCell.width = "100%";
curCell.align = "left";
curCell.vAlign = "center";
curCell.noWrap = true;
//create the third col of whole table
curCell = wholeTable.rows[0].insertCell();
curCell.noWrap = true;
curCell.align = "center";
curCell.vAlign = "center";
curCell.className = "subalterbar";
if( this.subnode!=null && this.subnode.length>0 ){
if( this.open )
curImage = document.createElement("<img onclick='doOpen(this.viewNode);' src='" +contextPath+ "/images/expand.gif' width='18' height='18' style='cursor=hand;' >");
else
curImage = document.createElement("<img onclick='doOpen(this.viewNode);' src='" +contextPath+ "/images/shrink.gif' width='18' height='18' style='cursor=hand;' >");
curImage.viewNode = aDiv;
aDiv.openImage = curImage;
curCell.appendChild(curImage);
}else{
curCell.width="18";
}
return aDiv;
}
//show organization unit by char model
function NodeCreateViewNodeH(oid){
var idUnitItem = "unititem" + oid;
var idItem = "item" + oid;
var aDiv = document.createElement("<div class='orgunitchartitemcell'>");
aDiv.treeNode = this;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -