|
想在点击图片的时候预览该文件,代码如下:Model.prototype.toShow = function(event, rowid) {
debugger;
var fUploadFiles = this.comp("productDocumentation").getValueByID("fUploadFiles", rowid);
var json = eval("("+fUploadFiles+")");
var fileID = json["fileID"];
var docName = json["docName"];
var docPath = json["docPath"];
var url = DocUtils.InnerUtils.getdocServerAction({
"docPath" : docPath,
urlPattern : "/repository/file/view/" + fileID + "/last/content",
isFormAction : false,
context : this.getContext()
});
url = url.indexOf(window.location.protocol) < 1 ? url : window.location.protocol + "//" + window.location.host + url;// 拼接最终需要的url
url = encodeURI(encodeURI(url));
var fileType = docName.substring(docName.indexOf(".")),type;// 获取文件的后缀判断设置不同的类型
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 (!($(".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);
}
};
|
-
|