⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 structure_tree.js

📁 实现了基本的oa功能:个人日志。。。
💻 JS
📖 第 1 页 / 共 4 页
字号:

         if( length%2==0 && i==length/2-1 ){
   	    //insert "──┴──"
	    subTable = document.createElement("<table height='100%' width='20' border='0' cellspacing='0' cellpadding='0'>");
	    wholeTable.rows[i*2+1].cells[2].appendChild(subTable);
	    wholeTable.rows[i*2+1].cells[2].height="100%";
	    curCell = subTable.insertRow().insertCell();
	    curCell.width="20";
	    curCell.height="100%";
	    curCell.vAlign="center";
	    curCell.background = contextPath + "/images/orgverticallong.gif";

	    curImage = document.createElement("<img src='" +contextPath+ "/images/orgverticalcenter2.gif' width='20' height='60'>");
	    curCell.appendChild( curImage );

         }else{
	    //insert "─────"
	    subTable = document.createElement("<table height='100%' width='20' border='0' cellspacing='0' cellpadding='0'>");
	    wholeTable.rows[i*2+1].cells[2].appendChild(subTable);
	    curCell = subTable.insertRow().insertCell();
	    curCell.width="100%";
	    curCell.height="100%";
	    curCell.background = contextPath + "/images/orgverticallong.gif";
         }
       }

       //call the child's createAllNode() method
       if( this.open ){
          var subViewNode;
          for(i=0;i<length;i++){
             subViewNode = this.getSubnode(i).createAllNodeV(i,length);
             wholeTable.rows[i*2].cells[2].appendChild(subViewNode);
          }
       }

    }

    return wholeTable;
}


function adaptPosition(){
    var childViewNode ;
    for(var i=adaptNodes.length-1;i>=0;i--){
        if( adaptNodes[i].treeNode.open){
            if (adaptNodes[i].offsetHeight == 0) continue;
            adaptNodes[i].parentNode.height = adaptNodes[i].offsetHeight;
            adaptNodes[i].parentNode.width = adaptNodes[i].offsetWidth;
            adaptNodes[i].style.position = "absolute";
            childViewNode = adaptNodes[i].treeNode.subnode[(adaptNodes[i].treeNode.subnode.length-1)/2].viewNode;
            if( childViewNode.style.position!="absolute" )
                adaptNodes[i].style.left = calculateSumOffset(childViewNode, "offsetLeft");
            else
                adaptNodes[i].style.left = childViewNode.style.left;
            adaptNodes[i].style.top = calculateSumOffset(adaptNodes[i].parentNode, "offsetTop");
            if( adaptImages[i]!=null ){
               adaptImages[i].parentNode.height = adaptImages[i].offsetHeight;
               adaptImages[i].parentNode.width = adaptImages[i].offsetWidth;
               adaptImages[i].style.position = "absolute";
               adaptImages[i].style.left = parseInt(adaptNodes[i].style.left) + ( parseInt(adaptNodes[i].offsetWidth)-parseInt(adaptImages[i].offsetWidth) )/2;
               adaptImages[i].style.top = calculateSumOffset(adaptImages[i].parentNode, "offsetTop" );
            }
        }else{
            adaptNodes[i].style.position = "static";
            if( adaptImages[i]!=null )
                adaptImages[i].style.position = "static";
        }
    }

}

function NodeCreateAllNodesH(inParentIndex,parentChildCount){
    var needAdapt=false;
    if( this.subnode!=null && this.subnode.length!=0 && this.subnode.length%2==1 ){
        var child = this.subnode[(this.subnode.length-1)/2];
        needAdapt = (child.subnode!=null && child.subnode.length>0) ;
    }

    //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 ondragstart='doDragStart(this);' ondrag='doDrag(this);' ondragend='doDragEnd(this);' ondragenter='doDragEnter(this);' ondragover='doDragOver(this);' ondragleave='doDragLeave(this);' ondrop='doDrop(this);' onmousedown='doMouseDown(this);' onmousemove='doMouseMove(this);' onmouseup='doMouseUp(this);'  id='" + idUnitItem + "' 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";

    if( isEHR ){
    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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -