Browse Source

2026-08-05

物料档案管理-》SOP清单-》从文件库添加增加【删除】功能
master
fengyuan_yang 2 months ago
parent
commit
c8db1c78f0
  1. 1
      src/api/qc/qc.js
  2. 154
      src/views/modules/qc/sopFileUpload.vue

1
src/api/qc/qc.js

@ -261,6 +261,7 @@ export const getCustomerList = data => createAPI(`/pms/qc/getCustomerList`,'post
// ===================================== SOP清单 =====================================
export const sopListSearch = data => createAPI(`/pms/qc/sopListSearch`,'post',data)
export const sopAvailableFiles = data => createAPI(`/pms/qc/sopAvailableFiles`,'post',data)
export const sopAvailableFilesDelete = data => createAPI(`/pms/qc/sopAvailableFiles/delete`,'post',data)
/** 物料SOP「文件上传」弹窗:批量本地上传,写入 file_management(D:\\sop_files + UspInsertSOP) */
export const sopFileBatchUpload = data => createAPI(`/pms/qc/sopFileBatchUpload`, 'post', data)
// 查询检验页面的SOP文件列表(IPQC/IQC/FQC/OQC/过程检验)

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

@ -27,6 +27,7 @@
<el-form-item style="margin-left: 40px">
<el-button type="primary" icon="el-icon-search" @click="getFileList()">查询</el-button>
<el-button type="primary" @click="openUploadDialog()">上传文件</el-button>
<el-button type="danger" :disabled="selectedFiles.length === 0" :loading="deleteLoading" @click="deleteSelectedFiles">删除</el-button>
</el-form-item>
</el-form>
@ -219,7 +220,8 @@ import SopFileManagementUpload from './sopFileManagementUpload'
import {
sopAvailableFiles,
sopFileUploadSave,
getStandardOperation
getStandardOperation,
sopAvailableFilesDelete
} from '@/api/qc/qc.js'
export default {
@ -243,9 +245,12 @@ export default {
filePageIndex: 1,
filePageSize: 10,
fileTotalPage: 0,
serverFileTotalPage: 0, //
fileListLoading: false,
selectedFiles: [],
deleteLoading: false,
uploadedFileList: [],
pendingAddedFiles: [], //
selectedUploadedFiles: [], //
operationList: []
}
@ -282,15 +287,71 @@ export default {
}
this.selectedFiles = []
this.uploadedFileList = []
this.pendingAddedFiles = []
this.selectedUploadedFiles = []
this.fileList = []
this.originalFileList = []
this.filePageIndex = 1
this.fileTotalPage = 0
this.serverFileTotalPage = 0
},
openUploadDialog () {
this.$nextTick(() => {
this.$refs.sopFileManagementUpload.init(this.currentSite, this.currentBuNo)
})
},
//
getFileKey (file) {
if (!file) {
return ''
}
if (file.id !== null && file.id !== undefined && file.id !== '') {
return `id_${file.id}`
}
const site = file.site || ''
const buNo = file.buNo || ''
const fileNo = file.fileNo || ''
const sopRevNo = file.sopRevNo || ''
return `${site}__${buNo}__${fileNo}__${sopRevNo}`
},
//
syncPendingAddedFiles () {
this.pendingAddedFiles = this.uploadedFileList.map(file => ({
id: file.id,
site: file.site,
buNo: file.buNo,
fileNo: file.fileNo,
fileName: file.fileName,
fileType: file.fileType,
sopRevNo: file.sopRevNo
}))
},
//
isFileMatchCurrentSearch (file) {
const fileNoKeyword = (this.searchForm.fileNo || '').trim().toLowerCase()
const fileNameKeyword = (this.searchForm.fileName || '').trim().toLowerCase()
const fileTypeKeyword = (this.searchForm.fileType || '').trim().toLowerCase()
const sopRevNoKeyword = (this.searchForm.sopRevNo || '').trim().toLowerCase()
const fileNo = String(file.fileNo || '').toLowerCase()
const fileName = String(file.fileName || '').toLowerCase()
const fileType = String(file.fileType || '').toLowerCase()
const sopRevNo = String(file.sopRevNo || '').toLowerCase()
return (!fileNoKeyword || fileNo.indexOf(fileNoKeyword) > -1) &&
(!fileNameKeyword || fileName.indexOf(fileNameKeyword) > -1) &&
(!fileTypeKeyword || fileType.indexOf(fileTypeKeyword) > -1) &&
(!sopRevNoKeyword || sopRevNo.indexOf(sopRevNoKeyword) > -1)
},
//
getPendingAddedCountForCurrentSearch () {
return this.pendingAddedFiles.filter(file => this.isFileMatchCurrentSearch(file)).length
},
// +
refreshFileListView () {
const pendingFileKeys = new Set(this.pendingAddedFiles.map(file => this.getFileKey(file)))
this.fileList = this.originalFileList.filter(file => !pendingFileKeys.has(this.getFileKey(file)))
const pendingCount = this.getPendingAddedCountForCurrentSearch()
this.fileTotalPage = Math.max((this.serverFileTotalPage || 0) - pendingCount, 0)
},
//
getFileList () {
this.fileListLoading = true
@ -306,17 +367,21 @@ export default {
}).then(({data}) => {
if (data && data.code === 0) {
this.originalFileList = data.page.list || [] //
//
this.fileList = this.originalFileList.filter(file =>
!this.uploadedFileList.some(uploaded => uploaded.fileNo === file.fileNo && uploaded.sopRevNo === file.sopRevNo)
)
this.fileTotalPage = data.page.totalCount || 0
this.serverFileTotalPage = data.page.totalCount || 0
this.refreshFileListView()
} else {
this.fileList = []
this.originalFileList = []
this.serverFileTotalPage = 0
this.fileTotalPage = 0
}
this.fileListLoading = false
}).catch(() => {
this.fileList = []
this.originalFileList = []
this.serverFileTotalPage = 0
this.fileTotalPage = 0
this.fileListLoading = false
})
},
//
@ -346,10 +411,51 @@ export default {
//
this.selectedFiles = val.map(selectedFile => {
//
const completeFile = this.fileList.find(file => file.fileNo === selectedFile.fileNo && file.sopRevNo === selectedFile.sopRevNo)
const selectedFileKey = this.getFileKey(selectedFile)
const completeFile = this.fileList.find(file => this.getFileKey(file) === selectedFileKey)
return completeFile || selectedFile
})
},
// file_management
deleteSelectedFiles () {
if (this.selectedFiles.length === 0) {
this.$message.warning('请先选择要删除的文件')
return
}
this.$confirm(`确定删除选中的 ${this.selectedFiles.length} 个文件吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.deleteLoading = true
const deleteList = this.selectedFiles.map(file => ({
id: file.id,
site: file.site,
buNo: file.buNo,
fileNo: file.fileNo,
sopRevNo: file.sopRevNo,
sopUrl: file.sopUrl || ''
}))
sopAvailableFilesDelete(deleteList).then(({ data }) => {
if (data && data.code === 0) {
this.$message.success(`成功删除 ${this.selectedFiles.length} 个文件`)
const deleteFileKeys = new Set(deleteList.map(file => this.getFileKey(file)))
this.uploadedFileList = this.uploadedFileList.filter(file => !deleteFileKeys.has(this.getFileKey(file)))
this.syncPendingAddedFiles()
this.$refs.fileTable && this.$refs.fileTable.clearSelection()
this.selectedFiles = []
this.getFileList()
} else {
this.$message.error((data && data.msg) || '删除失败')
}
}).catch(() => {
this.$message.error('删除失败')
}).finally(() => {
this.deleteLoading = false
})
}).catch(() => {})
},
//
addSelectedFiles () {
if (this.selectedFiles.length === 0) {
@ -362,11 +468,13 @@ export default {
//
this.selectedFiles.forEach(file => {
const exists = this.uploadedFileList.some(uploaded => uploaded.fileNo === file.fileNo && uploaded.sopRevNo === file.sopRevNo)
const fileKey = this.getFileKey(file)
const exists = this.uploadedFileList.some(uploaded => this.getFileKey(uploaded) === fileKey)
if (exists) {
duplicateCount++
} else {
this.uploadedFileList.push({
id: file.id,
site: file.site,
buNo: file.buNo,
fileNo: file.fileNo,
@ -388,11 +496,8 @@ export default {
if (duplicateCount > 0) {
this.$message.warning(`存在 ${duplicateCount} 个文件编码和版本号重复的文件,不能重复添加`)
}
//
this.fileList = this.fileList.filter(file =>
!this.uploadedFileList.some(uploaded => uploaded.fileNo === file.fileNo && uploaded.sopRevNo === file.sopRevNo)
)
this.syncPendingAddedFiles()
this.refreshFileListView()
if (addedCount > 0) {
this.$message.success(`已添加 ${addedCount} 个文件`)
@ -408,26 +513,17 @@ export default {
this.$message.warning('请先选择要删除的文件')
return
}
//
this.selectedUploadedFiles.forEach(file => {
//
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 && existing.sopRevNo === file.sopRevNo)
if (!exists) {
this.fileList.push(originalFile)
}
}
})
const selectedCount = this.selectedUploadedFiles.length
const selectedFileKeys = new Set(this.selectedUploadedFiles.map(file => this.getFileKey(file)))
//
this.uploadedFileList = this.uploadedFileList.filter(file =>
!this.selectedUploadedFiles.some(selected => selected.fileNo === file.fileNo && selected.sopRevNo === file.sopRevNo)
!selectedFileKeys.has(this.getFileKey(file))
)
this.syncPendingAddedFiles()
this.refreshFileListView()
this.$message.success(`已删除${this.selectedUploadedFiles.length}个文件`)
this.$message.success(`已删除${selectedCount}个文件`)
//
this.$refs.uploadedFileTable && this.$refs.uploadedFileTable.clearSelection()
@ -440,6 +536,8 @@ export default {
//
removeUploadedFile (index) {
this.uploadedFileList.splice(index, 1)
this.syncPendingAddedFiles()
this.refreshFileListView()
this.$message.success('文件已移除')
},
//

Loading…
Cancel
Save