diff --git a/package-lock.json b/package-lock.json index 39fcd597..205955d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,6 +57,7 @@ "sortablejs": "^1.15.5", "streamsaver": "^2.0.6", "svgo": "^1.2.2", + "unzipit": "^2.0.3", "v-viewer": "^1.7.4", "vcrontab": "^0.3.5", "vue": "2.7.16", @@ -21835,6 +21836,15 @@ "node": ">=0.10.0" } }, + "node_modules/unzipit": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unzipit/-/unzipit-2.0.3.tgz", + "integrity": "sha512-e6+ftgSQRj9Hwf2mIWFwYIGqBoKV7AziG/d7pep2Uv3NCzHbhLO5d9dGRwpahVlnpQ7aQC+5kWk72dnWocdYyA==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/unzipper": { "version": "0.10.14", "resolved": "https://registry.npmmirror.com/unzipper/-/unzipper-0.10.14.tgz", diff --git a/package.json b/package.json index e10c42e7..3be3af68 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "sortablejs": "^1.15.5", "streamsaver": "^2.0.6", "svgo": "^1.2.2", + "unzipit": "^2.0.3", "v-viewer": "^1.7.4", "vcrontab": "^0.3.5", "vue": "2.7.16", diff --git a/src/components/uploadDicomAndNonedicom/index.vue b/src/components/uploadDicomAndNonedicom/index.vue index c5f19dbd..98510f22 100644 --- a/src/components/uploadDicomAndNonedicom/index.vue +++ b/src/components/uploadDicomAndNonedicom/index.vue @@ -3,7 +3,7 @@ :append-to-body="true" class="uploadDicomAndNonedicom"> {{ title }} - + { return { SubjectId: null, @@ -332,6 +333,34 @@ export default { store.dispatch('trials/setUnLock', false) }, methods: { + async readZipFileListRaw(zipFile) { + try { + // 1. 使用 unzipRaw 读取原始条目列表 + const { entries } = await unzipRaw(zipFile); + + // 2. entries 是一个数组,需要手动处理 + const fileList = entries.map(entry => { + // 3. 使用 TextDecoder 指定编码来解码文件名 + // 例如,对于简体中文 ZIP 包,可以使用 'gbk' + const decoder = new TextDecoder('gbk'); // 或者 'big5' + const name = decoder.decode(entry.nameBytes); + + return { + path: name, + name: name.split('/').pop(), + isDirectory: entry.isDirectory, + size: entry.size, + lastModified: entry.lastModDate + }; + }); + + console.log('解码后的文件列表:', fileList); + return fileList; + } catch (error) { + console.error('读取 ZIP 失败:', error); + throw error; + } + }, async getList() { try { this.searchData.SubjectId = this.SubjectId @@ -370,11 +399,15 @@ export default { // 扫描待上传文件 beginScanFiles(e) { var files = [...e.target.files] - var sameFiles = [] + var sameFiles = [], zipFiles = [], f = false files.forEach((file) => { var extendName = file.name .substring(file.name.lastIndexOf('.')) .toLocaleLowerCase() + if (extendName === '.zip' && this.IsImageSegment) { + if (file.name.indexOf('筛选期') > -1 || file.name.indexOf('研究结束') > -1) f = true + zipFiles.push(file) + } if ( this.faccept.indexOf(extendName) !== -1 && this.fileList.findIndex((v) => v.name === file.name) > -1 @@ -382,6 +415,16 @@ export default { sameFiles.push(file.name) } }) + if (zipFiles.length > 0) { + zipFiles.forEach(async file => { + let list = await this.readZipFileListRaw(file) + if (!f) f = list.some(i => i.path.indexOf('筛选期') > -1 || i.path.indexOf('研究结束') > -1) + list = null + }) + } + if (f) return this.$confirm(this.$t("trials:uploadNonDicoms:confirm:zipNameNonCompliant"), '', { + type: "warning" + }) var scope = this if (sameFiles.length > 0) { const h = this.$createElement diff --git a/src/views/trials/trials-panel/attachments/site-research/components/Questions.vue b/src/views/trials/trials-panel/attachments/site-research/components/Questions.vue index 35db4ecd..60d4ffc7 100644 --- a/src/views/trials/trials-panel/attachments/site-research/components/Questions.vue +++ b/src/views/trials/trials-panel/attachments/site-research/components/Questions.vue @@ -166,7 +166,7 @@