Commit 74a6fdc5 by 宋祥

1.文件预览调整为在线预览

parent b60489f3
......@@ -40,7 +40,9 @@ function addRecord(fileId, docId, docType){
function previewFile(docId, docType) {
// 隐藏文本描述
$("#descDiv").css('display', 'none');
if (isText(docType)) {
if (true) {
previewOnline(docId, "xxxxx." + docType);
} else if (isText(docType)) {
previewText(docId);
} else if (isXml(docType)) {
previewXml(docId);
......@@ -265,6 +267,17 @@ function previewFrame(docId) {
}
/**
* 在线预览
*
* @param docId
* @param fileName
*/
function previewOnline(docId, fileName) {
$("#previewFrame").css('display', '');
$("#previewFrame").attr("src", CommonUtils.previewFile(docId, fileName));
}
/**
* 监听iframe
*/
function iframeLoad() {
......@@ -330,7 +343,7 @@ let realImage = null;
let bigImage = null;
window.onload = function () {
// 监听iframe
iframeLoad();
// iframeLoad();
imageOuterDiv = document.querySelector("#imageOuterDiv");
realImage = document.querySelector("#image");
bigImage = document.querySelector("#bigImage");
......
......@@ -109,21 +109,6 @@ function downloadHref(docId, isPreview) {
}
/**
* 预览
*
* @param 文件类型,例如:jpg/docx/pdf
* @param 文件ID
*/
function previewDoc(fileType, docId) {
if (!isBlank(fileType) && fileType.toLowerCase() == "docx") {
let url = "HGWD098?inqu_status-0-docId=" + docId;
window.open(url, '_blank');
} else {
window.open(downloadHref(docId, true), '_blank');
}
}
/**
* 获取窗口宽度
*
* @returns {number}
......@@ -664,10 +649,31 @@ function loadChange(grid,e,field) {
});
}
/**
* 预览
*
* @param docId 文件ID
* @param fileName 文件名称必须带后缀
*/
function previewFile(docId, fileName) {
let hostname = window.location.hostname;
let domain = hostname === "localhost" ? "http://129.211.46.84:8085": window.location.origin;
let url = domain + IPLATUI.CONTEXT_PATH + '/file/download/preview/' + docId
+ "?fullfilename=" + fileName;
// Base64转码
let urlEncode = encodeURIComponent(btoa(url));
if (PROJECT_ENV === "run" || PROJECT_ENV === "RUN") {
return "https://www.eis-paas.com/preview/onlinePreview?url=" + urlEncode
} else {
return "http://139.224.202.156:8012/preview/onlinePreview?url=" + urlEncode;
}
}
// export 到全局作用域 window对象
$.extend(window, {
CommonUtils: {
uploadFile: uploadFile,
previewFile: previewFile,
}
});
})(window.jQuery);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment