From 10452579723e80f8a59c81a0fd5c730a772c356c Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Fri, 9 Jun 2023 14:16:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA)?= =?UTF-8?q?=EF=BC=9A=E5=AF=BC=E5=85=A5=E7=BC=BA=E9=99=B7=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E9=94=99=E8=AF=AF=E5=90=8E=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=8E=9F=E5=A7=8B=E6=96=87=E4=BB=B6=E5=B9=B6=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=EF=BC=8C=E6=8A=A5network=5Ferror?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1026473 --user=王旭 【测试跟踪】缺陷管理,导入缺陷文件内容错误后,修改一下原始文件再保存,报network error https://www.tapd.cn/55049933/s/1379517 --- .../frontend/src/i18n/lang/track/en-US.js | 1 + .../frontend/src/i18n/lang/track/zh-CN.js | 1 + .../frontend/src/i18n/lang/track/zh-TW.js | 1 + .../issue/components/import/IssueImport.vue | 64 +++++++++++-------- 4 files changed, 39 insertions(+), 28 deletions(-) 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; }); } }