/** * 金格服务端地址 * */ ///var mHttpUrl="202.111.178.254:8082/iWebOffice2015V2/"; var mHttpUrl="10.10.10.116:8082/iWebOffice2015V2/"; /** * 附件管理。 * @returns {OnlineText} */ if (typeof OnlineText == 'undefined') { OnlineText = {}; } /** * 选择非直接上传附件时判断用flash还是html */ OnlineText.addFile=function(obj){ OnlineText.htmlUpLoadFile(obj); } /** * 选择直接上传附件时判断用flash还是html */ OnlineText.directUpLoadFile=function(obj){ OnlineText.htmlUpLoadFile(obj); } /** * flash附件非直接上传 */ OnlineText.FlexAddFile=function(obj){ var inputObj=$(obj); var fieldName=inputObj.attr("field"); var parent=inputObj.parent().parent(); var rights="w"; var divName="div.onlinetext"; var inputName="input[name='" +fieldName +"'],textarea[name='" +fieldName +"']"; //获取div对象。 var divObj=$(divName,parent); var inputJson=$(inputName,parent); var aryJson=OnlineText.getFileJsonArray(divObj); //文件选择器 FlexUploadDialog({isSingle:false,callback:function (fileIds,fileNames,filePaths,extPaths){ if(fileIds==undefined || fileIds=="") return ; var aryFileId=fileIds.split(","); var aryName=fileNames.split(","); var aryExtPath=extPaths.split(","); for(var i=0;i'); div.append('
'); div.append(''); var onclick="OnlineText.addFile(this)"; if($(this).attr("isdirectupload")=="1"){ onclick="OnlineText.directUpLoadFile(this)"; } div.append('选择'); if(this.value==""||typeof(this.value)=="undefined"||this.value.indexOf("¥@@¥") != -1){ $(this).after(div); $(this).remove(); } }); if( $.isEmpty(parent)){ parent = $("div[name='div_onlinetext_container']"); } parent.each(function(){ var me=$(this), rights=me.attr("right"); //如果没有权限属性,可能是子表中的附件 if(!rights){ rights=me.closest("[type='subtable']").attr("right"); } //对于弹出框的处理 if(!$.isEmpty(subRights)) rights = subRights; if(rights){ rights=rights.toLowerCase(); } if(rights!="w" && rights!="r" && rights!="b"){ //rights="w"; } // else{ if(rights=="r"){ //$("a.attachement").remove(); //$("a.selectFile").remove(); $("a[field]",me).remove(); } var atta =$("textarea[controltype='onlinetext']",me); var jsonStr = atta.val(); if(!$.isEmpty(jsonStr)){ jsonStr = jsonStr.replaceAll("¥@@¥","\""); atta.val(jsonStr); } var divOnlineText=$("div.onlinetext",me); //json数据为空。 OnlineText.insertHtml(divOnlineText,jsonStr,rights); // } }); }; /** * 附件插入显示 * @param {} div * @param {} jsonStr * @param {} rights 权限 如果不传,默认是r */ OnlineText.insertHtml= function(div,jsonStr,rights){ if($.isEmpty(jsonStr)) { div.empty(); return ; } if($.isEmpty(rights)) rights ='r'; var jsonObj=[]; try { jsonStr = jsonStr.replaceAll("¥@@¥","\""); jsonObj = jQuery.parseJSON(jsonStr); } catch (e) { } var html=OnlineText.getHtml(jsonObj,rights); div.empty(); div.append($(html)); }; /** * 获取文件的html。 * @param aryJson * @returns {String} */ OnlineText.getHtml=function(aryJson,rights){ var str=""; var template=""; var templateW="
  • #name# #preview#
  • "; var templateR="
  • #name##preview#
  • "; if(rights=="w"){ template=templateW; } else{ template=templateR; } for(var i=0;i0){ tmp=template.replace("#file#",file).replace("#preview#","").replace("#path#",path).replace("#name#", OnlineText.parseName(name)).replace("#title#",name).replace("#fileId#", id); }else{ tmp=template.replace("#file#",file).replace("#preview#","").replace("#path#",path).replace("#name#", OnlineText.parseName(name)).replace("#title#",name).replace("#fileId#", id); } //PDF预览新增代码end 李猛ADD //附件如果是图片就显示到后面 str+=tmp; } str = ""; /*改为一个附件就占领一行*/ return str; }; OnlineText.parseName = function(name){ if(name.length >10) return name.substr(0,10)+"..."; /*暂时去掉截取字段*/ return name; } /** * 添加json。 * @param fileId * @param name * @param path * @param aryJson */ OnlineText.addJson=function(fileId,name,aryJson){ var rtn=OnlineText.isFileExist(aryJson,fileId); if(!rtn){ var obj={id:fileId,name:name}; aryJson.push(obj); } }; /** * 删除json。 * @param fileId 文件ID。 * @param aryJson 文件的JSON。 */ OnlineText.delJson=function(fileId,aryJson){ for(var i=aryJson.length-1;i>=0;i--){ var obj=aryJson[i]; if(obj.id==fileId){ aryJson.splice(i,1); } } }; /** * 判断文件是否存在。 * @param aryJson * @param fileId * @returns {Boolean} */ OnlineText.isFileExist=function(aryJson,fileId){ for(var i=0;i0) var fileId = span.attr("fileId"); var userId= $("input[name='curUserId']").val(); var userName= $("input[name='curUserName']").val(); var aurl=' /samples/WordPermissions/Adv_WordPermissions.jsp?fileId='+fileId+"&userId="+userId+"&userName="+userName; $.ajax({ type: "get", async: false, // url: "http://127.0.0.1:9588/LongListen?id=111", url: "http://127.0.0.1:9588/QueryOpen", jsonp: "hookback", dataType: "jsonp", success: function (data) { Link(aurl, 1); // skin 0灰色 1蓝色 2黄色 3绿色 4红色 }, error: function () { var answer = confirm("未安装支持多浏览器应用程序是否点击安装\n提示:安装的时候360全部点击允许程序所有操作"); if (answer) {//判断是否点击确定 window.location.href = "http://"+mHttpUrl + "KGBrowserSetup.exe"; //安装KGBrower } } }); // ie 8+, chrome and some other browsers var head = document.head || $('head')[0] || document.documentElement; // code from jquery var script = $(head).find('script')[0]; script.onerror = function (evt) { var answer = confirm("未安装支持多浏览器应用程序是否点击安装\n提示:安装的时候360全部点击允许程序所有操作"); if (answer) {//判断是否点击确定 window.location.href = "http://"+mHttpUrl + "KGBrowserSetup.exe"; //安装KGBrower } // do some clean // delete script node if (script.parentNode) { script.parentNode.removeChild(script); } // delete jsonCallback global function var src = script.src || ''; var idx = src.indexOf('hookback='); if (idx != -1) { var idx2 = src.indexOf('&'); if (idx2 == -1) { idx2 = src.length; } var hookback = src.substring(idx + 13, idx2); delete window[hookback]; } }; } function Link(url, skin) { var link = "KGBrowser://$link:http://"+mHttpUrl+"" + url + "$skin=" + skin + "$tabshow=1" + "$cookie=" + document.cookie; // skin 0灰色 1蓝色 2黄色 3绿色 4红色 location.href = link; console.log(link); connect(); } function connect() //与弹窗应用页面通讯使用 { $.ajax({ type: "get", async: false, url: "http://127.0.0.1:9588/LongListen?id=111", //此代码ip固定,端口号与Edit页面该方法一致,其他固定。 jsonp: "hookback", dataType: "jsonp", success: function (data) { var jsonobj = eval(data); if (jsonobj.ret == "save") { //此判断处理Edit页面Msg传过来的值,判断之后下面做响应处理即可 alert("save"); setTimeout("location.reload();", 100); } if (jsonobj.ret == "returnlist") { //此判断处理Edit页面Msg传过来的值,判断之后下面做响应处理即可 //alert("returnlist"); setTimeout("location.reload();", 100); } if (jsonobj.ret != "none"){ alert("接收上个页面传输的数据为:" + jsonobj.ret); } else if (jsonobj.ret == "none") { setTimeout("connect();", 500); //这里一定要调用,不可删除 } }, error: function (a, b, c) { } }); } //在线拟文方法 OnlineText.CreateNew = function(runId){ var userId= $("input[name='curUserId']").val(); var userName= $("input[name='curUserName']").val(); var aurl='/samples/WordPermissions/Adv_WordPermissions.jsp?func=create&userId='+userId+'&runId='+runId+'&userName='+userName; $.ajax({ type: "get", async: false, url: "http://127.0.0.1:9588/QueryOpen", jsonp: "hookback", dataType: "jsonp", success: function (data) { Link(aurl, 1); // skin 0灰色 1蓝色 2黄色 3绿色 4红色 }, error: function () { var answer = confirm("未安装支持多浏览器应用程序是否点击安装\n提示:安装的时候360全部点击允许程序所有操作"); if (answer) {//判断是否点击确定 window.location.href = "http://"+mHttpUrl + "KGBrowserSetup.exe"; //安装KGBrower } } }); // ie 8+, chrome and some other browsers var head = document.head || $('head')[0] || document.documentElement; // code from jquery var script = $(head).find('script')[0]; script.onerror = function (evt) { var answer = confirm("未安装支持多浏览器应用程序是否点击安装\n提示:安装的时候360全部点击允许程序所有操作"); if (answer) {//判断是否点击确定 window.location.href = "http://"+mHttpUrl + "KGBrowserSetup.exe"; //安装KGBrower } // do some clean // delete script node if (script.parentNode) { script.parentNode.removeChild(script); } // delete jsonCallback global function var src = script.src || ''; var idx = src.indexOf('hookback='); if (idx != -1) { var idx2 = src.indexOf('&'); if (idx2 == -1) { idx2 = src.length; } var hookback = src.substring(idx + 13, idx2); delete window[hookback]; } }; } //正文审核方法 OnlineText.onlineTextEdit = function(fileId,runId){ var userId= $("input[name='curUserId']").val(); var userName= $("input[name='curUserName']").val(); var fileId=fileId; var runId=runId; //var fileId=$("input[ctltype='onlinetext']").val(); if(fileId==""||fileId==null){ $.ligerDialog.warn("该流程未产生正文!","提示"); return; } var aurl=' /samples/WordPermissions/Adv_WordPermissions.jsp?func=open&fileId='+fileId+'&runId='+runId+'&userId='+userId+'&userName='+userName; $.ajax({ type: "get", async: false, url: "http://127.0.0.1:9588/QueryOpen", jsonp: "hookback", dataType: "jsonp", success: function (data) { Link(aurl, 1); // skin 0灰色 1蓝色 2黄色 3绿色 4红色 }, error: function () { var answer = confirm("未安装支持多浏览器应用程序是否点击安装\n提示:安装的时候360全部点击允许程序所有操作"); if (answer) {//判断是否点击确定 window.location.href = "http://"+mHttpUrl + "KGBrowserSetup.exe"; //安装KGBrower } } }); // ie 8+, chrome and some other browsers var head = document.head || $('head')[0] || document.documentElement; // code from jquery var script = $(head).find('script')[0]; script.onerror = function (evt) { var answer = confirm("未安装支持多浏览器应用程序是否点击安装\n提示:安装的时候360全部点击允许程序所有操作"); if (answer) {//判断是否点击确定 window.location.href = "http://"+mHttpUrl + "KGBrowserSetup.exe"; //安装KGBrower } // do some clean // delete script node if (script.parentNode) { script.parentNode.removeChild(script); } // delete jsonCallback global function var src = script.src || ''; var idx = src.indexOf('hookback='); if (idx != -1) { var idx2 = src.indexOf('&'); if (idx2 == -1) { idx2 = src.length; } var hookback = src.substring(idx + 13, idx2); delete window[hookback]; } }; } //正文编辑方法 OnlineText.onlineTextOverride = function(fileId,runId){ var userId= $("input[name='curUserId']").val(); var userName= $("input[name='curUserName']").val(); var fileId=fileId; var runId=runId; if(fileId==""||fileId==null){ $.ligerDialog.warn("该流程未产生正文!","提示"); return; } var aurl=' /samples/WordPermissions/Adv_WordPermissions.jsp?func=create&fileId='+fileId+'&runId='+runId+'&userId='+userId+'&userName='+userName; $.ajax({ type: "get", async: false, url: "http://127.0.0.1:9588/QueryOpen", jsonp: "hookback", dataType: "jsonp", success: function (data) { Link(aurl, 1); // skin 0灰色 1蓝色 2黄色 3绿色 4红色 }, error: function () { var answer = confirm("未安装支持多浏览器应用程序是否点击安装\n提示:安装的时候360全部点击允许程序所有操作"); if (answer) {//判断是否点击确定 window.location.href = "http://"+mHttpUrl + "KGBrowserSetup.exe"; //安装KGBrower } } }); // ie 8+, chrome and some other browsers var head = document.head || $('head')[0] || document.documentElement; // code from jquery var script = $(head).find('script')[0]; script.onerror = function (evt) { var answer = confirm("未安装支持多浏览器应用程序是否点击安装\n提示:安装的时候360全部点击允许程序所有操作"); if (answer) {//判断是否点击确定 window.location.href = "http://"+mHttpUrl + "KGBrowserSetup.exe"; //安装KGBrower } // do some clean // delete script node if (script.parentNode) { script.parentNode.removeChild(script); } // delete jsonCallback global function var src = script.src || ''; var idx = src.indexOf('hookback='); if (idx != -1) { var idx2 = src.indexOf('&'); if (idx2 == -1) { idx2 = src.length; } var hookback = src.substring(idx + 13, idx2); delete window[hookback]; } }; } //模板套红方法 OnlineText.onlineTextTemplateTaoHong = function(fileId,runId){ var userId= $("input[name='curUserId']").val(); var userName= $("input[name='curUserName']").val(); var fileId=fileId; var runId=runId; if(fileId==""||fileId==null){ $.ligerDialog.warn("该流程未产生正文!","提示"); return; } var aurl=' /samples/TemplateTaoHong/Adv_TemplateTaoHong.jsp?func=taohong&fileId='+fileId+'&runId='+runId+'&userId='+userId+'&userName='+userName; $.ajax({ type: "get", async: false, url: "http://127.0.0.1:9588/QueryOpen", jsonp: "hookback", dataType: "jsonp", success: function (data) { Link(aurl, 1); // skin 0灰色 1蓝色 2黄色 3绿色 4红色 }, error: function () { var answer = confirm("未安装支持多浏览器应用程序是否点击安装\n提示:安装的时候360全部点击允许程序所有操作"); if (answer) {//判断是否点击确定 window.location.href = "http://"+mHttpUrl + "KGBrowserSetup.exe"; //安装KGBrower } } }); // ie 8+, chrome and some other browsers var head = document.head || $('head')[0] || document.documentElement; // code from jquery var script = $(head).find('script')[0]; script.onerror = function (evt) { var answer = confirm("未安装支持多浏览器应用程序是否点击安装\n提示:安装的时候360全部点击允许程序所有操作"); if (answer) {//判断是否点击确定 window.location.href = "http://"+mHttpUrl + "KGBrowserSetup.exe"; //安装KGBrower } // do some clean // delete script node if (script.parentNode) { script.parentNode.removeChild(script); } // delete jsonCallback global function var src = script.src || ''; var idx = src.indexOf('hookback='); if (idx != -1) { var idx2 = src.indexOf('&'); if (idx2 == -1) { idx2 = src.length; } var hookback = src.substring(idx + 13, idx2); delete window[hookback]; } }; }