diff --git a/src/views/modules/qc/sopFileManagementUpload.vue b/src/views/modules/qc/sopFileManagementUpload.vue index 56f1556..fd08949 100644 --- a/src/views/modules/qc/sopFileManagementUpload.vue +++ b/src/views/modules/qc/sopFileManagementUpload.vue @@ -158,15 +158,20 @@ export default { const nameWithoutSuffix = lastDotIndex > -1 ? fileName.substring(0, lastDotIndex) : fileName const suffix = lastDotIndex > -1 ? fileName.substring(lastDotIndex + 1) : '' + const currentDate = new Date() + const formatDate = currentDate.getFullYear() + '-' + + String(currentDate.getMonth() + 1).padStart(2, '0') + '-' + + String(currentDate.getDate()).padStart(2, '0') + this.fileList.push({ raw: file.raw, fileNo: nameWithoutSuffix, fileName: fileName, sopType: '', fileSuffix: suffix, - version: 'A0', + version: '', itemNo: '', - phaseInDate: '', + phaseInDate: formatDate, phaseOutDate: '' }) } @@ -235,7 +240,7 @@ export default { fileName: file.fileName || '', sopType: file.sopType || '', fileSuffix: file.fileSuffix || '', - version: file.version || 'A0', + version: file.version || '', itemNo: file.itemNo || '', phaseInDate: file.phaseInDate || formatDate, phaseOutDate: file.phaseOutDate || '' diff --git a/src/views/modules/qc/sopFileUpload.vue b/src/views/modules/qc/sopFileUpload.vue index f75bb01..5c0e8dc 100644 --- a/src/views/modules/qc/sopFileUpload.vue +++ b/src/views/modules/qc/sopFileUpload.vue @@ -308,7 +308,7 @@ export default { this.originalFileList = data.page.list || [] // 保存原始数据 // 过滤掉已添加的文件 this.fileList = this.originalFileList.filter(file => - !this.uploadedFileList.some(uploaded => uploaded.fileNo === file.fileNo) + !this.uploadedFileList.some(uploaded => uploaded.fileNo === file.fileNo && uploaded.sopRevNo === file.sopRevNo) ) this.fileTotalPage = data.page.totalCount || 0 } else { @@ -346,7 +346,7 @@ export default { // 确保选中的文件包含完整数据 this.selectedFiles = val.map(selectedFile => { // 从原始文件列表中找到完整的文件信息 - const completeFile = this.fileList.find(file => file.fileNo === selectedFile.fileNo) + const completeFile = this.fileList.find(file => file.fileNo === selectedFile.fileNo && file.sopRevNo === selectedFile.sopRevNo) return completeFile || selectedFile }) }, @@ -357,10 +357,15 @@ export default { return } + let duplicateCount = 0 + let addedCount = 0 + // 添加到已上传列表 this.selectedFiles.forEach(file => { - const exists = this.uploadedFileList.some(uploaded => uploaded.fileNo === file.fileNo) - if (!exists) { + const exists = this.uploadedFileList.some(uploaded => uploaded.fileNo === file.fileNo && uploaded.sopRevNo === file.sopRevNo) + if (exists) { + duplicateCount++ + } else { this.uploadedFileList.push({ site: file.site, buNo: file.buNo, @@ -376,15 +381,22 @@ export default { phaseInDate: file.phaseInDate || '', phaseOutDate: file.phaseOutDate || '' }) + addedCount++ } }) + if (duplicateCount > 0) { + this.$message.warning(`存在 ${duplicateCount} 个文件编码和版本号重复的文件,不能重复添加`) + } + // 从上方列表中移除已添加的文件 this.fileList = this.fileList.filter(file => - !this.selectedFiles.some(selected => selected.fileNo === file.fileNo) + !this.uploadedFileList.some(uploaded => uploaded.fileNo === file.fileNo && uploaded.sopRevNo === file.sopRevNo) ) - this.$message.success(`已添加${this.selectedFiles.length}个文件`) + if (addedCount > 0) { + this.$message.success(`已添加 ${addedCount} 个文件`) + } // 清空选择 this.$refs.fileTable && this.$refs.fileTable.clearSelection() @@ -400,10 +412,10 @@ export default { // 将删除的文件重新添加到上方列表 this.selectedUploadedFiles.forEach(file => { // 检查原始列表中是否存在该文件 - const originalFile = this.originalFileList.find(original => original.fileNo === file.fileNo) + const originalFile = this.originalFileList.find(original => original.fileNo === file.fileNo && original.sopRevNo === file.sopRevNo) if (originalFile) { // 检查上方列表中是否已存在 - const exists = this.fileList.some(existing => existing.fileNo === file.fileNo) + const exists = this.fileList.some(existing => existing.fileNo === file.fileNo && existing.sopRevNo === file.sopRevNo) if (!exists) { this.fileList.push(originalFile) } @@ -412,7 +424,7 @@ export default { // 从已上传列表中移除 this.uploadedFileList = this.uploadedFileList.filter(file => - !this.selectedUploadedFiles.some(selected => selected.fileNo === file.fileNo) + !this.selectedUploadedFiles.some(selected => selected.fileNo === file.fileNo && selected.sopRevNo === file.sopRevNo) ) this.$message.success(`已删除${this.selectedUploadedFiles.length}个文件`)