|
发表于 2017-3-31 15:58:07
|
显示全部楼层
如下附件中的doc和xls用自己创建的officeViewer显示
- var data = this.comp("mainData");
- var fFJ = data.getValue("fFJ");
- var jsonList = eval("(" + fFJ + ")");
- var url = "";
- var type = "";
- // var url = "http://192.168.1.97:8080/x5/UI2/appdemo/test/process/attachmentEditor2/bbb.doc";
- if (jsonList.length > 0) {
- for (var i = 0; i < jsonList.length; i++) {
- var docPath = jsonList[0]["docPath"];
- var fileID = jsonList[0]["fileID"];
- var docName = jsonList[0]["docName"];
- url = DocUtils.InnerUtils.getdocServerAction({
- "docPath" : docPath,
- urlPattern : "/repository/file/view/" + fileID + "/last/content",
- isFormAction : false,
- context : this.getContext(),
- useCookie:false
- });
- url = url.indexOf(window.location.protocol) < 1 ? url : window.location.protocol+"//"+ window.location.host + url;
- var fileType = docName.substring(docName.indexOf("."));
- if(fileType == ".doc" || fileType == ".docx")
- type = "Word.Application";
- else if(fileType == ".xls" || fileType == ".xlsx")
- type = "Excel.Application"
- }
- }
- var divID = this.getIDByXID("officeViewer");
- var ocxID = divID + "_ocx";
- if (event.tab.select().find("a").html() == 'officeViewer') {
- if (!$(".officeViewr").length>0) {
- $("#" + divID).append('<div class="officeViewr" style="overflow:hidden;width:100%;height:100%;"><div style="overflow:auto;width:100%;height:100%;" id="' + ocxID + '"></div></div>');
- }
- $('#'+ocxID).attr('showToolbar',false);//隐藏工具栏
-
- $OV(ocxID).CreateOfficeViewer('100%', '100%');
- var officeObj = $OV(ocxID);
- officeObj.ShowMenubar(false);//隐藏菜单栏
- if(type && !officeObj.isOpened())
- officeObj.Open(url,type);
- else
- return;
-
- }
复制代码 |
|