From b6ec991ce7f4fa1eb528a64f6cd28f323400fa7c Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 24 Mar 2021 13:20:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=96=B0=E5=BB=BA=E5=92=8C=E7=BC=96=E8=BE=91=E6=80=A7?= =?UTF-8?q?=E8=83=BD=E6=B5=8B=E8=AF=95=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/mapper/ext/ExtLoadTestMapper.xml | 1 + .../test/components/ExistFiles.vue | 37 +++++++------------ 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml index 8580002eff..2eb995b3d8 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml @@ -148,5 +148,6 @@ AND file_metadata.name LIKE CONCAT('%', #{request.name}, '%') + order by update_time DESC \ No newline at end of file diff --git a/frontend/src/business/components/performance/test/components/ExistFiles.vue b/frontend/src/business/components/performance/test/components/ExistFiles.vue index 224c874960..53f7541e98 100644 --- a/frontend/src/business/components/performance/test/components/ExistFiles.vue +++ b/frontend/src/business/components/performance/test/components/ExistFiles.vue @@ -221,15 +221,6 @@ export default { f().then(res => { let response = res.data; if (response.data.length === 0) { - let type = file.name.substring(file.name.lastIndexOf(".") + 1); - - this.tableData.push({ - name: file.name, - size: (file.size / 1024).toFixed(2) + ' KB', - type: type.toUpperCase(), - updateTime: file.lastModified, - }); - callback(); } else { this.$error(this.$t('load_test.project_file_exist') + ', name: ' + file.name); @@ -241,21 +232,21 @@ export default { let file = uploadResources.file; this.checkFileExist(file, () => { - self.uploadList.push(file); - let type = file.name.substring(file.name.lastIndexOf(".") + 1); - if (type.toLowerCase() !== 'jmx') { - return; + let formData = new FormData(); + let url = '/project/upload/files/' + getCurrentProjectID() + formData.append("file", file); + let options = { + method: 'POST', + url: url, + data: formData, + headers: { + 'Content-Type': undefined + } } - let jmxReader = new FileReader(); - jmxReader.onload = (event) => { - let threadGroups = findThreadGroup(event.target.result, file.name); - threadGroups.forEach(tg => { - tg.options = {}; - self.scenarios.push(tg); - }); - self.$emit('fileChange', self.scenarios); - }; - jmxReader.readAsText(file); + self.$request(options, (response) => { + self.$success(this.$t('commons.save_success')); + self.getProjectFiles(); + }); }) }, handleExceed() {