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, data,
}) })
} }
// 预览文件时调用接口增加访问量
export function addFileAccessCountAPI(data = {}) {
return request({
url: '/screen/document/addLookNum',
method: 'POST',
data,
})
}

View File

@ -127,8 +127,8 @@ export default {
}, },
// change // change
handleTypeIdChange(value) { handleTypeIdChange(value) {
this.addAndEditForm.typeName = this.labelTypeList.find( this.addAndEditForm.typeName = this.dict.type.tags_type.find(
(item) => item.value === value, (item) => item.value == value,
)?.label )?.label
}, },
// //

View File

@ -27,7 +27,10 @@
</div> </div>
<div v-if="showRightSection" class="header-right"> <div v-if="showRightSection" class="header-right">
<div v-if="showSearch" class="search-box"> <div
v-if="showSearch && activeNav !== 'DocCenter'"
class="search-box"
>
<input <input
v-model="internalSearchKeyword" v-model="internalSearchKeyword"
type="text" type="text"
@ -63,7 +66,7 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import {getPermissions} from "../../../utils/auth"; import { getPermissions } from '../../../utils/auth'
export default { export default {
name: 'NavBar', name: 'NavBar',
@ -103,29 +106,31 @@ export default {
// activeNav // activeNav
activeNav() { activeNav() {
// //
const routeName = this.$route.name; const routeName = this.$route.name
const routePath = this.$route.path; const routePath = this.$route.path
// //
if (routeName) { if (routeName) {
const matchedItem = this.navItems.find(item => item.routePath === routeName); const matchedItem = this.navItems.find(
(item) => item.routePath === routeName,
)
if (matchedItem) { if (matchedItem) {
return matchedItem.routePath; return matchedItem.routePath
} }
} }
// //
if (routePath) { if (routePath) {
const matchedItem = this.navItems.find(item => const matchedItem = this.navItems.find((item) =>
routePath.includes(item.routePath.toLowerCase()) routePath.includes(item.routePath.toLowerCase()),
); )
if (matchedItem) { if (matchedItem) {
return matchedItem.routePath; return matchedItem.routePath
} }
} }
// //
return 'ProductCenter'; return 'ProductCenter'
}, },
setting: { setting: {
get() { get() {
@ -169,7 +174,7 @@ export default {
} }
}, },
watch: { watch: {
'$route'() { $route() {
// activeNav // activeNav
}, },
searchKeyword(newVal) { searchKeyword(newVal) {
@ -181,7 +186,7 @@ export default {
internalSearchKeyword(newVal) { internalSearchKeyword(newVal) {
// //
this.$emit('update:searchKeyword', newVal) this.$emit('update:searchKeyword', newVal)
} },
}, },
methods: { methods: {
handleNavClick(item) { handleNavClick(item) {
@ -205,7 +210,6 @@ export default {
// //
this.$message.error('没有后台权限,请联系管理员') this.$message.error('没有后台权限,请联系管理员')
} }
}, },
logout() { logout() {
@ -222,8 +226,7 @@ export default {
: '/index' : '/index'
}) })
}) })
.catch(() => { .catch(() => {})
})
}, },
}, },
} }

View File

@ -107,8 +107,81 @@
{{ item.label }} {{ item.label }}
</el-dropdown-item> </el-dropdown-item>
</template> </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-menu>
</el-dropdown> </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> </div>
</template> </template>
</el-table-column> </el-table-column>
@ -227,6 +300,17 @@
> >
<TagFilter @query="handleTagQuery" @reset="handleTagReset" /> <TagFilter @query="handleTagQuery" @reset="handleTagReset" />
</el-drawer> </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> </div>
</template> </template>
@ -242,10 +326,14 @@ import AddCopy from './tableCom/addCopy.vue'
import TagFilter from './tableCom/tagFilter.vue' import TagFilter from './tableCom/tagFilter.vue'
import EditWord from './tableCom/editWord.vue' import EditWord from './tableCom/editWord.vue'
import { encryptCBCTime } from '@/utils/aes'
import useBase64 from '@/utils/base64Utils.js'
import { import {
getDocCenterRightListAPI, getDocCenterRightListAPI,
deleteDocCenterAPI, deleteDocCenterAPI,
cancelSharePermissionAPI, cancelSharePermissionAPI,
addFileAccessCountAPI,
} from '@/api/publicService/docCenter' } from '@/api/publicService/docCenter'
export default { export default {
name: 'RightTable', name: 'RightTable',
@ -360,37 +448,44 @@ export default {
label: '下载', label: '下载',
click: this.handleBatchDownload_1, click: this.handleBatchDownload_1,
acthType: ['1', null], acthType: ['1', null],
authType: [],
}, },
{ {
label: '移动', label: '移动',
click: this.handleMove_1, click: this.handleMove_1,
acthType: [null], acthType: [null],
authType: [],
}, },
{ {
label: '删除', label: '删除',
click: this.handleDelete_1, click: this.handleDelete_1,
acthType: [null], acthType: [null],
authType: [],
}, },
{ {
label: '共享', label: '共享',
click: this.handleShare_1, click: this.handleShare_1,
acthType: [null], acthType: [null],
authType: [],
}, },
{ {
label: '重命名', label: '重命名',
click: this.handleEdit_1, click: this.handleEdit_1,
acthType: [null], acthType: [null],
authType: [],
}, },
{ {
label: '添加副本', label: '添加副本',
click: this.handleAddCopy_1, click: this.handleAddCopy_1,
acthType: [null], acthType: [null],
authType: [],
}, },
{ // {
label: '取消共享', // label: '',
click: this.handleCancelShare_1, // click: this.handleCancelShare_1,
acthType: ['1', '2'], // acthType: ['1', '2'],
}, // authType: ['myShare'],
// },
], ],
dialogConfig: { dialogConfig: {
@ -400,6 +495,14 @@ export default {
outerComponent: null, outerComponent: null,
outerComponentProps: {}, outerComponentProps: {},
}, },
dialogConfig1: {
outerTitle: '预览',
outerVisible: false,
outerWidth: '90%',
minHeight: '90vh',
maxHeight: '90vh',
},
// //
selectedFilesForDownload: [], selectedFilesForDownload: [],
@ -414,6 +517,9 @@ export default {
// //
selectedFiles: [], selectedFiles: [],
lookFile: 'http://192.168.0.14:8012/onlinePreview?url=',
filePreviewPath: 'http://218.21.27.6:18013/onlinePreview?url=',
iframeUrl: '',
} }
}, },
watch: { watch: {
@ -646,6 +752,9 @@ export default {
}, },
`文档_${new Date().getTime()}.zip`, `文档_${new Date().getTime()}.zip`,
) )
//
this.getTableList()
}, },
// //
@ -657,6 +766,9 @@ export default {
}, },
`文档_${new Date().getTime()}.zip`, `文档_${new Date().getTime()}.zip`,
) )
//
this.getTableList()
}, },
// //
@ -673,9 +785,11 @@ export default {
this.dialogConfig.outerTitle = '共享' this.dialogConfig.outerTitle = '共享'
this.dialogConfig.outerVisible = true this.dialogConfig.outerVisible = true
this.dialogConfig.outerComponent = 'SharePermissionForm' this.dialogConfig.outerComponent = 'SharePermissionForm'
this.dialogConfig.outerComponentProps = { // this.dialogConfig.outerComponentProps = {
selectedFiles: this.selectedFilesForShare, // selectedFiles: this.selectedFilesForShare,
} // }
this.selectedFiles = this.selectedFilesForShare
}, },
handleShare_1(row) { handleShare_1(row) {
@ -688,9 +802,11 @@ export default {
this.dialogConfig.outerTitle = '共享' this.dialogConfig.outerTitle = '共享'
this.dialogConfig.outerVisible = true this.dialogConfig.outerVisible = true
this.dialogConfig.outerComponent = 'SharePermissionForm' this.dialogConfig.outerComponent = 'SharePermissionForm'
this.dialogConfig.outerComponentProps = { // this.dialogConfig.outerComponentProps = {
selectedFiles: this.selectedFilesForShare, // selectedFiles: this.selectedFilesForShare,
} // }
this.selectedFiles = this.selectedFilesForShare
}, },
// //
@ -864,6 +980,73 @@ export default {
// console.log('', command) // console.log('', command)
command.item.click(command.row) 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> </script>

View File

@ -7,7 +7,12 @@
:rules="addWordFormRules" :rules="addWordFormRules"
> >
<el-form-item label="文档夹名称" prop="folderName"> <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-item>
</el-form> </el-form>
</div> </div>

View File

@ -44,10 +44,11 @@
:on-change="handleFileChange" :on-change="handleFileChange"
:on-remove="handleRemove" :on-remove="handleRemove"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:limit="10" :limit="5"
multiple multiple
drag drag
class="upload-dragger" class="upload-dragger"
:before-upload="handleBeforeUpload"
> >
<div class="upload-content"> <div class="upload-content">
<i class="el-icon-upload upload-icon"></i> <i class="el-icon-upload upload-icon"></i>
@ -56,7 +57,8 @@
<em class="upload-link">点击上传</em> <em class="upload-link">点击上传</em>
</div> </div>
<div class="upload-tip"> <div class="upload-tip">
按住Ctrl可同时多选,支持上传rar/zip格式文件,单个文件不能超过500kb <!-- 按住Ctrl可同时多选,支持上传rar/zip格式文件,单个文件不能超过500kb -->
按住Ctrl可同时多选,单个文件不能超过 10 MB
</div> </div>
<div class="upload-warning"> <div class="upload-warning">
严禁上传包含色情暴力反动等相关违法信息的文件 严禁上传包含色情暴力反动等相关违法信息的文件
@ -159,19 +161,19 @@ export default {
const fileName = rawFile.name || file.name || '' const fileName = rawFile.name || file.name || ''
const fileSize = rawFile.size || file.size || 0 const fileSize = rawFile.size || file.size || 0
// // ()
const allowedTypes = ['rar', 'zip'] // const allowedTypes = ['rar', 'zip']
const fileExtension = fileName.split('.').pop().toLowerCase() // const fileExtension = fileName.split('.').pop().toLowerCase()
if (!allowedTypes.includes(fileExtension)) { // if (!allowedTypes.includes(fileExtension)) {
if (showMessage) { // if (showMessage) {
this.$modal.msgError('只支持上传rar/zip格式文件!') // this.$modal.msgError('rar/zip!')
} // }
return false // return false
} // }
// (500kb = 0.5MB) // (10MB)
const maxSize = 0.5 const maxSize = 10
const isLtMaxSize = fileSize / 1024 / 1024 < maxSize const isLtMaxSize = fileSize / 1024 / 1024 < maxSize
if (!isLtMaxSize) { if (!isLtMaxSize) {
@ -189,18 +191,121 @@ export default {
return false 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 return true
}, },
// //
handleFileChange(file, fileList) { handleFileChange(file, fileList) {
// if (!this.validateFile(file, { showMessage: true })) { if (!this.validateFile(file, { showMessage: true })) {
// this.fileList = fileList.filter((item) => item.uid !== file.uid) this.fileList = fileList.filter((item) => item.uid !== file.uid)
// return return
// } }
this.fileList = fileList 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) { handleRemove(file, fileList) {
this.fileList = fileList this.fileList = fileList