NtkoSignManage.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /**
  2. * @author Raise
  3. */
  4. NtkoSignManage = function() {
  5. this.ntkoSignObj;
  6. /**
  7. * 加载NTKO电子印章控件
  8. * arg targetId 加载控件存放的目标Dom元素。
  9. * arg attachmentId NTKO电子印章文件的ID。如果不为空,加载对应的文件
  10. */
  11. this.load = function(targetId,attachmentId) {
  12. var cabPath=__ctx +"/media/office/ntkosigntool.cab#version=4,0,0,2";
  13. var tags="";
  14. tags+='<object id="ntkosignctl" classid="clsid:97D0031E-4C58-4bc7-A9BA-872D5D572896" codebase="'+cabPath+'" ';
  15. tags+=' width=450 height=100> ';
  16. tags+='<param name="BackColor" value="16744576"> ';
  17. tags+='<param name="ForeColor" value="16777215"> ';
  18. tags+='<param name="IsShowStatus" value="-1"> ';
  19. tags+='<param name="EkeyType" value="1"> '; // HT
  20. tags+='<SPAN STYLE="color:red">不能装载印章管理控件,必须使用IE内核浏览器。可能需要在浏览器的Internet选项安全设置中修改ActiveX配置。按提示加载控件。</SPAN> ';
  21. tags+='</object> ';
  22. $('<div style="display: none;" id="divntko"></div>').prependTo('body');
  23. $('#'+targetId).append(tags);
  24. this.ntkoSignObj = document.getElementById("ntkosignctl");
  25. if('undefined' == typeof (this.ntkoSignObj.StatusCode)){
  26. $.ligerDialog.warn("不能装载印章管理控件,必须使用IE内核浏览器。可能需要在浏览器的Internet选项安全设置中修改ActiveX配置。",'提示信息',function(){
  27. window.history.back();
  28. });
  29. return false;
  30. }
  31. if((attachmentId!="")||('undefined' == typeof (attachmentId))){
  32. this.openFormURL(attachmentId);
  33. if (0 != this.ntkoSignObj.StatusCode) {
  34. window.history.back();
  35. }
  36. }
  37. };
  38. /**
  39. * 获取ntkoSignObj,代表当前的电子印章对象
  40. */
  41. this.getntkoSignObject = function() {
  42. this.ntkoSignObj.IsShowRect = false;
  43. return this.ntkoSignObj;
  44. };
  45. /**
  46. * 从指定的文件ID,打开电子印章。
  47. */
  48. this.openFormURL = function(fileId) {
  49. var url=__ctx + "/platform/system/sysFile/getFileById.ht?fileId=" + fileId;
  50. this.ntkoSignObj.OpenFromURL(url);
  51. if (0 != this.ntkoSignObj.StatusCode) {
  52. alert("打开印章出错!");
  53. }
  54. };
  55. /**
  56. * 从本地打开或导入电子印章。
  57. */
  58. this.openFromLocal = function() {
  59. this.ntkoSignObj.OpenFromLocal('',true);
  60. };
  61. /**
  62. * 从导出到本地电子印章。
  63. */
  64. this.saveToLocal = function() {
  65. var spassowrd = this.ntkoSignObj.Password;
  66. if('undefined'==typeof (spassowrd)||spassowrd==null||spassowrd==""){
  67. alert("没有印章!");
  68. return false;
  69. }
  70. this.ntkoSignObj.SaveToLocal('',true);
  71. if(0 == this.ntkoSignObj.StatusCode){
  72. alert("保存印章到本地文件成功!");
  73. }else{
  74. alert("保存印章到本地文件失败!");
  75. }
  76. };
  77. /**
  78. * 创建新的电子印章
  79. */
  80. this.newSign = function(callback) {
  81. this.ntkoSignObj.IsShowRect = false;
  82. var url=__ctx+ "/platform/system/seal/addSign.ht";
  83. url=url.getNewUrl();
  84. var params={
  85. };
  86. var that =this;
  87. DialogUtil.open({
  88. height:400,
  89. width: 600,
  90. title : '电子印章',
  91. url: url,
  92. isResize: true,
  93. //自定义参数
  94. params: params,
  95. sucCall:function(rtn){
  96. that.ntkoSignObj.CreateNew(rtn.signname,rtn.username,rtn.password,rtn.filename);
  97. callback(rtn);
  98. }
  99. });
  100. };
  101. /**
  102. * 将电子印章保存到服务器上。
  103. */
  104. this.saveSign=function(){
  105. var sname = this.ntkoSignObj.SignSN;
  106. if('undefined'==typeof (sname)||sname==null||sname==""){
  107. sname = "导入:"+this.ntkoSignObj.SignName;
  108. }
  109. var path= __ctx + "/platform/system/sysFile/saveFile.ht";
  110. var result = this.ntkoSignObj.SaveToURL(path,"EspFileName","file_cat=sealSign&uploadName=EspFileName",sname+'.esp',0);
  111. if (0 != this.ntkoSignObj.StatusCode) {
  112. alert("创建印章错误.");
  113. return false;
  114. }
  115. if(result==-1){
  116. return false;
  117. }
  118. return result;
  119. };
  120. /**
  121. * 创建并保存电子印章。
  122. */
  123. this.createSign=function(name, user, password, file){
  124. var ntkoSignObj = this.getntkoSignObject();
  125. ntkoSignObj.IsShowRect = false;
  126. ntkoSignObj.CreateNew(name, user, password, file);
  127. if (0 != ntkoSignObj.StatusCode) {
  128. alert("创建印章错误.");
  129. return false;
  130. }
  131. var path= __ctx + "/platform/system/sysFile/saveFile.ht";
  132. var result = ntkoSignObj.SaveToURL(path,"EspFileName","file_cat=sealSign&uploadName=EspFileName",ntkoSignObj.SignSN+'.esp',0);
  133. if (0 != ntkoSignObj.StatusCode) {
  134. alert("创建印章错误.");
  135. return false;
  136. }
  137. return result;
  138. };
  139. };