From 0af0844a94d0b515456195115662687dcd676778 Mon Sep 17 00:00:00 2001 From: xuhuajiao <13476289682@163.com> Date: Wed, 28 Jan 2026 17:13:08 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prearchiveLibrary/prearchiveLibrary.js | 10 +- .../managementLibrary/file/index.vue | 28 +++++- .../module/uploadFile/index.vue | 28 +++++- .../collectionLibrary/file/index.vue | 28 +++++- .../module/collectHeader.vue | 14 ++- .../module/uploadFile/index.vue | 28 +++++- src/views/components/category/PreviewForm.vue | 24 +++-- src/views/components/category/preUpload.vue | 17 +++- src/views/prearchiveLibrary/file/index.vue | 96 +++++++++++++------ src/views/prearchiveLibrary/module/detail.vue | 28 +++++- 10 files changed, 246 insertions(+), 55 deletions(-) diff --git a/src/api/prearchiveLibrary/prearchiveLibrary.js b/src/api/prearchiveLibrary/prearchiveLibrary.js index 9de4409..8492621 100644 --- a/src/api/prearchiveLibrary/prearchiveLibrary.js +++ b/src/api/prearchiveLibrary/prearchiveLibrary.js @@ -125,4 +125,12 @@ export function FetchMinioReDocumentBase64ByFileId(params) { }) } -export default { add, prearchEdit, del, FetchInitPreDocument, FetchInitDocumentsViewTable, FetchDoeditDocument, FetchBatchToFile, FetchMergeToFile, FetchMove, FetchArchivesDetails, FetchFileListByDocumentId, FetchArchivesMetadata, FetchReDocumentBase64ByFileId, FetchMinioReDocumentBase64ByFileId } +export function FetchDeleteDocumentFile(data) { + return request({ + url: 'api/re-document/deleteDocumentFile', + method: 'post', + data + }) +} + +export default { add, prearchEdit, del, FetchInitPreDocument, FetchInitDocumentsViewTable, FetchDoeditDocument, FetchBatchToFile, FetchMergeToFile, FetchMove, FetchArchivesDetails, FetchFileListByDocumentId, FetchArchivesMetadata, FetchReDocumentBase64ByFileId, FetchMinioReDocumentBase64ByFileId, FetchDeleteDocumentFile } diff --git a/src/views/archivesManage/managementLibrary/file/index.vue b/src/views/archivesManage/managementLibrary/file/index.vue index 737e92e..397335f 100644 --- a/src/views/archivesManage/managementLibrary/file/index.vue +++ b/src/views/archivesManage/managementLibrary/file/index.vue @@ -159,9 +159,31 @@ export default { }, methods: { getFileSize(fileSize) { - const fileSizeInKB = (fileSize / 1024).toFixed(2) + ' KB' - const fileSizeInB = fileSize + 'B' - return (fileSize / 1024) <= 0.01 ? fileSizeInB : fileSizeInKB + // 1. 先将接口返回的KB值转为数字,处理非数字/空值情况 + const sizeInKB = Number(fileSize) + if (isNaN(sizeInKB) || sizeInKB < 0) { + return '0 KB' // 异常值默认显示0 KB + } + + // 2. 定义单位换算关系(1 MB = 1024 KB,1 GB = 1024 MB) + const KB = 1 + const MB = 1024 * KB + const GB = 1024 * MB + + // 3. 根据大小自动选择单位并格式化 + if (sizeInKB >= GB) { + // 大于等于1GB,显示GB(保留2位小数) + return (sizeInKB / GB).toFixed(2) + ' GB' + } else if (sizeInKB >= MB) { + // 大于等于1MB且小于1GB,显示MB(保留2位小数) + return (sizeInKB / MB).toFixed(2) + ' MB' + } else if (sizeInKB < 1) { + // 不足1KB,统一显示1 KB(保持你之前的需求) + return '1 KB' + } else { + // 1KB到1MB之间,显示KB(保留2位小数) + return sizeInKB + ' KB' + } }, getCommonData(categoryLevel, parentId, type) { this.getViewTable(categoryLevel, parentId, type) diff --git a/src/views/archivesManage/managementLibrary/module/uploadFile/index.vue b/src/views/archivesManage/managementLibrary/module/uploadFile/index.vue index 2bd488d..0b5c21a 100644 --- a/src/views/archivesManage/managementLibrary/module/uploadFile/index.vue +++ b/src/views/archivesManage/managementLibrary/module/uploadFile/index.vue @@ -134,9 +134,31 @@ export default { localStorage.setItem('fileCurrent', JSON.stringify(row)) }, getFileSize(fileSize) { - const fileSizeInKB = (fileSize / 1024).toFixed(2) + ' KB' - const fileSizeInB = fileSize + 'B' - return (fileSize / 1024) <= 0.01 ? fileSizeInB : fileSizeInKB + // 1. 先将接口返回的KB值转为数字,处理非数字/空值情况 + const sizeInKB = Number(fileSize) + if (isNaN(sizeInKB) || sizeInKB < 0) { + return '0 KB' // 异常值默认显示0 KB + } + + // 2. 定义单位换算关系(1 MB = 1024 KB,1 GB = 1024 MB) + const KB = 1 + const MB = 1024 * KB + const GB = 1024 * MB + + // 3. 根据大小自动选择单位并格式化 + if (sizeInKB >= GB) { + // 大于等于1GB,显示GB(保留2位小数) + return (sizeInKB / GB).toFixed(2) + ' GB' + } else if (sizeInKB >= MB) { + // 大于等于1MB且小于1GB,显示MB(保留2位小数) + return (sizeInKB / MB).toFixed(2) + ' MB' + } else if (sizeInKB < 1) { + // 不足1KB,统一显示1 KB(保持你之前的需求) + return '1 KB' + } else { + // 1KB到1MB之间,显示KB(保留2位小数) + return sizeInKB + ' KB' + } }, // 上传list getFileList() { diff --git a/src/views/collectReorganizi/collectionLibrary/file/index.vue b/src/views/collectReorganizi/collectionLibrary/file/index.vue index cc86074..e673d9e 100644 --- a/src/views/collectReorganizi/collectionLibrary/file/index.vue +++ b/src/views/collectReorganizi/collectionLibrary/file/index.vue @@ -192,9 +192,31 @@ export default { } }, getFileSize(fileSize) { - const fileSizeInKB = (fileSize / 1024).toFixed(2) + ' KB' - const fileSizeInB = fileSize + 'B' - return (fileSize / 1024) <= 0.01 ? fileSizeInB : fileSizeInKB + // 1. 先将接口返回的KB值转为数字,处理非数字/空值情况 + const sizeInKB = Number(fileSize) + if (isNaN(sizeInKB) || sizeInKB < 0) { + return '0 KB' // 异常值默认显示0 KB + } + + // 2. 定义单位换算关系(1 MB = 1024 KB,1 GB = 1024 MB) + const KB = 1 + const MB = 1024 * KB + const GB = 1024 * MB + + // 3. 根据大小自动选择单位并格式化 + if (sizeInKB >= GB) { + // 大于等于1GB,显示GB(保留2位小数) + return (sizeInKB / GB).toFixed(2) + ' GB' + } else if (sizeInKB >= MB) { + // 大于等于1MB且小于1GB,显示MB(保留2位小数) + return (sizeInKB / MB).toFixed(2) + ' MB' + } else if (sizeInKB < 1) { + // 不足1KB,统一显示1 KB(保持你之前的需求) + return '1 KB' + } else { + // 1KB到1MB之间,显示KB(保留2位小数) + return sizeInKB + ' KB' + } }, getCommonData(categoryLevel, parentId, type) { this.getViewTable(categoryLevel, parentId, type) diff --git a/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue b/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue index 7e0c444..d5489c5 100644 --- a/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue +++ b/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue @@ -693,6 +693,10 @@ export default { this.$refs.previewForm.archivesType = 'edit' this.$refs.previewForm.addOrUpdateForm = data.echo // this.$refs.previewForm.FetchNoFormatField(this.selectedCategory.id) + + if (data.echo.fonds_name === '' || data.echo.fonds_name === null) { + this.$set(this.$refs.previewForm.addOrUpdateForm, 'fonds_name', this.selectedCategory.fondName) + } }) }) }) @@ -850,11 +854,17 @@ export default { return false } } + console.log('this.collectLevel', this.collectLevel) + console.log('this.activeIndex', this.activeIndex) let messageTip if (this.activeIndex === 1) { - messageTip = '此删除将把会所选条目与其子集彻底删除' + messageTip = '此删除将把所选条目与其子集彻底删除' } else { - messageTip = '此删除将把会所选条目与其子集放入回收站' + if (this.collectLevel === 4) { + messageTip = '此删除将把所选条目彻底删除' + } else { + messageTip = '此删除将把所选条目与其子集放入回收站' + } } this.$confirm(messageTip + '你是否还要继续?', '提示', { confirmButtonText: '继续', diff --git a/src/views/collectReorganizi/collectionLibrary/module/uploadFile/index.vue b/src/views/collectReorganizi/collectionLibrary/module/uploadFile/index.vue index f51670f..68300de 100644 --- a/src/views/collectReorganizi/collectionLibrary/module/uploadFile/index.vue +++ b/src/views/collectReorganizi/collectionLibrary/module/uploadFile/index.vue @@ -200,9 +200,31 @@ export default { } }, getFileSize(fileSize) { - const fileSizeInKB = (fileSize / 1024).toFixed(2) + ' KB' - const fileSizeInB = fileSize + 'B' - return (fileSize / 1024) <= 0.01 ? fileSizeInB : fileSizeInKB + // 1. 先将接口返回的KB值转为数字,处理非数字/空值情况 + const sizeInKB = Number(fileSize) + if (isNaN(sizeInKB) || sizeInKB < 0) { + return '0 KB' // 异常值默认显示0 KB + } + + // 2. 定义单位换算关系(1 MB = 1024 KB,1 GB = 1024 MB) + const KB = 1 + const MB = 1024 * KB + const GB = 1024 * MB + + // 3. 根据大小自动选择单位并格式化 + if (sizeInKB >= GB) { + // 大于等于1GB,显示GB(保留2位小数) + return (sizeInKB / GB).toFixed(2) + ' GB' + } else if (sizeInKB >= MB) { + // 大于等于1MB且小于1GB,显示MB(保留2位小数) + return (sizeInKB / MB).toFixed(2) + ' MB' + } else if (sizeInKB < 1) { + // 不足1KB,统一显示1 KB(保持你之前的需求) + return '1 KB' + } else { + // 1KB到1MB之间,显示KB(保留2位小数) + return sizeInKB + ' KB' + } }, // 选择附件 async changeFile(e) { diff --git a/src/views/components/category/PreviewForm.vue b/src/views/components/category/PreviewForm.vue index d310654..d5d2cf9 100644 --- a/src/views/components/category/PreviewForm.vue +++ b/src/views/components/category/PreviewForm.vue @@ -122,11 +122,11 @@ - + @@ -598,6 +598,7 @@ export default { return row.level ? row.level === 3 : true }, normalizer(node) { + console.log('normalizer', node.dictionaryName) if ((node.childDictionarys && !node.childDictionarys.length) || node.childDictionarys === null) { delete node.childDictionarys } @@ -630,12 +631,20 @@ export default { }, // 处理vue-treeSelect回显出现unknown问题 getAutoNameUnknown(name) { - if (name.lastIndexOf('unknown') > -1) { - // 当treeselect翻译不了值时,name中有id,截取id,去调接口或者字典查询出名字 - return name.split('(')[0] - } else { - return name + // 1. 边界判断:空值/非字符串直接返回 + if (!name || typeof name !== 'string') { + return name || '' } + + // 2. 正则匹配并移除 (unknown) 或 (Unknown)/(UNKNOWN) 等变体 + // 正则说明: + // - \(\s* : 匹配左括号,允许括号后有空格 + // - unknown : 匹配unknown,i表示忽略大小写 + // - \s*\) : 匹配右括号,允许括号前有空格 + const unknownRegex = /\(\s*unknown\s*\)/i + + // 只替换 (unknown) 部分,其他括号内容保留 + return name.replace(unknownRegex, '').trim() }, getNode(list, dictionaryName) { let data; @@ -1152,6 +1161,7 @@ export default { if (item.fieldName === 'fonds_no' && this.isDesFormType !== 'category') { this.$set(this.addOrUpdateForm, item.fieldName, this.selectedCategory.fondsNo) } + if (item.fieldName === 'fonds_name' && this.isDesFormType !== 'category') { this.$set(this.addOrUpdateForm, item.fieldName, this.selectedCategory.fondName) } diff --git a/src/views/components/category/preUpload.vue b/src/views/components/category/preUpload.vue index b14912f..07d713d 100644 --- a/src/views/components/category/preUpload.vue +++ b/src/views/components/category/preUpload.vue @@ -1,7 +1,7 @@ - + + 删除 + @@ -100,17 +100,6 @@ - - @@ -123,7 +112,7 @@ import { header, form } from '@crud/crud' import { mapGetters } from 'vuex' import { downloadFile } from '@/utils/index' -import { FetchFileListByDocumentId } from '@/api/prearchiveLibrary/prearchiveLibrary' +import { FetchFileListByDocumentId, FetchDeleteDocumentFile } from '@/api/prearchiveLibrary/prearchiveLibrary' import { getToken } from '@/utils/auth' import PreUpload from '@/views/components/category/preUpload' @@ -230,9 +219,31 @@ export default { } }, getFileSize(fileSize) { - const fileSizeInKB = (fileSize / 1024).toFixed(2) + ' KB' - const fileSizeInB = fileSize + 'B' - return (fileSize / 1024) <= 0.01 ? fileSizeInB : fileSizeInKB + // 1. 先将接口返回的KB值转为数字,处理非数字/空值情况 + const sizeInKB = Number(fileSize) + if (isNaN(sizeInKB) || sizeInKB < 0) { + return '0 KB' // 异常值默认显示0 KB + } + + // 2. 定义单位换算关系(1 MB = 1024 KB,1 GB = 1024 MB) + const KB = 1 + const MB = 1024 * KB + const GB = 1024 * MB + + // 3. 根据大小自动选择单位并格式化 + if (sizeInKB >= GB) { + // 大于等于1GB,显示GB(保留2位小数) + return (sizeInKB / GB).toFixed(2) + ' GB' + } else if (sizeInKB >= MB) { + // 大于等于1MB且小于1GB,显示MB(保留2位小数) + return (sizeInKB / MB).toFixed(2) + ' MB' + } else if (sizeInKB < 1) { + // 不足1KB,统一显示1 KB(保持你之前的需求) + return '1 KB' + } else { + // 1KB到1MB之间,显示KB(保留2位小数) + return sizeInKB + ' KB' + } }, getFile() { this.getTableDisplayFieldsLoading = true @@ -281,18 +292,49 @@ export default { handleCurrentChange(selection, row) { this.selections = selection }, - handleSizeChange(size) { - this.currentPage = 1 - this.page.size = size - this.page.page = 0 - }, - handleCurrentPage(pageVal) { - this.currentPage = pageVal - this.page.page = pageVal - 1 - }, handleClose(done) { done() }, + toDelete() { + if (this.selections.length === 0) { + this.$message({ message: '您还未勾选需要操作的条目,请先确认!', offset: 8 }) + return false + } + + this.$confirm( + '此删除将把所选条目彻底删除你是否还要继续?', + '提示', + { + confirmButtonText: '继续', + cancelButtonText: '取消', + type: 'warning', + dangerouslyUseHTMLString: true + } + ).then(() => { + const params = this.selections.map(val => { + return { + 'documentId': this.selectedDocument.id, + 'documentFileId': val.id, + 'archivesId': this.parentInfo.id + } + }) + + // 4. 调用删除接口并处理结果 + FetchDeleteDocumentFile(params).then((res) => { + if (res.code !== 500) { + this.$message({ message: '删除成功' || '删除成功', type: 'success', offset: 8 }) + this.getFile() + } else { + this.$message({ message: '删除所选电子原文失败', type: 'error', offset: 8 }) + } + }).catch(err => { + console.error('删除接口调用失败:', err) + this.$message({ message: '网络异常,删除失败', type: 'error', offset: 8 }) + }) + }).catch(() => { + this.$message({ message: '已取消删除', type: 'info', offset: 8 }) + }) + }, toPreview(row) { const routeData = this.$router.resolve({ path: '/preview', diff --git a/src/views/prearchiveLibrary/module/detail.vue b/src/views/prearchiveLibrary/module/detail.vue index 373c040..140333b 100644 --- a/src/views/prearchiveLibrary/module/detail.vue +++ b/src/views/prearchiveLibrary/module/detail.vue @@ -191,9 +191,31 @@ export default { localStorage.setItem('fileCurrent', JSON.stringify(row)) }, getFileSize(fileSize) { - const fileSizeInKB = (fileSize / 1024).toFixed(2) + ' KB' - const fileSizeInB = fileSize + 'B' - return (fileSize / 1024) <= 0.01 ? fileSizeInB : fileSizeInKB + // 1. 先将接口返回的KB值转为数字,处理非数字/空值情况 + const sizeInKB = Number(fileSize) + if (isNaN(sizeInKB) || sizeInKB < 0) { + return '0 KB' // 异常值默认显示0 KB + } + + // 2. 定义单位换算关系(1 MB = 1024 KB,1 GB = 1024 MB) + const KB = 1 + const MB = 1024 * KB + const GB = 1024 * MB + + // 3. 根据大小自动选择单位并格式化 + if (sizeInKB >= GB) { + // 大于等于1GB,显示GB(保留2位小数) + return (sizeInKB / GB).toFixed(2) + ' GB' + } else if (sizeInKB >= MB) { + // 大于等于1MB且小于1GB,显示MB(保留2位小数) + return (sizeInKB / MB).toFixed(2) + ' MB' + } else if (sizeInKB < 1) { + // 不足1KB,统一显示1 KB(保持你之前的需求) + return '1 KB' + } else { + // 1KB到1MB之间,显示KB(保留2位小数) + return sizeInKB + ' KB' + } }, getDetial(rowId) { const params = {