/**
* WebSign控件。
* 使用方法:
* var obj=new NtkoWebSign();
* loadWebSign(targetId,attachmentId,espFileIdx,widthx,heightx);
* targetId: 文档容器id
* espFileIdx:附件id,如果指定那么根据该文件id加载签章。
*
* saveRemote:保存文档到服务器
*
* @returns {OfficeControl}
*/
NtkoWebSign=function(){
{
var _self=this;
this.user = {id:"0",name:"开发用户",groupId:"0",groupName:"开发部"};
this.divId="targetId";
this.webSignId="ntkoocx";
this.webSignObj=null;
this.espFileId="";
this.height="0"; //隐藏
this.width="0"; //隐藏
this.checkForm="";
this.configStyle={user:{},imgStyle:'display: none;',buttonStyle:"display: none;"};
};
/**
* 加载NTKO Web版电子印章控件
* arg targetId 加载控件存放的目标Dom元素(Div)最好是唯一的。
* arg attachmentId NTKO电子印章对象ID。如果不为空,加载对应的文件 最好是唯一的
* espFileIdx 有没有对应的 NTKO电子印章文件(info文件),加载时放入!espFileIdx唯一标识
*/
this.loadWebSign = function(targetId,attachmentId,espFileIdx,conf) {
this.divId=targetId;
if((attachmentId!="")&&(attachmentId!=null)&&('undefined' != typeof (attachmentId))){
this.webSignId=attachmentId;
}
this.espFileId=espFileIdx;
this.configStyle=$.extend({},this.configStyle,conf);
this.user = conf.user;
var cabPath=__ctx +"/js/ntkoWebSign/ntkoWebSign.cab#version=4,0,2,0";
var tags="";
//图片 以后扩展有用...
// tags+='
![]()
';
//Web印章对象
tags+='';
tags+='
';
tags+='
';
//用于默认要需要表单验证功能标记 (如果表单设计没有需要表单验证的字段(没有页面对象中没有validate="{'isWebSign':true}")时,这标签可以防止签单报错)
tags+='';
//用于获取鼠标的位置的对象
tags+='';
tags+='';
//Web印章按钮的相关内容
/* tags+='';*/
$('#'+this.divId).html(tags);
// alert($('#'+this.divId).html());
this.webSignObj = document.getElementById(this.webSignId);
if('undefined' == typeof (this.webSignObj.StatusCode)){
$.ligerDialog.warn("不能装载WEB印章控件,必须使用IE内核浏览器。可能需要在浏览器的Internet选项安全设置中修改ActiveX配置。",'提示信息',function(){
window.history.back();
});
return false;
}
if((this.espFileId!="")&&(this.espFileId!=null)&&('undefined' != typeof (this.espFileId))){
this.loadFileInfo();
}
};
/**
* 获取webSignObj,代表当前的电子印章对象
*/
this.getntkoWebSignObj = function() {
// this.webSignObj.IsShowRect = false;
return this.webSignObj;
};
//注意:以下四个方法是接管印章事件的内部方法。
//NtkoReservedEvent_BeforeDoSecSign如果返回true,标识可以继续盖章,如果返回false,标识取消印章。
//可以在这个函数中,调用Helper对象的DoWebExecute2方法查询服务器是否可以继续盖章并返回true或者false.
this.NtkoReservedEvent_BeforeDoSecSign = function (UserName,SignName,SignUser,SignSN)
{
return true;
// alert("1NtkoReservedEvent_BeforeDoSecSign:UserName="+UserName+",SignName="+SignName+",SignUser="+SignUser+",SignSN="+SignSN);
try
{
var retValue = this.webSignObj.DoWebExecute2("http://192.168.0.100/testchecksign/checksign.asp",
"UserName="+UserName+"&SignName="+SignName+"&SignUser="+SignUser+"&SignSN="+SignSN);
// alert(retValue);
return true;
}
catch(err)
{
alert("查询印章可用状态错误!"+ err.number + ":" + err.description);
return false;
}
};
//NtkoReservedEvent_BeforeDoSecSignFromEkey如果返回true,标识可以继续盖章,如果返回false,标识取消印章。
//可以在这个函数中,调用Helper对象的DoWebExecute2方法查询服务器是否可以继续盖章并返回true或者false.
this.NtkoReservedEvent_BeforeDoSecSignFromEkey = function (UserName,SignName,SignUser,SignSN,EkeySN)
{
return true;
// alert("NtkoReservedEvent_BeforeDoSecSignFromEkey:UserName="+UserName+",SignName="+SignName+",SignUser="+SignUser+",SignSN="+SignSN+",EkeySN="+EkeySN);
try
{
var retValue = this.webSignObj.DoWebExecute2("http://192.168.0.100/testchecksign/checksign.asp",
"UserName="+UserName+"&SignName="+SignName+"&SignUser="+SignUser+"&SignSN="+SignSN+"&EkeySN="+EkeySN);
// alert(retValue);
return true;
}
catch(err)
{
alert("查询印章可用状态错误!"+ err.number + ":" + err.description);
return false;
}
};
//该事件在印章被删除之后触发。
this.NtkoReservedEvent_AfterSecSignDeleted = function(UserName,SignName,SignUser,SignSN,EkeySN,UserData)
{
//alert("3NtkoReservedEvent_AfterSecSignDeleted:UserName="+UserName+",SignName="+SignName+",SignUser="+SignUser+",SignSN="+SignSN+",EkeySN="+EkeySN+",UserData="+UserData);
};
//NtkoReservedEvent_BeforeSecSignCheckRight事件在印章需要验证权限之前被触发。
/***************************************************************
其中的SignType:印章类型.0标识印章.1标识手写签名,2标识键盘批注
返回0,1,2.
0:标识用户自定义权限验证成功,且不需要系统进一步验证。
1:标识用户自定义权限验证失败,且不需要系统进一步验证。
2:标识用户自定义权限不起作用,需要系统进一步验证(用自身方法)
/***************************************************************/
this.NtkoReservedEvent_BeforeSecSignCheckRight = function(UserName,SignName,SignUser,SignSN,EkeySN,SignType,UserData)
{
// alert("BeforeSecSignCheckRight:UserName="+UserName+",SignName="+SignName+",SignUser="+SignUser+
// ",SignSN="+SignSN+",EkeySN="+EkeySN+",SignType="+SignType+",UserData="+UserData);
/***********************************************************************
//以下可以通过调用Helper对象的DoWebExecute2方法查询服务器
try
{
var retValue = ntkoobj.DoWebExecute2("http://192.168.0.100/testchecksign/checkright.asp",
"UserName="+UserName+"&SignName="+SignName+"&SignUser="+SignUser+"&SignSN="+SignSN+"&EkeySN="+EkeySN);
alert(retValue);
return 0; //0:标识用户自定义权限验证成功,且不需要系统进一步验证。
}
catch(err)
{
alert("查询印章权限错误!"+ err.number + ":" + err.description);
return 1; //1:标识用户自定义权限验证失败,且不需要系统进一步验证。
}
*****************************************************************/
return 2; //2:标识用户自定义权限不起作用,需要系统进一步验证(用自身方法)
};
/**
* 增加有提示的手写WEB批注(没有自动对正大小)
*/
this.AddSecHandSign=function()
{
var secSignObj = this.webSignObj.AddSecSignOcx("SecHandSignID",20,20);
secSignObj.WebSignInfo = this.checkPrintForm(); //要Web签章验证的信息;
secSignObj.HandSignPenColor = 14402205; // 此数值计算方式为:假设需要设定颜色值RGB,则value = (blue * 65536) + (green * 256) + red
secSignObj.HandSignPenWidth = 5; //笔宽为5
secSignObj.HandSignPenStyle = 0; //笔形为1
//secSignObj.IsReadOnlyMode = true;
this.webSignObj.AddSecHandSign(secSignObj,_self.user.name,0,false,false,true,true,null,true);
};
/**
* 增加没有提示的手写WEB批注(自动对正大小)
*/
this.AddSecHandSignNoPrompt=function()
{
var strxy = this.getXy();
if( strxy!="" && (strxy.split("&").length==2)){
var arrys = strxy.split("&");
var secSignObj = this.webSignObj.AddSecSignOcx("SecHandSignID",arrys[0],arrys[1]);
if(secSignObj)
{
secSignObj.WebSignInfo = this.checkPrintForm(); //要Web签章验证的信息;
// secSignObj.HandSignPenColor = 0; // 此数值计算方式为:假设需要设定颜色值RGB,则value = (blue * 65536) + (green * 256) + red
secSignObj.HandSignPenWidth = 3; //笔宽为5
secSignObj.HandSignPenStyle = 0; //笔形为1
secSignObj.UserData = "my user data";
this.webSignObj.AddSecHandSign(secSignObj,_self.user.name,2,false,false,true,false,null,false,80);
}
}
};
/**
* 增加有提示的手写WEB批注(自动对正大小)
*/
this.AddSecHandSignAdjust=function()
{
var secSignObj = this.webSignObj.AddSecSignOcx("SecHandSignID",20,20);
secSignObj.WebSignInfo = this.checkPrintForm(); //要Web签章验证的信息;
this.webSignObj.AddSecHandSign(secSignObj,_self.user.name,0,false,false,true,true,null,true,50);
};
/**
* 增加输入WEB批注(自动对正大小)
*/
this.AddSecKeyBoardComment=function()
{
var secSignObj = this.webSignObj.AddSecSignOcx("SecKeyBoardCommentID",20,20);
secSignObj.WebSignInfo = this.checkPrintForm(); //要Web签章验证的信息;
this.webSignObj.AddSecKeyBoardComment(secSignObj,_self.user.name,0,false,false,true,false);
};
/**
* 输入有提示的本地WEB签章批注
*/
this.AddSecSignFromLocal=function(isAddComment)
{
var secSignObj = this.webSignObj.AddSecSignOcx("SecSignFromLocalID",20,20);
secSignObj.WebSignInfo = this.checkPrintForm(); //要Web签章验证的信息;
this.webSignObj.AddSecSignFromLocal(secSignObj,_self.user.name,'',true,1,false,false,true,true,null,isAddComment);
};
/**
* 输入有提示的远程(URL)WEB签章批注
*/
this.AddSecSignFromURL=function()
{
var secSignObj = this.webSignObj.AddSecSignOcx("SecSignFromURLID",20,20);
secSignObj.WebSignInfo = this.checkPrintForm(); //要Web签章验证的信息;
//secSignObj.PositionTagId = "JiaFanSpan";//定义印章加盖的位置 JiaFanSpan 一般为DIV
this.webSignObj.AddSecSignFromURL(secSignObj,_self.user.name,
'http://www.ntko.com/admin/ocv14_test.nsf/vwSigns/2C0B608DD5844CA848256E46000A4C3D/$file/zhang_hetong.gif.esp?openelement',
2,false,false,true,false,"11111111",false);
};
/**
* 从服务器中选印章对表单进行签章
*/
this.AddSecSignFromService=function(){
var strxy = this.getXy();
if( strxy!="" && (strxy.split("&").length==2)){
var arrys = strxy.split("&");
// alert("X:"+arrys[0]+" Y:"+arrys[1]);
var url = __ctx + "/platform/system/seal/dialog.ht";
var winArgs = "dialogWidth=800px;dialogHeight=600px;help=0;status=0;scroll=1;center=0;resizable=1;";
url = url.getNewUrl();
//var retVal = window.showModalDialog(url, "", winArgs);
/*if(typeof(retVal)==undefined){
return false;
}
if(retVal.fileId.isEmpty()){
return false;
}
var signUrl=__ctx + "/platform/system/sysFile/getFileById.ht?fileId=" + retVal.fileId;
try{
var secSignObj = this.webSignObj.AddSecSignOcx("SecSignFromURLID",arrys[0],arrys[1]);
secSignObj.WebSignInfo = this.checkPrintForm(); //要Web签章验证的信息;
//secSignObj.PositionTagId = "JiaFanSpan";//定义印章加盖的位置 JiaFanSpan 一般为DIV
this.webSignObj.AddSecSignFromURL(secSignObj,_self.user.name,signUrl,2,false,false,true,false,"",false);
}catch(err){
alert("AddSecSignFromService:" +err.name + ": " + err.message);
return -1;
}*/
var that =this;
/*KILLDIALOG*/
DialogUtil.open({
height:600,
width: 800,
title : '签章',
url: url,
showMax: false,
showToggle: true,
showMin: false,
isResize: true,
slide: false,
//自定义参数
sucCall:function(retVal){
if(typeof(retVal)==undefined){
return;
}
if(retVal.fileId.isEmpty()){
return;
}
var signUrl=__ctx + "/platform/system/sysFile/getFileById.ht?fileId=" + retVal.fileId;
try{
var secSignObj = that.webSignObj.AddSecSignOcx("SecSignFromURLID",arrys[0],arrys[1]);
secSignObj.WebSignInfo = that.checkPrintForm(); //要Web签章验证的信息;
//secSignObj.PositionTagId = "JiaFanSpan";//定义印章加盖的位置 JiaFanSpan 一般为DIV
that.webSignObj.AddSecSignFromURL(secSignObj,_self.user.name,signUrl,2,false,false,true,false,"",false);
}catch(err){
alert("AddSecSignFromService:" +err.name + ": " + err.message);
return -1;
}
}
});
}
};
/**
* 输入有提示的Ekey硬件WEB签章批注
*/
this.AddSecSignFromEkey=function()
{
if(this.webSignObj!=null){
/*if(!this.webSignObj.IsEkeyConnected)
{
alert("没有检测到EKEY.请将EKEY插入到计算机!然后点击确定继续.");
return false;
}*/
var secSignObj = this.webSignObj.AddSecSignOcx("SecSignFromEkeyID",20,20);
secSignObj.WebSignInfo = this.checkPrintForm(); //要Web签章验证的信息;
this.webSignObj.AddSecSignFromEkey(secSignObj,_self.user.name,2,false,false,true,true);
}
};
/**
* 输入有提示的Ekey硬件WEB签章批注
*/
this.AddSecSignFromEkeyWithSignIndex=function()
{
if(this.webSignObj!=null){
/*if(!this.webSignObj.IsEkeyConnected)
{
alert("没有检测到EKEY.请将EKEY插入到计算机!然后点击确定继续.");
return false;
}*/
var secSignObj = this.webSignObj.AddSecSignOcx("SecSignFromEkeyID",20,20);
secSignObj.WebSignInfo = this.checkPrintForm(); //要Web签章验证的信息;
this.webSignObj.AddSecSignFromEkey(secSignObj,_self.user.name,2,false,false,true,true,null,true,1/*SignIndex*/);
}
};
/**
* 获取所有签章的相关信息
*/
this.ShowSignsInfo=function()
{
var objs = document.getElementsByTagName("object");
for(var i=0;i=0;i--)
{
var obj = objs(i);
if(obj.classid == "clsid:AA4B3728-B61C-4bcc-AEE7-0AA47D3C0DDA")
{
obj.Close();
obj.removeNode();
}
}
};
/**
* 是否支持印章对象对表单验证
*/
this.AllCheckDocChange=function(mark)
{
var objs = document.getElementsByTagName("object");
for(var i=0;i0){
this.checkForm = this.checkForm.substr(0,this.checkForm.length-1) //去年最后一个字符
}
return this.checkForm;
};
/**
* 保存签章相关信息
*/
this.SaveToServer = function()
{
var path= __ctx + "/platform/system/sysFile/saveFileInfo.ht";
var uploadName = this.webSignId +"_pdf"
var params="fileId=" + this.espFileId + "&uploadName="+ uploadName;
var curDate=new Date();
var espName=Math.random()*curDate.getMilliseconds()*10000;
//保存数据到服务器。
var retstr = this.webSignObj.SaveToURL(path,uploadName,params,espName+".info",0);
if(retstr!=""&&('undefined' != typeof (retstr))&& retstr>0){
this.espFileId = retstr;
return retstr;
}else{
return "";
}
};
/**
* 加载签章相关信息
*/
this.loadFileInfo = function()
{
if((this.espFileId!="")&&(this.espFileId!=null)&&('undefined' != typeof (this.espFileId))){
var path= __ctx + "/platform/system/sysFile/getFileById.ht?fileId=" + this.espFileId;
this.webSignObj.LoadFromURL(path);
if (0 != this.webSignObj.StatusCode) {
return false;
}
}
};
/**
* 鼠标获取位置
*/
this.getXy=function()
{
var mousePosX = document.getElementById('mousePosX').value;
var mousePosY = document.getElementById('mousePosY').value;
var str = mousePosX +"&"+ mousePosY;
document.getElementById('mousePosX').value = '50';
document.getElementById('mousePosY').value = '50';
if(mousePosX=='50' && mousePosY=='50'){
if(confirm("当前签章将保存位置:横坐标("+mousePosX+"px),纵坐标("+mousePosY+"px)!确认不需要更改吗?")){
return str;
}else{
alert("请通过双击鼠标左键确定将选择的印章位置,再进行签章!");
return "";
}
}else{
return str;
}
};
};