You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
366 lines
10 KiB
366 lines
10 KiB
function HebcaClient()
|
|
{
|
|
this.clientCtrl = null;
|
|
}
|
|
|
|
HebcaClient.prototype = {
|
|
|
|
/*
|
|
旧版客户端实现
|
|
_GetClientCtrl: function() {
|
|
if (this.clientCtrl)
|
|
return this.clientCtrl;
|
|
else {
|
|
document.body.insertAdjacentHTML(
|
|
"afterEnd",
|
|
'<OBJECT classid="CLSID:78D1D24A-C552-4402-95FA-E9CA2E8924F2" id="HebcaClient" VIEWASTEXT width="1" height="1"></object>'
|
|
);
|
|
this.clientCtrl = document.getElementById("HebcaClient");
|
|
return this.clientCtrl;
|
|
}
|
|
},
|
|
*/
|
|
|
|
_GetClientCtrl: function() {
|
|
if (this.clientCtrl)
|
|
return this.clientCtrl;
|
|
else {
|
|
var certMgrObj;
|
|
try {
|
|
certMgrObj = new ActiveXObject("HebcaP11X.CertMgr");
|
|
}
|
|
catch (e) {
|
|
throw Error("没有安装客户端软件或IE阻止其运行");
|
|
}
|
|
|
|
certMgrObj.Licence = "aWViYx5oZWIcYWhlnWxhaJplY2FoZWJjoKw7gT6hg+O7EtJhfalPbDH9UlE=";
|
|
this.clientCtrl = certMgrObj;
|
|
return this.clientCtrl;
|
|
}
|
|
},
|
|
|
|
|
|
Sign: function(source) {
|
|
var c = this._GetClientCtrl().SelectSignCert();
|
|
return c.SignText(source, 1);
|
|
},
|
|
|
|
GetSignCert: function() {
|
|
return this._GetClientCtrl().SelectSignCert().GetCertB64();
|
|
},
|
|
|
|
GetCryptCert: function() {
|
|
return this._GetClientCtrl().SelectEncryptCert().GetCertB64();
|
|
},
|
|
//登录设备
|
|
Login: function(pwd) {
|
|
|
|
this._GetClientCtrl().SelectDevice().Login(pwd);
|
|
},
|
|
//退出设备
|
|
Logout:function(){
|
|
this._GetClientCtrl().SelectSignCert().Logout();
|
|
},
|
|
GetSubjectItem: function(item) {
|
|
return this._GetClientCtrl().SelectSignCert().GetSubjectItem(item);
|
|
}
|
|
|
|
};
|
|
|
|
/*
|
|
function HebcaEncrypt(){
|
|
this.alg = 0;
|
|
this.userCertMap = new Array();
|
|
this.fileIn = "";
|
|
this.fileOut = "";
|
|
this.userKeyMap = new Array();
|
|
this.clientCtrl = null;
|
|
}
|
|
|
|
HebcaEncrypt.prototype =
|
|
{
|
|
_GetClientCtrl: function() {
|
|
if (this.clientCtrl)
|
|
return this.clientCtrl;
|
|
else {
|
|
var certMgrObj;
|
|
try {
|
|
certMgrObj = new ActiveXObject("HebcaClient.CertMgr");
|
|
}
|
|
catch (e) {
|
|
throw Error("没有安装客户端软件或IE组织其运行");
|
|
}
|
|
|
|
certMgrObj.Licence = "aWViYx5oZWIcYWhlnWxhaJplY2FoZWJjoKw7gT6hg+O7EtJhfalPbDH9UlE=";
|
|
this.clientCtrl = certMgrObj;
|
|
return this.clientCtrl;
|
|
}
|
|
},
|
|
|
|
//添加一个接收者
|
|
AddReciever : function(user,cert){
|
|
this.userCertMap[this.userCertMap.length]={
|
|
user: user,
|
|
cert: cert
|
|
};
|
|
},
|
|
|
|
//加密
|
|
Encrypt : function(){
|
|
|
|
// _GetClientCtrl().
|
|
|
|
},
|
|
|
|
//获取用户名和密钥的对应字符串,字符串格式如下:
|
|
//用户1:用户1密钥;用户2:用户2密钥; ....
|
|
GetUserKeyString : function(){
|
|
var str="";
|
|
for(var i=0;i<this.userKeyMap.length;i++)
|
|
{
|
|
str=this.userKeyMap[i].user+":"+this.userKeyMap[i].key;
|
|
if(i!=this.userKeyMap.length-1)
|
|
str+=";";
|
|
}
|
|
return str;
|
|
}
|
|
};
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//第一次提交提示签名,第二次提交可以直接提交
|
|
var count = 0;
|
|
function checkSignature() {
|
|
var mLength1 = document.getElementsByName("iHtmlSignature").length;
|
|
//已签名
|
|
if (mLength1 > 0) {
|
|
return true;
|
|
}
|
|
else {
|
|
//第二次提交,签不签名都提交
|
|
if (count == 1) {
|
|
count = 0;
|
|
return true;
|
|
}
|
|
else {
|
|
//第一次提交,提示
|
|
alert("需要先签名后,再提交!");
|
|
count += 1;
|
|
return false;
|
|
|
|
}
|
|
}
|
|
//return true;
|
|
}
|
|
|
|
//作用:进行签名
|
|
function doSignature(objectname,caName,signatureid,documentid) {
|
|
if (document.getElementById("txtTransactMessage").value.replace(/^\s+|\s+$/g, '') == "") {
|
|
|
|
alert('请先填写处理意见,再签名!');
|
|
return false;
|
|
}
|
|
var client = new HebcaClient();
|
|
var aa = client.GetSubjectItem("G");
|
|
if (caName == "") {
|
|
alert('请先到个人设置中绑定证书,再进行签名!');
|
|
return false;
|
|
}
|
|
|
|
if (aa != caName ) {
|
|
alert('请用登录的key进行签名!');
|
|
return false;
|
|
}
|
|
//对各个字段值以分号连接组织成一串字符串
|
|
var formData = document.getElementById("txtTransactMessage").value; //自定义组织数据结构形式
|
|
try {
|
|
//调用签章控件的盖章接口, 显示电子签章并生成签章结果
|
|
archivesSealResult = document.getElementById(objectname).SignAndSealForResult(formData, "", 1, false, true);
|
|
document.getElementById("archivesSealResult").value = archivesSealResult;
|
|
if (archivesSealResult != null && archivesSealResult != "") {
|
|
$.ajax({
|
|
type: "post",
|
|
url: "../HebCAService.ashx",
|
|
data: { keyvalue: archivesSealResult, InstanceRecordId: signatureid, filesId: documentid },
|
|
dataType: 'text',
|
|
success: function(msg) {
|
|
|
|
},
|
|
error: function() {
|
|
// alert("默认审核人未能自动获取,请点击“选择用户”");
|
|
}
|
|
});
|
|
}
|
|
} catch (e) {
|
|
alert(e.message);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
//处理环节不能为空,选择用户不能为空,处理意见不能为空
|
|
function submitCheck(isSignatureBool, caName) {
|
|
var radios = document.getElementsByName("radiobutton");
|
|
var j = 0;
|
|
var m = 0;
|
|
if (radios != null) {
|
|
var i;
|
|
for (i = 0; i < radios.length; i++) {
|
|
if (radios[i].checked) {
|
|
j = j + 1;
|
|
}
|
|
else {
|
|
m = 0;
|
|
}
|
|
}
|
|
}
|
|
if (j == 0) {
|
|
alert("请选择处理环节!");
|
|
return false;
|
|
}
|
|
|
|
if (document.getElementById("selectUser").value == "") {
|
|
alert('请填写选择用户!');
|
|
return false;
|
|
}
|
|
|
|
if (document.getElementById("txtTransactMessage").value.replace(/^\s+|\s+$/g, '') == "") {
|
|
alert("请填写处理意见!");
|
|
return false;
|
|
}
|
|
|
|
//验证意见的长度 不能超过250个汉字或500个字符 一个汉字=2个字符
|
|
if (!checkdata()) {
|
|
alert("不能超过250个汉字或500个字符!");
|
|
return false;
|
|
}
|
|
|
|
|
|
//检查签章
|
|
return SignatureOnOpinion(isSignatureBool, caName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//意见审批页面必须要签名的判断
|
|
|
|
function SignatureOnOpinion(isSignatureBool, caName) {
|
|
//验证是否需要签名
|
|
if (new String(isSignatureBool).toLowerCase() == "true") {
|
|
//验证是否签名
|
|
if (document.getElementById("archivesSealResult").value == "") {
|
|
alert("请先签名,再提交!");
|
|
return false;
|
|
}
|
|
//验证签名是否有效
|
|
document.getElementById(caName).VerifyAndShowSealWithResult(document.getElementById("archivesSealResult").value, 1, document.getElementById("txtTransactMessage").value);
|
|
var result = document.getElementById(caName).GetVerifyResult();
|
|
if (result != "0") {
|
|
alert("意见已修改,请在签名上点击右键,选择撤销签名,撤销后重新签名!");
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
//在网页中验证和显示签章
|
|
function verifyAndShowSeal(documentid, url1) {
|
|
var obs = document.getElementsByName("object");
|
|
for (var i = 0; i < obs.length; i++) {
|
|
|
|
var id = obs.item(i).id;
|
|
var opinion = obs.item(i).title;
|
|
$.ajax({
|
|
type: "post",
|
|
url: url1+"HebCAService.ashx",
|
|
data: { InstanceRecordId: id, filesId: documentid, opinion: opinion },
|
|
dataType: 'text',
|
|
success: function(msg) {
|
|
if (msg.length > 0) {
|
|
var a = msg.split(",");
|
|
if (a.length == 3) {
|
|
document.getElementById(a[0]).VerifyAndShowSealWithResult(a[1], 1, a[2]);
|
|
if (document.getElementById(a[0] + "1") != null) {
|
|
document.getElementById(a[0] + "1").VerifyAndShowSealWithResult(a[1].replace(" ", "+"), 1, a[2]);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
error: function(msg) {
|
|
alert(msg);
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|
|
function checkdata() {
|
|
|
|
//判断输入长度是否合法
|
|
if (strlen(document.getElementById("txtTransactMessage").value) > 500) {
|
|
|
|
return false;
|
|
}
|
|
else {
|
|
return true;
|
|
}
|
|
}
|
|
//获取字符串长度
|
|
function strlen(str) {
|
|
|
|
var totalCount = 0;
|
|
for (var i = 0; i < str.length; i++) {
|
|
var c = str.charCodeAt(i);
|
|
if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
|
|
totalCount++;
|
|
}
|
|
else {
|
|
totalCount += 2;
|
|
}
|
|
}
|
|
return totalCount;
|
|
}
|
|
//无效章的判断
|
|
function TjConfirm(validate) {
|
|
if (validate == "0")
|
|
{
|
|
var j = 0;
|
|
var mSignXMl = DocForm.SignatureControl.GetSignatureInfo();
|
|
var XmlObj = new ActiveXObject("Microsoft.XMLDOM");
|
|
XmlObj.async = false;
|
|
var LoadOk = XmlObj.loadXML(mSignXMl);
|
|
var ErrorObj = XmlObj.parseError;
|
|
|
|
var CurNodes = XmlObj.getElementsByTagName("iSignature_HTML");
|
|
for (var iXml = 0; iXml < CurNodes.length; iXml++)
|
|
{
|
|
var TmpNodes = CurNodes.item(iXml);
|
|
if (TmpNodes.selectSingleNode("SignatureResult").text == "False")
|
|
{
|
|
j = j + 1;
|
|
}
|
|
}
|
|
if (j >= 1)
|
|
{
|
|
alert("当前文档内有" + j + "个无效章,请撤销重新签章后,再提交!");
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|