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

📄 spreadsheetsingle.js

📁 实现了基本的oa功能:个人日志。。。
💻 JS
📖 第 1 页 / 共 2 页
字号:
var dataXMLDOC ;
var optionsFlags ;
var optionsValues = new Array(); ////记录:表名|字段名|type|id|memo|extendtype|baseinfo
var iteminfoValues = new Array(); //纪录总的复合信息集的信息
var optionvalue="";

function divideOptionValue(optionvalue)
{
 //optionvalue="epmsTirpTbl|vcCommon001ID|1|1|序列号|610001|0";	
 temp = optionvalue;
 i = 0;
 while(temp.indexOf("|")!=-1)
 {
   loc = temp.indexOf("|");
   optionsValues[i] = temp.substring(0,loc);
   i++;
   temp = temp.substring(loc+1);	
 }
 optionsValues[i] = temp ; //baseinfo
}

function deleteXmlNode(form,deledcell)
{
   activecell = deledcell ;
     
   for(i=0;i<dataXMLDOC.documentElement.childNodes.length;i++)
      {
  	   datanode = dataXMLDOC.documentElement.childNodes.item(i);
  	   for(j=0;j<datanode.childNodes.length;j++)
  	   {
  	      fieldnode = datanode.childNodes.item(j);  //每一个定义的结点
  	      row = fieldnode.getAttribute("row");
  	      col = fieldnode.getAttribute("col");
  	      xx = activecell.row;yy = activecell.column;
  	      
  	      if(row==xx&&col==yy)  //定义过并且符合 则删除
  	      {
			if(fieldnode.getAttribute("rep")=="0")
			{
				datanode.removeChild(fieldnode);
				activecell.value="";
				break ;
            }
			else if(fieldnode.getAttribute("rep")=="1")
			{	
                while(datanode.childNodes.length>0)
  	           {
				 for(pp=0;pp<datanode.childNodes.length;pp++)
				 {
				  fieldnode = datanode.childNodes.item(pp);  //每一个定义的结点
				  rowrow = fieldnode.getAttribute("row");
				  colcol = fieldnode.getAttribute("col");
                  Spreadsheet.Cells(rowrow,colcol).value="";
				  datanode.removeChild(fieldnode);
				 }
			   }
				 break ;
            }
  	      }
  	   }
  	}
	 var innodelen=dataXMLDOC.documentElement.childNodes.length;
	 for(ip=0;ip<innodelen;ip++)
      {
  	   datanode = dataXMLDOC.documentElement.childNodes.item(ip);
	   alert("datanode:"+datanode);
	   if(!(datanode.childNodes.length>0))
	   {
	     dataXMLDOC.documentElement.removeChild(datanode);
		 break;
	   }
	  }	
    return true;
}

function ModifyStyle(form)  //提交更改后的报表样式
{
  form.action = "";
  form.submit();	
}

function OnLoadData(stylepath,datapath)
{
 Spreadsheet.HTMLURL = stylepath.value ;
 xmlDoc.load(datapath.value);
  for(x=0;x<xmlDoc.documentElement.childNodes.length;x++)
   {
      currNode = xmlDoc.documentElement.childNodes.item(x);
      row = currNode.getAttribute("row");
      col = currNode.getAttribute("col");
      value =  currNode.getAttribute("value");
      if(value.indexOf("0")==0)Spreadsheet.Cells(row,col).Value = "'"+value ;
      else Spreadsheet.Cells(row,col).Value = value ;
   }
}

function OnCountCond(form,infostr) //确定统计条件
{
  var allinfoarray=infostr.split("#||#");
  var initeminfoarray=allinfoarray[2].split("^");
  var conditionarray=allinfoarray[3].split("^");
  var usersArray;


  if(allinfoarray[0]=="0")
{
  var rows = Spreadsheet.Selection.Rows.Count ;
  var cols = Spreadsheet.Selection.Columns.Count ;
  var beginrow = Spreadsheet.Selection.row;
  var begincol = Spreadsheet.Selection.column;
  var definedNode ;
  var activecell = Spreadsheet.ActiveCell;
  var datanode;
  var seledtable;
  defined = true;
  var selectIndex=-1; //选中的option
  var kkkk;
  if(true)
  {
  	 nodecount=0;
	data = allinfoarray[3];
  	optionsValues=data.split("&");
    
  	fieldname = optionsValues[1];
    activecell = Spreadsheet.ActiveCell ;
   for(i=0;i<dataXMLDOC.documentElement.childNodes.length;i++)
     {
  	      datanode = dataXMLDOC.documentElement.childNodes.item(i);
  	      tablename = datanode.getAttribute("name");
		  if(optionsValues[1]==tablename)
		 {
			seledtable=i;
			break;
  	     }
	  nodecount++;
  	}
    if(nodecount==dataXMLDOC.documentElement.childNodes.length)
	{
		newDataNode = dataXMLDOC.createElement("table");
		newDataNode.setAttribute("name",optionsValues[1]);
		newDataNode.setAttribute("rep","0");
		dataElement = dataXMLDOC.documentElement;
		dataElement.appendChild(newDataNode);
		newDataNode = dataXMLDOC.createElement("field");
		
		i = activecell.row;
		j = activecell.column;
		newDataNode.setAttribute("row",i);
		newDataNode.setAttribute("col",j);
		newDataNode.setAttribute("name",optionsValues[2]);
		newDataNode.setAttribute("showname",optionsValues[4]);
		newDataNode.setAttribute("type",optionsValues[3]);
		if(optionsValues[3]=="3")
		{
		 newDataNode.setAttribute("format","yy-MM-dd");
		}
		if(optionsValues[5]!=""&&optionsValues[5]!=null)
		{
		 newDataNode.setAttribute("code",optionsValues[5]);
		}
		if(optionsValues[6]!=""&&optionsValues[6]!=null)
		{
		 newDataNode.setAttribute("consql",optionsValues[6]);
		}
		chfieldname = optionsValues[4];
	}
	else
	{
	         newDataNode = datanode;
             dataElement = dataXMLDOC.documentElement;
             nodecount=0;
			 for(pp=0;pp<datanode.childNodes.length;pp++)
			 {
				  fieldnode = datanode.childNodes.item(pp);  //每一个定义的结点
				  if(fieldnode.getAttribute("name")==optionsValues[2])
				  {
					   if(confirm("此信息项已经在其他位置被设置过,是否需要重新设置?"))
						   {
								rowtmp=fieldnode.getAttribute("row");
								coltmp=fieldnode.getAttribute("col");
								Spreadsheet.Activesheet.Cells(rowtmp,coltmp).value="";
								i = activecell.row;
				                j = activecell.column;
								fieldnode.setAttribute("row",i);
								fieldnode.setAttribute("col",j);
								chfieldname = optionsValues[4];
								if(chfieldname.indexOf(".")!=-1)
							    { 
								  activecell.value="["+chfieldname.substring(chfieldname.indexOf(".")+1)+"]"; 
								}
                                else
							   {
								activecell.value = "["+chfieldname+"]";
							   }
								return;
								//break;
						   }
					   else
						   {
							    return;
						   }
				  }
				  else
				  {
                    nodecount++;
				  }
			  }
            if(nodecount==datanode.childNodes.length)
		   {
				dataElement.appendChild(newDataNode);
				newDataNode = dataXMLDOC.createElement("field");

				i = activecell.row;
				j = activecell.column;
				newDataNode.setAttribute("row",i);
				newDataNode.setAttribute("col",j);
				newDataNode.setAttribute("name",optionsValues[2]);
				newDataNode.setAttribute("showname",optionsValues[4]);
				newDataNode.setAttribute("type",optionsValues[3]);
				if(optionsValues[3]=="3")
				{
				 newDataNode.setAttribute("format","yy-MM-dd");
				}
				if(optionsValues[5]!=""&&optionsValues[5]!=null)
				{
				 newDataNode.setAttribute("code",optionsValues[5]);
				}
				if(optionsValues[6]!=""&&optionsValues[6]!=null)
				{
				 newDataNode.setAttribute("consql",optionsValues[6]);
				}
		   }
		   chfieldname = optionsValues[4];
	}

  	for(x=0;x<dataXMLDOC.documentElement.childNodes.length;x++)
    {
  	   datanode = dataXMLDOC.documentElement.childNodes.item(x);
  	   for(i=0;i<datanode.childNodes.length;i++)
  	   {
  	      fieldnode = datanode.childNodes.item(i);
  	      xxx = fieldnode.getAttribute("row");
  	      yyy = fieldnode.getAttribute("col");
  	      xxxx = activecell.row ;
  	      yyyy = activecell.column ;
  	      if(xxx==xxxx&&yyy==yyyy)
  	      {	
			deleteXmlNode(document.forms(0),Spreadsheet.Cells(xxxx,yyyy));
  	        break ;	
  	      }
  	      
  	   }
     }	
  	
  	for(x=0;x<dataXMLDOC.documentElement.childNodes.length;x++)
        {
  	   datanode = dataXMLDOC.documentElement.childNodes.item(x);
  	   datanode.appendChild(newDataNode);
  	   
  	}
       if(chfieldname.indexOf(".")!=-1)activecell.value="["+chfieldname.substring(chfieldname.indexOf(".")+1)+"]"; 
       else activecell.value = "["+chfieldname+"]";
        
  }
  else   //该字段已经定义过
  {
  	kkkk = -1;
  	for(x=0;x<dataXMLDOC.documentElement.childNodes.length;x++)
        {
  	   datanode = dataXMLDOC.documentElement.childNodes.item(x);
  	   for(i=0;i<datanode.childNodes.length;i++)
  	   {
  	      fieldnode = datanode.childNodes.item(i);
  	      xxx = fieldnode.getAttribute("row");
  	      yyy = fieldnode.getAttribute("col");
  	      xxxx = activecell.row ;
  	      yyyy = activecell.column ;
  	      if(xxx==xxxx&&yyy==yyyy)
  	      {
  	        for(k=0;k<form.queryfield.options.length;k++)
  	      	 {
  	      	  datad = form.queryfield.options[k].value;
  	      	  //divideOptionValue(datad);
			  optionsValues=datad.split("$");
  	      	  fieldname1 = optionsValues[1];
  	      	  if(fieldname1==fieldnode.nodeName)  //找到对应的选择过的字段在select中的编号
  	      	  {
                    kkkk = k ;
  	      	    if(k!=selectIndex)
  	      	    {
  	      	    	optionsFlags[k] = false ;//修改记录该字段是否被选择过的值
  	      	    }
  	      	    break ; 	
  	      	  }
  	      	}
  	      	datad = form.queryfield.options[k].value;
			optionsValues=datad.split("$");
  	      	
  	      	if(kkkk!=selectIndex)datanode.removeChild(fieldnode); //该格式中如果定义过则删除结点
  	        break ;	
  	      }
  	      
  	   }
        }
        
         data = form.queryfield.options[selectIndex].value;
		optionsValues=data.split("$");
  	 fieldname = optionsValues[1];	
  	  	
    for(x=0;x<dataXMLDOC.documentElement.childNodes.length;x++)
        {
  	   datanode = dataXMLDOC.documentElement.childNodes.item(x);
  	   for(i=0;i<datanode.childNodes.length;i++)
  	   {
  	      fieldnode = datanode.childNodes.item(i);
  	      if(fieldnode.nodeName==fieldname)
  	      {
  	         row = fieldnode.getAttribute("row");
  	         col = fieldnode.getAttribute("col");
  	         Spreadsheet.Activesheet.Cells(row,col).value = "";
  	         row = activecell.row;col=activecell.column;
  	         ssssT = form.queryfield.options[selectIndex].text ;
  	         if(ssssT.indexOf(".")!=-1)ssssT = ssssT.substring(ssssT.indexOf(".")+1);
  	         Spreadsheet.Activesheet.Cells(row,col).value = "["+ssssT+"]";
  	         fieldnode.setAttribute("row",row);
  	         fieldnode.setAttribute("col",col); //修改行列值
  	         break;	
  	      }
  	   }
  	}
     
    }  
 }


 else if((allinfoarray[0]=="1"))
 {
  iteminfoValues=allinfoarray[2].split("^"); 	
  var rows = Spreadsheet.Selection.Rows.Count ;
  var cols = Spreadsheet.Selection.Columns.Count ;
  var beginrow = Spreadsheet.Selection.row;
  var begincol = Spreadsheet.Selection.column;
  var definedNode ;
  var activecell = Spreadsheet.ActiveCell;
  var datanode;
  var seledtable;
  defined = true;
  var selectIndex=-1; //选中的option
  var kkkk;
  for(tt=0;tt<iteminfoValues.length-1;tt++)
 {
  if(true)
  {
  	nodecount=0;
	data = iteminfoValues[tt];
  	optionsValues=data.split("&,&");
  	fieldname = optionsValues[1];
    activecell = Spreadsheet.ActiveCell ;
   for(i=0;i<dataXMLDOC.documentElement.childNodes.length;i++)
     {
  	      datanode = dataXMLDOC.documentElement.childNodes.item(i);
  	      tablename = datanode.getAttribute("name");
		  if(optionsValues[1]==tablename&&allinfoarray[4]==datanode.getAttribute("timemark"))
		 {
			seledtable=i;
			break;
  	     }
	  nodecount++;
  	}
	var rowrow;
	var colcol;
    if(nodecount==dataXMLDOC.documentElement.childNodes.length)
	{
		newDataNode = dataXMLDOC.createElement("table");
		newDataNode.setAttribute("name",optionsValues[1]);
		newDataNode.setAttribute("rep","1");
		newDataNode.setAttribute("timemark",allinfoarray[4]);
		dataElement = dataXMLDOC.documentElement;
		dataElement.appendChild(newDataNode);
		newDataNode = dataXMLDOC.createElement("field");
		
		i = activecell.row;
		j = activecell.column;
		newDataNode.setAttribute("row",i);
		newDataNode.setAttribute("col",j);
		newDataNode.setAttribute("condition","");
		//newDataNode.setAttribute("actcount","0");
		newDataNode.setAttribute("name",optionsValues[2]);
		newDataNode.setAttribute("showname",optionsValues[4]);
		newDataNode.setAttribute("type",optionsValues[3]);
		if(optionsValues[3]=="3")
		{
		 newDataNode.setAttribute("format","yy-MM-dd");
		}
		if(optionsValues[5]!=""&&optionsValues[5]!=null)
		{
		 newDataNode.setAttribute("code",optionsValues[5]);
		}
		if(optionsValues[6]!=""&&optionsValues[6]!=null)
		{
		 newDataNode.setAttribute("consql",optionsValues[6]);
		}
		chfieldname = optionsValues[4];
		rowrow=i;
	    colcol=j;
	}
	else
	{
	        newDataNode = datanode;
            dataElement = dataXMLDOC.documentElement;
		    dataElement.appendChild(newDataNode);
			newDataNode = dataXMLDOC.createElement("field");
			
			i = activecell.row;
			j = activecell.column;
			newDataNode.setAttribute("row",i);
			newDataNode.setAttribute("col",j+tt);
			newDataNode.setAttribute("condition","");
			//newDataNode.setAttribute("actcount","0");
			newDataNode.setAttribute("name",optionsValues[2]);
			newDataNode.setAttribute("showname",optionsValues[4]);
			newDataNode.setAttribute("type",optionsValues[3]);
			if(optionsValues[3]=="3")
			{
			 newDataNode.setAttribute("format","yy-MM-dd");
			}
			if(optionsValues[5]!=""&&optionsValues[5]!=null)
		    {
		     newDataNode.setAttribute("code",optionsValues[5]);
		    }
			if(optionsValues[6]!=""&&optionsValues[6]!=null)
		    {
		     newDataNode.setAttribute("consql",optionsValues[6]);
		    }
			//newDataNode.setAttribute("rep","1");
			chfieldname = optionsValues[4];
			rowrow=i;
	        colcol=j+tt;
	}

  	for(x=0;x<dataXMLDOC.documentElement.childNodes.length;x++)
        {
  	   datanode = dataXMLDOC.documentElement.childNodes.item(x);
  	   for(i=0;i<datanode.childNodes.length;i++)
  	   {
  	      fieldnode = datanode.childNodes.item(i);
  	      xxx = fieldnode.getAttribute("row");
  	      yyy = fieldnode.getAttribute("col");
  	      xxxx = activecell.row ;
  	      yyyy = activecell.column+tt ;
  	      if(xxx==xxxx&&yyy==yyyy)
  	      {	
			deleteXmlNode(document.forms(0),Spreadsheet.Cells(xxxx,yyyy));
  	        break ;	
  	      }
  	      
  	   }
        }	
  	

⌨️ 快捷键说明

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