feat: There is no way the, online preview
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html style="height: 100%">
|
||||
<head>
|
||||
<head id="vue">
|
||||
<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"/>
|
||||
@@ -8,8 +8,10 @@
|
||||
<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>-->
|
||||
<script type="text/javascript" src="http://127.0.0.1:9011/web-apps/apps/api/documents/api.js"></script>
|
||||
<!-- <script src="js/vue.min.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%">
|
||||
@@ -17,12 +19,46 @@
|
||||
<div id="iframeEditor"></div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
import { baseUrl } from '@/sysConfig'
|
||||
|
||||
// var preview = GetQueryValue('preview')
|
||||
// var vm = new Vue({
|
||||
// el: '#vue',
|
||||
// data: {
|
||||
// titleName: preview ? "在线预览":"在线编辑",
|
||||
// },
|
||||
// methods: {
|
||||
// details: function() {
|
||||
// return this.site + " - 学的不仅是技术,更是梦想!";
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
var oldFileName = GetQueryValue('oldFileName')
|
||||
var filePath = GetQueryValue('filePath')
|
||||
var fileName = GetQueryValue('fileName')
|
||||
var fileUrl = GetQueryValue('fileUrl')
|
||||
var standNo = GetQueryValue('standNo')
|
||||
var key = GetQueryValue('key')
|
||||
// var attId = GetQueryValue('attId')
|
||||
var fileSuffix = GetQueryValue('fileType')
|
||||
// 文档类word-text、表格类excel-spreadsheet、ppt类-presentation
|
||||
var documentType = ''
|
||||
var arr_data_ppt = ['pdf', 'PDF', 'pptx', 'PPTX', 'ppt', 'PPT'];
|
||||
var arr_data_word = ['pdf', 'PDF', 'doc','DOC', 'docx','DOCX'];
|
||||
var arr_data_xls = ['xls', 'XLS', 'xlsx', 'XLSX','.xls', '.XLS', '.xlsx', '.XLSX'];
|
||||
|
||||
arr_data_ppt.find(function(value) {
|
||||
if(value === fileSuffix) {
|
||||
documentType = 'presentation'
|
||||
}})
|
||||
arr_data_word.find(function(value) {
|
||||
if(value === fileSuffix) {
|
||||
documentType = 'text'
|
||||
}})
|
||||
arr_data_xls.find(function(value) {
|
||||
if(value === fileSuffix) {
|
||||
documentType = 'spreadsheet'
|
||||
}})
|
||||
//将文件后缀处理掉
|
||||
// fileSuffix = fileSuffix.split(".").join("");
|
||||
var docEditor;
|
||||
@@ -60,15 +96,20 @@
|
||||
// const fileUrl = 'http://172.20.10.2:9090/conver.docx'
|
||||
var config = {
|
||||
"document": {
|
||||
"fileType": 'docx',
|
||||
"permissions": {
|
||||
"edit": true, //是否可以编辑: 只能查看,传false
|
||||
"download":true,//是否可以下载
|
||||
"print":true //是否可以打印
|
||||
},
|
||||
"fileType": 'pptx',
|
||||
"key": key,
|
||||
"title": fileName,
|
||||
"title": oldFileName,
|
||||
"url": fileUrl
|
||||
},
|
||||
"documentType": "text",
|
||||
"documentType": documentType, // 文档类word-text、表格类excel-spreadsheet、ppt类-presentation
|
||||
"editorConfig": {
|
||||
// 此处配置回调地址
|
||||
"callbackUrl": `http://39.98.140.126:10005/api/att/attFile/recieveFile?fileNm=${fileName}&standNo=${standNo}`,
|
||||
"callbackUrl": baseUrl+`/api/att/attFile/recieveFile?fileNm=${fileName}&standNo=${filePath}`,
|
||||
"mode":"edit",
|
||||
"lang":"zh-CN",
|
||||
// "customization": {
|
||||
@@ -135,8 +176,10 @@
|
||||
// "frameEditorId": "iframeEditor",
|
||||
// "parentOrigin": "http://172.20.10.2:8081"
|
||||
// }
|
||||
|
||||
console.log(config)
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor", config);
|
||||
console.log(docEditor)
|
||||
|
||||
|
||||
/**
|
||||
* [通过参数名获取url中的参数值]
|
||||
|
||||
+6
File diff suppressed because one or more lines are too long
@@ -0,0 +1,199 @@
|
||||
<!DOCTYPE html>
|
||||
<html style="height: 100%">
|
||||
<head id="vue">
|
||||
<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://127.0.0.1:9011/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">
|
||||
import { baseUrl } from '@/sysConfig'
|
||||
|
||||
// var preview = GetQueryValue('preview')
|
||||
// var vm = new Vue({
|
||||
// el: '#vue',
|
||||
// data: {
|
||||
// titleName: preview ? "在线预览":"在线编辑",
|
||||
// },
|
||||
// methods: {
|
||||
// details: function() {
|
||||
// return this.site + " - 学的不仅是技术,更是梦想!";
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
var fileName = GetQueryValue('fileName')
|
||||
var filePath = GetQueryValue('filePath')
|
||||
var fileUrl = GetQueryValue('fileUrl')
|
||||
var standNo = GetQueryValue('standNo')
|
||||
var key = GetQueryValue('key')
|
||||
// var attId = GetQueryValue('attId')
|
||||
var fileSuffix = GetQueryValue('fileType')
|
||||
// 文档类word-text、表格类excel-spreadsheet、ppt类-presentation
|
||||
var documentType = ''
|
||||
var arr_data_ppt = ['pdf', 'PDF', 'pptx', 'PPTX', 'ppt', 'PPT'];
|
||||
var arr_data_word = ['pdf', 'PDF', 'doc','DOC', 'docx','DOCX'];
|
||||
var arr_data_xls = ['xls', 'XLS', 'xlsx', 'XLSX','.xls', '.XLS', '.xlsx', '.XLSX'];
|
||||
|
||||
arr_data_ppt.find(function(value) {
|
||||
if(value === fileSuffix) {
|
||||
documentType = 'presentation'
|
||||
}})
|
||||
arr_data_word.find(function(value) {
|
||||
if(value === fileSuffix) {
|
||||
documentType = 'text'
|
||||
}})
|
||||
arr_data_xls.find(function(value) {
|
||||
if(value === fileSuffix) {
|
||||
documentType = 'spreadsheet'
|
||||
}})
|
||||
//将文件后缀处理掉
|
||||
// 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": {
|
||||
"permissions": {
|
||||
"edit": false, //是否可以编辑: 只能查看,传false
|
||||
"download":true,//是否可以下载
|
||||
"print":true //是否可以打印
|
||||
},
|
||||
"fileType": fileSuffix,
|
||||
"key": key,
|
||||
"title": fileName,
|
||||
"url": fileUrl
|
||||
},
|
||||
"documentType": documentType,
|
||||
"editorConfig": {
|
||||
// 此处配置回调地址
|
||||
"callbackUrl": baseUrl+`/api/att/attFile/recieveFile?fileNm=${fileName}&standNo=${filePath}`,
|
||||
"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"
|
||||
// }
|
||||
console.log(config)
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor", config);
|
||||
console.log(docEditor)
|
||||
|
||||
|
||||
/**
|
||||
* [通过参数名获取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>
|
||||
@@ -604,6 +604,15 @@ export function getConvertFileByAttId(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 获取openOffice 在线预览文件
|
||||
export function getBusStandFileByAttId(data) {
|
||||
return axios({
|
||||
url: 'api/att/attFile/getBusStandFileByAttId',
|
||||
method: 'get',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
// 未符合项跟踪修改状态
|
||||
export function updateBaseInfo(data) {
|
||||
return axios({
|
||||
|
||||
@@ -67,7 +67,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getConvertFileByAttId } from 'api/process'
|
||||
import { getConvertFileByAttId,getBusStandFileByAttId } from 'api/process'
|
||||
let Base64 = require('js-base64').Base64;
|
||||
export default {
|
||||
name: 'CustomFile',
|
||||
data() {
|
||||
@@ -335,29 +336,43 @@ export default {
|
||||
handlePreview(file) {
|
||||
const attId = file.response.data.id
|
||||
if (this.preview) {
|
||||
this.getConvertFileByAttId(attId)
|
||||
.then(res => {
|
||||
switch (res.convertState) {
|
||||
case 'ERROR':
|
||||
this.$message.warning('文档转换失败')
|
||||
break
|
||||
case 'LODING':
|
||||
this.$message.info('文档转换中,请稍后查看')
|
||||
break
|
||||
case 'SUCCESS':
|
||||
const { convertFileInfo } = res
|
||||
window.open('/static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + convertFileInfo.id))
|
||||
break
|
||||
}
|
||||
}).catch(e => {
|
||||
this.$message.warning('文档转换失败')
|
||||
})
|
||||
if (attId) {
|
||||
window.location.href = '/api/att/attFile/downloadFileForSar?fileId=' + attId
|
||||
} else {
|
||||
this.$message.warning('文件不存在,下载失败')
|
||||
}
|
||||
} else {
|
||||
if (attId) {
|
||||
window.location.href = '/api/att/attFile/downloadFileForSar?fileId=' + attId
|
||||
} else {
|
||||
this.$message.warning('文件不存在,下载失败')
|
||||
}
|
||||
this.getBusStandFileByAttId(attId)
|
||||
.then(res => {
|
||||
console.log(res)
|
||||
if(res){
|
||||
const editFileInfo = res
|
||||
console.log(editFileInfo)
|
||||
if(editFileInfo.fileSuffix === 'pdg' || editFileInfo.fileSuffix === 'PDG'){
|
||||
window.open('book://ssreader/e0?url='+editFileInfo.downLoadUrl)
|
||||
}else {
|
||||
const nowTime = new Date().getTime()
|
||||
// window.open('http://127.0.0.1:8012/onlinePreview?url='+encodeURIComponent(Base64.encode(editFileInfo.downLoadUrl)));
|
||||
window.open('/static/onlyOffice/onlinePreview.html?oldFileName=' + editFileInfo.oldFileName + '&fileType=' + editFileInfo.fileSuffix + '&attId=' + editFileInfo.id + '&fileUrl=' + editFileInfo.downLoadUrl + '&key=' + editFileInfo.id + nowTime+'&filePath='+editFileInfo.filePath+'&fileName='+editFileInfo.fileName)
|
||||
}
|
||||
// window.open('/static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + editFileInfo.id))
|
||||
}
|
||||
// switch (res.convertState) {
|
||||
// case 'ERROR':
|
||||
// this.$message.warning('文档转换失败')
|
||||
// break
|
||||
// case 'LODING':
|
||||
// this.$message.info('文档转换中,请稍后查看')
|
||||
// break
|
||||
// case 'SUCCESS':
|
||||
// const { convertFileInfo } = res
|
||||
// window.open('/static/pdf/web/viewer.html?file=' + encodeURIComponent('/api/att/attFile/getFileInfo?fileId=' + convertFileInfo.id))
|
||||
// break
|
||||
// }
|
||||
}).catch(e => {
|
||||
console.log(e)
|
||||
this.$message.warning('文件不存在,预览失败')
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
@@ -377,6 +392,21 @@ export default {
|
||||
})
|
||||
})
|
||||
},
|
||||
getBusStandFileByAttId(attId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getBusStandFileByAttId({
|
||||
attId
|
||||
}).then(res => {
|
||||
if (res.ok) {
|
||||
resolve(res.data)
|
||||
} else {
|
||||
reject()
|
||||
}
|
||||
}).catch(e => {
|
||||
reject(e)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* @description: 获取展示的文件
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user