This commit is contained in:
BianLzhaoMin 2025-11-21 12:05:47 +08:00
parent c5600777bc
commit afd8f420ba
6 changed files with 640 additions and 335 deletions

View File

@ -141,3 +141,12 @@ export function getMoveAndAddCopyTreeAPI(data = {}) {
data,
})
}
// 预览文件时调用接口增加访问量
export function addFileAccessCountAPI(data = {}) {
return request({
url: '/screen/document/addLookNum',
method: 'POST',
data,
})
}

View File

@ -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
},
//

View File

@ -21,13 +21,16 @@
@click="handleNavClick(item)"
:class="{ active: activeNav === item.routePath }"
>
<img :src="item.icon" :alt="item.label" class="nav-icon"/>
<img :src="item.icon" :alt="item.label" class="nav-icon" />
<span class="nav-text">{{ item.label }}</span>
</div>
</div>
<div v-if="showRightSection" class="header-right">
<div v-if="showSearch" class="search-box">
<div
v-if="showSearch && activeNav !== 'DocCenter'"
class="search-box"
>
<input
v-model="internalSearchKeyword"
type="text"
@ -46,7 +49,7 @@
class="avatar-container right-menu-item hover-effect"
>
<div class="avatar-wrapper">
<img :src="avatar" class="user-avatar"/>
<img :src="avatar" class="user-avatar" />
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="handleLogoClick">
@ -62,8 +65,8 @@
</template>
<script>
import {mapGetters} from 'vuex'
import {getPermissions} from "../../../utils/auth";
import { mapGetters } from 'vuex'
import { getPermissions } from '../../../utils/auth'
export default {
name: 'NavBar',
@ -103,29 +106,31 @@ export default {
// activeNav
activeNav() {
//
const routeName = this.$route.name;
const routePath = this.$route.path;
const routeName = this.$route.name
const routePath = this.$route.path
//
if (routeName) {
const matchedItem = this.navItems.find(item => item.routePath === routeName);
const matchedItem = this.navItems.find(
(item) => item.routePath === routeName,
)
if (matchedItem) {
return matchedItem.routePath;
return matchedItem.routePath
}
}
//
if (routePath) {
const matchedItem = this.navItems.find(item =>
routePath.includes(item.routePath.toLowerCase())
);
const matchedItem = this.navItems.find((item) =>
routePath.includes(item.routePath.toLowerCase()),
)
if (matchedItem) {
return matchedItem.routePath;
return matchedItem.routePath
}
}
//
return 'ProductCenter';
return 'ProductCenter'
},
setting: {
get() {
@ -169,7 +174,7 @@ export default {
}
},
watch: {
'$route'() {
$route() {
// activeNav
},
searchKeyword(newVal) {
@ -181,7 +186,7 @@ export default {
internalSearchKeyword(newVal) {
//
this.$emit('update:searchKeyword', newVal)
}
},
},
methods: {
handleNavClick(item) {
@ -205,7 +210,6 @@ export default {
//
this.$message.error('没有后台权限,请联系管理员')
}
},
logout() {
@ -222,8 +226,7 @@ export default {
: '/index'
})
})
.catch(() => {
})
.catch(() => {})
},
},
}

View File

@ -107,8 +107,81 @@
{{ item.label }}
</el-dropdown-item>
</template>
<el-dropdown-item
:command="{
row: scope.row,
item: {
label: '取消共享',
click: handleCancelShare_1,
},
}"
v-if="
['myShare'].includes(authType) &&
['1', '2'].includes(scope.row.auth)
"
>
取消共享
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-dropdown
trigger="click"
@command="onHandleCommand"
v-if="
scope.row.fileType == 1 &&
['myShare'].includes(authType) &&
['1', '2'].includes(scope.row.auth)
"
>
<span class="el-dropdown-link">
<i
class="el-icon-setting el-icon--right"
style="font-size: 18px"
>
</i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
:command="{
row: scope.row,
type: 1,
}"
v-if="
['myShare'].includes(authType) &&
['1', '2'].includes(scope.row.auth)
"
>
取消共享
</el-dropdown-item>
<!-- <el-dropdown-item
:command="{
row: scope.row,
type: 2,
}"
v-if="
['myShare'].includes(authType) &&
['1', '2'].includes(scope.row.auth)
"
>
下载
</el-dropdown-item> -->
</el-dropdown-menu>
</el-dropdown>
<!-- 增加一个文件预览按钮 -->
<el-button
type="text"
size="mini"
icon="el-icon-view"
style="margin-left: 10px"
v-if="scope.row.fileType == 1"
@click="handlePreview(scope.row)"
>
预览
</el-button>
</div>
</template>
</el-table-column>
@ -227,6 +300,17 @@
>
<TagFilter @query="handleTagQuery" @reset="handleTagReset" />
</el-drawer>
<DialogModel
:dialogConfig="dialogConfig1"
@closeDialogOuter="handleCloseDialogOuter1"
>
<template #outerContent>
<div class="preview-docs" style="height: 75vh">
<iframe :src="iframeUrl" width="100%" height="100%" />
</div>
</template>
</DialogModel>
</div>
</template>
@ -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
},
},
}
</script>

View File

@ -7,7 +7,12 @@
:rules="addWordFormRules"
>
<el-form-item label="文档夹名称" prop="folderName">
<el-input v-model="addWordForm.folderName" />
<el-input
clearable
maxlength="50"
show-word-limit
v-model.trim="addWordForm.folderName"
/>
</el-form-item>
</el-form>
</div>

View File

@ -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"
>
<div class="upload-content">
<i class="el-icon-upload upload-icon"></i>
@ -56,7 +57,8 @@
<em class="upload-link">点击上传</em>
</div>
<div class="upload-tip">
按住Ctrl可同时多选,支持上传rar/zip格式文件,单个文件不能超过500kb
<!-- 按住Ctrl可同时多选,支持上传rar/zip格式文件,单个文件不能超过500kb -->
按住Ctrl可同时多选,单个文件不能超过 10 MB
</div>
<div class="upload-warning">
严禁上传包含色情暴力反动等相关违法信息的文件
@ -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