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

统一处理打开文件的问题

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