form file 加载本地文件,逻辑调整

This commit is contained in:
任珮宇 2023-10-19 17:24:56 +08:00
parent b70211b4e5
commit 7e7d2f226a

View File

@ -631,14 +631,27 @@ export default {
//
if (this.canUseFilePicker) {
const propNames = ['sampleFileName', 'gasFileName', 'detFileName', 'qcFileName']
const propStatus = ['sampleFileStatus', 'gasFileStatus', 'detFileStatus', 'qcFileStatus']
const files = []
const allFiles = []
for (const item of this.list) {
propNames.forEach((propName) => {
const value = item[propName]
if (value && value.file) {
files.push(value.file)
if (item.fileType) {
let fileObj = {
files: [],
fileType: item.fileType,
}
})
propNames.forEach((propName, index) => {
const value = item[propName]
if (value && value.file) {
fileObj[propStatus[index]] = true
files.push(value.file)
fileObj.files.push(value.file)
} else {
fileObj[propStatus[index]] = false
}
})
allFiles.push(fileObj)
}
}
if (!files.length) {
this.$message.warn('File is Empty ')
@ -649,24 +662,45 @@ export default {
try {
const { success, message } = await this.uploadZipFile(zipedFiles)
if (success) {
try {
const { success, result, message } = await getAction('/spectrumAnalysis/getFilesBySampleFile', {
fileName: this.list
.filter((item) => item.sampleFileName)
.map((item) => item.sampleFileName.file.name)
.join(','),
})
if (success) {
this.visible = false
this.$emit('loadFormFile', result)
let result = []
allFiles.forEach((el) => {
let obj = {}
if (el.fileType == 'B') {
obj.sampleSystemType = el.fileType
el.files.forEach((item) => {
if (item.name.search('_S_')) {
obj.sampleFileName = item.name
}
if (item.name.search('_G_')) {
obj.gasFileName = item.name
obj.gasFileStatus = el.gasFileStatus
}
if (item.name.search('_D_')) {
obj.detFileName = item.name
obj.detFileStatus = el.detFileStatus
}
if (item.name.search('_Q_')) {
obj.qcFileName = item.name
obj.qcFileStatus = el.qcFileStatus
}
})
} else {
this.$message.error(message)
el.files.forEach((item) => {
if (item.name.search('_S_')) {
obj.sampleSystemType = el.fileType
obj.sampleFileName = item.name
obj.gasFileName = ''
obj.detFileName = ''
obj.qcFileName = ''
}
})
}
} catch (error) {
console.error(error)
} finally {
this.isUploadingZip = false
}
result.push(obj)
})
this.$emit('loadFormFile', result)
this.visible = false
this.isUploadingZip = false
// }
} else {
this.isUploadingZip = false
this.$message.error(message)