提交 abb709f1 authored 作者: 龙菲's avatar 龙菲

统一处理打开文件的问题

上级 f4527808
......@@ -12,3 +12,7 @@ VUE_APP_BASE_QW_API = '/api'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true
# 服务器(涉密机)地址
VUE_APP_BASE_HOST = 'http://192.168.1.5:5432/basePdfFiles/'
\ No newline at end of file
......@@ -8,4 +8,7 @@ ENV = 'production'
VUE_APP_BASE_API = '/prod-api'
# 奇文网盘
VUE_APP_BASE_QW_API = '/api'
\ No newline at end of file
VUE_APP_BASE_QW_API = '/api'
# 服务器(涉密机)地址
VUE_APP_BASE_HOST = 'http://192.168.1.5:5432/basePdfFiles/'
\ No newline at end of file
......@@ -10,4 +10,7 @@ ENV = 'staging'
VUE_APP_BASE_API = '/stage-api'
# 奇文网盘
VUE_APP_BASE_QW_API = '/api'
\ No newline at end of file
VUE_APP_BASE_QW_API = '/api'
# 服务器(涉密机)地址
VUE_APP_BASE_HOST = 'http://192.168.1.5:5432/basePdfFiles/'
\ No newline at end of file
......@@ -41,13 +41,7 @@
:src="$file.setFileImg(scope.row)"
:title="`${scope.row.isDir ? '' : '点击预览'}`"
style="width: 30px; max-height: 30px; cursor: pointer"
@click="
$file.handleFileNameClickNew(
scope.row,
scope.$index,
sortedFileList
)
"
@click="$file.handleFileNameClickNew(scope.row, $fileKeys.qiwen)"
v-else
/>
</template>
......@@ -64,13 +58,7 @@
</template>
<template slot-scope="scope">
<span
@click="
$file.handleFileNameClickNew(
scope.row,
scope.$index,
sortedFileList
)
"
@click="$file.handleFileNameClickNew(scope.row, $fileKeys.qiwen)"
>
<span
class="file-name"
......
......@@ -11,7 +11,7 @@
>
<li
class="right-menu-item"
@click="$file.handleFileNameClickNew(selectedFile, 0, [selectedFile])"
@click="$file.handleFileNameClickNew(selectedFile, $fileKeys.qiwen)"
v-if="seeBtnShow"
>
<i class="el-icon-view"></i> 查看
......@@ -555,7 +555,7 @@ export default {
* @param {object} fileInfo 文件信息
*/
handleClickFileEdit(fileInfo) {
this.$file.handleFileNameClickNew(fileInfo);
this.$file.handleFileNameClickNew(fileInfo,this.$fileKeys.qiwen);
},
/**
* 文件详情按钮点击事件
......
......@@ -22,7 +22,7 @@
:title="$file.getFileNameComplete(item)"
:style="`width: ${gridSize + 40}px; `"
:class="item.userFileId === selectedFile.userFileId ? 'active' : ''"
@click="$file.handleFileNameClickNew(item, index, fileListSorted)"
@click="$file.handleFileNameClickNew(item, $fileKeys.qiwen)"
@contextmenu.prevent="handleContextMenu(item, index, $event)"
>
<video
......
// 由于奇文框架、kbase框架和政研室原系统的字段名不一致,导致在预览文件时使用的key不一致
// 此文件用于统一记录文件打开文件的各个key名
const fileKeys = {
qiwen: {
extendNameKey: 'extendName',
fileIdKey: 'fileId',
urlKey: 'fileUrl',
},
kbase: {
extendNameKey: '',
fileIdKey: 'id',
urlKey: 'weburl',
},
zys: {
extendNameKey: 'suffix',
fileIdKey: 'id',
urlKey: 'url',
},
zysDoc: {
extendNameKey: 'docSType',
fileIdKey: 'docId',
urlKey: '',
},
zysHome: {
extendNameKey: 'suffix',
fileIdKey: 'id',
urlKey: 'downloadUrl',
},
zysShare: {
extendNameKey: 'extendName',
fileIdKey: 'fileId',
urlKey: 'downloadUrl',
},
zysNote:{
extendNameKey: 'docSType',
fileIdKey: 'docId',
urlKey: 'downloadUrl',
}
}
export default fileKeys
\ No newline at end of file
......@@ -234,11 +234,11 @@ const fileFunction = {
* 文件预览——word使用wps预览,pdf使用pdf组件进行预览
* @description 若当前点击的为文件夹,则进入文件夹内部;若是文件,则进行相应的预览。
* @param {object} row 文件信息
* @param {number} currentIndex 当前文件索引
* @param {array} fileList 文件列表
* @param {string} extendNameKey 后缀名key,用哪一个字段进行后缀名的判断
* @param {string} urlKey 链接key,用哪一个字段进行url的打开
* @param {string} fileIdKey 文件id key,用哪个字段记录文件id
*/
handleFileNameClickNew(row, currentIndex = 0, fileList = []) {
// console.log(11, row);
handleFileNameClickNew(row, { extendNameKey, urlKey, fileIdKey }) {
// 若是文件夹则进入该文件夹
if (row.isDir) {
router.push({
......@@ -252,18 +252,33 @@ const fileFunction = {
const WORD = ['doc', 'docx']
const PDF = ['pdf']
// 若当前点击项是word
let extendName = row.extendName || row.suffix || row.showType || row.docSType
// console.log('extendName', extendName);
const { fileId, userId, id, docId, fileUrl } = row
let extendName = row[extendNameKey]
if (!extendName) {
Message.error('预览失败!无法判断文件类型:文件类型' + extendName)
return
}
extendName = extendName.toLowerCase()
const fileId = row[fileIdKey] || row.fileId
let pdfUrl = row[urlKey] || row.url//有部分url未加前缀,但是浏览器会自动寻址加到当前的主机
if (WORD.includes(extendName.toLowerCase())) {
if (!pdfUrl.includes('http')) {
pdfUrl = process.env.VUE_APP_BASE_HOST + pdfUrl
}
// console.log('pdfUrl', pdfUrl);
// return
const { userId } = row
if (WORD.includes(extendName)) {
let flag = false
if (!fileId) {
Message.error('预览失败!文件ID失效:' + fileId)
return
}
// 根据当前文件的作者的userId进行判断,和本人一致则是可编辑
if (store.getters.userInfo.userId == userId) {
flag = true
}
const params = {
fileId: fileId || id,
fileId,
flag
}
getViewUrlDbPath(params).then(res => {
......@@ -282,23 +297,19 @@ const fileFunction = {
}
})
return false
// 实际实现逻辑---end
}
else if (PDF.includes(extendName.toLowerCase())) {
// console.log(666, 'pdf');
// 若当前点击项是pdf
if (!fileUrl) {
Message.error('预览失败!请检查该文件路径是否正确。文件路径:' + fileUrl)
else if (PDF.includes(extendName)) {
if (!pdfUrl) {
Message.error('预览失败!请检查该文件路径是否正确。文件路径:' + pdfUrl)
return
}
let resolve = router.resolve({
path: '/pdfReader',
query: {
fileId,
url: fileUrl
url: pdfUrl
}
})
// console.log(333, row);
window.open(resolve.href, '_blank')
return false
}
......
......@@ -49,7 +49,8 @@ import DictData from '@/components/DictData'
// 引入右键菜单组件
import VueContextMenu from 'vue-contextmenu'
// 引入文件keys
import fileKeys from '@/constants/fileKey'
// 全局方法挂载
Vue.prototype.getDicts = getDicts
......@@ -70,6 +71,11 @@ for (let key in globalFunction) {
// 全局配置挂载-奇文
Vue.prototype.$qwConfig = qwConfig
// 全局挂载文件keys
Vue.prototype.$fileKeys = fileKeys
// 全局组件挂载
Vue.component('DictTag', DictTag)
Vue.component('Pagination', Pagination)
......
......@@ -145,7 +145,6 @@ export default {
// 上传文件
handleUploadFile() {
const uploadFileParams = { filePath: "/我的创作", isDir: 0 }; // 上传文件组件参数
// debugger;
this.$openBox.uploadFile({
params: uploadFileParams,
uploadWay: 0, //0-文件上传 1-文件夹上传 2-粘贴图片或拖拽上传
......@@ -168,7 +167,7 @@ export default {
// 点击表格某一行
handleClickName(row) {
console.log("row", row);
this.$file.handleFileNameClickNew(row);
this.$file.handleFileNameClickNew(row,this.$fileKeys.zysHome);
},
handleToCreate() {
this.$router.push("/mine/myCreate");
......
......@@ -409,7 +409,7 @@ export default {
},
// 点击打开文件
handleOpenFile(file) {
this.$file.handleFileNameClickNew(file);
this.$file.handleFileNameClickNew(file,this.$fileKeys.zysShare);
},
},
};
......
......@@ -31,7 +31,7 @@ export default {
this.$message.success("已复制到剪贴板");
break;
case "view":
this.$file.handleFileNameClickNew(item);
this.$file.handleFileNameClickNew(item,this.$fileKeys.zysNote);
break;
case "edit":
this.handleOpenEditNote(item);
......
......@@ -334,7 +334,7 @@ export default {
},
// 点击打开文件
handleOpenFile(file) {
this.$file.handleFileNameClickNew(file);
this.$file.handleFileNameClickNew(file,this.$fileKeys.zysShare);
},
},
};
......
......@@ -283,10 +283,9 @@ export default {
},
// 点击更多的下拉框
handleClickDropdown(type, item) {
console.log(type, item);
switch (type) {
case "view":
this.$file.handleFileNameClickNew(item);
this.$file.handleFileNameClickNew(item,this.$fileKeys.zysNote);
break;
case "edit":
this.handleOpenAddUpdateDialog(item);
......
......@@ -8,6 +8,7 @@
<div :class="{ 'reader-container': true, 'show-panel': panelVisible }">
<PDFAnnot
:url="url"
v-if="url"
ref="pdfRef"
@copy="copyText"
@addNote="addNote"
......@@ -60,8 +61,8 @@ export default {
},
data() {
return {
// url: "http://192.168.1.5:5432/files/upload/20230919/1008502f32c92041fee8d248981770d1.pdf",
url: "/output.pdf",
// url: "http://localhost:99/basePdfFiles/upload/20231007/1008502f32c92041fee8d248981770d1.pdf",
// url: "/output.pdf",
// 新增笔记需要的参数
form: {
docId: "", //文档Id
......@@ -78,12 +79,11 @@ export default {
panelVisible: false, //笔记的窗口
noteList: [],
pdfAnnotInstance: null,
// url: "",
url: "",
};
},
mounted() {
const { fileId, url } = this.$route.query;
console.log(222, url);
this.form.docId = fileId;
this.url = url;
},
......
......@@ -53,13 +53,13 @@
>
<template slot-scope="scope">
<div class="fileName">
<el-link @click="handleOpenFile(scope.row)">
<!-- <el-link @click="handleOpenFile(scope.row)"> -->
<!-- <img
:src="$file.setFileImg(scope.row, 'showType')"
style="width: 20px; height: 20px; margin-right: 4px"
/> -->
{{ scope.row.name }}
</el-link>
<!-- </el-link> -->
</div>
</template>
</el-table-column>
......@@ -210,7 +210,7 @@ export default {
// 点击打开文件
handleOpenFile(file) {
this.$file.handleFileNameClickNew(file);
this.$file.handleFileNameClickNew(file,this.$fileKeys.kbase);
},
// 获取下载地址
getDownloadFilePath(file) {
......
......@@ -178,7 +178,7 @@ export default {
// 点击打开文件
handleOpenFile(file) {
this.$file.handleFileNameClickNew(file);
this.$file.handleFileNameClickNew(file,this.$fileKeys.qiwen);
},
async loadData() {
......
......@@ -239,7 +239,7 @@ export default {
},
// 点击打开文件
handleOpenFile(file) {
this.$file.handleFileNameClickNew(file);
this.$file.handleFileNameClickNew(file, this.$fileKeys.zysShare);
},
// 批量下载
handleMultiDownload() {
......@@ -263,7 +263,7 @@ export default {
extendName,
filePath,
fileName,
isTemplate:false,
isTemplate: false,
templateId: "",
};
newfile(params)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论