diff --git a/framework/sdk-parent/frontend/src/i18n/lang/track/en-US.js b/framework/sdk-parent/frontend/src/i18n/lang/track/en-US.js index 66ff02d4e4..a851e3b411 100644 --- a/framework/sdk-parent/frontend/src/i18n/lang/track/en-US.js +++ b/framework/sdk-parent/frontend/src/i18n/lang/track/en-US.js @@ -197,6 +197,7 @@ export default { upload_limit_count: "Only one file can be uploaded at a time", upload_limit_format: "Upload files can only be XLS, XLSX format!", upload_limit_size: "Upload file size cannot exceed 100MB!", + upload_refresh_tips: "Content has been updated, please upload the file again!", upload_limit_other_size: "Upload file size cannot exceed", success: "Import success", error: "Import error", diff --git a/framework/sdk-parent/frontend/src/i18n/lang/track/zh-CN.js b/framework/sdk-parent/frontend/src/i18n/lang/track/zh-CN.js index a665278172..66600173f7 100644 --- a/framework/sdk-parent/frontend/src/i18n/lang/track/zh-CN.js +++ b/framework/sdk-parent/frontend/src/i18n/lang/track/zh-CN.js @@ -174,6 +174,7 @@ export default { upload_limit_count: "一次只能上传一个文件", upload_limit_format: "只支持 xls/xlsx格式文件", upload_limit_size: "上传文件大小不能超过 100MB!", + upload_refresh_tips: "内容已更新,请重新上传文件!", success: "导入成功", error: "导入失败", importing: "导入中...", diff --git a/framework/sdk-parent/frontend/src/i18n/lang/track/zh-TW.js b/framework/sdk-parent/frontend/src/i18n/lang/track/zh-TW.js index 68e494e387..9bb5a8bb20 100644 --- a/framework/sdk-parent/frontend/src/i18n/lang/track/zh-TW.js +++ b/framework/sdk-parent/frontend/src/i18n/lang/track/zh-TW.js @@ -174,6 +174,7 @@ export default { upload_limit_count: "一次只能上傳一個文件", upload_limit_format: "只支持 xls/xlsx格式文件", upload_limit_size: "上傳文件大小不能超過 100MB!", + upload_refresh_tips: "内容已更新,請重新上傳文件!", success: "導入成功!", importing: "導入中...", excel_title: "錶格文件", diff --git a/test-track/frontend/src/business/issue/components/import/IssueImport.vue b/test-track/frontend/src/business/issue/components/import/IssueImport.vue index e3f0e2bbca..af3a5a3014 100644 --- a/test-track/frontend/src/business/issue/components/import/IssueImport.vue +++ b/test-track/frontend/src/business/issue/components/import/IssueImport.vue @@ -123,35 +123,43 @@ export default { return; } let uploadFile = this.uploadFiles[0] - let suffix = uploadFile.name.substring(uploadFile.name.lastIndexOf('.') + 1); - if (suffix !== 'xls' && suffix !== 'xlsx') { - this.$warning(this.$t('test_track.case.import.upload_limit_format')); - return; - } - if (uploadFile.size / 1024 / 1024 > 100) { - this.$warning(this.$t('test_track.case.import.upload_limit_size')); - return; - } - let param = { - workspaceId: getCurrentWorkspaceId(), - projectId: getCurrentProjectID(), - userId: getCurrentUserId(), - importType: this.importType - }; - this.loading = true; - this.$fileUpload('/issues/import', uploadFile, param) - .then(response => { - this.loading = false; - let res = response.data; - if (res.success) { - this.$success(this.$t('test_track.case.import.success')); - this.cancel(); - this.$emit("refresh"); - } else { - this.errList = res.errList; + + this.uploadFiles[0].slice(0, 1).arrayBuffer() + .then(() => { + let suffix = uploadFile.name.substring(uploadFile.name.lastIndexOf('.') + 1); + if (suffix !== 'xls' && suffix !== 'xlsx') { + this.$warning(this.$t('test_track.case.import.upload_limit_format')); + return; } - }).catch((err) => { - this.loading = false; + if (uploadFile.size / 1024 / 1024 > 100) { + this.$warning(this.$t('test_track.case.import.upload_limit_size')); + return; + } + let param = { + workspaceId: getCurrentWorkspaceId(), + projectId: getCurrentProjectID(), + userId: getCurrentUserId(), + importType: this.importType + }; + this.loading = true; + this.$fileUpload('/issues/import', uploadFile, param) + .then(response => { + this.loading = false; + let res = response.data; + if (res.success) { + this.$success(this.$t('test_track.case.import.success')); + this.cancel(); + this.$emit("refresh"); + } else { + this.errList = res.errList; + } + }).catch((err) => { + this.loading = false; + }); + }) + .catch((err) => { + this.$warning(this.$t('test_track.case.import.upload_refresh_tips')); + return; }); } }