Files
foton-laws-system-front/public/static/onlyOffice/editor.html
T
2021-05-25 18:06:45 +08:00

159 lines
4.8 KiB
HTML

<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="mobile-web-app-capable" content="yes"/>
<title>在线编辑</title>
<!-- 此处配置onlyOffice地址 -->
<script type="text/javascript" src="http://106.2.13.189:9001/web-apps/apps/api/documents/api.js"></script>
<!-- <script type="text/javascript" src="http://172.20.10.5/web-apps/apps/api/documents/api.js"></script>-->
</head>
<body style="height: 100%">
<div class="form" style="height: 100%">
<div id="iframeEditor"></div>
</div>
<script type="text/javascript">
var fileName = GetQueryValue('fileName')
var fileUrl = GetQueryValue('fileUrl')
var standNo = GetQueryValue('standNo')
var key = GetQueryValue('key')
// var attId = GetQueryValue('attId')
var fileSuffix = GetQueryValue('fileType')
//将文件后缀处理掉
// fileSuffix = fileSuffix.split(".").join("");
var docEditor;
var innerAlert = function (message) {
if (console && console.log)
console.log(message);
};
var onAppReady = function () {
innerAlert("Document editor ready");
};
var onDocumentStateChange = function (event) {
var title = document.title.replace(/\*$/g, "");
document.title = title + (event.data ? "*" : "");
};
var onRequestEditRights = function () {
location.href = location.href.replace(RegExp("mode=view\&?", "i"), "");
};
var onError = function (event) {
if (event)
innerAlert(event.data);
};
var onOutdatedVersion = function (event) {
location.reload(true);
};
// console.log(key)
// console.log(fileUrl)
// console.log(attId)
// console.log(fileName)
// const fileUrl = 'http://172.20.10.2:9090/conver.docx'
var config = {
"document": {
"fileType": 'docx',
"key": key,
"title": fileName,
"url": fileUrl
},
"documentType": "text",
"editorConfig": {
// 此处配置回调地址
"callbackUrl": `http://39.98.140.126:10005/api/att/attFile/recieveFile?fileNm=${fileName}&standNo=${standNo}`,
"mode":"edit",
"lang":"zh-CN",
// "customization": {
// "forcesave": "true"
// }
}
};
// var config = {
// "type": "desktop",
// "mode": "edit",
// "documentType": "text",
// "document": {
// "title": "new.docx",
// "url": "http://172.20.10.2:9090/conver.docx",
// "fileType": "docx",
// "key": "-1988670278",
// "permissions": {
// "comment": true,
// "download": true,
// "edit": true,
// "fillForms": true,
// "modifyFilter": true,
// "modifyContentControl": true,
// "review": true
// }
// },
// "editorConfig": {
// "mode": "edit",
// "callbackUrl": "http://39.98.140.126:10005/api/IndexServlet?type=track&fileName=new.docx&userAddress=172.20.10.2",
// "lang": "zh",
// "user": {
// "id": "uid-1",
// "name": "John Smith"
// },
// "customization": {
// "goback": {
// "url": "http://39.98.140.126:10005/api/IndexServlet"
// },
// "about": true,
// "feedback": false
// },
// "canCoAuthoring": true,
// "canUseHistory": false,
// "canHistoryClose": false,
// "canHistoryRestore": false,
// "canSendEmailAddresses": false,
// "canRequestEditRights": true,
// "canRequestClose": false,
// "canRename": false,
// "canMakeActionLink": true,
// "canRequestUsers": false,
// "canRequestSendNotify": false,
// "canRequestSaveAs": false,
// "canRequestInsertImage": false,
// "canRequestMailMergeRecipients": false,
// "canRequestCompareFile": false,
// "canRequestSharingSettings": false,
// "canRequestCreateNew": false
// },
// "width": "100%",
// "height": "100%",
// "events": {},
// "frameEditorId": "iframeEditor",
// "parentOrigin": "http://172.20.10.2:8081"
// }
docEditor = new DocsAPI.DocEditor("iframeEditor", config);
/**
* [通过参数名获取url中的参数值]
* 示例URL:http://htmlJsTest/getrequest.html?uid=admin&rid=1&fid=2&name=小明
* @param {[string]} queryName [参数名]
* @return {[string]} [参数值]
*/
function GetQueryValue(queryName) {
var query = decodeURI(window.location.search.substring(1));
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == queryName) { return pair[1]; }
}
return null;
}
</script>
</body>
</html>