新的beta 谱增加本地文件匹配功能

This commit is contained in:
任珮宇 2024-01-26 14:18:31 +08:00
parent 1299a3cb6c
commit e8ac78034a
2 changed files with 60 additions and 2 deletions

View File

@ -102,6 +102,10 @@ export class PHDParser {
const filePrefixes = this.getFilePrefixes(headerInfo[2])
this.sampleFilePrefix = filePrefixes.splice(0, 1)[0]
this.otherFilePrefixes = filePrefixes
} else if (this.fileType == 'C') {
const filePrefixes = this.getFilePrefixes(headerInfo[2])
this.sampleFilePrefix = filePrefixes.splice(0, 1)[0]
this.otherFilePrefixes = filePrefixes.splice(0, 1)
} else {
this.sampleFilePrefix = this.getGammaFilePrefix(headerInfo[2])
}

View File

@ -370,7 +370,7 @@ export default {
if (column !== 'sampleFileName' && (!record.sampleFileName || record.fileType !== 'B')) {
return
}
console.log('this.directoryHanlder', this.directoryHanlder)
if (this.directoryHanlder) {
this.chooseFile(column, record, rowIndex)
} else {
@ -384,6 +384,7 @@ export default {
async chooseFile(column, record, rowIndex) {
try {
const [fileHandle] = await FilePicker.chooseFile(false, [{ accept: { 'text/phd': ['.phd'] } }])
console.log('fileHandle', fileHandle)
try {
const isFileInDirectory = await FilePicker.isFileInDirectory(this.directoryHanlder, fileHandle)
if (!isFileInDirectory) {
@ -394,7 +395,9 @@ export default {
}
const file = await fileHandle.getFile()
console.log('file', file)
const text = await readFile(file)
console.log('text', text)
const phdParser = new PHDParser(text)
console.log('%c [ phdParser ]-313', 'font-size:13px; background:pink; color:#bf2c9f;', phdParser)
const match = this.fileNameAndColumnMatch(column, phdParser.dataType)
@ -477,6 +480,42 @@ export default {
}
}
record.qcFileName = qcFileInfo
} else if (phdParser.fileType == 'C') {
const iter = await this.directoryHanlder.values()
const fileList = []
let result = await iter.next()
while (!result.done) {
const fileHandle = result.value
const file = await fileHandle.getFile()
fileList.push(file)
result = await iter.next()
}
const nameKeys = ['detFileName']
const fileTypes = ['D']
otherFilePrefixes.forEach((otherFilePrefix, index) => {
const fileType = fileTypes[index]
// sample
const findFile = fileList.find((file) => {
return file.name.includes(`${otherFilePrefix}${fileType}_${qualify}`)
})
if (findFile) {
const regExp = new RegExp(
`(${otherFilePrefix}${fileType}_${qualify}_\\d{1,}\\.{0,}\\d{0,}).*?(\\.PHD)`
)
record[nameKeys[index]] = {
file: findFile,
fileName: findFile.name.replace(regExp, '$1$2'),
}
} else {
record[nameKeys[index]] = {
file: undefined,
fileName: `${otherFilePrefix}${fileType}.PHD`,
}
}
})
} else {
Object.assign(record, {
gasFileName: undefined,
@ -637,6 +676,7 @@ export default {
const propStatus = ['sampleFileStatus', 'gasFileStatus', 'detFileStatus', 'qcFileStatus']
const files = []
const allFiles = []
console.log('this.list', this.list)
for (const item of this.list) {
if (item.fileType) {
let fileObj = {
@ -656,11 +696,14 @@ export default {
allFiles.push(fileObj)
}
}
console.log('allFilesallFiles', allFiles)
console.log('filesfiles', files)
if (!files.length) {
this.$message.warn('File is Empty ')
return
}
const zipedFiles = await zipFile(files, 'test.zip')
console.log('zipedFileszipedFiles', zipedFiles)
this.isUploadingZip = true
try {
const { success, message } = await this.uploadZipFile(zipedFiles)
@ -688,6 +731,17 @@ export default {
obj.qcFileStatus = el.qcFileStatus
}
})
} else if (el.fileType == 'C') {
obj.sampleSystemType = el.fileType
el.files.forEach((item) => {
if (item.includes('_S_')) {
obj.sampleFileName = item
}
if (item.includes('_D_')) {
obj.detFileName = item
obj.detFileStatus = el.detFileStatus
}
})
} else {
el.files.forEach((item) => {
if (item.includes('_S_')) {
@ -701,7 +755,7 @@ export default {
}
result.push(obj)
})
console.log(result)
console.log('result', result)
this.$emit('loadFormFile', result)
this.visible = false
this.isUploadingZip = false