Browse Source

2026-04-01

物料档案管理-》SOP清单上传优化
master
fengyuan_yang 2 weeks ago
parent
commit
1e3b39bf11
  1. 11
      src/views/modules/qc/sopFileManagementUpload.vue
  2. 30
      src/views/modules/qc/sopFileUpload.vue

11
src/views/modules/qc/sopFileManagementUpload.vue

@ -158,15 +158,20 @@ export default {
const nameWithoutSuffix = lastDotIndex > -1 ? fileName.substring(0, lastDotIndex) : fileName const nameWithoutSuffix = lastDotIndex > -1 ? fileName.substring(0, lastDotIndex) : fileName
const suffix = lastDotIndex > -1 ? fileName.substring(lastDotIndex + 1) : '' 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({ this.fileList.push({
raw: file.raw, raw: file.raw,
fileNo: nameWithoutSuffix, fileNo: nameWithoutSuffix,
fileName: fileName, fileName: fileName,
sopType: '', sopType: '',
fileSuffix: suffix, fileSuffix: suffix,
version: 'A0',
version: '',
itemNo: '', itemNo: '',
phaseInDate: '',
phaseInDate: formatDate,
phaseOutDate: '' phaseOutDate: ''
}) })
} }
@ -235,7 +240,7 @@ export default {
fileName: file.fileName || '', fileName: file.fileName || '',
sopType: file.sopType || '', sopType: file.sopType || '',
fileSuffix: file.fileSuffix || '', fileSuffix: file.fileSuffix || '',
version: file.version || 'A0',
version: file.version || '',
itemNo: file.itemNo || '', itemNo: file.itemNo || '',
phaseInDate: file.phaseInDate || formatDate, phaseInDate: file.phaseInDate || formatDate,
phaseOutDate: file.phaseOutDate || '' phaseOutDate: file.phaseOutDate || ''

30
src/views/modules/qc/sopFileUpload.vue

@ -308,7 +308,7 @@ export default {
this.originalFileList = data.page.list || [] // this.originalFileList = data.page.list || [] //
// //
this.fileList = this.originalFileList.filter(file => 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 this.fileTotalPage = data.page.totalCount || 0
} else { } else {
@ -346,7 +346,7 @@ export default {
// //
this.selectedFiles = val.map(selectedFile => { 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 return completeFile || selectedFile
}) })
}, },
@ -357,10 +357,15 @@ export default {
return return
} }
let duplicateCount = 0
let addedCount = 0
// //
this.selectedFiles.forEach(file => { 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({ this.uploadedFileList.push({
site: file.site, site: file.site,
buNo: file.buNo, buNo: file.buNo,
@ -376,15 +381,22 @@ export default {
phaseInDate: file.phaseInDate || '', phaseInDate: file.phaseInDate || '',
phaseOutDate: file.phaseOutDate || '' phaseOutDate: file.phaseOutDate || ''
}) })
addedCount++
} }
}) })
if (duplicateCount > 0) {
this.$message.warning(`存在 ${duplicateCount} 个文件编码和版本号重复的文件,不能重复添加`)
}
// //
this.fileList = this.fileList.filter(file => 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() this.$refs.fileTable && this.$refs.fileTable.clearSelection()
@ -400,10 +412,10 @@ export default {
// //
this.selectedUploadedFiles.forEach(file => { 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) { 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) { if (!exists) {
this.fileList.push(originalFile) this.fileList.push(originalFile)
} }
@ -412,7 +424,7 @@ export default {
// //
this.uploadedFileList = this.uploadedFileList.filter(file => 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}个文件`) this.$message.success(`已删除${this.selectedUploadedFiles.length}个文件`)

Loading…
Cancel
Save