From afd8f420bad188170702246fb48e3d269a3b8d64 Mon Sep 17 00:00:00 2001
From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com>
Date: Fri, 21 Nov 2025 12:05:47 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/publicService/docCenter.js | 9 +
.../docs-tags/components/addAndEditForm.vue | 4 +-
src/views/publicService/components/navBar.vue | 611 +++++++++---------
.../docCenter/components/rightTable.vue | 205 +++++-
.../docCenter/components/tableCom/addWord.vue | 7 +-
.../docCenter/components/tableCom/upload.vue | 139 +++-
6 files changed, 640 insertions(+), 335 deletions(-)
diff --git a/src/api/publicService/docCenter.js b/src/api/publicService/docCenter.js
index 24cf6ac..8e92d3c 100644
--- a/src/api/publicService/docCenter.js
+++ b/src/api/publicService/docCenter.js
@@ -141,3 +141,12 @@ export function getMoveAndAddCopyTreeAPI(data = {}) {
data,
})
}
+
+// 预览文件时调用接口增加访问量
+export function addFileAccessCountAPI(data = {}) {
+ return request({
+ url: '/screen/document/addLookNum',
+ method: 'POST',
+ data,
+ })
+}
diff --git a/src/views/dataManage/docs-tags/components/addAndEditForm.vue b/src/views/dataManage/docs-tags/components/addAndEditForm.vue
index a1c7e36..158dac4 100644
--- a/src/views/dataManage/docs-tags/components/addAndEditForm.vue
+++ b/src/views/dataManage/docs-tags/components/addAndEditForm.vue
@@ -127,8 +127,8 @@ export default {
},
// 标签类型change事件
handleTypeIdChange(value) {
- this.addAndEditForm.typeName = this.labelTypeList.find(
- (item) => item.value === value,
+ this.addAndEditForm.typeName = this.dict.type.tags_type.find(
+ (item) => item.value == value,
)?.label
},
// 获取标签类型下拉
diff --git a/src/views/publicService/components/navBar.vue b/src/views/publicService/components/navBar.vue
index 4bf9b83..77e8454 100644
--- a/src/views/publicService/components/navBar.vue
+++ b/src/views/publicService/components/navBar.vue
@@ -1,397 +1,400 @@
-
@@ -242,10 +326,14 @@ import AddCopy from './tableCom/addCopy.vue'
import TagFilter from './tableCom/tagFilter.vue'
import EditWord from './tableCom/editWord.vue'
+import { encryptCBCTime } from '@/utils/aes'
+import useBase64 from '@/utils/base64Utils.js'
+
import {
getDocCenterRightListAPI,
deleteDocCenterAPI,
cancelSharePermissionAPI,
+ addFileAccessCountAPI,
} from '@/api/publicService/docCenter'
export default {
name: 'RightTable',
@@ -360,37 +448,44 @@ export default {
label: '下载',
click: this.handleBatchDownload_1,
acthType: ['1', null],
+ authType: [],
},
{
label: '移动',
click: this.handleMove_1,
acthType: [null],
+ authType: [],
},
{
label: '删除',
click: this.handleDelete_1,
acthType: [null],
+ authType: [],
},
{
label: '共享',
click: this.handleShare_1,
acthType: [null],
+ authType: [],
},
{
label: '重命名',
click: this.handleEdit_1,
acthType: [null],
+ authType: [],
},
{
label: '添加副本',
click: this.handleAddCopy_1,
acthType: [null],
+ authType: [],
},
- {
- label: '取消共享',
- click: this.handleCancelShare_1,
- acthType: ['1', '2'],
- },
+ // {
+ // label: '取消共享',
+ // click: this.handleCancelShare_1,
+ // acthType: ['1', '2'],
+ // authType: ['myShare'],
+ // },
],
dialogConfig: {
@@ -400,6 +495,14 @@ export default {
outerComponent: null,
outerComponentProps: {},
},
+
+ dialogConfig1: {
+ outerTitle: '预览',
+ outerVisible: false,
+ outerWidth: '90%',
+ minHeight: '90vh',
+ maxHeight: '90vh',
+ },
// 用于下载的文件列表
selectedFilesForDownload: [],
@@ -414,6 +517,9 @@ export default {
// 用于移动的文件列表
selectedFiles: [],
+ lookFile: 'http://192.168.0.14:8012/onlinePreview?url=',
+ filePreviewPath: 'http://218.21.27.6:18013/onlinePreview?url=',
+ iframeUrl: '',
}
},
watch: {
@@ -646,6 +752,9 @@ export default {
},
`文档_${new Date().getTime()}.zip`,
)
+
+ // 刷新列表
+ this.getTableList()
},
// 下载
@@ -657,6 +766,9 @@ export default {
},
`文档_${new Date().getTime()}.zip`,
)
+
+ // 刷新列表
+ this.getTableList()
},
// 共享
@@ -673,9 +785,11 @@ export default {
this.dialogConfig.outerTitle = '共享'
this.dialogConfig.outerVisible = true
this.dialogConfig.outerComponent = 'SharePermissionForm'
- this.dialogConfig.outerComponentProps = {
- selectedFiles: this.selectedFilesForShare,
- }
+ // this.dialogConfig.outerComponentProps = {
+ // selectedFiles: this.selectedFilesForShare,
+ // }
+
+ this.selectedFiles = this.selectedFilesForShare
},
handleShare_1(row) {
@@ -688,9 +802,11 @@ export default {
this.dialogConfig.outerTitle = '共享'
this.dialogConfig.outerVisible = true
this.dialogConfig.outerComponent = 'SharePermissionForm'
- this.dialogConfig.outerComponentProps = {
- selectedFiles: this.selectedFilesForShare,
- }
+ // this.dialogConfig.outerComponentProps = {
+ // selectedFiles: this.selectedFilesForShare,
+ // }
+
+ this.selectedFiles = this.selectedFilesForShare
},
// 重命名
@@ -864,6 +980,73 @@ export default {
// console.log('下拉菜单点击', command)
command.item.click(command.row)
},
+
+ onHandleCommand(command) {
+ if (command.type === 1) {
+ this.handleCancelShare_1(command.row)
+ } else if (command.type === 2) {
+ this.handleBatchDownload_1(command.row)
+ }
+ },
+
+ // 预览
+ handlePreview(row) {
+ // console.log('预览', row)
+
+ addFileAccessCountAPI({ id: row.id })
+ .then((res) => {})
+ .finally(() => {
+ this.previewDocs({
+ originalName: row.name,
+ url: row.filePath,
+ })
+ // 刷新列表
+ this.getTableList()
+ })
+ },
+
+ // 预览文档
+ previewDocs(item) {
+ const { originalName, url } = item
+ let filePreviewPath = ''
+ let time = encryptCBCTime(Math.floor(Date.now()).toString())
+ // if (originalName.split('.')[1].toLowerCase() === 'pdf') {
+ // filePreviewPath = filePath.includes('http')
+ // ? filePath
+ // : `${this.lookFile}/${filePath}`
+ // } else {
+ // const encodedPath = filePath.includes('http')
+ // ? encodeURIComponent(useBase64.encode64(`${filePath}`))
+ // : encodeURIComponent(
+ // useBase64.encode64(`${this.lookFile}/${filePath}`),
+ // )
+ // filePreviewPath = `${this.filePreviewPath}${encodedPath}&token=${time}`
+ // }
+
+ const encodedPath = url.includes('http')
+ ? encodeURIComponent(useBase64.encode64(`${url}`))
+ : encodeURIComponent(
+ useBase64.encode64(`${this.lookFile}/${url}`),
+ )
+ filePreviewPath = `${this.lookFile}${encodedPath}&token=${time}`
+
+ const isEdgeOrOther = /Edg|Chrome|Firefox|Safari/.test(
+ navigator.userAgent,
+ )
+ if (isEdgeOrOther) {
+ const url = new URL(filePreviewPath)
+ url.searchParams.append('preventDownload', 'true')
+ filePreviewPath = url.toString()
+ }
+
+ this.iframeUrl = filePreviewPath
+ console.log('this.iframeUrl', this.iframeUrl)
+ this.dialogConfig1.outerVisible = true
+ },
+
+ handleCloseDialogOuter1() {
+ this.dialogConfig1.outerVisible = false
+ },
},
}
diff --git a/src/views/publicService/docCenter/components/tableCom/addWord.vue b/src/views/publicService/docCenter/components/tableCom/addWord.vue
index 40001fd..b6ae51d 100644
--- a/src/views/publicService/docCenter/components/tableCom/addWord.vue
+++ b/src/views/publicService/docCenter/components/tableCom/addWord.vue
@@ -7,7 +7,12 @@
:rules="addWordFormRules"
>
-
+
diff --git a/src/views/publicService/docCenter/components/tableCom/upload.vue b/src/views/publicService/docCenter/components/tableCom/upload.vue
index 5a70e59..95812ac 100644
--- a/src/views/publicService/docCenter/components/tableCom/upload.vue
+++ b/src/views/publicService/docCenter/components/tableCom/upload.vue
@@ -44,10 +44,11 @@
:on-change="handleFileChange"
:on-remove="handleRemove"
:on-exceed="handleExceed"
- :limit="10"
+ :limit="5"
multiple
drag
class="upload-dragger"
+ :before-upload="handleBeforeUpload"
>
@@ -56,7 +57,8 @@
点击上传
- 按住Ctrl可同时多选,支持上传rar/zip格式文件,单个文件不能超过500kb
+
+ 按住Ctrl可同时多选,单个文件不能超过 10 MB
严禁上传包含色情、暴力、反动等相关违法信息的文件。
@@ -159,19 +161,19 @@ export default {
const fileName = rawFile.name || file.name || ''
const fileSize = rawFile.size || file.size || 0
- // 检查文件格式
- const allowedTypes = ['rar', 'zip']
- const fileExtension = fileName.split('.').pop().toLowerCase()
+ // 检查文件格式 (暂时不限制文件格式)
+ // const allowedTypes = ['rar', 'zip']
+ // const fileExtension = fileName.split('.').pop().toLowerCase()
- if (!allowedTypes.includes(fileExtension)) {
- if (showMessage) {
- this.$modal.msgError('只支持上传rar/zip格式文件!')
- }
- return false
- }
+ // if (!allowedTypes.includes(fileExtension)) {
+ // if (showMessage) {
+ // this.$modal.msgError('只支持上传rar/zip格式文件!')
+ // }
+ // return false
+ // }
- // 检查文件大小 (500kb = 0.5MB)
- const maxSize = 0.5
+ // 检查文件大小 (10MB)
+ const maxSize = 10
const isLtMaxSize = fileSize / 1024 / 1024 < maxSize
if (!isLtMaxSize) {
@@ -189,18 +191,121 @@ export default {
return false
}
+ // 检查文件名称不能超过 50 个字符
+ if (fileName.length > 50) {
+ if (showMessage) {
+ this.$modal.msgError('文件名不能超过 50 个字符!')
+ }
+ return false
+ }
+
+ // 检查文件名称不能包含特殊字符
+ if (fileName.includes(' ')) {
+ if (showMessage) {
+ this.$modal.msgError('文件名不能包含空格!')
+ }
+ return false
+ }
+
+ // 替换文件路径中的#号
+
+ // 替换文件路径中的#号
+ const newFileName = file.name.replace(/#/g, '@')
+ const newFile = new File([file], newFileName, { type: file.type })
+
+ // 修改原始文件的name属性
+ Object.defineProperty(file, 'name', {
+ value: newFileName,
+ })
+
return true
},
// 文件变化
handleFileChange(file, fileList) {
- // if (!this.validateFile(file, { showMessage: true })) {
- // this.fileList = fileList.filter((item) => item.uid !== file.uid)
- // return
- // }
+ if (!this.validateFile(file, { showMessage: true })) {
+ this.fileList = fileList.filter((item) => item.uid !== file.uid)
+ return
+ }
this.fileList = fileList
},
+ // 上传前
+ handleBeforeUpload(file) {
+ // return this.validateFile(file, { showMessage: true })
+ const showMessage = true
+
+ const rawFile = file?.raw || file
+ if (!rawFile) {
+ if (showMessage) {
+ this.$modal.msgError('文件信息异常,请重新选择文件!')
+ }
+ return false
+ }
+
+ const fileName = rawFile.name || file.name || ''
+ const fileSize = rawFile.size || file.size || 0
+
+ console.log(fileName, fileSize, 'fileName, fileSize')
+
+ // 检查文件格式 (暂时不限制文件格式)
+ // const allowedTypes = ['rar', 'zip']
+ // const fileExtension = fileName.split('.').pop().toLowerCase()
+
+ // if (!allowedTypes.includes(fileExtension)) {
+ // if (showMessage) {
+ // this.$modal.msgError('只支持上传rar/zip格式文件!')
+ // }
+ // return false
+ // }
+
+ // 检查文件大小 (10MB)
+ const maxSize = 10
+ const isLtMaxSize = fileSize / 1024 / 1024 < maxSize
+
+ if (!isLtMaxSize) {
+ if (showMessage) {
+ this.$modal.msgError(`文件大小不能超过 ${maxSize}MB!`)
+ }
+ return false
+ }
+
+ // 检查文件名是否包含特殊字符
+ if (fileName.includes(',')) {
+ if (showMessage) {
+ this.$modal.msgError('文件名不能包含英文逗号!')
+ }
+ return false
+ }
+
+ // 检查文件名称不能超过 50 个字符
+ if (fileName.length > 50) {
+ if (showMessage) {
+ this.$modal.msgError('文件名不能超过 50 个字符!')
+ }
+ return false
+ }
+
+ // 检查文件名称不能包含特殊字符
+ if (fileName.includes(' ')) {
+ if (showMessage) {
+ this.$modal.msgError('文件名不能包含空格!')
+ }
+ return false
+ }
+
+ // 替换文件路径中的#号
+
+ // 替换文件路径中的#号
+ const newFileName = file.name.replace(/#/g, '@')
+ const newFile = new File([file], newFileName, { type: file.type })
+
+ // 修改原始文件的name属性
+ Object.defineProperty(file, 'name', {
+ value: newFileName,
+ })
+ },
+
// 移除文件
handleRemove(file, fileList) {
this.fileList = fileList