xinyb
2022-12-05 4bda8904a83c80b09985d7df8f6c49a6cbe027dd
提交 | 用户 | age
f7809b 1 var version = 0;// 版本号
a6a76f 2 var pwdCallBack = null;// 密码输入点击确定后回调函数
F 3 var obj22 = null;// 22类型传值对象
7f7112 4 var shx=false;
a6a76f 5 var leftWidth="0";
F 6 var gridId=[];
7 //var uploadObj = null;
8 //var edit='';
9 var pic={};// 格线附件上传参数属性
10 var rsakey={
11     pubkey:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkRupiYcKVGGUtDBDoR1t/1zm3ZtZgnte39iTJW6hlqjdY0UagKjpNiIv7J6XjtgfX7SgsR4AWnivqQHAICIvdPKfGZZzIs62OQ19MqrDTMoB/LvK5teNWhClv23WMUfRbP+EHgprT6hTw8U5apw1IB6i/y57NkLav792wiYBYRU4X45NoTaT+aiTSLFEflbfm94EXnhSS3vFkBmrZGy5BRNI8gmzafroslGx2Hk90CqlNdeKYxgZQ6xtvj+u33yrszWvPT6F9fsJT8aMjtvH050iYKRVct+x6Q7VRJgCI4MgvAexnTKdxW54YzvXCuO5bDiy5la7CgerWkTAq9dzXwIDAQAB"
12 };
13 //拼接附件url
14 function getAttachmentUrl(staticUrl,formid,unid,domain,dbid,isShowOrgPic,width,height,fileExt,isDownLoad){
7f7112 15     // if (staticUrl != null && staticUrl != "") {
X 16     //     if (isDownLoad) {
17     //         return unid + "_" + dbid + "_" + formid + "_" + fileExt;
18     //     } else {
19     //         return domain + staticUrl;
20     //     }
21     // }
38c24d 22     width = width || 80;
X 23     height = height || 80;
24     isShowOrgPic = isShowOrgPic || false;
25     fileExt = "." + fileExt || "";
26     return domain + "/uploads/attachment/" + dbid + "/" + formid + "/" + unid + (isShowOrgPic ? ("_" + width + "x" + height) : "") + fileExt;
a6a76f 27 }
F 28 //31类型新增sqlWhere设置,拼接sql,在可编辑状态时调用
29 //dysql:select * from gfield where formid=120201 order by statisid desc, sqlWhere: formname='xxx'
30 //返回 select * from gfield where (formid=120201) and (formname='xxx') order by statisid desc
31 // by danaus 2019/12/21 16:46
32 function processDysqlV2(dysql,sqlWhere){
33     if(sqlWhere!=undefined&&sqlWhere!=""){//存在sqlWhere
34         var patt1=new RegExp(/where.*/i);//判断有没where部分
35         var whereArry=patt1.exec(dysql);
36         if(whereArry!=null){//表示原sql有where条件 where formid=120201 order by statisid desc
37             var where=whereArry[0];
38             dysql=dysql.replace(where,"");
39             patt1=new RegExp(/order by.*/i);//判断有没order by部分
40             var orderby=patt1.exec(where);
41             if(orderby!=null){//order by statisid desc
42                 where=" where ("+where.replace(patt1,"").replace(/where/i,"")+") and ("+sqlWhere+") "+orderby[0];
43             }else{
44                 where=" where ("+where.replace(/where/i,"")+") and ("+sqlWhere+") ";
45             }
46             dysql=dysql+where;
47         }else{//是否有order by
48             //直接在原sql上加sqlWhere
49             patt1=new RegExp(/order by.*/i);//判断有没order by部分
50             var orderby=patt1.exec(dysql);
51
52             if(orderby!=null){//order by statisid desc
53
54                 dysql=dysql.replace(orderby,"")+" where (1=1) and ("+sqlWhere+") "+orderby[0];
55             }else{
56                 dysql=dysql+" where (1=1) and ("+sqlWhere+") ";
57             }
58         }
59     }
60     return dysql;
61 }
62 function generateUUID() {
63     var d = new Date().getTime();
64     if (window.performance && typeof window.performance.now === "function") {
65         d += performance.now(); //use high-precision timer if available
66     }
67     var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
68         var r = (d + Math.random() * 16) % 16 | 0;
69         d = Math.floor(d / 16);
70         return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
71     });
72     return uuid;
73 }
74
75 // 2类型树节点,显示图片
76 function createUploadDiv(colname, value) {
77     if ((";" + nodejs.uploadColName + ";").match(";" + colname + ";")) {
78         $("#uploadDiv_" + colname).empty();
79         var photo = $('<div id="uploadRootDiv_"' + colname + '></div>')
80                 .append(
81                         '<input id="'
82                                 + colname
83                                 + '_up" type="file" multiple class="file" data-overwrite-initial="false" data-min-file-count="1"><input id="'
84                                 + colname + '" name="' + colname
85                                 + '" value="" type="hidden" />');
86         $("#uploadDiv_" + colname).append(photo);
87         onfileiput(formId, colname, panMain[0].panInfo[colname].controltype,
88                "", "", nodejs.usercode, value);
89         picevent(colname);   // 事件
90         $doc(colname).val(value);
91     }
92 }
93
693828 94 /**
X 95  *下面的方法是针对9/19附件控件类型 xin 2021-5-13 09:59:58
96  */
7f7112 97 //渲染出附件界面出来
X 98  var BootstrapFileInputOption = function(id){
99     let o = {
100         e: $('#' + id + '_up'),
101         id:$('#'+id),
102         name:id,
83ba69 103         NumberofSummary:[],//更新次数集合
7f7112 104         option: {//属性
X 105             uploadUrl: '#',   // String,用于上传处理操作的URL(通常是基于Ajax的处理)
e9ff5e 106             uploadIdEvnt:$('#'+id),
7f7112 107             language: 'zh',   // 语言
X 108             uploadAsync: false,   // bool是否多文件批量上传将并行异步/。默认为true
109             showCaption: false,//是否显示被选文件的简介
110             showBrowse: false,//是否显示文件浏览按钮
be5949 111             showBatchDownload:true,//显示批量下载按钮
7f7112 112             showUpload: false,//是否显示上传按钮
X 113             showCancel: false,//是否显示取消按钮
114             showRemove: false,//是否显示移除按钮
115             showDrag:false,//是否显示拖动按钮
116             showClose: false,//是否显示关闭按钮
117             dropZoneEnabled: true,   //是否显示拖拽区域
118             browseOnZoneClick: false,   //布尔值,是否在点击预览区域时触发文件浏览/选择。默认为false
119             showUploadedThumbs: true,   // 是否在预览窗口中持续显示已经上传的文件缩略图(用于ajax上传),直到按下删除/清除按钮
120             maxFilesNum: 10,   // 上传最大的文件数量
121             maxFileCount: 0,   // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
122             isNine: false,   // 19类型就为false,9类型就为true,下面有判断
123             validateInitialCount: false,   // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
124             overwriteInitial: true,   // 是否要覆盖初始预览内容和标题设置
125             initialPreviewAsData:true,
126             allowedFileExtensions:null,//允许上传的文件扩展名列表。默认情况下设置为 null
127             dropZoneTitle:'点击或拖拽文件',
128             dropZoneClickTitle:'',
129             layoutTemplates : {
130                  indicator:''//去掉上传状态图标
131                 ,actionUpload: ''//去除缩略图中文件上传操作按钮的模板
132                 ,actionDrag:''//去掉缩略图拖动图标
133                 ,footer : '<div class="file-thumbnail-footer" style="height: auto">\n' +
134                 '    {actions}\n' +
135                 '</div>'
136             },
137             //自定义按钮(权限)
138             otherActionButtons:'<button type="button" onclick="mylockFile(this)" ' +
139                 'class="kv-file-lock btn btn-sm btn-kv btn-default btn-outline-secondary"' +
140                 'title="权限"{dataKey}><i class="bi-shield-lock"></i></button>'
141             ,previewSettings: {   // 设置显示的图片相同的宽度高度
142                 image: {width: '110px', height: '110px'},
143                 html: {width: "110px", height: "110px"},
144                 text: {width: "110px", height: "110px"},
145                 office: {width: "110px", height: "110px"},
146                 gdocs: {width: "110px", height: "110px"},
147                 video: {width: "110px", height: "110px"},
148                 audio: {width: "110px", height: "110px"},
149                 flash: {width: "110px", height: "110px"},
150                 object: {width: "110px", height: "110px"},
151                 pdf: {width: "110px", height: "110px"},
152                 other: {width: "110px", height: "110px"}
153             },
f58373 154             previewSettingsSmall: {
X 155                 image: {width: '110px', height: '110px', 'max-width': '110px', 'max-height': '110px'},
156                 html: {width: '110px', height: '110px'},
157                 text: {width: '110px', height: '110px'},
158                 office: {width: '110px', height: '110px'},
159                 gdocs: {width: '110px', height: '110px'},
160                 video: {width: '110px', height: '110px'},
161                 audio: {width: '110px', height: '110px'},
162                 flash: {width: '110px', height: '110px'},
163                 object: {width: '110px', height: '110px'},
164                 pdf: {width: '110px', height: '110px'},
165                 other: {width: '110px', height: '110px'}
166             },
27db5c 167             preferIconicPreview: true,
X 168             previewFileIconSettings: {
169                 'doc': '<i class="bi bi-filetype-doc" style="color: #3b93e7"></i>',
170                 'xls': '<i class="bi bi-filetype-exe" style="color: #479347"></i>',
171                 'ppt': '<i class="bi bi-filetype-ppt" style="color: #ea500a"></i>',
172                 'pdf': '<i class="bi bi-filetype-pdf" style="color: red"></i>',
173                 'zip': '<i class="bi bi-file-earmark-zip" style="color: #2a7e77"></i>',
174                 'htm': '<i class="bi bi-filetype-html" style="color:#369584"></i>',
175                 'txt': '<i class="bi bi-filetype-txt" style="color: #5d5a5a"></i>',
176                 'mov': '<i class="bi bi-film"></i>',
177                 'mp3': '<i class="bi bi-filetype-mp3"></i>'
178             },
179             previewFileExtSettings: {
180                 'doc': function(ext) {
181                     return ext.match(/(doc|docx)$/i);
182                 },
183                 'xls': function(ext) {
184                     return ext.match(/(xls|xlsx)$/i);
185                 },
186                 'ppt': function(ext) {
187                     return ext.match(/(ppt|pptx)$/i);
188                 },
189                 'zip': function(ext) {
190                     return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
191                 },
192                 'htm': function(ext) {
193                     return ext.match(/(htm|html)$/i);
194                 },
195                 'txt': function(ext) {
196                     return ext.match(/(txt|ini|csv|java|php|js|css)$/i);
197                 },
198                 'mov': function(ext) {
199                     return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
200                 },
201                 'mp3': function(ext) {
202                     return ext.match(/(mp3|wav)$/i);
203                 }
204             },
879d54 205             isNodragging:false,//自定义属性,在只读状态是否可以执行拖拽
7f7112 206             fileActionSettings:{//用于在预览窗口中为新选择的文件缩略图设置文件操作的配置
X 207                 // showDownload:false,//是否在缩略图中显示下载按钮
208                 showUpload:false//是否在缩略图中显示上传按钮
209             },
210             // usePdfRenderer: true,//启动自定义的内部插件,false值或不设置这个属性将是默认的插件
211             // pdfRendererUrl: '',//'/general/pdf/web/viewer.jsp',//预览pdf格式的插件路径
212             initialPreview: [],   // 字符串或者数组,要显示的初始预览内容
213             initialPreviewConfig: [],   // 数组,为每个initialPreview条目(就是initialPreview中的每个预览)设置重要属性的配置
214             showPreview: true,   // 布尔值,是否显示文件预览。默认值为true
215             maxFileSize: 0//允许上传的文件大小(默认为0,不限制)
216         },
217         fileInput: function () {//渲染,并且绑定事件
218             this.e.fileinput(this.option);
219         },
220         events:function (isGrid,g) {
221             let fileInputId=this.e;
222             let id=this.id;
223             let name=this.name;
009fd3 224             let Event=this;
7f7112 225             let datas={};
X 226             fileInputId.on("filebatchselected", function(event, files) {
227                 // 在预览中选择并显示一批文件后触发此事件(选择结束后触发的事件)
228                 if(!g){   // 不是格线
229                     // 触发修改(面板有内容改动,刷新界面时候有提示)
230                     upSub(name);
231                 }
232                 //触发上传功能
233                 fileInputId.fileinput('upload');
234             }).on('filebatchuploadsuccess', function(event, data) {
235                 // 此事件仅在ajax上传且文件批量上传成功之后触发
236                 let tmp={};
237                 let oldKey=id.val();// 旧的值
238                 let newKey=data.response.uuid?data.response.uuid+";":"";   // 新的值
239                 if(oldKey!=""){
240                     var keys=oldKey.split(";");
241                     for(var i=1;i<keys.length;i++){
242                         newKey=newKey.replace(";"+keys[i]+";",";");
243                     }
244                 }
245                 tmp.key=newKey;
246                 tmp.type=data.response.type;
247                 tmp.filedId=name;
248                 tmp.oldKey=oldKey;
249                 let unid = data.response.uuid?data.response.uuid:"";
250                 id.val(unid);
adafe0 251                 if(data.thumbs!=null){
X 252                     data.thumbs.attr("data-key",JSON.stringify(tmp));
253                 }
7f7112 254                 // 格线调用
X 255                 if(g){
256                     let grid=g.id;
257                     let obj=unid+";"+data.response.fileType;// by by danaus 2020/4/30 11:32
258                     grid.SetValue(g.row, g.col,obj,0);
259                     grid.RefreshCell(g.row, g.col);
260                 }
261             }).on('filebeforedelete', function(event, params) {
262                 // 在删除initialPreview内容集中的每个缩略图文件之前触发此事件
263                 let e=!confirm("您确定要删除吗?");
264                 return e;
265             }).on('filedeleted', function(event, key) {
266                 // 在删除initialPreview内容集中的每个缩略图文件之后触发此事件
267                 // 格线调用
268                 if (isGrid != null && isGrid == 'grid') {
269                     if (g) {
270                         let grid = g.id;
271                         let obj = "";
272                         grid.SetValue(g.row, g.col, obj, 0);
273                         grid.RefreshCell(g.row, g.col);
274                     }
275                 } else {   // 面板
276                     let va = id.val();
277                     key = key.split(";")[1];
278                     va = va.replace(";" + key, "");
279                     if (va.indexOf(";") < 0) {
280                         va = "";
281                     }
282                     id.val(va);
283                     panMain[panIndex].isChange = 1;  //解决110101上传后删除附件不成功,而出现多个序号的问题
284                 }
285             }).on('filesuccessremove', function(event, val) {
286                 // 使用缩略图删除按钮删除成功上传的缩略图后,会触发此事件
adafe0 287                 if(val!=null && val.key!=null){
X 288                     let vals = val.key.split(";");
289                     let uuid;
290                     let seq = 0;
291                     if (vals.length > 1) {
292                         uuid = val.key.split(";")[0];
293                         seq = val.key.split(";")[1];
7f7112 294                     }
adafe0 295                     $.ajax({
X 296                         type: "POST",
297                         dataType: 'json',
298                         url: '/attachment/deleteOwnerAttachment.do?type=' + val.type + '&unid=' + uuid + '&seq=' + seq,   // 删除路径
299                         success: function (data) {
300                             let newUid = val.oldKey == "" ? "" : val.oldKey.replace(";" + seq, "");
301                             id.val(newUid);
302                         }
303                     });
304                 }
7f7112 305             }).on('filezoomshown', function(event, params) {
X 306                 //此事件在模态对用户可见后触发(将等待 CSS 转换完成)
83ba69 307                 Event.NumberofSummary=params.NumberofSummary||[];
71dba6 308                 Event.imageEvent(params);
7f7112 309             }).on('filezoomprev', function(event, params) {
X 310                 //事件在缩放预览模式下,当点击上一个导航按钮查看上一个文件时触发(也在缩放模式下按下键盘左箭头时触发)
e91f77 311                 setTimeout(function(){//这个事件不是渲染完进入,导致提前渲染图片查看器。 没什么决绝办法用setTimeout吧
71dba6 312                     Event.imageEvent(params)
X 313                 },300);
7f7112 314             }).on('filezoomnext', function(event, params) {
X 315                 //该事件在缩放预览模式下,当点击下一个导航按钮查看下一个文件时触发(也在缩放模式下按下键盘右箭头时触发)。
71dba6 316                 setTimeout(function(){
X 317                     Event.imageEvent(params)
318                 },300);
7f7112 319             });
71dba6 320         },imageEvent:function (param) {
X 321             try {
ec2539 322                 let that=this;
71dba6 323                 isFileInputImage = new Viewer(param.modal.find('ul')[0], {
ec2539 324                     title: true, inline: true, button: false,
X 325                     viewed: function (e) {// 图片渲染完后进入,旋转大图片
326                         if(typeof isFileInputImage!='undefined' && isFileInputImage!=null){
327                             that.imageAjax(param.modal,isFileInputImage);
328                         }
329                     }
71dba6 330                 });
X 331                 isFileInputImage.imageCurrent = 0
332                 isFileInputImage.view(param.viewerIndex || 0);
ec2539 333                 if(typeof isFileInputImage!='undefined' && isFileInputImage!=null){
X 334                     that.imageAjax(param.modal,isFileInputImage);
335                 }
71dba6 336             } catch (e) {
X 337                 isFileInputImage = null;
009fd3 338             }
ec2539 339         },imageAjax:function (modal,isfile) {
83ba69 340             let seq = 0;
X 341             let number = this.NumberofSummary;
ec2539 342             let image = isfile.image.currentSrc;
X 343             let i = image.split("/");
344             i = i[i.length - 1];
345             let p = i.split('@p@');
346             if (p.length == 2) {
83ba69 347                 seq = p[1].split('.')[0];
ec2539 348             }
83ba69 349             if (number.length > 0) {
X 350                 for (let s = 0; s < number.length; s++) {
351                     if (seq == number[s].seq) {
352                         if(number[s].state==-1){//没有查看次数后隐藏
353                             modal.find('.viewer-canvas').find('img').hide();
354                             modal.find('.viewer-canvas').html('<div style="visibility: visible;font-size: 30px;padding-top: 100px">'+number[s].describe+'</div>');
355                         }
356                         modal.find('.kv-zoom-caption').html(number[s].fileName);
357                         modal.find('.kv-zoom-caption').attr('title', number[s].fileName);
358                         modal.find('.viewsNumber').html(number[s].totaViewNums);
359                         modal.find('.downNumber').html(number[s].totaDownNums);
4bda89 360                         modal.find('.numberofviews').attr('title','总查看次数:'+number[s].totaViewNums);
X 361                         modal.find('.amountofdownloads').attr('title','总下载次数:'+number[s].totaDownNums);
362                         if(number[s].allowViewNums>0){
363                             modal.find('.zoom-view').show();
364                             modal.find('.viewNums').html(number[s].viewNums);
365                             modal.find('.zoom-view').attr('title','允许查看次数:'+number[s].allowViewNums+'\n您已查看:'+number[s].viewNums);
366                         }else{
367                             modal.find('.zoom-view').hide();
368                         }
369                         if(number[s].allowDownNums>0){
370                             modal.find('.zoom-down').show();
371                             modal.find('.downNums').html(number[s].downNums);
372                             modal.find('.zoom-down').attr('title','允许下载次数:'+number[s].allowDownNums+'\n您已下载:'+number[s].downNums);
373                         }else{
374                             modal.find('.zoom-down').hide();
375                         }
83ba69 376                         break;
ec2539 377                     }
X 378                 }
83ba69 379             }
7f7112 380         }
X 381     }
382     return o;
383 }
693828 384 /**
X 385  *-----end-----上面的方法是针对9/19附件控件类型 xin 2021-5-13 09:59:58
386  */
7f7112 387 /**
X 388  * 加载面板附件内容
389  * @param formid 功能号
390  * @param id 控件ID
391  * @param controlType 控件类型
392  * @param docstatus 单据状态值
393  * @param rowid rowId
394  * @param usercode 账号
395  * @param uuid uuId
396  * @param maxFileSize 上传附件大小限制值
397  */
a6a76f 398 function onfileiput(formid,id,controlType,docstatus,rowid,usercode,uuid,maxFileSize){
7f7112 399     //获取到插件基本属性
X 400     let fileInput = BootstrapFileInputOption(id);
401     var isReadOnly = false;
402     try {
403         // 上传附件需要的参数
404         var param = {};
405         var panelautoSave = "";//标记是否为单据
a6a76f 406         var readerUserCodes = $('#readerusercodes').val();
7f7112 407         var uid = $('#' + id).val();
X 408         uid = uid == undefined ? "" : uid.replace(/^;+/g, "");//处理值是;;;这样1个或多个的情况
409         param.fieldid = id;
410         param.controltype = controlType;
411         param.formid = formid;
412         param.unid = (uuid == undefined ? uid : uuid);
413         param.maxFileSize = maxFileSize;
414         param.docstatus = docstatus;
415         param.rowid = rowid;
416         param.usercode = usercode;
417         try {
418             param.doccode = $('#doccode').val();
419             if (param.doccode == undefined) {
420                 param.doccode = panMain[panIndex].panelAuditValue.doccode;
a6a76f 421             }
7f7112 422             if (param.doccode && readerUserCodes != undefined && readerUserCodes != '') {
X 423                 param.readerusercodes = readerUserCodes;
a6a76f 424             }
7f7112 425         } catch (e) {
X 426             param.doccode = panMain[panIndex].panelAuditValue.doccode;
a6a76f 427         }
7f7112 428         if (formType && (formType == 5 || formType == 9
X 429             || formType == 15 || formType == 8
430             || formType == 496 || formType == 497
431             || formType == 16 || formType == 17)) {
432             panelautoSave = "&is16=1";
433             for (var i in panMain) {   // 循环状态值,如果面板有这个0或1就循环下去,没有就直接跳过
434                 if (panMain[i].picState[id] != undefined) {
435                     var ed = panMain[i].picState[id].split(";pb#");
436                     param.headflag = ed[0];
437                     param.editstatus = (ed.length > 1 && ed[1] != null ? ed[1] : ed[0]);
438                     if (param.editstatus != "") {
439                         if ((";" + param.editstatus + ";").indexOf(";" + docstatus + ";") > -1) {
440                             isReadOnly = false;
441                         } else {
442                             isReadOnly = true;
a6a76f 443                         }
F 444                     }
7f7112 445                 }
a6a76f 446             }
F 447         }
7f7112 448         // 请求后台数据信息
X 449         $.ajax({
450             url: '/attachment/getAttachmentList.do',
451             type: "POST",
452             async: false,
453             data: {pant: JSON.stringify(param)},
454             dataType: 'json',
455             success: function (jsons) {
456                 if (isReadOnly) {//只读状态时候
457                     fileInput.option.layoutTemplates.actionDelete = '';//隐藏删除
458                     fileInput.option.otherActionButtons = '';//隐藏权限
879d54 459                     fileInput.option.isNodragging=true;//禁止拖拽(自定义)
7f7112 460                 }
X 461                 fileInput.option.browseOnZoneClick = !isReadOnly;//是只读状态就禁用点击区域上传附件功能
462                 fileInput.option.maxFileSize = maxFileSize;//上传大小(kb)
a6a76f 463                 var encrypt = new JSEncrypt();
F 464                 encrypt.setPublicKey(rsakey.pubkey);
7f7112 465                 for (var i = 0; i < jsons.length; i++) {
X 466                     //表示返回的新单需要的数据,而不是附件的内容
467                     if (jsons.length == 1 && jsons[0].isNewAttachment == 1) {
468                         param.domain = jsons[0].domain;
469                         param.dbid = jsons[0].dbid;
470                         param.usercode = jsons[0].userCode;
471                         param.username = jsons[0].userName;
a6a76f 472                         break;
F 473                     }
474                     // 图片属性
7f7112 475                     if (i == 0) {
X 476                         param.domain = jsons[i].domain;
477                         param.usercode = jsons[i].userCode;
478                         param.username = jsons[i].userName;
479                         param.dbid = jsons[i].dbid;
a6a76f 480                     }
7f7112 481                     //文件路径
X 482                     let fileURL = getAttachmentUrl(jsons[i].staticUrl, jsons[i].formid,
483                         jsons[i].unid + "@p@" + jsons[i].seq, jsons[i].domain, jsons[i].dbid,
484                         false, 60, 60, jsons[i].orgFileType);
485                     //文件显示信息
c74a0b 486                     let title = '文件名: ' + jsons[i].originalFileName +
X 487                         ' \n类型: ' + jsons[i].fileType +
488                         ' \n大小: ' + jsons[i].fileSizeStr +
489                         ' \n上传者: ' + jsons[i].authorName +
4bda89 490                         ' \n上传时间: ' + jsons[i].uploadTimeStr +
X 491                         ' \n\n总查看次数: ' + jsons[i].totalViewNums +
492                         ' \n总下载次数: ' + jsons[i].totalDownNums;
493                         if(jsons[i].allowViewNums>0 || jsons[i].allowDownNums>0){
494                             title+=' \n\n作者【'+jsons[i].authorName+'】授权您:'
495                         }
496                         if(jsons[i].allowViewNums>0) {
497                             title+= ' \n允许查看次数: ' + jsons[i].allowViewNums +
498                             ' \n您已查看: ' + jsons[i].viewNums +'\n' ;
499                         }
500                         if(jsons[i].allowDownNums>0) {
501                             title += ' \n允许下载次数: ' + jsons[i].allowDownNums +
502                             ' \n您已下载: ' + jsons[i].downNums;
503                         }
7f7112 504                     //下载地址
X 505                     let Down = jsons[i].domain + "/attachment/downLoadAttachment.do?filePath=" +
506                         jsons[i].unid + "@p@" + jsons[i].seq + "_" + jsons[i].dbid + "_" +
507                         jsons[i].formid + "_" + jsons[i].orgFileType;
508                     //删除地址
adafe0 509                     let deleURL = '#';
27db5c 510                     if (!isReadOnly) {//不是只读
X 511                         deleURL = jsons[i].domain + '/attachment/deleteAttachmentV2.do?' +
512                             'type=' + (controlType == 9 ? '1' : '3') + '&formid=' + param.formid +
513                             '&doccode=' + param.doccode + '&fieldid=' + id + '&unid=' + jsons[i].unid + '&seq=' +
514                             jsons[i].seq + '&docstatus=' + param.docstatus + '&ishd=1&usercode=' +
515                             encodeURIComponent(encrypt.encrypt(jsons[i].authorCode)) + '&readerusercodes=' +
516                             readerUserCodes + '&dbid=' + encodeURIComponent(encrypt.encrypt(jsons[i].dbid)) +
517                             '&curUsername=' + encodeURIComponent(encrypt.encrypt(jsons[i].userName)) + '&curUsercode=' +
518                             encodeURIComponent(encrypt.encrypt(jsons[i].userCode));
519                     }
f9e811 520                     //注释,不用viewer.jsp打开pdf文件,因为用这个打开有印章的pdf,印章会被屏蔽 xin 2022-6-23 09:44:07
X 521                     // if (jsons[i].fileType.toLowerCase() == 'pdf') {//pdf格式调用插件
522                     //     fileURL = jsons[i].domain + '/general/pdf/web/viewer.jsp?file=' + fileURL;
523                     // }
7f7112 524                     if (jsons[i].orgFileType == 'doc' || jsons[i].orgFileType == 'docx' || jsons[i].orgFileType == 'xls'
X 525                         || jsons[i].orgFileType == 'xlsx' || jsons[i].orgFileType == 'ppt' || jsons[i].orgFileType == 'pptx') {
526                         jsons[i].fileType = 'office';
f182c8 527                         fileURL = encodeURIComponent(fileURL);
7f7112 528                     }
X 529                     fileInput.option.initialPreview.push(fileURL);
530                     fileInput.option.initialPreviewConfig.push({
531                         'caption': jsons[i].originalFileName,   // 上传的图片名称
532                         'time': jsons[i].uploadTimeStr,  //上传开始时间
533                         'name': jsons[i].authorName,  //作者名称
534                         'size': jsons[i].fileSizeStr,   // 上传的图片大小
535                         'type': jsons[i].fileType,   // 上传的图片类型
27db5c 536                         'filename': jsons[i].originalFileName,//jsons[i].physicalFile,   //物理文件
7f7112 537                         'filetype': jsons[i].fileType + '/' + jsons[i].orgFileType,
X 538                         'title': title,//title
539                         'key': jsons[i].unid + ';' + jsons[i].seq,//key
899da7 540                         'seq':jsons[i].seq,
7f7112 541                         'downloadUrl': jsons[i].allowDownload ? Down : false,   // true值时候设置下载地址,否则设置false不显示下载按钮
0c06a4 542                         'downClick':'downFile(this,\''+jsons[i].unid+'\',\''+jsons[i].seq+'\')',//下载按钮onclick事件 xin 2022-12-2 08:40:35
7f7112 543                         'url': deleURL,// 附件删除路径
X 544                         'hasZoom': jsons[i].allowView,//是否能查看
545                         // 'hasDwn': jsons[i].allowDownload,//是否能下载
546                         'hasDel': jsons[i].allowDelete,//是否能删除
71dba6 547                         'hasLock': jsons[i].authorCode != null && jsons[i].authorCode == param.usercode ? true : false,//是否能显示权限
ec2539 548                         'viewsNumber':jsons[i].viewNums,//查看次数
X 549                         'downNumber':jsons[i].downNums//下载次数
7f7112 550                     });
a6a76f 551                 }
7f7112 552                 // 附件上传路径(组装参数)
27db5c 553                 let upURL = '';
X 554                 if(!isReadOnly) {//不是只读
555                     upURL= param.domain + '/attachment/uploadAttachmentV2.do?' +
7f7112 556                     'type=' + (controlType == 9 ? '1' : '3') + '&formid=' + param.formid +
X 557                     '&doccode=' + param.doccode + '&fieldid=' + id + '&rowid=' + Math.random() +
558                     '&usercode=' + encodeURIComponent(encrypt.encrypt(param.usercode)) +
559                     '&username=' + encodeURIComponent(encrypt.encrypt(param.username)) +
e9ff5e 560                     '&ishd=1' + panelautoSave + '&dbid=' + encodeURIComponent(encrypt.encrypt(param.dbid));
X 561                     // '&uuid=' + uid;//$('#' + id).val();
27db5c 562                 }
7f7112 563                 fileInput.option.uploadUrl = upURL;
a6a76f 564                 // 判断如果是9类型就输出,如果是19类型就不输出
7f7112 565                 if (controlType == 9) {
f182c8 566                     fileInput.option.maxTotalFileCount = 1;// 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
X 567                     fileInput.option.isNine = true;   // 19类型就为false,9类型就为true---(忽略验证检查)
7f7112 568                     fileInput.option.validateInitialCount = true;   // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
X 569                     fileInput.option.overwriteInitial = false;   // 是否要覆盖初始预览内容和标题设置
a6a76f 570                 }
F 571             }
572         });
7f7112 573     } catch (e) {
a6a76f 574         $.messager.alert("提示", "未能加载附件信息!" + e, "warning");
7f7112 575     } finally {
X 576         // 渲染显示
577         fileInput.fileInput();
578         if (isReadOnly) {//是只读
27db5c 579             $("#"+id+"_show_type .file-preview").css("background", "#CCC");
e0a458 580             $("#"+id+"_show_type .file-footer-buttons").find("a").css("background", "#CCC").css("color","#6c757d");
27db5c 581             $("#"+id+"_show_type .file-footer-buttons").find("button").css("background", "#CCC");
7f7112 582         }
a6a76f 583     }
F 584 }
585
0c06a4 586 //更新下载次数
X 587 function downFile(e,unid,seq) {
588     let json={};
589     json.unid=unid;
590     json.seqArray=[];
591     json.seqArray.push(seq);
592     json.type="down";
593     $.ajax({
594         url: '/attachmentOa/getAllowOa.do',
595         type: 'POST',
596         data: JSON.stringify(json),
597         dataType: 'json',
598         // async: false,
599         contentType: 'application/json',
600         success: function (res) {
601             if (res != null && res.code == 0) {
602                     let dat=res.data;
603                     if(dat[0]!=null){
604                         if((dat[0].state==-1 || dat[0].allowDownNums==dat[0].downNums) && dat[0].allowDownNums!=0){
605                             // layui.layer.msg("你在此附件允许下载的次数已经用完");
606                             $(e).hide();
607                         }
608                     }
609             }
610         }, error: function (xmlHttpRequest, textStatus, errorThrown) {
611             layui.layer.alert(xmlHttpRequest.responseText);
612         }
613     })
614 }
615
a6a76f 616 /******图片在图片框内按宽高比例自动缩放!!!***/
F 617 // Img:要放图片的img元素,onload时传参可用this
618
619 // maxHeight  :img元素的高度,像素(图片框 最大高度)
620
621 // maxWidth:img元素的宽度,像素(图片框 最大宽度)
622 function AutoSize(Img, maxWidth, maxHeight) {
623     var image = new Image();
624     // 原图片原始地址(用于获取原图片的真实宽高,当<img>标签指定了宽、高时不受影响)
625     image.src = Img.src;
7f7112 626     // 当图片比图片框小时不做任何改变
a6a76f 627     if (image.width < maxWidth&& image.height < maxHeight) {
F 628         Img.width = image.width;
629         Img.height = image.height;
630     }
631     else{ // 原图片宽高比例 大于 图片框宽高比例,则以框的宽为标准缩放,反之以框的高为标准缩放
632         if (maxWidth/ maxHeight  <= image.width / image.height){ // 原图片宽高比例 大于 图片框宽高比例
633             Img.width = maxWidth;   // 以框的宽度为标准
634             Img.height = maxWidth* (image.height / image.width);
635         }
636         else {   // 原图片宽高比例 小于 图片框宽高比例
637             Img.width = maxHeight  * (image.width / image.height);
638             Img.height = maxHeight  ;   // 以框的高度为标准
639         }
640     }
641 }
642
7f7112 643 // 40类型 查看图片(旧的,可放弃)
9b3705 644 function showModalImg(value,controlType,callback){
7f7112 645     // try{
X 646     //     var pant=value.split("?")[1];
647     //     var pants=pant.split("&");
648     //     var pic={};
649     //     for(var i=0;i<pants.length;i++){
650     //         c=pants[i].split("=");
651     //         pic[c[0]]=c[1];
652     //     }
653     //     var src="#";
654     //     var results="";
655     //     if(pic.oldgrid!=undefined){
656     //         if(pic.oldgrid.indexOf('http')!=-1){   //判断http协议,有无地址
657     //             results=pic.oldgrid.split(";")[1]; //显示网址图片
658     //         }else{
659     //             src = pic.oldgrid.replace(".do;",".do?type="+(controlType == 9?"1":"3")+"&uuid=");
660     //             var picobj=pic.oldgrid.split(";");
661     //             var unid=picobj[1];
662     //             var seq=picobj[2];
663     //             var fileExt=picobj[picobj.length-1];
664     //             if(picobj.length>4){
665     //                 fileExt="unknown";
666     //             }
667     //             if('jpge;jpg;png;gif'.indexOf(fileExt.toLowerCase())==-1){//不是图片后缀的
668     //                 callback();//执行回调
669     //                 return true;//如果不是图片的后缀那就返回true xin 2021-7-15 10:11:50
670     //             }
671     //             if(seq!=null&&seq!=undefined&&seq!=""){
672     //                 unid=unid+"@p@"+seq;
673     //             }
674     //             results=getAttachmentUrl(pic.staticUrl,pic.formid,unid,pic.domain,pic.dbid,false,80,80,fileExt);
675     //         }
676     //     }else{
677     //         return false;
678     //     }
679     //     $("#bimg").attr("src",results);
680     //     document.getElementById("uploadForm").style.display="none";
681     //     document.getElementById("bimg").style.display="inline-block";
682     //     //AutoSize($("#bimg"),600,500);
683     //     return true ;
684     // }catch(e){alert(e);}
a6a76f 685 }
F 686
7f7112 687 // 格线执行 附件 进入的函数,主要是9类型(旧的,可以放弃)
a6a76f 688 function showModal(id,value){
7f7112 689     // var controlType = 9;  // 专用于格线
X 690     // var readerUserCodes = $('#readerusercodes').val();
691     // // 加载图片需要的属性(固定ID)
692     // let fileInput = BootstrapFileInputOption('fileUpload');
693     // // 定义属性,拆分值
694     // document.getElementById("uploadForm").style.display = "block";
695     // document.getElementById("bimg").style.display = "none";
696     // var picPer = [];
697     // var authBtn = '';
698     // var c;
699     // var unid;
700     // var seq;
701     // pic = {};
702     // var pant = value.split("?")[1];
703     // var pants = pant.split("&");
704     // for (var i = 0; i < pants.length; i++) {
705     //     c = pants[i].split("=");
706     //     pic[c[0]] = c[1];
707     // }
708     // var encrypt = new JSEncrypt();
709     // encrypt.setPublicKey(rsakey.pubkey);
710     // var picpant = {};
711     // try {// 赋值
712     //     if ((pic.uuid == undefined || pic.uuid == '') && (pic.oldgrid != null &&
713     //         pic.oldgrid != undefined && pic.oldgrid != '')) {
714     //         var unid = pic.oldgrid.split(';');
715     //         pic['uuid'] = unid[0] + ";" + unid[1];//uuid+seq
716     //         if (unid.length >= 4 && unid[0].indexOf('.do') != -1) {
717     //             if (unid.length > 4) {
718     //                 if (unid[unid.length - 2] != null && !isNaN(unid[unid.length - 2])) {
719     //                     controlType = 19;//存在多个seq,表示是多附件
720     //                 }
721     //             }
722     //             pic['uuid'] = unid[1] + ";" + unid[2];//uuid+seq
723     //         }
724     //         picpant['unid'] = pic['uuid'].replace("|48|48|", "");
725     //     }
726     //     picpant['fieldid'] = pic["fieldid"];
727     //     picpant['controltype'] = controlType;
728     //     picpant['formid'] = pic["formid"];
729     //
730     //     picpant['ishd'] = pic['ishd'];
731     //     var strIs = "";
732     //     if (pic["is1"] != undefined && pic["is1"] != "") {
733     //         strIs = "&is1=" + pic['is1'] + "&ishd=" + pic['ishd'];
734     //     } else if (pic["is8"] != undefined && pic["is8"] != "") {
735     //         strIs = "&is8=" + pic['is8'] + "&ishd=" + pic['ishd'];
736     //     } else {
737     //         strIs = "&ishd=" + pic['ishd'];
738     //     }
739     //     picpant['docstatus'] = pic["docstatus"] == undefined ? 0 : pic["docstatus"];
740     //     picpant['rowid'] = pic["rowid"];
741     //     picpant['usercode'] = pic["usercode"];
742     //     picpant['doccode'] = pic["doccode"];
743     //     picpant['headflag'] = (pic['ishd'] == 0) ? 1 : 0;
744     //     try {
745     //         if (picpant.doccode == undefined) {
746     //             picpant['doccode'] = $('#doccode').val();
747     //             if (picpant.doccode == undefined)
748     //                 picpant.doccode = panMain[panIndex].panelAuditValue.doccode;
749     //         }
750     //         if (picpant['doccode'] && readerUserCodes != undefined && readerUserCodes != '') {
751     //             picpant['readerusercodes'] = readerUserCodes;
752     //         }
753     //     } catch (e) {
754     //         picpant.doccode = "";
755     //     }
756     //     try {
757     //         var picpants = JSON.stringify(picpant);
758     //     } catch (e) {
759     //         alert(e);
760     //     }
761     //     // 图片显示的方法
762     //     $.ajax({
763     //         url: '/attachment/getAttachmentList.do',
764     //         type: "POST",
765     //         async: false,
766     //         data: {pant: picpants},
767     //         dataType: 'json',
768     //         success: function (data) {
769     //             try {
770     //                 var jsons = data;
771     //                 if ((pic.uuid != undefined && pic.uuid != '') || (pic.oldgrid != null &&
772     //                     pic.oldgrid != undefined && pic.oldgrid != '')) {
773     //                     for (var i = 0; i < jsons.length; i++) {
774     //                         // 图片属性
775     //                         if (picpant.usercode == "") {
776     //                             picpant.usercode = jsons[i].userCode;
777     //                         }
778     //                         if (i == 0) {
779     //                             picpant.username = jsons[i].userName;
780     //                             picpant.dbid = jsons[i].dbid;
781     //                             picpant.domain = jsons[i].domain;
782     //                         }
783     //                         var deleToken = 'type=' + (controlType == 9 ? '1' : '3') + '&formid=' + picpant.formid + '&doccode=' + picpant.doccode + '&fieldid=' + id + '&unid=' + jsons[i].unid + '&seq=' +
784     //                             jsons[i].seq + '&docstatus=' + picpant.docstatus + '&ishd=' + picpant.ishd + '&usercode=' + encodeURIComponent(encrypt.encrypt(jsons[i].authorCode)) + '&readerusercodes=' + readerUserCodes + '&dbid=' + encodeURIComponent(encrypt.encrypt(jsons[i].dbid)) + '&curUsername=' + encodeURIComponent(encrypt.encrypt(jsons[i].userName)) + '&curUsercode=' + encodeURIComponent(encrypt.encrypt(jsons[i].userCode));
785     //                         fileInput.option.initialPreviewConfig.push({
786     //                             'caption': jsons[i].originalFileName,   // 上传的图片名称
787     //                             'filename': jsons[i].physicalFile,   // 上传文件名
788     //                             'time': jsons[i].uploadTimeStr,  //上传开始时间
789     //                             'name': jsons[i].authorName,  //作者名称
790     //                             'size': jsons[i].fileSizeStr,   // 上传的图片大小
791     //                             'type': jsons[i].fileType,   // 上传的图片类型
792     //                             'key': jsons[i].unid +';'+jsons[i].seq,
793     //                             'downloadUrl': jsons[i].domain + "/attachment/downLoadAttachment.do?filePath=" + getAttachmentUrl(jsons[i].staticUrl, jsons[i].formid, jsons[i].unid + "@p@" + jsons[i].seq, "", jsons[i].dbid, false, 60, 60, jsons[i].orgFileType, true),
794     //                             'url': jsons[i].domain + '/attachment/deleteAttachmentV2.do?' + deleToken
795     //                         });   // 附件删除路径
796     //
797     //                         // 判断是否需要权限,如果要那么就加载权限按钮属性
798     //                         if (jsons[i].authorCode != null && jsons[i].authorCode == picpant.usercode) {   // authorCode 作者
799     //                             authBtn = '<a href="javascript:authorize(\'' + jsons[i].unid + '\',\'' + jsons[i].seq + '\');" ' +
800     //                                 'class="btn btn-kv btn-default btn-outline-secondary" title="授权" style="padding: 0px;">' +
801     //                                 '<i class="glyphicon glyphicon-lock" style="padding-top: 6px;"></i></a>';   // 授权按钮
802     //                         }
803     //                         // 添加图片权限
804     //                         picPer.push({
805     //                             key: jsons[i].seq, isAllowDelete: jsons[i].hasDelete, isAllowUpdate: jsons[i].hasUpdate,
806     //                             isAllowDownload: jsons[i].hasDownload, authBtn: authBtn
807     //                         });
808     //                         // 图片
809     //                         let t='文件名:' + jsons[i].originalFileName +
810     //                                   ' \n类型:' + jsons[i].fileType +
811     //                                   ' \n大小:' + jsons[i].fileSizeStr +
812     //                                   ' \n上传者:' + jsons[i].authorName +
813     //                                   ' \n上传时间:' + jsons[i].uploadTimeStr ;
814     //                         // let img='<img src="' + getAttachmentUrl(jsons[i].staticUrl, jsons[i].formid,
815     //                         //     jsons[i].unid + "@p@" + jsons[i].seq, jsons[i].domain, jsons[i].dbid,
816     //                         //     false, 60, 60, jsons[i].orgFileType) + '" ' +
817     //                         //     'style="height: 60px;" class="kv-preview-data file-preview-image" title='+t+'>';
818     //                         let img=getAttachmentUrl(jsons[i].staticUrl, jsons[i].formid,
819     //                                 jsons[i].unid + "@p@" + jsons[i].seq, jsons[i].domain, jsons[i].dbid,
820     //                                 false, 60, 60, jsons[i].orgFileType);
821     //                         fileInput.option.initialPreview.push(img);
822     //                     }
823     //                     var upToken = 'type=' + (controlType == 9 ? '1' : '3') + '&formid=' + picpant.formid
824     //                         + '&doccode=' + picpant.doccode + '&fieldid=' + picpant.fieldid
825     //                         + '&usercode=' + encodeURIComponent(encrypt.encrypt(picpant.usercode)) + '&username=' + encodeURIComponent(encrypt.encrypt(picpant.username)) + '&dbid=' + encodeURIComponent(encrypt.encrypt(picpant.dbid))
826     //                         + strIs + '&rowid=' + picpant.rowid + '&uuid=' + (picpant.unid == undefined ? "" : picpant.unid);
827     //                     fileInput.option.uploadUrl = picpant.domain + '/attachment/uploadAttachmentV2.do?' + upToken; // 附件上传路径
828     //                     // $('#'+id).val(pic.unid);
829     //                     fileInput.option.otherActionButtons='';
830     //                     fileInput.option.maxFileCount = 1;   // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
831     //                     fileInput.option.isNine = true;
832     //                     fileInput.option.validateInitialCount = true;   // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
833     //                     fileInput.option.overwriteInitial = false;   // 是否要覆盖初始预览内容和标题设置
834     //                 } else {
835     //                     fileInput.option.maxFileSize = jsons[0].allowMaxFileSize;//从后台取数回来 by danaus 2020/8/7 10:47
836     //                     fileInput.option.initialPreviewConfig.push({
837     //                         'caption': '',   // 上传的图片名称
838     //                         'filename': '',   // 上传文件名
839     //                         'time': '',  //上传开始时间
840     //                         'name': '',  //作者名称
841     //                         'size': '',   // 上传的图片大小
842     //                         'type': '',   // 上传的图片类型
843     //                         'key': ''
844     //                     });
845     //                      fileInput.option.uploadUrl = pic.domain + '/attachment/uploadAttachmentV2.do?type=' + (controlType == 9 ? '1' : '3') + '&formid=' + pic.formid
846     //                         + '&doccode=' + pic.doccode + '&fieldid=' + pic.fieldid
847     //                         + '&usercode=' + encodeURIComponent(encrypt.encrypt(pic.usercode)) + '&username=' + encodeURIComponent(encrypt.encrypt(pic.username)) + '&dbid=' + encodeURIComponent(encrypt.encrypt(pic.dbid))
848     //                         + strIs + '&rowid=' + pic.rowid + '&uuid=' + (pic.unid == undefined ? "" : pic.unid); // 附件上传路径
849     //                     fileInput.option.maxFileCount = 1;   // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
850     //                     fileInput.option.isNine = true;
851     //                     fileInput.option.validateInitialCount = true;   // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
852     //                     fileInput.option.overwriteInitial = false;   // 是否要覆盖初始预览内容和标题设置
853     //                 }
854     //                 fileInput.destroy();// 销毁文件输入控件并恢复到普通的本地文件输入
855     //                 fileInput.fileInput();// 加载图片显示
856     //                 // others();
857     //                 // picBtn(picPer, fileInput.option, id);   //fileInput.option 控制审核后不能删除
858     //             } catch (e) {
859     //                 alert(e);
860     //             }
861     //         }
862     //     });
863     // } catch (e) {
864     //     alert(e);
865     // }
a6a76f 866 }
F 867 var uploadKey=[];
868 //图片上传触发事件
869 function picevent(id,isGrid,obj){
7f7112 870     //绑定事件 xin 2022-2-26 10:06:25
X 871     BootstrapFileInputOption(id).events(isGrid,obj);
872 //     if(typeof(myFresh)=="undefined") myFresh={};
873 //     myFresh.mygrid=obj;
874 //     $('#'+id+'_up').on('fileuploaderror', function(event, data, msg) {
875 //         var temp=data;
876 //
877 //     }).on('filesuccessremove', function(event, id) {   // 使用缩略图删除按钮删除成功上传的缩略图后,会触发此事件
878 //         var unid=$('#'+id ).find("img").attr("unid");
879 //         var val=JSON.parse(unid);
880 //         var uuid=val.key.split(";")[0];
881 //           var seq=val.key.split(";")[1];
882 //         $.ajax({
883 //             type:"POST",
884 //             dataType:'json',
885 //             url:'/attachment/deleteOwnerAttachment.do?type='+val.type+'&unid='+uuid+'&seq='+seq,   // 删除路径
886 //             success: function(data){
887 //                 var newUid=val.oldKey==""?"":val.oldKey.replace(";"+seq,"");
888 //                 $('#'+val.filedId).val(newUid);
889 //             }
890 //         });
891 // //        $.each(uploadKey,function(i,val) {
892 // //            if(val.md5==img_md5){
893 // //                var uuid=val.key.split(";")[0];
894 // //                var seq=val.key.split(";")[1];
895 // //                $.ajax({
896 // //                    type:"POST",
897 // //                    dataType:'json',
898 // //                    url:'/attachment/deleteOwnerAttachment.do?type='+val.type+'&unid='+uuid+'&seq='+seq,   // 删除路径
899 // //                    success: function(data){
900 // //                        var newUid=val.oldKey==""?"":val.oldKey.replace(";"+seq,"");
901 // //                        $('#'+val.filedId).val(newUid);
902 // //                    }
903 // //                });
904 // //            }
905 // //        });
906 //
907 //     }).on('filepredelete', function(event, params) {   // 在删除initialPreview内容集中的每个缩略图文件之前触发此事件
908 //         event.stopImmediatePropagation();
909 //         if(!confirm("您确定要删除吗?")){
910 //             //处理不删除图片操作
911 //             return false;
912 //         }
913 //
914 //     }).on('filedeleted', function(event, key) {   // 在删除initialPreview内容集中的每个缩略图文件之后触发此事件
915 //         if(isGrid=='grid'){   // 格线
916 //             try{
917 //                 if(myFresh.mygrid){
918 //                     var grid=myFresh.mygrid.id;
919 //                     var obj="";
920 //                     grid.SetValue(myFresh.mygrid.row, myFresh.mygrid.col,obj,0);
921 //                     grid.RefreshCell(myFresh.mygrid.row, myFresh.mygrid.col);
922 //                 }
923 //             }catch(e){alert(e);}
924 //         }else{   // 面板
925 //             var va =$('#'+id).val();
926 //             va = va.replace(";"+key,"");
927 //             if(va.indexOf(";")<0) va="";
928 //             $('#'+id).val(va);
929 //             panMain[panIndex].isChange =1;  //解决110101上传后删除附件不成功,而出现多个序号的问题
930 //         }
931 //         $('#'+id+'_up').fileinput({uuidkey:key});
932 //
933 //     }).on('filebatchuploadsuccess', function(event, data, previewId, index) {   // 此事件仅在ajax上传且文件批量上传成功之后触发
934 //         // get_filemd5sum(data,id);
935 //         // console.log("tmp.md5:"+tmp.md5);
936 //         // tmp.md5=$.md5(data.reader.result);
937 //         var tmp={};
938 //         var oldKey=$('#'+id).val();   // 旧的值
939 //          var newKey=data.response.uuid?data.response.uuid+";":"";   // 新的值
940 //          if(oldKey!=""){
941 //              var keys=oldKey.split(";");
942 //              for(var i=1;i<keys.length;i++){
943 //                  newKey=newKey.replace(";"+keys[i]+";",";");
944 //              }
945 //          }
946 //          tmp.key=newKey;
947 //          tmp.type=data.response.type;
948 //          tmp.filedId=id;
949 //          tmp.oldKey=oldKey;
950 //         var unid = data.response.uuid?data.response.uuid:"";
951 //         data.thumb.find("img").attr("unid",JSON.stringify(tmp));
952 //            this.uuidkey = unid;
953 //            $('#'+id).val(unid);
954 //            if(myFresh.mygrid){   // 格线
955 //                var grid=myFresh.mygrid.id;
956 //                var obj=unid+";"+data.response.fileType;// by by danaus 2020/4/30 11:32
957 //                grid.SetValue(myFresh.mygrid.row, myFresh.mygrid.col,obj,0);
958 //                grid.RefreshCell(myFresh.mygrid.row, myFresh.mygrid.col);
a6a76f 959 //            }
7f7112 960 //
X 961 //     }).on('filebatchuploadcomplete', function(event, files, extra) {   // 此事件仅对于ajax上传且完成同步或异步ajax批量上传后触发
962 //         console.log(event);
963 //         console.log('File batch upload complete');
964 //
965 //     }).on("filebatchselected", function(event, files) {   // 在预览中选择并显示一批文件后触发此事件
966 //         if(myFresh.mygrid){   // 格线
967 //             $('#'+id+'_up').fileinput('upload');
968 //         }
969 //         else{
970 //             upSub(id);   // 触发修改(面板有内容改动)
971 //             $('#'+id+'_up').fileinput('upload',{uuidurl:$('#'+id).val()});   // 触发所选文件的ajax上传。仅适用于uploadUrl已设置的情况。此方法将文件输入元素作为jQuery对象返回,因此可以链式调用其他方法。
972 //         }
973 //
974 //     // }).on('filezoomshow', function(event, params) {   // 当单击缩放按钮以在模式对话框中显示内容详细预览时触发此事件。以下参数将另外作为一个 JSON 对象发送,其键是。
975 //     //     let modeal=params.modal.find(".file-zoom-content").find("object");
976 //     //     if(modeal!=null && modeal.length>0){
977 //     //         modeal.show();
978 //     //         params.modal.find(".file-zoom-content").find("img").hide();
979 //     //     }
980 //     }).on('filezoomshown', function(event, params) {   // 在模态框已被用户看到之后触发此事件(将等待CSS转换完成)
981 //         $(".modal-backdrop").attr("class", "");
982 //         $(".modal-content").css( "zIndex", 999999);
983 //
984 //     }).on('filebrowse', function(event) {   // 单击文件浏览按钮以打开文件选择对话框时触发此事件
985 //         try{
986 //             if(typeof(fileupload_config)=="undefined"){
987 //                 if(myFresh.mygrid){
988 //                     var grid=myFresh.mygrid.id;
989 //                     if(grid.Cols[myFresh.mygrid.col].CanEdit==0){
990 //                         event.preventDefault=false;
991 //                         return false;
992 //                     }
993 //                 }
994 //             }else{
995 //                 if(!fileupload_config.browseOnZoneClick){
996 // //                  if(typeof(event.preventDefault)!=="function")
997 //                     event.preventDefault();
998 // //                    event.preventDefault=false;
999 // //                  return false;
1000 //                 }
1001 //             }
1002 //         }catch(e){
1003 //             alert(e);
1004 //         }
1005 //
1006 //     }).on('fileuploaderror', function(event, data, msg) {   // 此事件仅在ajax上传时触发,并且主要针对ajax上传时遇到上载或文件输入验证错误
1007 //         var form = data.form, files = data.files, extra = data.extra,
1008 //             response = data.response, reader = data.reader;
1009 //     });
a6a76f 1010 }
F 1011
1012 function get_filemd5sum(data, id) {
1013     var tmp = {};
1014     var file = data.files[0];
1015     var tmp_md5;
1016     var blobSlice = File.prototype.slice || File.prototype.mozSlice
1017             || File.prototype.webkitSlice,
1018     // file = this.files[0],
1019     chunkSize = 8097152, // Read in chunks of 2MB
1020     chunks = Math.ceil(file.size / chunkSize), currentChunk = 0, spark = new SparkMD5.ArrayBuffer();
1021     var fileReader = data.reader;
1022
1023     fileReader.onload = function(e) {
1024         // console.log('read chunk nr', currentChunk + 1, 'of', chunks);
1025         spark.append(e.target.result); // Append array buffer 追加数组缓冲器
1026         currentChunk++;
1027         var md5_progress = Math.floor((currentChunk / chunks) * 100);
1028         console.log(file.name + "  正在处理,请稍等," + "已完成" + md5_progress + "%");
1029         // var handler_info = document.getElementById("handler_info");
1030         // var progressbar = document.getElementsByClassName("progressbar")[0];
1031         // handler_info.innerHTML = file.name + " 正在处理,请稍等," + "已完成" +
1032         // md5_progress + "%"
1033         // progressbar.value = md5_progress;
1034         if (currentChunk < chunks) {
1035             loadNext();
1036         } else {
1037             tmp.md5 = spark.end();
1038             console.log("-------------tmp.md5:" + tmp.md5)
1039             var oldKey = $('#' + id).val(); // 旧的值
1040             var newKey = data.response.uuid ? data.response.uuid : ""; // 新的值
1041             if (oldKey != "") {
1042                 var keys = oldKey.split(";");
1043                 for (var i = 1; i < keys.length; i++) {
1044                     newKey = newKey.replace(";" + keys[i], "");
1045                 }
1046             }
1047             tmp.key = newKey;
1048             tmp.type = data.response.type;
1049             tmp.filedId = id;
1050             tmp.oldKey = oldKey;
1051             uploadKey.push(tmp);
1052             var unid = data.response.uuid ? data.response.uuid : "";
1053             this.uuidkey = unid;
1054             $('#' + id).val(unid);
1055             if (myFresh.mygrid) { // 格线
1056                 var grid = myFresh.mygrid.id;
1057                 var obj = data.response.path ? data.response.path : "";
1058                 grid.SetValue(myFresh.mygrid.row, myFresh.mygrid.col, obj, 0);
1059                 grid.RefreshCell(myFresh.mygrid.row, myFresh.mygrid.col);
1060             }
1061         }
1062     };
1063
1064     fileReader.onerror = function() {
1065         console.warn('oops, something went wrong.');
1066     };
1067
1068     function loadNext() {
1069         var start = currentChunk * chunkSize, end = ((start + chunkSize) >= file.size) ? file.size
1070                 : start + chunkSize;
1071         fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));
1072     }
1073     loadNext();
1074 }
1075 function others() {
1076     // 上传控件的一些控制
1077     $(".file-footer-caption").css("display", "none");
1078     $(".file-thumbnail-footer").css("height", "10px");
1079     $(".glyphicon-download").css("padding-top", "6px");
1080     $(".btn").css("padding", "0px");
1081     $(".fileinput-remove").css("display", "none"); // 隐藏控件右上角的清除按钮(叉号)
1082     $(".glyphicon-move").css("display", "none"); // 隐藏控件的移动按钮
1083     try {
1084         $(".file-caption-main").css("display", "none");
1085     } catch (e) {
1086         alert(e);
1087     }
7f7112 1088
a6a76f 1089 }
F 1090 function getReturnValue(str) {
1091     if (window.ActiveXObject) { // IE
1092         window.returnValue = str;
1093         window.close();
1094     } else { // 非IE
1095         if (window.opener) {
1096             window.opener.setValue(str); // 直接调用父页面的方法来操作处理
1097             window.close();
1098         }
1099     }
1100 }
1101
1102 // 9 ,19控件授权
1103 function authorize(unid,seq){
7f7112 1104     // parent.addTab('',9763,10,'wherePan=unid=\''+unid+'\' and seq='+seq);
X 1105 }
1106 function mylockFile(e){
1107     let u = $(e).data("key");
1108     if (u != null) {
1109         let s = u.split(";");
1110         if (s.length == 2) {
ec748c 1111             layerIndex = layer.open({
X 1112                 type: 2,//可传入的值有:0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)。 若你采用layer.open({type: 1})方式调用
1113                 shade: 0.1,
1114                 title: "维护附件上传权限", //不显示标题
1115                 area: ['1280px', '650px'], //宽高
1116                 content: '/general/fileInputoa/uploadPromission.html?unid='+s[0]+'&seq='+s[1],
1117                 cancel: function () {
1118                     layer.closeAll();
1119                 },
1120                 success: function(){
1121                 }
1122             });
1123             // parent.addTab('', 9763, 10, 'wherePan=unid=\'' + s[0] + '\' and seq=' + s[1]);
7f7112 1124         }
X 1125     }
a6a76f 1126 }
F 1127 // 权限按钮属性显示
1128 function picBtn(picPer,uploadObj,fieldid) {
7f7112 1129     // var findObj = "#uploadDiv_" + fieldid + " .kv-file-remove";
X 1130     // var delBtn = $(findObj); // 删除
1131     // for (var i = 0; i < delBtn.length; i++) {
1132     //     var dataKey = $(delBtn[i]).attr("data-key");
1133     //     for (var j = 0; j < picPer.length; j++) {
1134     //         if ((dataKey == picPer[j].key && !picPer[j].isAllowDelete)
1135     //             || !uploadObj.browseOnZoneClick) {   //控制删除按钮在最终审核后,所有人都不能进行删除
1136     //             $(delBtn[i]).hide();
1137     //         }
1138     //     }
1139     // }
1140     // var downBtn = $(".glyphicon-download"); // 下载
1141     // for (var i = 0; i < downBtn.length; i++) {
1142     //     var a = $(downBtn[i]).parent();
1143     //     var href = $(a).attr("href");
1144     //     if (href == null)
1145     //         continue;
1146     //     for (var j = 0; j < picPer.length; j++) {
1147     //         if (href.indexOf(";" + picPer[j].key) >= 0) {
1148     //             if (!picPer[j].isAllowDownload) {
1149     //                 $(a).hide();
1150     //             }
1151     //             if (picPer[j].authBtn != "") {
1152     //                 $(a).before(picPer[j].authBtn)
1153     //             }
1154     //         }
1155     //     }
1156     // }
a6a76f 1157 }
F 1158 function openNewDoc() {
1159     var flag = checkSession();// session失效后弹出登录框,flag为true时表示已经失效
1160     if(flag){
1161         return;
1162     }
1163     openByType($(this).attr("docType"));
1164 }
1165 function openByType(type) {
1166     try {
1167         if(type==undefined) type=$("#tpNewDoc").attr("docType");
1168         parent.addTab('', formId, type);
1169     } catch (e) {
1170         alert(e);
1171         showWindow("/app" + spellPath + formId + "/" + type + "/index.jsp");
1172     }
1173 }
aa5c59 1174 function openOldXlsImport(title,doccode){
X 1175     //旧版本调用
1176     try {
1177         var url = "/general/xlsImport.jsp";
1178         url+="?title="+title+"&doccode="+doccode+"&formid="+formId+"&formType="+formType;
1179         parent.changFrame = inThisFrame;
1180         parent.addTab(formId + "数据导入管理", '', '', '', url);
1181     } catch (e) {
1182         window.open(url);
1183     }
1184 }
a6a76f 1185 $( function() {
F 1186     try{top.myFresh.formType=formType;top.myFresh.panel[top.tabindex]=formType;}catch(e){}//关闭页卡排除的窗体类型。
1187     $("#loading").css("opacity", '0.8');
1188     if (typeof (formId) != "undefined") {
1189         if (parent.getTabSelected!=undefined&&parent.getTabSelected().panel!=undefined&&parent.getTabSelected().panel("options").title.indexOf("加载中") != -1) {
1190             var title = $("title").html() + "--" + formId;
1191             parent.resetTabName(title);
1192         }
1193     }
1194
1195     $("#tpNewDoc,#tpDocList").click(openNewDoc);
1196     $.getScript("/js/index/query.js"); // 加载查询js
1197     setTimeout( function() {
1198         closeLoading();
1199     }, 400);
1200     $("#otherFormat").click(function(){
1201         var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
1202         if(flag){
1203             return;
1204         }
1205         var url = "/general/report.jsp?formId=" + formId + "&formType="
1206             + formType;
1207         try {
1208             parent.addTab(formId + "报表格式管理", '', '', '', url);
1209         } catch (e) {
1210             window.open(url);
1211         }
1212         moreWindowClose(); // 2、3类型更多按钮的关闭事件
1213     });
1214
1215
1216     $("#importXls").click(function() {
aa5c59 1217         var url = "/general/xlsImport1.jsp";
X 1218         var title = $('#title_top').html();
1219         var doccode = $('#doccode').val();
1220         doccode = (doccode != null ? doccode : "");
1221         url += "?title=" + title + "&doccode=" + doccode + "&formid=" + formId + "&formType=" + formType;
a6a76f 1222         try {
aa5c59 1223             var xlsContent = layer.open({
X 1224                 type: 2,
1225                 title: '',
1226                 maxmin: false,
1227                 skin: 'layui-layer-molv',
1228                 shadeClose: true, //点击遮罩关闭层
1229                 area: ['700px', '350px'],
1230                 content: url
1231             });
a6a76f 1232         } catch (e) {
aa5c59 1233             openOldXlsImport(title, doccode);
a6a76f 1234         }
F 1235     });
1236     $("#tpbuild").click( function() {
1237         var flag = checkSession();//session失效后弹出登录框,flag为true时表示已经失效
1238         if(flag){
1239             return;
1240         }
1241         var fid = $("#formid").val();
1242         if (undefined == fid || fid == null || fid == "") {
1243             $.messager.alert("操作提示", "请输入功能号!","warning");
1244             return;
1245         }
1246         try {
1247             parent.addTab("生成" + fid, "", "", "", "/buildv2.do?formID=" + fid);
1248         } catch (e) {
1249         }
1250     });
1251     $("#tpselect").click( function() { // 选择按钮
1252         var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
1253         if(flag){
1254             return;
1255         }
1256         if (2 == formType || 20 == formType) {
1257             $(".simpleTree").find(".active").dblclick(); // 获取返回值在simple.tree.js文件执行
1258
1259         } else {
1260             try {
1261                 mygrid.buttonClicked();
1262             } catch (e) {
1263             }
1264         }
1265     });
1266     $("#func").menu( {
1267         onShow : function() {
1268             setBackGournd4ie6("#func");
1269         },
1270         onHide : function() {
1271             hideBackGournd4ie6();
1272         }
1273     });
1274     $("#print").menu( {
1275         onShow : function() {
1276             setBackGournd4ie6("#print");
1277         },
1278         onHide : function() {
1279             hideBackGournd4ie6();
1280         }
1281     });
1282     // parent.openByFormId({formId:9802,formType:9901});
1283 });
1284
1285 function setBackGournd4ie6(id) {
1286     var iframe = $("#bg4ie6");
1287     if (null == iframe.html()) {
1288         iframe = $(
1289             "<iframe id='bg4ie6' style='position:absolute;z-index:3;border:0px;'/>")
1290             .appendTo($("body"));
1291     }
1292     var off = $(id).offset();
1293     var h = $(id).height() + 5;
1294     var w = $(id).width();
1295     var t = off.top;
1296     var l = off.left;
1297     iframe.css( {
1298         width :w,
1299         height :h,
1300         top :t,
1301         left :l
1302     }).show();
1303 }
1304 function hideBackGournd4ie6() {
1305     $("#bg4ie6").hide();
1306 }
1307 var self_datafields=""; // 返回自表字段的值
1308 // f:功能号     t:功能类型    sf:自身字段    lf:外表字段    lk:为1时执行存储过程,0显示界面,3弹出层
1309 // sd:自表字段 ld:外表字段     isp:         ef:where条件语句    mes:提示信息
1310 // clo:1表示关闭
1311 function funcLink(f, t, sf, lf, lk, sd, ld, isp, ef, mes, ref, clo, autoSave,sortid,messageTip) {
1312     var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
1313     if(flag){
1314         return;
1315     }
1316     showLoading();
1317     self_datafields=sd;
1318     // lqc
1319     if(typeof(f)=="string" && f.toLowerCase()=="formid" && formId!="" && typeof(formId)=="number" ){
1320         f=formId;
1321     }
1322     // end
1323     // 为了兼容以前代码,先判断是否存在以;分隔。没有则按新的处理方式,以@p@分隔
1324     // by danaus 2017-8-21
1325     var sfs =null;
1326     var lfs =null;
1327     var split=";";
1328     if(sf.indexOf("@p@")>0) split="@p@";
1329     lfs=lf.split(";"); // 字段分隔固定用;
1330     sfs=sf.split(split);
1331     if (sfs.length != lfs.length) {
1332         $.messager.alert('警告', "请检查外表字段与自身字段是否设置正确!", 'error');
1333         return;
1334     }
1335     if (mes&&mes.indexOf("&") != -1 && t == "22") {
1336         if (typeof (mygrid) != "undefined") {
1337             var rows = mygrid.getFieldForNew();
1338             var strTi = mes;
1339             var lit = new Array()
1340             var str1 = "";
1341             var tv = "";
1342             var ti = 0;
1343             while (strTi.indexOf("&") != -1) {
1344                 strTi = strTi.substring(strTi.indexOf("&") + 1);
1345                 if (mes.indexOf("&") != -1) {
1346                     str1 = strTi.substring(0, strTi.indexOf("&"));// .trim()
1347                     if (str1 != "") {
1348                         lit[ti] = str1;
1349                         ti++;
1350                         strTi = strTi.substring(strTi.indexOf("&") + 1);
1351                     }
1352                 }
1353             }
1354             for (var i = 0; i < lit.length; i++) {
1355                 tv = getValue((lit[i]).toLowerCase(), null, rows[0]);
1356                 mes = mes.replace("&" + lit[i] + "&", tv);
1357             }
1358
1359         }
1360     }
1361     if (mes && $.trim(mes) != "") { // 有提示信息
1362         //$.messager.defaults = { ok: "是", cancel: "否" };
1363         $.messager.confirm('提示', mes, function(r) {
1364             if (r) {
1365                 funcLink$(f, t, sfs, lfs, lk, sd, ld, isp, ef, ref, clo,
1b0a94 1366                     autoSave, sortid, messageTip, mes);
7f7112 1367                 $('.panel-tool-close').show();
a6a76f 1368             }else {
F 1369                 closeLoading(); //更新客户状态的取消
7f7112 1370                 $('.panel-tool-close').show();
a6a76f 1371             }
F 1372         }, "warning");
1373         $('.panel-tool-close').hide(); //取消更新客户状态的弹出框红叉      yang 2020-04-26
1374     } else {
1375         funcLink$(f, t, sfs, lfs, lk, sd, ld, isp, ef, ref, clo, autoSave,sortid,messageTip);
1376     }
1377     // 系统消息
1378     if(messageTip!=null && messageTip.indexOf(",")!=-1){
1379         var value=messageTip.split(",");
1380         if(value[1]=="message"){
1381             $.post("/usrReaded.do",{"messid":value[0]});
1382             // $.messagerTip.close();
1383         }
1384     }
1385     //moreWindowClose(); // 2、3类型更多按钮的关闭事件
1386 }
1387
1b0a94 1388 function funcLink$(f, t, sfs, lfs, lk, sd, ld, isp, ef, ref, clo, autoSave, sortid, messageTip, mes) {
a6a76f 1389     if (isp && isp == "1") {
1b0a94 1390         showPwd(f, t, function () {
F 1391             funcLink$$(f, t, sfs, lfs, lk, sd, ld, ef, ref, clo, autoSave, sortid, messageTip, mes);
a6a76f 1392         });
F 1393     } else {
1b0a94 1394         funcLink$$(f, t, sfs, lfs, lk, sd, ld, ef, ref, clo, autoSave, sortid, messageTip, mes);
a6a76f 1395     }
F 1396 }
1397 var savedExecFunclink;
1b0a94 1398
F 1399 function funcLink$$(f, t, sfs, lfs, lk, sd, ld, ef, ref, clo, autoSave, sortid, messageTip, mes) {
a6a76f 1400     savedExecFunclink = null;
F 1401     if (t == "22") {
1402         // autoSave=='1'是要先执行保存
1403         if (typeof (autoSave) != 'undefined' && '1' == autoSave) {
1404             var param = arguments;
1b0a94 1405             if (typeof (sortid) != 'undefined' && (formType == "16" || formType == "5")) {
F 1406                 savedFunclink16 = param[0] + ";" + param[1] + ";" + sortid + ";taobao";
a6a76f 1407                 save(2);
1b0a94 1408             } else {
F 1409                 savedExecFunclink = $(function () {
a6a76f 1410                     execProc(param[0], param[1], param[2], param[3], param[4],
1b0a94 1411                         param[8], param[9], messageTip, mes);
a6a76f 1412                 });
F 1413             }
1414         } else {
1b0a94 1415             execProc(f, t, sfs, lfs, lk, ref, clo, messageTip, mes);
a6a76f 1416         }
F 1417     } else {
1418         // autoSave=='1'是要先执行保存
1419         if (typeof (autoSave) != 'undefined' && '1' == autoSave) {
1420             var param = arguments;
1421             savedExecFunclink = $(function(){
1422                 funclink$$$(param[0], param[1], param[2], param[3], param[4],
1423                     param[5], param[6], param[7], param[8], param[9]);
1424             });
1425         } else {
1426             var lfsStr=lfs.join(","); // 把传进来的外表字段(数组类型)跟自表字段(数组类型)转换成字符串
1427             var sfsStr=sfs.join(",")
1428
1429             var _={}
1430             _.formParm=ld; // 外表字段
1431             _.toParm=sd; // 自表字段
1432
1433             if(typeof(mygrid)!="undefined"){
1434                 try{
1435                     mygrid.setGridInfoTOPop(_,mygrid);
1436                 }catch(e){
1437
1438                 }
1439
1440             }
1441
1442             funclink$$$(f, t, sfs, lfs, lk, sd, ld, ef, ref, clo,messageTip);
1443         }
1444     }
1445 }
1446 function prossDate(key,mygrid,rows,k) {
1447     try{
71e46f 1448         key = key.toLowerCase();
a6a76f 1449         if(mygrid.Cols[key].Type&&mygrid.Cols[key].Type=="Date"&&DateToString){//增加处理日期问题,时间有可能是用毫秒数表示的情况,by danaus 2019/11/25 15:45
F 1450                 rows[k][key]=DateToString(rows[k][key],mygrid.Cols[key].Format);
1451         }
1452     }catch(e){}
1453 }
1454 function funclink$$$(f, t, sfs, lfs, lk, sd, ld, ef, ref, clo,messageTip) {
1455
1456     var rows=[];
1457     var num=0;
1458     if (typeof (mygrid) != "undefined") {
1459         rows=mygrid.getFieldForNew();
526a72 1460         if(rows.length==0){
F 1461             num=1;
1462         }else {
1463             num = rows.length;
1464         }
a6a76f 1465     }else{ // 没格线则取0;
F 1466         num=1;
1467     }
1468     var temp = null;
1469     var strPam="";
1470     for (i = 0; i < sfs.length; i++) {
1471         var selfStr ="";
1472         for(var k=0;k<num;k++){ // 选中多少行,for多少
1473             if ($.trim(sfs[i]) == "")
1474                 break;
1475             // 系统消息
1476             if(messageTip!=null && messageTip.indexOf(",")!=-1){
1477                 var value=messageTip.split(",");
1478                 if(value[1]=="message"){
1479                     temp=sfs[i];
1480                 }
1481             }else{ // end
38c24d 1482                 var key = sfs[i].toLowerCase();
a6a76f 1483                 if (typeof (mygrid) != "undefined") {
F 1484                     prossDate(key, mygrid, rows, k);
1485                 }
38c24d 1486                 temp = getValue(key, null, rows[k]);
fe2b91 1487                 if(typeof temp!="string"&&typeof temp!="number"&& temp==false){
526a72 1488                     closeLoading();
F 1489                     return;
1490                 }
669b45 1491                 if(typeof panMain !="undefined") {
X 1492                     let info = panMain[panIndex].panInfo;
1493                     if (info != null) {
1494                         if (info[key] != null && info[key].controltype == 43) {
1495                             temp = $("#" + key).val();
1496                             if (temp != null && temp != "") {
1497                                 if (temp instanceof Array) {
1498                                     temp = temp.join(";");
1499                                 }
1500                             } else {
1501                                 temp = "";
38c24d 1502                             }
X 1503                         }
1504                     }
1505                 }
a6a76f 1506             }
F 1507             if (temp == undefined || temp == null) {
1508                 temp = sfs[i];
1509             } else if (temp == "null")
1510                 temp = "";
1511             if(selfStr=="")
1512                 selfStr += lfs[i] + "='" + ("" + temp).replaceAll("'", "")+"'";
1513             else
1514                 selfStr +=",'"+("" + temp).replaceAll("'", "")+"'";
1515         }
1516
1517         if(strPam=="")
1518             strPam+=selfStr
1519         else
1520             strPam+=" and "+selfStr
1521     }
1522 //    selfStr +=(temp=="" ? "(" : "")+ lfs[i] + "='" + ("" + temp).replaceAll("'", "")
1523 //        + ((i < sfs.length - 1) ? "'"+(temp=="" ? (" or "+lfs[i]+" is null)") : "")+" //and " : "'"+(temp=="" ? ")" : "")); //修改时间 2014-12-8 ---辛
1524     // lfs 外表字段名
1525
1526
1527
1528     var wp = $.trim(selfStr).length > 0 ? ("wherePan=" + strPam) : "";
1529     if (ef != undefined && ef != null && ef != "")
1530         wp = (wp == "") ? "wherePan=" + encodeURI(encodeURI(ef)) : wp + " and "
1531             + encodeURI(encodeURI(ef));
1532     try {
1533         closeLoading();
1534         parent.addTab("", f, t, wp);
1535     } catch (e) {
1536         closeLoading();
1537         showWindow("/app" + spellPath + f + "/" + t + "/index.jsp?" + wp, "");
1538     }
1539 }
1540
1541 var execParams = []; // 22窗体传值 lk表示是否打开界面或弹出层
1b0a94 1542 function execProc(f, ft, sfs, lfs, lk, ref, clo, exec, mes) { // 储存过程
a6a76f 1543     var paramVa = "";
F 1544     var t = null;
1b0a94 1545     var rows = [];
F 1546     var num = 0;
a6a76f 1547     if (typeof (mygrid) != "undefined") {
1b0a94 1548         rows = mygrid.getFieldForNew();
526a72 1549         if(rows.length==0){
F 1550             num=1;
1551         }else {
1552             num = rows.length;
1553         }
1b0a94 1554     } else { // 没格线则取0;
F 1555         num = 1;
a6a76f 1556     }
F 1557     var sp=";";
1558     for(var s=0;s<sfs.length;s++){
1559         if(sfs[s]!=""&&isNaN(sfs[s])&&sfs[s].indexOf(";")>0){
1560             sp="@p@";
1561             break;
1562         }
1563     }
1564     for(var k=0;k<num;k++){ // 选中多少行,for多少
1565         if(k>0) paramVa += "こ"; // 把用来隔开字段的逗号(,)替换成こ 逗号的使用率高  做字段的隔开不好 有时出现错误 所以改成こ 2014-9-26
1566         for (i = 0; i < sfs.length; i++) {
1567             if(i>0) paramVa += sp;
1568             if ($.trim(sfs[i]) == "") {
1569
1570                 continue;
1571             }
1572             if (sfs[i].indexOf("@") != -1 || $.trim(sfs[i]) == "") {
1573                 paramVa += sfs[i];
1574                 continue;
1575             }
1576             var key=sfs[i];
1577             try{
1578                 if (typeof (mygrid) != "undefined") {
1579                     prossDate(key, mygrid, rows, k);
1580                 }
1581             }catch(e){}
1582             t = getValue(key,null,rows[k]);
fe2b91 1583             if(typeof t!="string"&&typeof t!="number"&&t==false){
526a72 1584                 //没选中格线行数据,返回不执行
F 1585                 closeLoading();
1586                 return;
1587             }
a6a76f 1588             if (t==null||t=="null")
F 1589                 t = sfs[i];
1590             if(isNaN(t)&&t.indexOf(";")>0){ // 当内容存在;情况,需要替换 by danaus
1591                 sp="@p@";
1592                 paramVa=paramVa.replace(/;/g,sp); // 把之前的;也替换
1593             }
1594             paramVa += t;
1595         }
1596     }
1597     if(typeof (formId)!="undefined") {
1598         paramVa = paramVa.replaceAll("@formid", formId).replaceAll(
1599             "'", "");
1600     }
1601     var temp=paramVa.split("こ");
1602     var st="";
1603     var ln=sfs.length;
1604     for(var m=0;m<ln;m++){
1605         if(m>0) st+=sp;
1606         for(var v=0;v<temp.length;v++){
1607             var ss=temp[v].split(sp);
1608             if(v>0) st+=",";
1609             st+=(ss[m]==""?"\'\'":ss[m]); // 为""串时需要增加单引号
1610
1611
1612         }
1613     }
1614     paramVa=st;
1615     if (lk == "1") { // 直接执行存储过程
1b0a94 1616         //注释,执行自定义.do在后台执行,不需要在这里处理 xin 2020-5-14 11:01:40
a012ed 1617         exec = ((exec != undefined && exec.indexOf(".do") != -1) ? exec : "/execProcV2.do");///execProc.do
1b0a94 1618         /*
F 1619                 $.post(exec, {
1620                     "formid" :f,
1621                     "param" :paramVa,
1622                     "disableDuplicateSubmitUUID":systemUuid.uuid //by danaus 2019/11/22 11:12
1623                 }, function(data) {
1624                         procCallBack(data, ref, clo);
1625                 });
1626         */
1627         $.ajax({
1628             type: 'post',
1629             url: exec,
1630             data: {
1631                 "formid": f,
1632                 "param": paramVa,
1633                 "disableDuplicateSubmitUUID": systemUuid.uuid //by danaus 2019/11/22 11:12
1634             },
1635             beforeSend: function (XMLHttpRequest) {
1636                 //ShowLoading();
1637                 if (mes != null && mes != "" && $.messager.progress != undefined) {
1638
1639                     $.messager.progress({
1640                         title: '提示',
1641                         msg: '处理数据',
1642                         text: '努力中...',
1643                         interval: '300'
1644                     });
1645                 }
1646             },
1647             success: function (data, textStatus) {
a6a76f 1648                 procCallBack(data, ref, clo);
176de8 1649                 if (mes != null && mes != ""&& $.messager.progress != undefined) {
1b0a94 1650                     $.messager.progress('close');
F 1651                 }
1652             },
1653             complete: function (XMLHttpRequest, textStatus) {
1654                 // $.messager.progress('close');
1655             },
1656             error: function () {
1657                 //请求出错处理
176de8 1658                 if (mes != null && mes != ""&& $.messager.progress != undefined) {
d1ae8d 1659                     $.messager.progress('close');
F 1660                 }
1b0a94 1661             }
a6a76f 1662         });
1b0a94 1663
a6a76f 1664     } else {
F 1665         var stemp=paramVa.split("こ");
1666         var values =stemp[0].split(sp); // 只取第一个,因为新实现已可以选多行传值, paramVa.split(";");// 通过功能连接打开22类型直接通过execParams数组赋值
1667         parent.changFrame = inThisFrame;
1668         var t = [];
1669         var param = "";
1670         for (i = 0; i < values.length; i++) {
1671             t = [ lfs[i], values[i] ];
1672             execParams[i] = t;
1673             var value=values[i]; // isNaN(values[i])?(values[i].match(/&/)?values[i].replace(/&/,"@W@"):values[i]):values[i];
1674             if(value.indexOf("?")>0) value=value.replace("?","#p#");//处理有问号时 url传递有问题
1675             param += lfs[i].toLowerCase() + "=" +value+ "&";
1676         }
1677         if (param.length > 0) {
1678             param = param.substring(0, param.length - 1);
1679         }
1680         //if (param.indexOf("@") != -1) { // 去掉调用,因为在加载页面已实现
1681         //    replaceSessonKey(param, function(d) {
1682         //            parent.addTab('', f, ft, d);
1683         //    });
1684         //    } else {
1685         if(lk==3){//弹出层
1686             var url = "/app" + spellPath + f + "/" + ft + "/index.jsp?"+encodeURIComponent(param);
1687             // hotkey.js
1688             showLayerGrid(url,ref);
1689         }else{
1690             closeLoading();
1691             parent.addTab('', f, ft, param);
1692         }
1693         //    }
1694     }
1695     closeLoading();
1696 }
1697 function procCallBack(data, ref, clo) {
a012ed 1698     if (data.state != null && data.state == 0) {
X 1699         let info = data.data;
faf4ab 1700         if (info == null) {
X 1701             $.messager.alert('提示', '返回错误:' + info, "info");
021a6f 1702             refreshOrClose(ref, clo);
faf4ab 1703             return;
X 1704         }
a012ed 1705         let doc = info.linkdocinfo;
X 1706         let msg = info.memo;
1707         if (doc == null || doc == '') {
7a4b96 1708             var msgInfo = "";
F 1709             if(msg!=null) {
1710                  msgInfo = msg.split("@p@");
1711                  if(msgInfo.length==2){
1712                     //有跳转参数
1713                      $.messager.alert('提示', msgInfo[0], "info", function () {
1714                          redirect( msgInfo[1]);
1715                      });
1716                      return;
1717                  }
1718             }
a012ed 1719             $.messager.alert('提示', msg || '进程处理完毕', "info", function () {
faf4ab 1720                 if (typeof (savedExecFunclink) == "function") {
X 1721                     location.reload();
1722                 }
021a6f 1723                 refreshOrClose(ref, clo);
F 1724                 return;
faf4ab 1725             });
021a6f 1726         }else {
F 1727             if (msg != null && msg != '') {
1728                 $.messager.alert('提示', msg, "info", function () {
1729                     redirect(doc);
1730                 });
1731                 return;
1732             }else {
faf4ab 1733                 redirect(doc);
021a6f 1734             }
faf4ab 1735         }
a012ed 1736     } else if (data.state != null && data.state == -1) {
021a6f 1737         //错误信息
a012ed 1738         let msg = data.error || data.msg;
X 1739         if (data.data != null && data.data.isuuid) {
1740             $.messager.show({
1741                 title: '提示',
1742                 msg: msg,
1743                 showType: 'show',
1744                 //timeout:3,
1745                 style: {
1746                     right: '',
1747                     top: document.body.scrollTop + document.documentElement.scrollTop,
1748                     bottom: ''
1749                 }
1750             });
1751             return;
1752         }
7a4b96 1753         if(msg!=null) {
F 1754          var   msgInfo = msg.split("@p@");
1755             if(msgInfo.length==2){
1756                 //有跳转参数
1757                 $.messager.alert('提示', msgInfo[0], "info", function () {
1758                     redirect( msgInfo[1]);
1759                 });
1760                 return;
1761             }
1762         }
a012ed 1763         $.messager.alert('提示', msg || '出现错误', "info");
X 1764     } else {
176de8 1765         try{
F 1766             var obj=JSON.parse(data);
1767             $.messager.alert('提示', obj.msg, "info");
1768         }catch (e) {
1769             $.messager.alert('提示', data || '状态无法识别:' + data.state, "info");
1770         }
1771
1772
a6a76f 1773     }
a012ed 1774     // if(data.state!=null && data.state==0){
X 1775     //
1776     //
1777     // }else if(data.state!=null && data.state==-1){
1778     //
1779     // }else{
1780     //
1781     // }
1782     // if (data == null || data == "") {// 什么也没返回
1783     //     $.messager.alert('提示', "进程处理完毕.", "info", function () {
1784     //             if (typeof (savedExecFunclink) == "function") {
1785     //                 location.reload();
1786     //             }
1787     //             refreshOrClose(ref, clo);
1788     //         }
1789     //     );
1790     // } else {
1791     //     try {
1792     //         if (data.error != null && data.error != '') {
1793     //             $.messager.alert('提示', data.error, "info");
1794     //             return;
1795     //         }
1796     //         // if (data.replace(/\s+/g, "") === "(null)") {
1797     //         //     $.messager.alert('提示', data, "info");
1798     //         //     return;
1799     //         // }
1800     //         // data = JSON.parse(data);
1801     //         // if ((data.msg != undefined && data.msg == "") && (data.data == undefined || data.data == "")) {
1802     //         if (data.data == null || data.data == "") {
1803     //             $.messager.alert('提示', "进程处理完毕.", "info", function () {
1804     //                     if (typeof (savedExecFunclink) == "function") {
1805     //                         location.reload();
1806     //                     }
1807     //                     refreshOrClose(ref, clo);
1808     //                 }
1809     //             );
1810     //         }
1811     //     } catch (e) {
1812     //         alert(data.data.memo || data);
1813     //         refreshOrClose(ref, clo);
1814     //         return;
1815     //     }
1816     //     try {//by danaus 2019/11/22 17:42
1817     //         if (data.state = -1 && JSON.parse(data.data).isuuid) {
1818     //             $.messager.show({
1819     //                 title: '提示',
1820     //                 msg: data.msg,
1821     //                 showType: 'show',
1822     //                 //timeout:3,
1823     //                 style: {
1824     //                     right: '',
1825     //                     top: document.body.scrollTop + document.documentElement.scrollTop,
1826     //                     bottom: ''
1827     //                 }
1828     //             });
1829     //
1830     //             return;
1831     //         }
1832     //     } catch (e) {
1833     //     }
1834     //     // let memo=data.data.memo;
1835     //     // if (memo!=null && memo!="") {
1836     //     //     alert(memo);
1837     //     //     if (data.state != null && data.state == 0) {
1838     //     //         refreshOrClose(ref, clo);
1839     //     //     }
1840     //     // }
1841     //     // if (data.msg!=undefined&&data.msg != ""&&data.msg!=null&&data.msg!="null"){
1842     //     //     alert(data.msg);
1843     //     //     if(data.state!=undefined&&data.state==0) {
1844     //     //         refreshOrClose(ref, clo);
1845     //     //     }
1846     //     // return;
1847     //     // }
1848     //     // if (data.msg!=undefined&&data.msg != ""&&data.msg!=null&&data.msg!="null"){
1849     //     //     alert(data.msg);
1850     //     //     if(data.state!=undefined&&data.state==0) {
1851     //     //         refreshOrClose(ref, clo);
1852     //     //     }
1853     //     //    // return;
1854     //     // }
1855     //     if (data.state == 0 && data.data != null) {
1856     //         refreshOrClose(ref, clo);
1857     //         let msg = data.data.memo;
1858     //         $.messager.alert('提示', msg, "info", function () {
1859     //             redirect(data.data.linkdocinfo);
1860     //         });
1861     //         return;
1862     //     }
1863     //     // if (data.data!=undefined&&data.data!=null&&data.data !=""&&data.data !="null") {
1864     //     //     redirect(data.data);
1865     //     //     return;
1866     //     // }
1867     // }
a6a76f 1868 }
F 1869 function redirect(info) {
1870     if(info.indexOf("buildv2.do") > -1){ // 生成页面 by danaus 13-6-28 增加返回生成页面和打开多个功能号多张单的功能
1871         $.get(info);
1872     }else if(info.indexOf("open.callBack|") ==0){//处理第三方返回的数据,打开另一个页卡
1873         var url=info.replace("open.callBack|","");
1874       //  showLayerGrid(url,1,'900px','600px');
1875     var perContent= layer.open({
1876             type: 2,
1877             title: '德立测量单信息',
1878             maxmin: false,
1879             skin: 'layui-layer-molv',
1880             shadeClose: true, //点击遮罩关闭层
1881             area : ['1300px' , '800px'],
1882             content:  url       //'/app/67/0/cnzh/110502/1/index.jsp'
1883         });
1884         layer.full(perContent);
1885     }else{ // 打开页面
1886         var tt=info.split("|");
1887         for(var i=0;i<tt.length;i++){
1888             var t = tt[i].split(";");
1889             if (t.length != 3)
1890                 return;
1891             var temp = t[2];
1892             if (temp.indexOf("wherePan") == -1) {
1893                 var doc=temp.split(",");
1894                 for(var d=0;d<doc.length;d++){
1895                     temp = "wherePan=doccode='" + (doc[d]!=""?doc[d].replace("'","").replace("'",""):"") + "'"; // by 12-04-20 去掉内容的单引号“'”,因为当数据已有单引号时候出错
1896                     parent.addTab('', t[0], t[1], temp);
1897                 }
1898             }else{
1899                 parent.addTab('', t[0], t[1], temp);
1900             }
1901         }
1902     }
1903 }
1904 function showPwd(formId, pwdType, callBack) {
1905     $.post("/checkApprovingExists.do", {
1906         "formid" :formId,
1907         "type" :pwdType
1908     }, function(d) {
1909         pwdCallBack = callBack;
1910         if (d == "false") {
1911             $("#addPwd").dialog("open");
1912         } else {
1913             $("#openPwd").dialog("open");
1914         }
1915     });
1916 }
1917 function refreshOrClose(r, c) { // 刷新或关闭
1918     if(typeof(r)=="function"){
1919         if(opener)
1920             opener.location.reload();
1921         return;
1922     }
1923     if (r == "1") {
1924         if(location) location.reload();
1925     }else if(r=="2"){
1926         if(mygrid) mygrid.ReloadBody();
1927     }
1928     if (c == "1") {
1929        if(parent) parent.closeTab();
1930     }
1931 }
1932
1933 function showWindow(url, obj, callBack, arguments) {
1934     if (obj == undefined || obj == null || obj == '') {
1935         obj = {};
1936         obj.isDialog = 1;
1937     }
1938     // url=encodeURL(url);
1939     var param = {
1940         "url" :url,
1941         vArguments :obj,
1942         dialogWidth :(screen.availWidth - 60),
1943         dialogHeight :(screen.availHeight - 110),
1944         callBack :callBack
1945     };
1946     param = $.extend(param, arguments || {});
1947     var openPage = new myapp(param) // new 一个打开对象 **改变了窗体不是默认大小
1948     openPage.openNewWin();
1949 }
1950 function toolExit() { // 工具栏点击退出
1951     if (window.window.dialogArguments) {
1952         window.close();
1953     } else {
1954         parent.closeTab();
1955     }
1956 }
1957 function refresh() {
1958     var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
1959     var gridbol=false;
1960     if(flag){
1961         return;
1962     }
1963
1964     if(this.formType!=2&&this.formType!=16&&this.formType!=22&& this.formType!=20&& this.formType!=18&& this.formType!=38){
1965         if(this.formType==3||this.formType==10){
1966              var sh=false;
1967         }else{
1968             sh=shx;
1969         }
1970         try{
1971             if(typeof (mygrid)!='undefined'){
1972                 gridbol=mygrid.checkData();
1973             }
1974             if(gridbol||sh){
1975                 $.messager.defaults = { ok: "确定", cancel: "取消" }; // 修改Button显示文字
1976                 $.messager.confirm('确认','页面内容已有改动,刷新操作将会丢失数据,确定刷新吗?',function(r){
1977                     if (r){
1978                         location.reload();
1979                         top.myFresh.panel[top.tabindex+'-t']=false;
1980                     }
1981                 });
1982                 return;
1983             }else{
1984                 location.reload();
1985                 top.myFresh.panel[top.tabindex+'-t']=false;
1986             }
1987         } catch(e){
1988             location.reload();
1989             top.myFresh.panel[top.tabindex+'-t']=false;
1990         }
1991     }else{
1992         location.reload();
0279b8 1993         if( top.myFresh!=null){
X 1994             top.myFresh.panel[top.tabindex+'-t']=false;
1995         }
a6a76f 1996     }
F 1997
1998 }
1999 /**
2000  * top页面info按钮执行函数
2001  * @returns
2002  */
2003 //function showInfo(){
2004 //    var options = {width:"300px",height:"200px",title:'信息', msg:"无", showType:'show',timeout:10000,
2005 //        style:{left:'',right:17,top:document.body.scrollTop+document.documentElement.scrollTop+68,bottom:''}}
2006 //    try{
2007 //        $.ajax({url:'/showInfo.do',
2008 //            data:{'formid' :formid.value,'doccode':doccode.value},
2009 //            type:"POST",async:false,dataType:'text',
2010 //            success:function(mes) {
2011 //                if(mes!=''){
2012 //                    options.msg='<div align="center">'+mes+'</div>';
2013 //                }
2014 //            }});
2015 //    }catch(e){
2016 //        options.msg='<div align="center">加载信息失败【错误信息:'+e+'】</div>';
2017 //    }
2018 //    $.messager.show(options);
2019 //}
2020 function showLoading() {
2021     $("#loading").show();
2022 }
2023 function closeLoading() {
2024     $("#loading").hide();
2025 }
2026 /** ***************************************** */
2027 Object.extend = function(destination, source) {
2028     for ( var property in source) {
2029         destination[property] = source[property];
2030     }
2031     return destination;
2032 }
2033 var myapp = function(o) {
2034     this.options = {
2035         url :"", // 你要打开的页面url
2036         vArguments :"window", // 你要向打开的页面传递的数据
2037         dialogWidth :500, // 打开窗口的宽度
2038         dialogHeight :500, // 你打开窗口的高度
2039         center :"yes", // center: {yes | no | 1 | 0 }:窗口是否居中,默认yes,但仍可以指定高度和宽度。
2040         help :"no", // {yes | no | 1 | 0 }:是否显示帮助按钮,默认yes
2041         resizable :"yes", // {yes | no | 1 | 0 } [IE5+]:是否可被改变大小。默认no
2042         status :"yes", // {yes | no | 1 | 0 } [IE5+]:是否显示状态栏。默认为yes[
2043         // Modeless]或no[Modal]。
2044         scroll :"yes", // { yes | no | 1 | 0 | on | off }:指明对话框是否显示滚动条。默认为yes。
2045         callBack :false
2046     };
2047     Object.extend(this.options, o || {});
2048 }
2049 myapp.prototype = {
2050     openNewWin : function(url) {
2051         var options = this.options;
2052         var l = (screen.availWidth - options["dialogWidth"]) / 2;
2053         var h = (screen.availHeight - options["dialogHeight"]) / 2;
2054         var sp = "dialogTop:" + h + "px;dialogLeft:" + l + "px;dialogWidth:"
2055             + options["dialogWidth"] + "px;dialogHeight:"
2056             + options["dialogHeight"] + "px;center:" + options["center"]
2057             + ";help:" + options["help"] + ";resizable:"
2058             + options["resizable"] + ";status:" + options["status"]
2059             + ";scroll:" + options["scroll"];
2060         var newWin = null;
2061         if(window.showModalDialog!=undefined){
2062             newWin = window.showModalDialog(options["url"],options["vArguments"], sp);
2063             var call = options["callBack"];
2064             if (typeof call == "function") { // 调用 数据处理函数
2065                 call(newWin);
2066             }
2067         }else{
2068             window.open(options["url"],options["vArguments"], "height="+options["dialogHeight"]+",width="+options["dialogWidth"]+",top=300,left=350");
2069         }
2070         // var newWin = window.showModalDialog(options["url"],
2071         //        options["vArguments"], sp);
2072         // var call = options["callBack"];
2073         // if (typeof call == "function") {// 调用 数据处理函数
2074         //        call(newWin);
2075         //}
2076     },
2077     setOptions : function() {
2078     }
2079 }
2080 /** *************************************************************** */
2081 function encodeURL(url) {
2082     try {
2083         url = parent.encodeURL(url);
2084     } catch (e) {
2085     }
2086     return url;
2087 }
2088 function encodeText(t) {
2089     try {
2090         t = parent.encodeText(t);
2091     } catch (e) {
2092     }
2093     return t;
2094 }
2095 // 为String类添加replaceAll函数
2096 String.prototype.replaceAll = function(AFindText, ARepText) {
2097     raRegExp = new RegExp(AFindText, "g");
2098     return this.replace(raRegExp, ARepText)
2099 }
2100 Array.prototype.del = function(n) { // 为数组添加删除元素的函数
2101     if (n < 0)
2102         return this;
2103     else
2104         return this.slice(0, n).concat(this.slice(n + 1, this.length));
2105 }
2106 function replaceSessonKey(str, callback) { // 替换session值
2107     $.post("/replaceSessionKey.do", {
2108         "paramter" :str
2109     }, function(data) {
2110         callback(data);
2111     });
2112 }
2113 function replacePageValue(str) { // 替换页面值
2114     var list = new Array();
2115     var i = 0;
2116     var temp = null;
2117     var postion = 0;
2118     while (str.indexOf("&", i) != -1) {
2119         i = str.indexOf("&", i) + 1;
2120         postion = str.indexOf("&", i);
2121         if (postion == -1)
2122             break;
2123         temp = str.substring(i, postion);
2124         i = postion + 1;
2125         list.push(temp);
2126     }
2127     for (i = 0; i < list.length; i++) {
2128         temp = getValue(list[i]);
2129         str = str.replaceAll("&" + list[i] + "&",
2130             (temp == null || temp == "null") ? list[i] : temp);
2131     }
2132     return str;
2133 }
2134 function getValue(str,format,row) { // 获取页面值
2135     var t;
2136     try {
2137         t = getDoc(str.toLowerCase(), ".value");
2138     } catch (e) {
2139         t=undefined; // by danaus  出现异常赋值   作为判断识别
2140     }
2141     if(t==null){ // 只有是这种情况才需要继续向下查找 by danaus 原则:如果页面上有这个字段定义,不管它是什么值,都把它替换,如果没有这个字段,就继续向下查找,直到没有 则不用替(传什么就是什么)
2142
2143         if (typeof (mygrid) != "undefined") {
2144             try {
526a72 2145                 if(row==undefined){
11e5da 2146                     var tempRow=mygrid.getFristRow(1);//再判断一次,以确定这个字段是否存在于表格,存在才需要提示
F 2147                     if(tempRow!=null&&tempRow[str.toLowerCase()]!=undefined) {
2148                         alert("请从表格选中需要执行的行");
2149                         return false;
2150                     }
526a72 2151                 }
a6a76f 2152                 var d=t; // 保存原值
F 2153                 if(row!=undefined){
2154                     t = (row[str.toLowerCase()+"Link"]!==undefined)?row[str.toLowerCase()+"Link"]:((row[str.toLowerCase()]==undefined)?null:row[str.toLowerCase()]);
2155                 }else{
2156                     t=mygrid.getField(str.toLowerCase());
2157                 }
2158                 if (t==null&&d==null) return str;
2159             } catch (e) {
2160                 return str;
2161             }
2162         }
2163         return t;
2164     }else{
2165         if(t=='null'){t="";}
2166         return t;
2167     }
2168
2169 }
2170 function centerPopup(ctype, callback) { // 2确认 3通过驳回
2171     if (typeof (createPopupPwd) != 'function') {
2172         $.getScript("/js/pwd/inputPwd.js", function() {
2173             createPopupPwd(formId, ctype, callback);
2174         });
2175     } else {
2176         createPopupPwd(formId, ctype, callback);
2177     }
2178 }
2179 var hq={
2180     createPopSelect:function(fid, cfid, doccode, callback) {
2181         if (typeof (openLeaderSelect) != 'function') {
2182             $.getScript("/js/selectLeader/selectLeader.js", function() {
2183                 openLeaderSelect(fid, cfid, doccode, callback);
2184             });
2185         } else {
2186             openLeaderSelect(fid, cfid, doccode, callback);
2187         }
2188     }
2189 }
2190
2191 //报表打印
2192 function printButtonLink(formid, reportid, format, param, formtype,
2193                          Warnnessage, isDirectPrinter, isSelectPrinter, formats, isFont,isbeforerefreshcontent) {
2194     var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
2195     if(flag){
2196         return;
2197     }
2198     var Warn =function(){ // 打印前抛出的信息
2199         var json=JSON.parse(Warnnessage.replace(/'/g, "\""));
2200         if(json.parameters != ""){
2201             var temp=json.parameters.split(";");// getSymbol(Warnnessage,'&');
2202             var war=[];
2203             for(var i in temp){
2204                 war.push(getDoc(temp[i],'.value'));
2205             }
2206             json.parameters=war.join(";");
2207         }
2208 //        else{
2209 //            return confirm(Warnnessage);
2210 //        }
2211             var warbol=false;
2212             $.ajax({url:'/printReport.do?m=Warnnessage',data:json,type:"POST",async:false,dataType:'json',
2213                 success:function(r) {
2214                     if(r.state==0){
2215                         if(confirm(r.msg)){
2216                             warbol=true;
2217                         }
2218                     }    else{
2219                         warbol=true;
2220                     }
2221                 }});
2222          return warbol;
2223     }
2224     if (Warnnessage == "" || Warn()) {
2225         var proParam = "";
2226         if ($.trim(param) != "") {
2227             if (param.indexOf("@formid") != -1) {
2228                 param = param.replaceAll("@formid", formId);
2229             }
2230             var temp = param.split(";");
2231             for (i = 0; i < temp.length; i++) { // 循环获取报表设置参数的值,从面板和格线里面获取。 2014-10-25
2232                 var temp2 = temp[i].split("=");
2233                 if (temp2.length < 2) {
2234                     if (temp2.length == 1 && temp2[0] == "")
2235                         continue;
2236                     $.messager.alert("操作提示", formid + "报表参数配置有误:" + param,"warning");
2237                     return;
2238                 }
2239                 var t = null;
2240                 var rows=[];
2241                 var num=0;
2242                 if (typeof (mygrid) != "undefined") {
2243                     rows=mygrid.getFieldForNew();
cdeccd 2244                     if(rows.length==0){
F 2245                         num=1;
2246                     }else {
2247                         num = rows.length;
2248                     }
a6a76f 2249                 }else{ // 没格线则取0;
F 2250                     num=1;
2251                 }
2252                 proParam += temp2[0]+"=";
2253                 var tempx=(temp2[1].replaceAll("&", "")).toLowerCase();
2254                 for(var k=0;k<num;k++){ // 选中多少行,for多少
2255                     if(k>0) proParam += ","; // 多个值的时候用逗号(,)隔开。
2256                     if ($.trim(tempx) == "") {
2257                         continue;
2258                     }
2259                     t = getValue(tempx.toLowerCase(),null,rows[k]);
2260                     if (t==null)
2261                         t = tempx;
2262                     proParam += t; // 组装值
2263                 }
2264                 proParam +=";";
2265             }
2266             proParam = proParam.substring(0, proParam.length - 1);
7f7112 2267             proParam = encodeURI(encodeURI(proParam)); // 对参数进行编码。(进行二次编码)
a6a76f 2268         }
F 2269 //        var servlet = "/" + format.toLowerCase() + ".do?"
2270         var servlet="/printReport.do?m="+format.toLowerCase()
8a20b4 2271         var doccode = getDoc("doccode", ".value");//只取表头 by danaus 2022/8/17 11:10 getValue('doccode');
a6a76f 2272         var url = "formId=" + formid + "&reportId=" + reportid + "&parameter=" + proParam+";"
7f7112 2273             + "&p=" + Math.round(Math.random() * 100000);
a6a76f 2274         //html方法打印
F 2275         if (format.toLowerCase() == "html") {
2276             parent.addTab("flash打印", "", "", "", encodeURL("/swf.jsp?parm="
2277                 + url.replaceAll("=", "_pb").replaceAll("&", "_fen")
2278                 + "&format=" + format + "&reportId=" + reportid
2279                 + "&formId=" + formid + "&formtype=" + formtype
2280                 + "&doccode=" + doccode + "&print=" + isDirectPrinter
2281                 + "&Formats=" + formats));
2282             return false;
2283         }
2284         if(isbeforerefreshcontent==1){
2285                 //执行更新密码的程序
2286                 $.ajax({url:'/printReport.do?m=updatepwd',
2287                     data:{'formId':formid,'doccode':doccode},
2288                     type:"POST",
2289                     async:false,
2290                     dataType:'json',
2291                     success:function(r) {
2292                         if(r.state==-1){
2293                              $.messager.alert("操作提示", r.msg,"warning");
2294                         }
2295                     }
2296                  });
7f7112 2297          }
a6a76f 2298          //如果谷歌浏览器高于50版本才执行最新打印方式否则执行旧版打印方式
F 2299          if(format.toLowerCase() == "pdf" && getChromeVersion()>50){
2300                 //执行pdf打印,添加一个页卡显示。
2301                 //viewer.jsp是pdfjs提供的加载pdf文件的容器 -xin 2020-6-12 15:00:30
2302                 parent.addTab("PDF报表打印", "", "", "", "/general/pdf/web/viewer.jsp?file="+encodeURL(servlet
2303                        +"&"+ url)+"&formId="+formid+"&formType="+formtype+"&reportId="+reportid
7f7112 2304                        +"&printFormat="+format+"&doccode="+doccode+"&parameter="+proParam+"&isDirectPrinter="+isDirectPrinter);
a6a76f 2305                 return false;
F 2306             }
2307             //执行pdf打印,添加一个页卡显示。
2308             parent.addTab(format + "打印", "", "", "", encodeURL(servlet +"&"+url));
2309             //更新打印次数
2310             $.post("/printReport.do?m=number", {
2311                       "formId" :formid,
2312                       "formType" :formtype,
2313                       "reportId" :reportid,
2314                       "printFormat" :format,
2315                       "doccode" :doccode,
2316                       "parameter":proParam
2317                   },function(r){
2318                       if(r.state==-1){
2319                           $.messager.alert("操作提示", r.msg,"warning");
2320                       }
2321                   });
2322             }
2323 }
2324 //获取谷歌浏览器版本
2325 function getChromeVersion() {
7f7112 2326     var arr = navigator.userAgent.split(' ');
a6a76f 2327     var chromeVersion = '';
F 2328     for(var i=0;i < arr.length;i++){
2329         if(/chrome/i.test(arr[i]))
2330         chromeVersion = arr[i]
2331     }
2332     if(chromeVersion){
2333         return Number(chromeVersion.split('/')[1].split('.')[0]);
2334     } else {
2335         return false;
2336     }
2337 }
2338
2339 function getSymbol(sql,split){    // 获取有符号的字段
2340     var splitLength=split.length;
2341     //List<String> list=new ArrayList<String>();
2342     var i=0;
2343     var postion=0;
2344     var list = new Array();
2345     while(sql.indexOf(split,i)!=-1){
2346         i=sql.indexOf(split,i)+splitLength;
2347         postion=sql.indexOf(split, i);
2348         if(postion==-1)break;
2349         var temp=getDoc(sql.substring(i,postion),'.value');
2350         var tefu=sql.substring(i-1,postion+1);
2351         sql=sql.replace(tefu,temp);
2352         i=postion+splitLength;
2353     }
2354     return sql;
2355 }
2356
2357 function getReportPage(fid, rptid, fun) {
2358     $.post("/reportGetPage.do", {
2359         "formId" :fid,
2360         "reportId" :rptid
2361     }, function(d) {
2362         if (typeof fun == "function")
2363             fun(d);
2364     });
2365 }
2366 function recentFilesTo() {
2367     if (typeof formId != "undefined" && typeof formType != "undefined") {
2368         var url = "/recentfiles.do";
2369         var formname = document.title;
2370         var query_string = document.URL;
2371         query_string = (query_string.indexOf("?") == -1) ? "" : query_string
2372             .substring(query_string.indexOf("?") + 1);
2373         $.post(url, {
2374             "formid" :formId,
2375             "formtype" :formType,
2376             "formname" :formname,
2377             "query_string" :query_string
2378         }, '');
2379     }
2380 }
2381 function getDocURL(isNext) {
2382     var doccode = doc('doccode').value;
2383     panIndex = "0";
2384     $.post("/getDoc.do", {
2385         "t_doc" :isNext,
2386         "doccode" :doccode,
2387         "where" :"",
2388         "tUrl" :document.URL
2389     }, function(data) {
2390         if (data != null && data != "") {
2391             location.href = data;
2392         } else {
2393             alert(data);
2394         }
2395     });
2396 }
2397 var postToThis = null; // 接受字段 父页面
2398 var panelToPost = null; // 所需字段 子页面
2399 var inThisFrame = "";
2400 var inChangFrame = "";
2401 var C_Grid = "";
2402 var ispop="";
2403 $( function($) {
2404     if (typeof parent.getIframeAttr != 'undefined') {
2405         inThisFrame = parent.getIframeAttr("id");
2406         inChangFrame = parent.getIframeAttr("pframe");
2407         panelToPost = parent.getIframeAttr("paneltopost")!=undefined?parent.getIframeAttr("paneltopost").split(";"):"";
2408         postToThis = parent.getIframeAttr("posttothis")!=undefined?parent.getIframeAttr("posttothis").split(";"):"";
2409         C_Grid = parent.getIframeAttr("t_grid");
2410     }
d09c0b 2411   //recentFilesTo();
a6a76f 2412 });
F 2413
2414 // 【帮助】按钮事件函数,点击打开该功能的帮助页面
2415 function openHelpPage(tabtitle)
2416 {
2417     var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
2418     if(flag){
2419         return;
2420     }
2421     // 获取帮助文件所在目录路径
2422     var a = location.href;
2423     a=a.replace(/(.+\/).*$/g, '$1');
2424
2425     //alert(tabtitle);
2426     //var tabtile=.getElementById("tab_title").value;
2427
2428     // 组合路径并在tab打开页面
2429     try {
2430         //alert("1");
2431         var url=a+"help.jsp";
2432         //alert(url);
2433         parent.addTab(tabtitle+"-"+formId+"-帮助", formId, '','',  url);
2434     } catch (e) {
2435         alert(e); // window.open("help.jsp");
2436     }
2437 }
2438
2439
2440 //选择按钮的隐藏和显示
2441 $(function(){
2442     $("#tpselect").hide();
6f0a10 2443     if ((C_Grid != undefined && C_Grid != "" && eval('(' + C_Grid + ')').toP != "" && eval('(' + C_Grid + ')').toP != "null")
X 2444         || $.trim(postToThis).length > 0 || self_datafields != "") {
a6a76f 2445         $("#tpselect").show();
F 2446     }
6f0a10 2447     parent.numId = ""; // 设置单号的值
a6a76f 2448 })
F 2449
2450 // TW添加
2451 function showrestmenu(){
2452     var offset  = $('#showRestmenuDiv').offset()
2453     var top = parseInt(offset.top+$('#showRestmenuDiv').height()+5);
2454     if(isTopFixed()) {//固定头部用到 xin 2020-11-10 10:54:20
2455         top=67;
2456     }
2457     $('#restmenuDiv').css({"top":top,"left":offset.left});
2458     $('#restmenuDiv').show();
2459 }
2460 function restmenuclose(){
2461     $('#restmenuDiv').hide();
2462 }
2463 // 打开搜索框和更多
2464 $(function(){
2465     if (navigator.userAgent.match(/iPad|iPhone|Android/i)){
2466         $("#showRestmenuDiv").toggle(function(){
2467             $("#restmenuDiv").bind('touchstart',function(){
2468                 showrestmenu();
2469             })
2470         },function(){
2471             if($('div').hasClass("restmenuDiv")){
2472                 restmenuclose();
2473             }
2474         });
2475     }
2476     $('#selectinfo').mousedown(function(){
2477         var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
2478         if(flag){
2479             return;
2480         }
2481         $('#selectDiv').show();
2482     })
2483     $('#selectinfo').mouseup(function(){
2484         $('#queryValue').focus();
2485     })
2486     // 按下回车键执行的函数,先解除绑定,再绑定。解决事件累加而执行二次
2487     $('#queryValue').unbind('keydown').keydown(function(event){
2488         if(event.keyCode == 13){
2489             tw.simpConfirm(); // query.js里面的一个方法
ecd393 2490             windowClose();
a6a76f 2491         }
F 2492     })
2493     //更多里面的收藏按钮 -xin 2020-6-23 16:39:45
2494     // if(typeof(formId)!='undefined'){
2495     //     try{
2496     //         var Evt= $('#layoutIcon');
2497     //         $.post('/setIconMenu.do',{'formid':formId},function(data){
2498     //             Evt.linkbutton({
2499     //                 iconCls: (data.state==1?'icon-scok':'icon-scno'),
2500     //                 text:(data.state==1?'已添加':'添加'),
2501     //                 title:'为此功能号添加到图标菜单',
2502     //                 plain:true
2503     //             });
2504     //         },'json');
2505     //         Evt.bind('click',function(){
2506     //             alert('进入收藏');
2507     //         })
2508     //     }catch(e){}
2509     // }
2510 })
2511 function showselectDiv(){
2512      $('#queryValue').focus();
2513 }
2514 // 2、3类型搜索确认事件
2515 function selectSimpConfirm(){
2516     tw.simpConfirm();//query.js里面的一个方法
2517     windowClose();
2518 }
2519 // 2、3类型搜索确认事件
2520 function selectSimpConfirm2(){
2521     tw.confirm2();//query.js里面的一个方法
2522     windowClose();
2523 }
2524
2525 // 2、3类型搜索弹出事件
2526 function select(){
2527     $('#selectDiv').window('open');
2528
2529 }
2530 // 2、3类型搜索的关闭事件
2531 function windowClose(){
2532     $('#selectDiv').dialog('close');
2533 }
2534
2535 // 2、3类型更多按钮弹出事件
2536 function moreSelect(){
2537     var offset  = $('#showRestmenuDiv').offset();
2538     var top = parseInt(offset.top+$('#showRestmenuDiv').height()+5);
2539     $('#restmenuDiv').window({"top":top,"left":offset.left});
2540     $('#restmenuDiv').window('open');
2541 }
2542 // 2、3类型更多按钮的关闭事件
2543 function moreWindowClose(){
2544     $('#restmenuDiv').dialog('close');
2545 }
2546
2547 // 设置头部标题的高度
2548 $(function(){
2549     var a = $("#title_top").html();
2550     if(a!=null && typeof($('#top2').val())!="undefined"){
c81e3f 2551         $('#top2').layout('panel', 'north').panel('resize',{height:68});
a6a76f 2552         $('#top2').layout('resize');
F 2553     }
2554 })
2555
2556 // 窗体类型为20的头部标题的高度设置
2557 function formtype(){
2558     var a = $("#title_top").html();
2559     if(a!=null && typeof($('#top20').val())!="undefined"){
fc3567 2560         $('#top20').layout('panel', 'north').panel('resize',{height:110});
a6a76f 2561         // $('#h_all').layout('panel', 'north').panel('resize',{height:68});
F 2562         $('#top20').layout('resize');
2563         //$('#h_all').layout('resize');
2564     }else{
2565         //$('#h_all').layout('panel', 'north3').panel('resize',{height:0});
2566         $('#h_all').layout('panel', 'north').panel('resize',{height:33});
2567         $('#h_all').layout('resize');
2568     }
2569 }
2570
2571 // 系统消息
2572 var flag=false;
2573 function funB(){
2574     var init = $.cookie(userCode);
2575     if(init==null){
2576         $.cookie(userCode,flag);
2577     }
2578     if( $.cookie(userCode)=="false"){
2579         $.post("/messageTip.do",function(data){
2580             var message = data.message;
2581             if(message!=""){
2582                 $.messagerTip.lays(300, 220);
2583                 $.messagerTip.show(0, message);
2584                 flag= $("input[name='isTip']").is(":checked");
2585                 $.cookie(userCode,flag,{expires: 1})
2586             }
2587             setTimeout(funB, 300000); // 5分钟调用一次
2588         },"json")
2589     }
2590 }
2591
2592
2593
2594 function isChecked(){
2595     flag= $("input[name='isTip']").is(":checked");
2596     $.cookie(userCode,flag);
2597 }
2598
2599 function checkSession(){
2600     var flag = false;
2601     $.ajax({
2602         type : "post",
2603         url : "/checkSession.do",
2604         async : false,
2605         dataType: "json",
2606         success : function(data){
2607             if(data.status=="fail"){
2608                 if($.cookie("dbid")!=null&&$.cookie("dbid")!=""){
2609                     parent.deskTopShow('重新登录','/sessionFail.jsp',400,220,'');
2610                     flag=true;
2611                 }else{ // 不存在cookie,会出错,所以直接返回login页面
2612                     location.href="/login.jsp";
2613                 }
2614             }
2615         }
2616     });
2617     return flag;
2618 }
2619
2620 function gridSave(){
2621     var flag = checkSession();
2622     if(flag){
2623         return;
2624     }else{
2625         showLoading();
2626         mygrid.save('',function(){
2627             closeLoading();
2628         })
2629     }
2630 }
2631
2632 // 重启服务后生成功能号
2633 $(function(){
2634     $.post("/getRealUrl.do",function(data){
2635         if(data.error=="true"){
2636             alert(data.info);
2637         }else{
2638             if(data.formId!=""){ // 获取需要重新生成的功能号
2639                 if(data.formId=="all"){
2640                     // addTab('一键生成','','','','/buildv2.do?m=a','',{isFlowChart:true})
2641                     $.post('/buildv2.do?m=a');
2642                 }else{
2643                     $.post('/buildv2.do?m=a',{'list':data.formId});
2644                 }
2645                 // 将需要生成 的功能号进行清空
2646                 $.post('/property.do',{'formId':''});
2647             }
2648         }
2649     },'json')
2650 })
2651
2652 function checkVersion(){
2653     setTimeout(checkVersion, 86400000);
2654     setTimeout(checkVersion2, 86400000);//24小时调用一次
2655 }
2656
2657 function checkVersion2(){
2658     parent.deskTopShow('版本升级','/versionUpdate/isupdate.jsp?active=zhudong',550,520,'')
2659 }
2660
2661 // 测试$.post
2662 function testfunc(){
2663     $.ajaxError($.post("treeData.jsp"));
2664 }
2665
2666 // 根据单据报表设置的状态显示于隐藏
2667 function reportsdiv(dj,doctaout){
2668     try{
2669         var ent=$('.ReportStatus');
2670         if(ent !=undefined){
2671             $('.ReportStatus').each(function(i){
2672                 var status=$(this).data('status')+'';
2673                 status=status.split(';');
2674                 if(status.indexOf(doctaout)==-1 && status[0]!=""){
2675                     $(this).remove();
2676                 }
2677             })
2678         }else{
2679              var djs=dj.substring(0,dj.length-1).split("#");
2680                 for(var j=0;j<djs.length;j++){
2681                     if(doctaout==0){
2682                         if(djs[j].substring(0,1).indexOf(doctaout)!=-1){
2683                             if(document.getElementById(djs[j])){
2684                                 if(document.getElementById(djs[j]).style.display=="inline-block"){
2685                                     document.getElementById(djs[j]).style.display="inline-block";
2686                                 }else{
2687                                     document.getElementById(djs[j]).style.display="block";
2688                                 }
2689                             }
2690                         }else if(djs[j].indexOf("bdiv")!=-1){
2691                             if(document.getElementById(djs[j]))
2692                                 document.getElementById(djs[j]).style.display="inline-block";
2693                         }else{
2694                             document.getElementById(djs[j]).style.display="none";
2695                         }
2696                     }else{
2697                         var doct=djs[j].substring(0,djs[j].indexOf("-")).split(";");//获取报表设置的显示单据状态
2698                         var bolsecc=false;
2699                         for(var k=0;k<doct.length;k++){
2700                             if(doct[k]==doctaout){
2701                                 if(document.getElementById(djs[j])){
2702                                     if(document.getElementById(djs[j]).style.display=="inline-block"){
2703                                         document.getElementById(djs[j]).style.display="inline-block";
2704                                         bolsecc=true;
2705                                     }else{
2706                                         document.getElementById(djs[j]).style.display="block";//inline-block
2707                                         bolsecc=true;
2708                                     }
2709                                 }
2710                             }else if(djs[j].indexOf("bdiv")!=-1){
2711                                 if(document.getElementById(djs[j])){
2712                                     document.getElementById(djs[j]).style.display="inline-block";
2713                                     bolsecc=true;
2714                                 }
2715                             }
2716                         }
2717                         if(!bolsecc){
2718                             document.getElementById(djs[j]).style.display="none";//inline-block
2719                         }
2720                     }
2721                 }
7f7112 2722         }
a6a76f 2723     }catch (e) {
F 2724         //window.open("help.jsp");
2725     }
2726 }
2727 //-------------RSA---------------
2728 !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.JSEncrypt={})}(this,function(t){"use strict";var e="0123456789abcdefghijklmnopqrstuvwxyz";function a(t){return e.charAt(t)}function i(t,e){return t&e}function u(t,e){return t|e}function r(t,e){return t^e}function n(t,e){return t&~e}function s(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function o(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function c(t){var e,i,r="";for(e=0;e+3<=t.length;e+=3)i=parseInt(t.substring(e,e+3),16),r+=h.charAt(i>>6)+h.charAt(63&i);for(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),r+=h.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),r+=h.charAt(i>>2)+h.charAt((3&i)<<4));0<(3&r.length);)r+="=";return r}function f(t){var e,i="",r=0,n=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e){var s=h.indexOf(t.charAt(e));s<0||(0==r?(i+=a(s>>2),n=3&s,r=1):1==r?(i+=a(n<<2|s>>4),n=15&s,r=2):2==r?(i+=a(n),i+=a(s>>2),n=3&s,r=3):(i+=a(n<<2|s>>4),i+=a(15&s),r=0))}return 1==r&&(i+=a(n<<2)),i}var l,p=function(t,e){return(p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};var g,d=function(t){var e;if(void 0===l){var i="0123456789ABCDEF",r=" \f\n\r\t \u2028\u2029";for(l={},e=0;e<16;++e)l[i.charAt(e)]=e;for(i=i.toLowerCase(),e=10;e<16;++e)l[i.charAt(e)]=e;for(e=0;e<r.length;++e)l[r.charAt(e)]=-1}var n=[],s=0,o=0;for(e=0;e<t.length;++e){var h=t.charAt(e);if("="==h)break;if(-1!=(h=l[h])){if(void 0===h)throw new Error("Illegal character at offset "+e);s|=h,2<=++o?(n[n.length]=s,o=s=0):s<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n},v={decode:function(t){var e;if(void 0===g){var i="= \f\n\r\t \u2028\u2029";for(g=Object.create(null),e=0;e<64;++e)g["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<i.length;++e)g[i.charAt(e)]=-1}var r=[],n=0,s=0;for(e=0;e<t.length;++e){var o=t.charAt(e);if("="==o)break;if(-1!=(o=g[o])){if(void 0===o)throw new Error("Illegal character at offset "+e);n|=o,4<=++s?(r[r.length]=n>>16,r[r.length]=n>>8&255,r[r.length]=255&n,s=n=0):n<<=6}}switch(s){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=n>>10;break;case 3:r[r.length]=n>>16,r[r.length]=n>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=v.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return v.decode(t)}},m=1e13,y=function(){function t(t){this.buf=[+t||0]}return t.prototype.mulAdd=function(t,e){var i,r,n=this.buf,s=n.length;for(i=0;i<s;++i)(r=n[i]*t+e)<m?e=0:r-=(e=0|r/m)*m,n[i]=r;0<e&&(n[i]=e)},t.prototype.sub=function(t){var e,i,r=this.buf,n=r.length;for(e=0;e<n;++e)(i=r[e]-t)<0?(i+=m,t=1):t=0,r[e]=i;for(;0===r[r.length-1];)r.pop()},t.prototype.toString=function(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,i=e[e.length-1].toString(),r=e.length-2;0<=r;--r)i+=(m+e[r]).toString().substring(1);return i},t.prototype.valueOf=function(){for(var t=this.buf,e=0,i=t.length-1;0<=i;--i)e=e*m+t[i];return e},t.prototype.simplify=function(){var t=this.buf;return 1==t.length?t[0]:this},t}(),b="…",T=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,S=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function E(t,e){return t.length>e&&(t=t.substring(0,e)+b),t}var w,D=function(){function i(t,e){this.hexDigits="0123456789ABCDEF",t instanceof i?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}return i.prototype.get=function(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]},i.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},i.prototype.hexDump=function(t,e,i){for(var r="",n=t;n<e;++n)if(r+=this.hexByte(this.get(n)),!0!==i)switch(15&n){case 7:r+="  ";break;case 15:r+="\n";break;default:r+=" "}return r},i.prototype.isASCII=function(t,e){for(var i=t;i<e;++i){var r=this.get(i);if(r<32||176<r)return!1}return!0},i.prototype.parseStringISO=function(t,e){for(var i="",r=t;r<e;++r)i+=String.fromCharCode(this.get(r));return i},i.prototype.parseStringUTF=function(t,e){for(var i="",r=t;r<e;){var n=this.get(r++);i+=n<128?String.fromCharCode(n):191<n&&n<224?String.fromCharCode((31&n)<<6|63&this.get(r++)):String.fromCharCode((15&n)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return i},i.prototype.parseStringBMP=function(t,e){for(var i,r,n="",s=t;s<e;)i=this.get(s++),r=this.get(s++),n+=String.fromCharCode(i<<8|r);return n},i.prototype.parseTime=function(t,e,i){var r=this.parseStringISO(t,e),n=(i?T:S).exec(r);return n?(i&&(n[1]=+n[1],n[1]+=+n[1]<70?2e3:1900),r=n[1]+"-"+n[2]+"-"+n[3]+" "+n[4],n[5]&&(r+=":"+n[5],n[6]&&(r+=":"+n[6],n[7]&&(r+="."+n[7]))),n[8]&&(r+=" UTC","Z"!=n[8]&&(r+=n[8],n[9]&&(r+=":"+n[9]))),r):"Unrecognized time: "+r},i.prototype.parseInteger=function(t,e){for(var i,r=this.get(t),n=127<r,s=n?255:0,o="";r==s&&++t<e;)r=this.get(t);if(0===(i=e-t))return n?-1:0;if(4<i){for(o=r,i<<=3;0==(128&(+o^s));)o=+o<<1,--i;o="("+i+" bit)\n"}n&&(r-=256);for(var h=new y(r),a=t+1;a<e;++a)h.mulAdd(256,this.get(a));return o+h.toString()},i.prototype.parseBitString=function(t,e,i){for(var r=this.get(t),n="("+((e-t-1<<3)-r)+" bit)\n",s="",o=t+1;o<e;++o){for(var h=this.get(o),a=o==e-1?r:0,u=7;a<=u;--u)s+=h>>u&1?"1":"0";if(s.length>i)return n+E(s,i)}return n+s},i.prototype.parseOctetString=function(t,e,i){if(this.isASCII(t,e))return E(this.parseStringISO(t,e),i);var r=e-t,n="("+r+" byte)\n";(i/=2)<r&&(e=t+i);for(var s=t;s<e;++s)n+=this.hexByte(this.get(s));return i<r&&(n+=b),n},i.prototype.parseOID=function(t,e,i){for(var r="",n=new y,s=0,o=t;o<e;++o){var h=this.get(o);if(n.mulAdd(128,127&h),s+=7,!(128&h)){if(""===r)if((n=n.simplify())instanceof y)n.sub(80),r="2."+n.toString();else{var a=n<80?n<40?0:1:2;r=a+"."+(n-40*a)}else r+="."+n.toString();if(r.length>i)return E(r,i);n=new y,s=0}}return 0<s&&(r+=".incomplete"),r},i}(),x=function(){function c(t,e,i,r,n){if(!(r instanceof R))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=i,this.tag=r,this.sub=n}return c.prototype.typeName=function(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}},c.prototype.content=function(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),i=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+i,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+i);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+i,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+i,t);case 6:return this.stream.parseOID(e,e+i,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return E(this.stream.parseStringUTF(e,e+i),t);case 18:case 19:case 20:case 21:case 22:case 26:return E(this.stream.parseStringISO(e,e+i),t);case 30:return E(this.stream.parseStringBMP(e,e+i),t);case 23:case 24:return this.stream.parseTime(e,e+i,23==this.tag.tagNumber)}return null},c.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},c.prototype.toPrettyString=function(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(0<=this.length&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+="  ";for(var i=0,r=this.sub.length;i<r;++i)e+=this.sub[i].toPrettyString(t)}return e},c.prototype.posStart=function(){return this.stream.pos},c.prototype.posContent=function(){return this.stream.pos+this.header},c.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},c.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},c.decodeLength=function(t){var e=t.get(),i=127&e;if(i==e)return i;if(6<i)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===i)return null;for(var r=e=0;r<i;++r)e=256*e+t.get();return e},c.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,i=2*this.length;return t.substr(e,i)},c.decode=function(t){var r;r=t instanceof D?t:new D(t,0);var e=new D(r),i=new R(r),n=c.decodeLength(r),s=r.pos,o=s-e.pos,h=null,a=function(){var t=[];if(null!==n){for(var e=s+n;r.pos<e;)t[t.length]=c.decode(r);if(r.pos!=e)throw new Error("Content size is not correct for container starting at offset "+s)}else try{for(;;){var i=c.decode(r);if(i.tag.isEOC())break;t[t.length]=i}n=s-r.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(i.tagConstructed)h=a();else if(i.isUniversal()&&(3==i.tagNumber||4==i.tagNumber))try{if(3==i.tagNumber&&0!=r.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");h=a();for(var u=0;u<h.length;++u)if(h[u].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){h=null}if(null===h){if(null===n)throw new Error("We can't skip over an invalid tag with undefined length at offset "+s);r.pos=s+Math.abs(n)}return new c(e,o,n,i,h)},c}(),R=function(){function t(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){for(var i=new y;e=t.get(),i.mulAdd(128,127&e),128&e;);this.tagNumber=i.simplify()}}return t.prototype.isUniversal=function(){return 0===this.tagClass},t.prototype.isEOC=function(){return 0===this.tagClass&&0===this.tagNumber},t}(),B=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/B[B.length-1],O=function(){function b(t,e,i){null!=t&&("number"==typeof t?this.fromNumber(t,e,i):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}return b.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,r=(1<<e)-1,n=!1,s="",o=this.t,h=this.DB-o*this.DB%e;if(0<o--)for(h<this.DB&&0<(i=this[o]>>h)&&(n=!0,s=a(i));0<=o;)h<e?(i=(this[o]&(1<<h)-1)<<e-h,i|=this[--o]>>(h+=this.DB-e)):(i=this[o]>>(h-=e)&r,h<=0&&(h+=this.DB,--o)),0<i&&(n=!0),n&&(s+=a(i));return n?s:"0"},b.prototype.negate=function(){var t=M();return b.ZERO.subTo(this,t),t},b.prototype.abs=function(){return this.s<0?this.negate():this},b.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;0<=--i;)if(0!=(e=this[i]-t[i]))return e;return 0},b.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+U(this[this.t-1]^this.s&this.DM)},b.prototype.mod=function(t){var e=M();return this.abs().divRemTo(t,null,e),this.s<0&&0<e.compareTo(b.ZERO)&&t.subTo(e,e),e},b.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new I(e):new N(e),this.exp(t,i)},b.prototype.clone=function(){var t=M();return this.copyTo(t),t},b.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},b.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},b.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},b.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},b.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var i,r=this.DB-t*this.DB%8,n=0;if(0<t--)for(r<this.DB&&(i=this[t]>>r)!=(this.s&this.DM)>>r&&(e[n++]=i|this.s<<this.DB-r);0<=t;)r<8?(i=(this[t]&(1<<r)-1)<<8-r,i|=this[--t]>>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==n&&(128&this.s)!=(128&i)&&++n,(0<n||i!=this.s)&&(e[n++]=i);return e},b.prototype.equals=function(t){return 0==this.compareTo(t)},b.prototype.min=function(t){return this.compareTo(t)<0?this:t},b.prototype.max=function(t){return 0<this.compareTo(t)?this:t},b.prototype.and=function(t){var e=M();return this.bitwiseTo(t,i,e),e},b.prototype.or=function(t){var e=M();return this.bitwiseTo(t,u,e),e},b.prototype.xor=function(t){var e=M();return this.bitwiseTo(t,r,e),e},b.prototype.andNot=function(t){var e=M();return this.bitwiseTo(t,n,e),e},b.prototype.not=function(){for(var t=M(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},b.prototype.shiftLeft=function(t){var e=M();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},b.prototype.shiftRight=function(t){var e=M();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},b.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+s(this[t]);return this.s<0?this.t*this.DB:-1},b.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,i=0;i<this.t;++i)t+=o(this[i]^e);return t},b.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},b.prototype.setBit=function(t){return this.changeBit(t,u)},b.prototype.clearBit=function(t){return this.changeBit(t,n)},b.prototype.flipBit=function(t){return this.changeBit(t,r)},b.prototype.add=function(t){var e=M();return this.addTo(t,e),e},b.prototype.subtract=function(t){var e=M();return this.subTo(t,e),e},b.prototype.multiply=function(t){var e=M();return this.multiplyTo(t,e),e},b.prototype.divide=function(t){var e=M();return this.divRemTo(t,e,null),e},b.prototype.remainder=function(t){var e=M();return this.divRemTo(t,null,e),e},b.prototype.divideAndRemainder=function(t){var e=M(),i=M();return this.divRemTo(t,e,i),[e,i]},b.prototype.modPow=function(t,e){var i,r,n=t.bitLength(),s=F(1);if(n<=0)return s;i=n<18?1:n<48?3:n<144?4:n<768?5:6,r=n<8?new I(e):e.isEven()?new P(e):new N(e);var o=[],h=3,a=i-1,u=(1<<i)-1;if(o[1]=r.convert(this),1<i){var c=M();for(r.sqrTo(o[1],c);h<=u;)o[h]=M(),r.mulTo(c,o[h-2],o[h]),h+=2}var f,l,p=t.t-1,g=!0,d=M();for(n=U(t[p])-1;0<=p;){for(a<=n?f=t[p]>>n-a&u:(f=(t[p]&(1<<n+1)-1)<<a-n,0<p&&(f|=t[p-1]>>this.DB+n-a)),h=i;0==(1&f);)f>>=1,--h;if((n-=h)<0&&(n+=this.DB,--p),g)o[f].copyTo(s),g=!1;else{for(;1<h;)r.sqrTo(s,d),r.sqrTo(d,s),h-=2;0<h?r.sqrTo(s,d):(l=s,s=d,d=l),r.mulTo(d,o[f],s)}for(;0<=p&&0==(t[p]&1<<n);)r.sqrTo(s,d),l=s,s=d,d=l,--n<0&&(n=this.DB-1,--p)}return r.revert(s)},b.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return b.ZERO;for(var i=t.clone(),r=this.clone(),n=F(1),s=F(0),o=F(0),h=F(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),e?(n.isEven()&&s.isEven()||(n.addTo(this,n),s.subTo(t,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;r.isEven();)r.rShiftTo(1,r),e?(o.isEven()&&h.isEven()||(o.addTo(this,o),h.subTo(t,h)),o.rShiftTo(1,o)):h.isEven()||h.subTo(t,h),h.rShiftTo(1,h);0<=i.compareTo(r)?(i.subTo(r,i),e&&n.subTo(o,n),s.subTo(h,s)):(r.subTo(i,r),e&&o.subTo(n,o),h.subTo(s,h))}return 0!=r.compareTo(b.ONE)?b.ZERO:0<=h.compareTo(t)?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},b.prototype.pow=function(t){return this.exp(t,new V)},b.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var r=e;e=i,i=r}var n=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(n<s&&(s=n),0<s&&(e.rShiftTo(s,e),i.rShiftTo(s,i));0<e.signum();)0<(n=e.getLowestSetBit())&&e.rShiftTo(n,e),0<(n=i.getLowestSetBit())&&i.rShiftTo(n,i),0<=e.compareTo(i)?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return 0<s&&i.lShiftTo(s,i),i},b.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=B[B.length-1]){for(e=0;e<B.length;++e)if(i[0]==B[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<B.length;){for(var r=B[e],n=e+1;n<B.length&&r<A;)r*=B[n++];for(r=i.modInt(r);e<n;)if(r%B[e++]==0)return!1}return i.millerRabin(t)},b.prototype.copyTo=function(t){for(var e=this.t-1;0<=e;--e)t[e]=this[e];t.t=this.t,t.s=this.s},b.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,0<t?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},b.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var r=t.length,n=!1,s=0;0<=--r;){var o=8==i?255&+t[r]:C(t,r);o<0?"-"==t.charAt(r)&&(n=!0):(n=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=i)>=this.DB&&(s-=this.DB))}8==i&&0!=(128&+t[0])&&(this.s=-1,0<s&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),n&&b.ZERO.subTo(this,this)},b.prototype.clamp=function(){for(var t=this.s&this.DM;0<this.t&&this[this.t-1]==t;)--this.t},b.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;0<=i;--i)e[i+t]=this[i];for(i=t-1;0<=i;--i)e[i]=0;e.t=this.t+t,e.s=this.s},b.prototype.drShiftTo=function(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s},b.prototype.lShiftTo=function(t,e){for(var i=t%this.DB,r=this.DB-i,n=(1<<r)-1,s=Math.floor(t/this.DB),o=this.s<<i&this.DM,h=this.t-1;0<=h;--h)e[h+s+1]=this[h]>>r|o,o=(this[h]&n)<<i;for(h=s-1;0<=h;--h)e[h]=0;e[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()},b.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var r=t%this.DB,n=this.DB-r,s=(1<<r)-1;e[0]=this[i]>>r;for(var o=i+1;o<this.t;++o)e[o-i-1]|=(this[o]&s)<<n,e[o-i]=this[o]>>r;0<r&&(e[this.t-i-1]|=(this.s&s)<<n),e.t=this.t-i,e.clamp()}},b.prototype.subTo=function(t,e){for(var i=0,r=0,n=Math.min(t.t,this.t);i<n;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r-=t[i],e[i++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[i++]=this.DV+r:0<r&&(e[i++]=r),e.t=i,e.clamp()},b.prototype.multiplyTo=function(t,e){var i=this.abs(),r=t.abs(),n=i.t;for(e.t=n+r.t;0<=--n;)e[n]=0;for(n=0;n<r.t;++n)e[n+i.t]=i.am(0,r[n],e,n,0,i.t);e.s=0,e.clamp(),this.s!=t.s&&b.ZERO.subTo(e,e)},b.prototype.squareTo=function(t){for(var e=this.abs(),i=t.t=2*e.t;0<=--i;)t[i]=0;for(i=0;i<e.t-1;++i){var r=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,r,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}0<t.t&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},b.prototype.divRemTo=function(t,e,i){var r=t.abs();if(!(r.t<=0)){var n=this.abs();if(n.t<r.t)return null!=e&&e.fromInt(0),void(null!=i&&this.copyTo(i));null==i&&(i=M());var s=M(),o=this.s,h=t.s,a=this.DB-U(r[r.t-1]);0<a?(r.lShiftTo(a,s),n.lShiftTo(a,i)):(r.copyTo(s),n.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var f=c*(1<<this.F1)+(1<u?s[u-2]>>this.F2:0),l=this.FV/f,p=(1<<this.F1)/f,g=1<<this.F2,d=i.t,v=d-u,m=null==e?M():e;for(s.dlShiftTo(v,m),0<=i.compareTo(m)&&(i[i.t++]=1,i.subTo(m,i)),b.ONE.dlShiftTo(u,m),m.subTo(s,s);s.t<u;)s[s.t++]=0;for(;0<=--v;){var y=i[--d]==c?this.DM:Math.floor(i[d]*l+(i[d-1]+g)*p);if((i[d]+=s.am(0,y,i,v,0,u))<y)for(s.dlShiftTo(v,m),i.subTo(m,i);i[d]<--y;)i.subTo(m,i)}null!=e&&(i.drShiftTo(u,e),o!=h&&b.ZERO.subTo(e,e)),i.t=u,i.clamp(),0<a&&i.rShiftTo(a,i),o<0&&b.ZERO.subTo(i,i)}}},b.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return 0<(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)?this.DV-e:-e},b.prototype.isEven=function(){return 0==(0<this.t?1&this[0]:this.s)},b.prototype.exp=function(t,e){if(4294967295<t||t<1)return b.ONE;var i=M(),r=M(),n=e.convert(this),s=U(t)-1;for(n.copyTo(i);0<=--s;)if(e.sqrTo(i,r),0<(t&1<<s))e.mulTo(r,n,i);else{var o=i;i=r,r=o}return e.revert(i)},b.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},b.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||36<t)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),r=F(i),n=M(),s=M(),o="";for(this.divRemTo(r,n,s);0<n.signum();)o=(i+s.intValue()).toString(t).substr(1)+o,n.divRemTo(r,n,s);return s.intValue().toString(t)+o},b.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),r=Math.pow(e,i),n=!1,s=0,o=0,h=0;h<t.length;++h){var a=C(t,h);a<0?"-"==t.charAt(h)&&0==this.signum()&&(n=!0):(o=e*o+a,++s>=i&&(this.dMultiply(r),this.dAddOffset(o,0),o=s=0))}0<s&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),n&&b.ZERO.subTo(this,this)},b.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(b.ONE.shiftLeft(t-1),u,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(b.ONE.shiftLeft(t-1),this);else{var r=[],n=7&t;r.length=1+(t>>3),e.nextBytes(r),0<n?r[0]&=(1<<n)-1:r[0]=0,this.fromString(r,256)}},b.prototype.bitwiseTo=function(t,e,i){var r,n,s=Math.min(t.t,this.t);for(r=0;r<s;++r)i[r]=e(this[r],t[r]);if(t.t<this.t){for(n=t.s&this.DM,r=s;r<this.t;++r)i[r]=e(this[r],n);i.t=this.t}else{for(n=this.s&this.DM,r=s;r<t.t;++r)i[r]=e(n,t[r]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()},b.prototype.changeBit=function(t,e){var i=b.ONE.shiftLeft(t);return this.bitwiseTo(i,e,i),i},b.prototype.addTo=function(t,e){for(var i=0,r=0,n=Math.min(t.t,this.t);i<n;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r+=t[i],e[i++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,0<r?e[i++]=r:r<-1&&(e[i++]=this.DV+r),e.t=i,e.clamp()},b.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},b.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},b.prototype.multiplyLowerTo=function(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;0<r;)i[--r]=0;for(var n=i.t-this.t;r<n;++r)i[r+this.t]=this.am(0,t[r],i,r,0,this.t);for(n=Math.min(t.t,e);r<n;++r)this.am(0,t[r],i,r,0,e-r);i.clamp()},b.prototype.multiplyUpperTo=function(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;0<=--r;)i[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)i[this.t+r-e]=this.am(e-r,t[r],i,0,0,this.t+r-e);i.clamp(),i.drShiftTo(1,i)},b.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(0<this.t)if(0==e)i=this[0]%t;else for(var r=this.t-1;0<=r;--r)i=(e*i+this[r])%t;return i},b.prototype.millerRabin=function(t){var e=this.subtract(b.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var r=e.shiftRight(i);B.length<(t=t+1>>1)&&(t=B.length);for(var n=M(),s=0;s<t;++s){n.fromInt(B[Math.floor(Math.random()*B.length)]);var o=n.modPow(r,this);if(0!=o.compareTo(b.ONE)&&0!=o.compareTo(e)){for(var h=1;h++<i&&0!=o.compareTo(e);)if(0==(o=o.modPowInt(2,this)).compareTo(b.ONE))return!1;if(0!=o.compareTo(e))return!1}}return!0},b.prototype.square=function(){var t=M();return this.squareTo(t),t},b.prototype.gcda=function(t,e){var i=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(i.compareTo(r)<0){var n=i;i=r,r=n}var s=i.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)e(i);else{s<o&&(o=s),0<o&&(i.rShiftTo(o,i),r.rShiftTo(o,r));var h=function(){0<(s=i.getLowestSetBit())&&i.rShiftTo(s,i),0<(s=r.getLowestSetBit())&&r.rShiftTo(s,r),0<=i.compareTo(r)?(i.subTo(r,i),i.rShiftTo(1,i)):(r.subTo(i,r),r.rShiftTo(1,r)),0<i.signum()?setTimeout(h,0):(0<o&&r.lShiftTo(o,r),setTimeout(function(){e(r)},0))};setTimeout(h,10)}},b.prototype.fromNumberAsync=function(t,e,i,r){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(b.ONE.shiftLeft(t-1),u,this),this.isEven()&&this.dAddOffset(1,0);var n=this,s=function(){n.dAddOffset(2,0),n.bitLength()>t&&n.subTo(b.ONE.shiftLeft(t-1),n),n.isProbablePrime(e)?setTimeout(function(){r()},0):setTimeout(s,0)};setTimeout(s,0)}else{var o=[],h=7&t;o.length=1+(t>>3),e.nextBytes(o),0<h?o[0]&=(1<<h)-1:o[0]=0,this.fromString(o,256)}},b}(),V=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),I=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||0<=t.compareTo(this.m)?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),N=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=M();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&0<e.compareTo(O.ZERO)&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=M();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=32767&t[e],r=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),0<=t.compareTo(this.m)&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),P=function(){function t(t){this.m=t,this.r2=M(),this.q3=M(),O.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=M();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);0<=t.compareTo(this.m);)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function M(){return new O(null)}function q(t,e){return new O(t,e)}"Microsoft Internet Explorer"==navigator.appName?(O.prototype.am=function(t,e,i,r,n,s){for(var o=32767&e,h=e>>15;0<=--s;){var a=32767&this[t],u=this[t++]>>15,c=h*a+u*o;n=((a=o*a+((32767&c)<<15)+i[r]+(1073741823&n))>>>30)+(c>>>15)+h*u+(n>>>30),i[r++]=1073741823&a}return n},w=30):"Netscape"!=navigator.appName?(O.prototype.am=function(t,e,i,r,n,s){for(;0<=--s;){var o=e*this[t++]+i[r]+n;n=Math.floor(o/67108864),i[r++]=67108863&o}return n},w=26):(O.prototype.am=function(t,e,i,r,n,s){for(var o=16383&e,h=e>>14;0<=--s;){var a=16383&this[t],u=this[t++]>>14,c=h*a+u*o;n=((a=o*a+((16383&c)<<14)+i[r]+n)>>28)+(c>>14)+h*u,i[r++]=268435455&a}return n},w=28),O.prototype.DB=w,O.prototype.DM=(1<<w)-1,O.prototype.DV=1<<w;O.prototype.FV=Math.pow(2,52),O.prototype.F1=52-w,O.prototype.F2=2*w-52;var j,L,H=[];for(j="0".charCodeAt(0),L=0;L<=9;++L)H[j++]=L;for(j="a".charCodeAt(0),L=10;L<36;++L)H[j++]=L;for(j="A".charCodeAt(0),L=10;L<36;++L)H[j++]=L;function C(t,e){var i=H[t.charCodeAt(e)];return null==i?-1:i}function F(t){var e=M();return e.fromInt(t),e}function U(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}O.ZERO=F(0),O.ONE=F(1);var K=function(){function t(){this.i=0,this.j=0,this.S=[]}return t.prototype.init=function(t){var e,i,r;for(e=0;e<256;++e)this.S[e]=e;for(e=i=0;e<256;++e)i=i+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[i],this.S[i]=r;this.i=0,this.j=0},t.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]},t}();var k,_,z=256,Z=null;if(null==Z){Z=[];var G=void(_=0);if(window.crypto&&window.crypto.getRandomValues){var $=new Uint32Array(256);for(window.crypto.getRandomValues($),G=0;G<$.length;++G)Z[_++]=255&$[G]}var Y=function(t){if(this.count=this.count||0,256<=this.count||z<=_)window.removeEventListener?window.removeEventListener("mousemove",Y,!1):window.detachEvent&&window.detachEvent("onmousemove",Y);else try{var e=t.x+t.y;Z[_++]=255&e,this.count+=1}catch(t){}};window.addEventListener?window.addEventListener("mousemove",Y,!1):window.attachEvent&&window.attachEvent("onmousemove",Y)}function J(){if(null==k){for(k=new K;_<z;){var t=Math.floor(65536*Math.random());Z[_++]=255&t}for(k.init(Z),_=0;_<Z.length;++_)Z[_]=0;_=0}return k.next()}var X=function(){function t(){}return t.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=J()},t}();var Q=function(){function t(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}return t.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},t.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},t.prototype.setPublic=function(t,e){null!=t&&null!=e&&0<t.length&&0<e.length?(this.n=q(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")},t.prototype.encrypt=function(t){var e=function(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var i=[],r=t.length-1;0<=r&&0<e;){var n=t.charCodeAt(r--);n<128?i[--e]=n:127<n&&n<2048?(i[--e]=63&n|128,i[--e]=n>>6|192):(i[--e]=63&n|128,i[--e]=n>>6&63|128,i[--e]=n>>12|224)}i[--e]=0;for(var s=new X,o=[];2<e;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new O(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var r=i.toString(16);return 0==(1&r.length)?r:"0"+r},t.prototype.setPrivate=function(t,e,i){null!=t&&null!=e&&0<t.length&&0<e.length?(this.n=q(t,16),this.e=parseInt(e,16),this.d=q(i,16)):console.error("Invalid RSA private key")},t.prototype.setPrivateEx=function(t,e,i,r,n,s,o,h){null!=t&&null!=e&&0<t.length&&0<e.length?(this.n=q(t,16),this.e=parseInt(e,16),this.d=q(i,16),this.p=q(r,16),this.q=q(n,16),this.dmp1=q(s,16),this.dmq1=q(o,16),this.coeff=q(h,16)):console.error("Invalid RSA private key")},t.prototype.generate=function(t,e){var i=new X,r=t>>1;this.e=parseInt(e,16);for(var n=new O(e,16);;){for(;this.p=new O(t-r,1,i),0!=this.p.subtract(O.ONE).gcd(n).compareTo(O.ONE)||!this.p.isProbablePrime(10););for(;this.q=new O(r,1,i),0!=this.q.subtract(O.ONE).gcd(n).compareTo(O.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(O.ONE),h=this.q.subtract(O.ONE),a=o.multiply(h);if(0==a.gcd(n).compareTo(O.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(a),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(h),this.coeff=this.q.modInverse(this.p);break}}},t.prototype.decrypt=function(t){var e=q(t,16),i=this.doPrivate(e);return null==i?null:function(t,e){var i=t.toByteArray(),r=0;for(;r<i.length&&0==i[r];)++r;if(i.length-r!=e-1||2!=i[r])return null;++r;for(;0!=i[r];)if(++r>=i.length)return null;var n="";for(;++r<i.length;){var s=255&i[r];s<128?n+=String.fromCharCode(s):191<s&&s<224?(n+=String.fromCharCode((31&s)<<6|63&i[r+1]),++r):(n+=String.fromCharCode((15&s)<<12|(63&i[r+1])<<6|63&i[r+2]),r+=2)}return n}(i,this.n.bitLength()+7>>3)},t.prototype.generateAsync=function(t,e,n){var s=new X,o=t>>1;this.e=parseInt(e,16);var h=new O(e,16),a=this,u=function(){var e=function(){if(a.p.compareTo(a.q)<=0){var t=a.p;a.p=a.q,a.q=t}var e=a.p.subtract(O.ONE),i=a.q.subtract(O.ONE),r=e.multiply(i);0==r.gcd(h).compareTo(O.ONE)?(a.n=a.p.multiply(a.q),a.d=h.modInverse(r),a.dmp1=a.d.mod(e),a.dmq1=a.d.mod(i),a.coeff=a.q.modInverse(a.p),setTimeout(function(){n()},0)):setTimeout(u,0)},i=function(){a.q=M(),a.q.fromNumberAsync(o,1,s,function(){a.q.subtract(O.ONE).gcda(h,function(t){0==t.compareTo(O.ONE)&&a.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(i,0)})})},r=function(){a.p=M(),a.p.fromNumberAsync(t-o,1,s,function(){a.p.subtract(O.ONE).gcda(h,function(t){0==t.compareTo(O.ONE)&&a.p.isProbablePrime(10)?setTimeout(i,0):setTimeout(r,0)})})};setTimeout(r,0)};setTimeout(u,0)},t.prototype.sign=function(t,e,i){var r=function(t,e){if(e<t.length+22)return console.error("Message too long for RSA"),null;for(var i=e-t.length-6,r="",n=0;n<i;n+=2)r+="ff";return q("0001"+r+"00"+t,16)}((W[i]||"")+e(t).toString(),this.n.bitLength()/4);if(null==r)return null;var n=this.doPrivate(r);if(null==n)return null;var s=n.toString(16);return 0==(1&s.length)?s:"0"+s},t.prototype.verify=function(t,e,i){var r=q(e,16),n=this.doPublic(r);return null==n?null:function(t){for(var e in W)if(W.hasOwnProperty(e)){var i=W[e],r=i.length;if(t.substr(0,r)==i)return t.substr(r)}return t}(n.toString(16).replace(/^1f+00/,""))==i(t).toString()},t}();var W={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"};var tt={};tt.lang={extend:function(t,e,i){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,(t.prototype.constructor=t).superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),i){var n;for(n in i)t.prototype[n]=i[n];var s=function(){},o=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(s=function(t,e){for(n=0;n<o.length;n+=1){var i=o[n],r=e[i];"function"==typeof r&&r!=Object.prototype[i]&&(t[i]=r)}})}catch(t){}s(t.prototype,i)}}};var et={};void 0!==et.asn1&&et.asn1||(et.asn1={}),et.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var r="",n=0;n<i;n++)r+="f";e=new O(r,16).xor(t).add(O.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=et.asn1,i=e.DERBoolean,r=e.DERInteger,n=e.DERBitString,s=e.DEROctetString,o=e.DERNull,h=e.DERObjectIdentifier,a=e.DEREnumerated,u=e.DERUTF8String,c=e.DERNumericString,f=e.DERPrintableString,l=e.DERTeletexString,p=e.DERIA5String,g=e.DERUTCTime,d=e.DERGeneralizedTime,v=e.DERSequence,m=e.DERSet,y=e.DERTaggedObject,b=e.ASN1Util.newObject,T=Object.keys(t);if(1!=T.length)throw"key of param shall be only one.";var S=T[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+S+":"))throw"undefined key: "+S;if("bool"==S)return new i(t[S]);if("int"==S)return new r(t[S]);if("bitstr"==S)return new n(t[S]);if("octstr"==S)return new s(t[S]);if("null"==S)return new o(t[S]);if("oid"==S)return new h(t[S]);if("enum"==S)return new a(t[S]);if("utf8str"==S)return new u(t[S]);if("numstr"==S)return new c(t[S]);if("prnstr"==S)return new f(t[S]);if("telstr"==S)return new l(t[S]);if("ia5str"==S)return new p(t[S]);if("utctime"==S)return new g(t[S]);if("gentime"==S)return new d(t[S]);if("seq"==S){for(var E=t[S],w=[],D=0;D<E.length;D++){var x=b(E[D]);w.push(x)}return new v({array:w})}if("set"==S){for(E=t[S],w=[],D=0;D<E.length;D++){x=b(E[D]);w.push(x)}return new m({array:w})}if("tag"==S){var R=t[S];if("[object Array]"===Object.prototype.toString.call(R)&&3==R.length){var B=b(R[2]);return new y({tag:R[0],explicit:R[1],obj:B})}var A={};if(void 0!==R.explicit&&(A.explicit=R.explicit),void 0!==R.tag&&(A.tag=R.tag),void 0===R.obj)throw"obj shall be specified for 'tag'.";return A.obj=b(R.obj),new y(A)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},et.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",i=parseInt(t.substr(0,2),16),r=(e=Math.floor(i/40)+"."+i%40,""),n=2;n<t.length;n+=2){var s=("00000000"+parseInt(t.substr(n,2),16).toString(2)).slice(-8);if(r+=s.substr(1,7),"0"==s.substr(0,1))e=e+"."+new O(r,2).toString(10),r=""}return e},et.asn1.ASN1Util.oidIntToHex=function(t){var h=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},e=function(t){var e="",i=new O(t,10).toString(2),r=7-i.length%7;7==r&&(r=0);for(var n="",s=0;s<r;s++)n+="0";i=n+i;for(s=0;s<i.length-1;s+=7){var o=i.substr(s,7);s!=i.length-7&&(o="1"+o),e+=h(parseInt(o,2))}return e};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",r=t.split("."),n=40*parseInt(r[0])+parseInt(r[1]);i+=h(n),r.splice(0,2);for(var s=0;s<r.length;s++)i+=e(r[s]);return i},et.asn1.ASN1Object=function(){this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+"".length+",v="+this.hV;var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var i=e.length/2;if(15<i)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},et.asn1.DERAbstractString=function(t){et.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},tt.lang.extend(et.asn1.DERAbstractString,et.asn1.ASN1Object),et.asn1.DERAbstractTime=function(t){et.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var r=this.zeroPadding,n=this.localDateToUTC(t),s=String(n.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+r(String(n.getMonth()+1),2)+r(String(n.getDate()),2)+r(String(n.getHours()),2)+r(String(n.getMinutes()),2)+r(String(n.getSeconds()),2);if(!0===i){var h=n.getMilliseconds();if(0!=h){var a=r(String(h),3);o=o+"."+(a=a.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,i,r,n,s){var o=new Date(Date.UTC(t,e-1,i,r,n,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},tt.lang.extend(et.asn1.DERAbstractTime,et.asn1.ASN1Object),et.asn1.DERAbstractStructured=function(t){et.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},tt.lang.extend(et.asn1.DERAbstractStructured,et.asn1.ASN1Object),et.asn1.DERBoolean=function(){et.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},tt.lang.extend(et.asn1.DERBoolean,et.asn1.ASN1Object),et.asn1.DERInteger=function(t){et.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=et.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new O(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},tt.lang.extend(et.asn1.DERInteger,et.asn1.ASN1Object),et.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=et.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}et.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var i="0"+t;this.hTLV=null,this.isModified=!0,this.hV=i+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var i=0;i<=e;i++)t+="0";var r="";for(i=0;i<t.length-1;i+=8){var n=t.substr(i,8),s=parseInt(n,2).toString(16);1==s.length&&(s="0"+s),r+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",i=0;i<t.length;i++)1==t[i]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),i=0;i<t;i++)e[i]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},tt.lang.extend(et.asn1.DERBitString,et.asn1.ASN1Object),et.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=et.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}et.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},tt.lang.extend(et.asn1.DEROctetString,et.asn1.DERAbstractString),et.asn1.DERNull=function(){et.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},tt.lang.extend(et.asn1.DERNull,et.asn1.ASN1Object),et.asn1.DERObjectIdentifier=function(t){var h=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},s=function(t){var e="",i=new O(t,10).toString(2),r=7-i.length%7;7==r&&(r=0);for(var n="",s=0;s<r;s++)n+="0";i=n+i;for(s=0;s<i.length-1;s+=7){var o=i.substr(s,7);s!=i.length-7&&(o="1"+o),e+=h(parseInt(o,2))}return e};et.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var e="",i=t.split("."),r=40*parseInt(i[0])+parseInt(i[1]);e+=h(r),i.splice(0,2);for(var n=0;n<i.length;n++)e+=s(i[n]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){var e=et.asn1.x509.OID.name2oid(t);if(""===e)throw"DERObjectIdentifier oidName undefined: "+t;this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t):void 0!==t.oid?this.setValueOidString(t.oid):void 0!==t.hex?this.setValueHex(t.hex):void 0!==t.name&&this.setValueName(t.name))},tt.lang.extend(et.asn1.DERObjectIdentifier,et.asn1.ASN1Object),et.asn1.DEREnumerated=function(t){et.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=et.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new O(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},tt.lang.extend(et.asn1.DEREnumerated,et.asn1.ASN1Object),et.asn1.DERUTF8String=function(t){et.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},tt.lang.extend(et.asn1.DERUTF8String,et.asn1.DERAbstractString),et.asn1.DERNumericString=function(t){et.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},tt.lang.extend(et.asn1.DERNumericString,et.asn1.DERAbstractString),et.asn1.DERPrintableString=function(t){et.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},tt.lang.extend(et.asn1.DERPrintableString,et.asn1.DERAbstractString),et.asn1.DERTeletexString=function(t){et.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},tt.lang.extend(et.asn1.DERTeletexString,et.asn1.DERAbstractString),et.asn1.DERIA5String=function(t){et.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},tt.lang.extend(et.asn1.DERIA5String,et.asn1.DERAbstractString),et.asn1.DERUTCTime=function(t){et.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},tt.lang.extend(et.asn1.DERUTCTime,et.asn1.DERAbstractTime),et.asn1.DERGeneralizedTime=function(t){et.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},tt.lang.extend(et.asn1.DERGeneralizedTime,et.asn1.DERAbstractTime),et.asn1.DERSequence=function(t){et.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){t+=this.asn1Array[e].getEncodedHex()}return this.hV=t,this.hV}},tt.lang.extend(et.asn1.DERSequence,et.asn1.DERAbstractStructured),et.asn1.DERSet=function(t){et.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t.push(i.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},tt.lang.extend(et.asn1.DERSet,et.asn1.DERAbstractStructured),et.asn1.DERTaggedObject=function(t){et.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,i){this.hT=e,this.isExplicit=t,this.asn1Object=i,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=i.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.tag&&(this.hT=t.tag),void 0!==t.explicit&&(this.isExplicit=t.explicit),void 0!==t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},tt.lang.extend(et.asn1.DERTaggedObject,et.asn1.ASN1Object);var it=function(i){function r(t){var e=i.call(this)||this;return t&&("string"==typeof t?e.parseKey(t):(r.hasPrivateKeyProperty(t)||r.hasPublicKeyProperty(t))&&e.parsePropertiesFrom(t)),e}return function(t,e){function i(){this.constructor=t}p(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}(r,i),r.prototype.parseKey=function(t){try{var e=0,i=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?d(t):v.unarmor(t),n=x.decode(r);if(3===n.sub.length&&(n=n.sub[2].sub[0]),9===n.sub.length){e=n.sub[1].getHexStringValue(),this.n=q(e,16),i=n.sub[2].getHexStringValue(),this.e=parseInt(i,16);var s=n.sub[3].getHexStringValue();this.d=q(s,16);var o=n.sub[4].getHexStringValue();this.p=q(o,16);var h=n.sub[5].getHexStringValue();this.q=q(h,16);var a=n.sub[6].getHexStringValue();this.dmp1=q(a,16);var u=n.sub[7].getHexStringValue();this.dmq1=q(u,16);var c=n.sub[8].getHexStringValue();this.coeff=q(c,16)}else{if(2!==n.sub.length)return!1;var f=n.sub[1].sub[0];e=f.sub[0].getHexStringValue(),this.n=q(e,16),i=f.sub[1].getHexStringValue(),this.e=parseInt(i,16)}return!0}catch(t){return!1}},r.prototype.getPrivateBaseKey=function(){var t={array:[new et.asn1.DERInteger({int:0}),new et.asn1.DERInteger({bigint:this.n}),new et.asn1.DERInteger({int:this.e}),new et.asn1.DERInteger({bigint:this.d}),new et.asn1.DERInteger({bigint:this.p}),new et.asn1.DERInteger({bigint:this.q}),new et.asn1.DERInteger({bigint:this.dmp1}),new et.asn1.DERInteger({bigint:this.dmq1}),new et.asn1.DERInteger({bigint:this.coeff})]};return new et.asn1.DERSequence(t).getEncodedHex()},r.prototype.getPrivateBaseKeyB64=function(){return c(this.getPrivateBaseKey())},r.prototype.getPublicBaseKey=function(){var t=new et.asn1.DERSequence({array:[new et.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new et.asn1.DERNull]}),e=new et.asn1.DERSequence({array:[new et.asn1.DERInteger({bigint:this.n}),new et.asn1.DERInteger({int:this.e})]}),i=new et.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new et.asn1.DERSequence({array:[t,i]}).getEncodedHex()},r.prototype.getPublicBaseKeyB64=function(){return c(this.getPublicBaseKey())},r.wordwrap=function(t,e){if(!t)return t;var i="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(i,"g")).join("\n")},r.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return t+=r.wordwrap(this.getPrivateBaseKeyB64())+"\n",t+="-----END RSA PRIVATE KEY-----"},r.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return t+=r.wordwrap(this.getPublicBaseKeyB64())+"\n",t+="-----END PUBLIC KEY-----"},r.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},r.hasPrivateKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},r.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},r}(Q),rt=function(){function t(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}return t.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new it(t)},t.prototype.setPrivateKey=function(t){this.setKey(t)},t.prototype.setPublicKey=function(t){this.setKey(t)},t.prototype.decrypt=function(t){try{return this.getKey().decrypt(f(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return c(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,i){try{return c(this.getKey().sign(t,e,i))}catch(t){return!1}},t.prototype.verify=function(t,e,i){try{return this.getKey().verify(t,f(e),i)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new it,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},t.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},t.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},t.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},t.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},t.version="3.0.0-rc.1",t}();window.JSEncrypt=rt,t.JSEncrypt=rt,t.default=rt,Object.defineProperty(t,"__esModule",{value:!0})});