📄 public.js
字号:
document.write( '<form id="oForm"><input Class="userData" style="DISPLAY: none; HEIGHT: 22px; WIDTH: 26px" ID="oInput"></form><IE:clientCaps id="ExculpateRate"></IE:clientCaps>')
var userData=oForm.oInput
function loadLabelData(strType,screenWidth,screenHeight){
//strType="打印设计"/"打印预览"
//装入数据
//返回:无
//设置最大的Label的宽高
result.style.width =screenWidth-5
result.style.height =screenHeight-25
//从缓存中取出页面设置信息
var setformat=LoadUserData("billprint",BillName)
if (setformat!=""){
var oXML1=new ActiveXObject("Microsoft.XMLDOM")
oXML1.async="false"
oXML1.loadXML("<root>"+setformat+"</root>")
topwindage=parseFloat(oXML1.documentElement.childNodes.item(0).text)
leftwindage=parseFloat(oXML1.documentElement.childNodes.item(1).text)
printformat=oXML1.documentElement.childNodes.item(2).text
//缓存中纸张的宽高单位为mm
repWidth=parseFloat(oXML1.documentElement.childNodes.item(3).text)
repHeight=parseFloat(oXML1.documentElement.childNodes.item(4).text)
printCopys=parseInt(oXML1.documentElement.childNodes.item(5).text)
offsetAdjust=parseFloat(oXML1.documentElement.childNodes.item(6).text)
}
else {
//缺省值
topwindage=0
leftwindage=0
printformat="套打"
repWidth=210
repHeight=297
printCopys=3
offsetAdjust=0
}
//缺省的页面信息已预给
var pxRatemm=3.78 //*(297-offsetAdjust)/297
//------------
if (printCopys==0)printCopys=1
//装入数据,计算页数和节点数
var oXML=new ActiveXObject("Microsoft.XMLDOM")
oXML.async ="false"
oXML.loadXML(SendParameter)
if(strType=="打印设计") {
number=1 //打印设计是只能有一页
}
else {
//页数,它是第一级子节点的个数除以每页打印的份数
number=Math.ceil(oXML.documentElement.childNodes.length/printCopys)
}
var oneNodeNumber=oXML.documentElement.childNodes.length //第一级子节点的个数
lastnodenumber=oXML.documentElement .childNodes.item (0).childNodes .length//第二级子节点的个数
//-------------
var newDiv
var newDivtop=50 //缺省的第一个DIV top
//装入缓存中格式的值
var strAll=LoadUserData("node",BillName)
//strAll=""
if(isSpace(strAll)==false){
var oX=new ActiveXObject("Microsoft.XMLDOM")
oX.async="false";
oX.loadXML("<root>" +strAll+"</root>")
}
//--------
//sadfsd
//清空,以便刷新时正确
result.innerHTML=""
//打印页数循环
for (var i=0;i<number;i++){
newDiv=document.createElement("div")
newDiv.style.borderTopStyle="solid"
newDiv.style.borderTopColor="DarkGreen"
newDiv.style.borderTopWidth=2
newDiv.style.borderLeftStyle="solid"
newDiv.style.borderLeftColor="DarkGreen"
newDiv.style.borderLeftWidth=2
newDiv.style.borderRightStyle="solid"
newDiv.style.borderRightColor="DarkGreen"
newDiv.style.borderRightWidth=2
newDiv.style.borderBottomStyle="solid"
newDiv.style.borderBottomColor="DarkGreen"
newDiv.style.borderBottomWidth=2
newDiv.style.position="absolute"
newDiv.style.width=repWidth*pxRatemm
if(strType=="打印设计") {
newDiv.style.height=repHeight*pxRatemm/printCopys
}
else {
newDiv.style.height=repHeight*pxRatemm
}
newDiv.style.backgroundColor="White"
//newDiv.style.pageBreakAfter="always"
if ((screenWidth-repWidth*pxRatemm)*0.5-5>0){
newDiv.style.left=(screenWidth-repWidth*pxRatemm)*0.5-5
}
if ((screenWidth-repWidth*pxRatemm)*0.5-5<=0){
newDiv.style.left=0
}
newDiv.style.top=newDivtop
if(strType=="打印设计") {
newDivtop=newDivtop+repHeight*pxRatemm/printCopys+20
}
else {
newDivtop=newDivtop+repHeight*pxRatemm+20
}
result.insertAdjacentElement("beforeEnd",newDiv)
var spanTop=20 //缺省的第一个方块top
//每页打印信封份数循环
if(strType=="打印设计") printCopys=1
//每页打印份数循环
for(var copys=0;copys<printCopys;copys++){
//如果数据已用完
if(i*printCopys+copys>=oneNodeNumber) break
if (tableHtml!="") {
//计算背景
newDiv.innerHTML=newDiv.innerHTML+tableHtml
var oBillStyle=document.all.item("billstyle")
var curBillStyle //当前背景对象
if (oBillStyle.length>0){
curBillStyle=oBillStyle[oBillStyle.length-1]
}
else {
curBillStyle=oBillStyle
}
curBillStyle.style.top=copys*repHeight*pxRatemm/printCopys
}
//------------------
//每页里面的标签循环
for (var j=0;j<lastnodenumber;j++){
if(strType=="打印设计") {
newSpan=document.createElement("IE:piece")
newSpan.id="fcsoft_node"
newSpan.style.position="absolute"
newSpan.innerText=oXML.documentElement.childNodes.item (0).childNodes.item(j).tagName
}
else { //strType=="打印预览"
newSpan=document.createElement("span")
newSpan.style.position="absolute"
newSpan.id="fcsoft_node"
newSpan.innerText=oXML.documentElement .childNodes.item (i*printCopys+copys).childNodes.item(j).text
}
newDiv.insertAdjacentElement("beforeEnd",newSpan)
if(isSpace(strAll)==false){
//装入已存好的信息
newSpan.style.left=oX.documentElement.childNodes(j).childNodes.item(0).text
newSpan.style.top=parseInt(oX.documentElement.childNodes(j).childNodes.item (1).text)+repHeight*pxRatemm*copys/printCopys
if (oX.documentElement.childNodes(j).childNodes.item (2).text!=""){
newSpan .style.width=parseInt(oX.documentElement.childNodes(j).childNodes.item (2).text)
}
else{
newSpan .style.width=""
}
newSpan .style.letterSpacing=oX.documentElement.childNodes(j).childNodes.item (3).text
newSpan .style.fontSize=oX.documentElement.childNodes(j).childNodes.item (4).text
newSpan .style.fontFamily=oX.documentElement.childNodes(j).childNodes.item (5).text
newSpan .style.fontWeight=oX.documentElement.childNodes(j).childNodes.item (6).text
newSpan .style.textDecoration=oX.documentElement.childNodes(j).childNodes.item (7).text
newSpan .style.fontStyle=oX.documentElement.childNodes(j).childNodes.item (8).text
newSpan .style.color=oX.documentElement.childNodes(j).childNodes.item (9).text
newSpan .style.textAlign=oX.documentElement.childNodes(j).childNodes.item (10).text
}
else {
//缺省的方块信息
spanTop=spanTop+20
newSpan.style.top=spanTop
newSpan .style.left=100
newSpan.style.letterSpacing=1
newSpan .style.fontSize=15
newSpan .style.fontFamily="serif"
newSpan .style.fontWeight="normal"
newSpan .style.textDecoration="none"
newSpan .style.fontStyle="normal"
newSpan .style.color="black"
newSpan .style.textAlign="left"
}
}//每页里面的标签循环结束
} //每页打印信封份数循环结束
}//每页循环结束
}
function PrintDesign() {
//调用打印设计功能
var BillDesign=new Array()
BillDesign[0]=tableHtml
BillDesign[1]=BillName
BillDesign[2]=SendParameter
BillDesign[5]=strPageSet
BillDesign[6]=strPageAll
/*
//3,4空缺
BillDesign[5]=repWidth
BillDesign[6]=repHeight
BillDesign[7]=printCopys
BillDesign[8]=topOffset
BillDesign[9]=leftOffset
BillDesign[10]=printformat
BillDesign[11]=offsetAdjust
*/
var dialogStyle="dialogHeight:"+ExculpateRate.height+"px;dialogWidth:"+ExculpateRate.width+"px;dialogTop:0px;dialogLeft:0px;status:no;scroll:no"
var printReturn=window.showModalDialog("billprint\\printdesign.htm",BillDesign,dialogStyle)
}
function PrintPreview() {
//进入打印预览
var BillDesign=new Array()
BillDesign[0]=tableHtml
BillDesign[1]=BillName
BillDesign[2]=SendParameter
BillDesign[3]=ExculpateRate.width
BillDesign[4]=ExculpateRate.height
BillDesign[5]=strPageSet
BillDesign[6]=strPageAll
var dialogStyle="dialogHeight:"+ExculpateRate.height+"px;dialogWidth:"+ExculpateRate.width+"px;dialogTop:0px;dialogLeft:0px;status:no;scroll:no"
var printReturn=window.showModalDialog("billprint\\printpreview.htm",BillDesign,dialogStyle)
}
function PrintPreview1() {
//从打印设计界面进入打印预览
var BillDesign=new Array()
BillDesign[0]=tableHtml
BillDesign[1]=BillName
BillDesign[2]=SendParameter
BillDesign[3]=ExculpateRate.width
BillDesign[4]=ExculpateRate.height
BillDesign[5]=""
BillDesign[6]=""
var dialogStyle="dialogHeight:"+ExculpateRate.height+"px;dialogWidth:"+ExculpateRate.width+"px;dialogTop:0px;dialogLeft:0px;status:no;scroll:no"
var printReturn=window.showModalDialog("printpreview.htm",BillDesign,dialogStyle)
}
//////////////////////////////////////////////////////////////////////上面程序是billprint.htm页面中的
function ContDec(sValue,sPointNum) {
var dblValue=parseFloat(sValue)
if (isNaN(dblValue)) return sValue
var iPointNum=parseInt(sPointNum)
if (isNaN(iPointNum)) iPointNum=0
if (iPointNum>9) iPointNum=9
var dbl1=Math.round(dblValue*Math.pow(10,iPointNum))/Math.pow(10,iPointNum)
var s1=dbl1.toString()
if (s1.indexOf(".") == -1) {
var s2="000000000000000"
s1=s1+"."+s2.substring(0,iPointNum)
}
if (right(s1,1)==".")
s1=s1.substring(s1.length-1,s1.length)
return s1
}
function SaveUserData(Main,Sub,strContent){
//存到数据缓存中
//Main为主key 如"List"
//Sub 为子key 如"CustomerFlag"
//strContent 为要存入的内容
//无返回
try {
userData.setAttribute(Main+userData.value,strContent)
userData.save(Sub+userData.value)
}
catch (e){}
}
function LoadUserData(Main,Sub){
//从数据缓存中装入到变量中
//Main为主key 如"List"
//Sub 为子key 如"CustomerFlag"
//返回取出的内容
userData.load(Sub+userData.value)
var sTmp=userData.getAttribute(Main+userData.value)
if (sTmp==null) sTmp=""
return sTmp
}
/*
function ShowErr(sErr)
{
//显示错误信息
var sErr1=left(sErr,sErr.indexOf("</root>")+7)
var oXml=new ActiveXObject("Microsoft.XMLDOM")
oXml.async ="false"
oXml.loadXML(sErr1)
//alert(sErr)
alert(oXml.documentElement.text )
}
function showMenu() {
//this function will position and display a nested div that acts like a menu
whichDiv=event.srcElement;
s=whichDiv.innerHTML
var oClick=window.event.srcElement
if (oClick.tagName=="DIV") oClick=oClick.parentNode
if (oClick.tagName=="TD") oClick=oClick.parentNode
if (oClick.tagName=="TR") curRow= oClick.sectionRowIndex-1
// alert(curRow)
arr[1]=curRowXml(curRow,strX) // event.srcElement.parentNode.parentNode.childNodes(0).childNodes(0).innerText
menu1.style.posLeft=event.clientX+document.body.scrollLeft;
menu1.style.posTop=event.clientY+document.body.scrollTop;
menu1.style.display="";
menu1.setCapture();
}
function toggleMenu() {
el=event.srcElement;
if (el.className=="menuItem") {
el.className="highlightItem";
} else if (el.className=="highlightItem") {
el.className="menuItem";
}
}
function contextTwice() {
if (event.srcElement==whichDiv)
showMenu();
}
function curRowXml(curRow,strX){
//返回strX中curRow的节点串
//curRow当前行,strX源串
oXML.async="false";
oXML.loadXML('<root>' +strX+'</root>')
var o=oXML.XMLDocument.childNodes.item(0).childNodes.item(curRow)
if (o.getAttribute("flngCustomerID")!="0" && o.getAttribute("flag")=="" && o.tagName=="Customer")
{
if (navigator.onLine)
{
var s1=SendHttp("public.asp?key=getcustomerbyid","<No>"+o.getAttribute("flngCustomerID")+"</No>")
return s1
}
else
{
alert("脱机模式下不能修改(但可以删除)在数据库中的客户或供应商!请联上网后再使用.")
return oXML.XMLDocument.childNodes.item(0).childNodes.item(curRow).xml
}
}
if (o.getAttribute("flngSupplyID")!="0" && o.getAttribute("flag")=="" && o.tagName=="Supply")
{
if (navigator.onLine)
{
var s1=SendHttp("public.asp?key=getsupplybyid","<No>"+o.getAttribute("flngSupplyID")+"</No>")
return s1
}
else
{
alert("脱机模式下不能修改(但可以删除)在数据库中的客户或供应商!请联上网后再使用.")
return oXML.XMLDocument.childNodes.item(0).childNodes.item(curRow).xml
}
}
var s1=oXML.XMLDocument.childNodes.item(0).childNodes.item(curRow).xml
return s1
}
function RemoveRoot(strX){
//去掉根结点标记
if (strX.length>15)
{
strX=strX.substring(6,strX.length-9)
return strX
}
else
{
return ""
}
}
//函数名:chksafe
//功能介绍:检查是否含有"'",'\\',"/"
//参数说明:要检查的字符串
//返回值:0:是 1:不是
function chksafe(a)
{
return 1;
fibdn = new Array ("'" ,"\\", "、", ",", ";", "/");
i=fibdn.length;
j=a.length;
for (ii=0;ii<i;ii++)
{ for (jj=0;jj<j;jj++)
{ temp1=a.charAt(jj);
temp2=fibdn[ii];
if (tem';p1==temp2)
{ return 0; }
}
}
return 1;
}
//函数名:chkspc
//功能介绍:检查是否含有空格
//参数说明:要检查的字符串
//返回值:0:是 1:不是
function chkspc(a)
{
var i=a.length;
var j = 0;
var k = 0;
while (k<i)
{
if (a.charAt(k) != " ")
j = j+1;
k = k+1;
}
if (j==0)
{
return 0;
}
if (i!=j)
{ return 2; }
else
{
return 1;
}
}
//函数名:chkemail
//功能介绍:检查是否为Email Address
//参数说明:要检查的字符串
//返回值:0:不是 1:是
function chkemail(a)
{ var i=a.length;
var temp = a.indexOf('@');
var tempd = a.indexOf('.');
if (temp > 1) {
if ((i-temp) > 3){
if ((i-tempd)>0){
return 1;
}
}
}
return 0;
}
//opt1 小数 opt2 负数
//当opt2为1时检查num是否是负数
//当opt1为1时检查num是否是小数
//返回1是正确的,0是错误的
function chknbr(num,opt1,opt2)
{
var i=num.length;
var staus;
//staus用于记录.的个数
status=0;
if ((opt2!=1) && (num.charAt(0)=='-'))
{
//alert("You have enter a invalid number.");
return 0;
}
//当最后一位为.时出错
if (num.charAt(i-1)=='.')
{
//alert("You have enter a invalid number.");
return 0;
}
for (j=0;j<i;j++)
{
if (num.charAt(j)=='.')
{
status++;
}
if (status>1)
{
//alert("You have enter a invalid number.");
return 0;
}
if (num.charAt(j)<'0' || num.charAt(j)>'9' )
{
if (((opt1==0) || (num.charAt(j)!='.')) && (j!=0))
{
//alert("You have enter a invalid number.");
return 0;
}
}
}
return 1;
}
//函数名:chkdate
//功能介绍:检查是否为日期
//参数说明:要检查的字符串
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -