Merge branch 'master' of github.com:metersphere/metersphere
This commit is contained in:
commit
17e9f41833
|
@ -201,7 +201,7 @@ export default {
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
async beforeUploadFile(file) {
|
beforeUploadFile(file) {
|
||||||
if (!this.fileValidator(file)) {
|
if (!this.fileValidator(file)) {
|
||||||
/// todo: 显示错误信息
|
/// todo: 显示错误信息
|
||||||
return false;
|
return false;
|
||||||
|
@ -211,14 +211,14 @@ export default {
|
||||||
this.$error(this.$t('load_test.delete_file'));
|
this.$error(this.$t('load_test.delete_file'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let valid = false;
|
},
|
||||||
|
checkFileExist(file, callback) {
|
||||||
// 检查数据库是否存在同名文件
|
// 检查数据库是否存在同名文件
|
||||||
async function f() {
|
async function f() {
|
||||||
return await axios.post('/performance/file/' + getCurrentProjectID() + '/getMetadataByName', {name: file.name})
|
return await axios.post('/performance/file/' + getCurrentProjectID() + '/getMetadataByName', {name: file.name})
|
||||||
}
|
}
|
||||||
|
|
||||||
await f().then(res => {
|
f().then(res => {
|
||||||
let response = res.data;
|
let response = res.data;
|
||||||
if (response.data.length === 0) {
|
if (response.data.length === 0) {
|
||||||
let type = file.name.substring(file.name.lastIndexOf(".") + 1);
|
let type = file.name.substring(file.name.lastIndexOf(".") + 1);
|
||||||
|
@ -229,33 +229,34 @@ export default {
|
||||||
type: type.toUpperCase(),
|
type: type.toUpperCase(),
|
||||||
updateTime: file.lastModified,
|
updateTime: file.lastModified,
|
||||||
});
|
});
|
||||||
valid = true;
|
|
||||||
|
callback();
|
||||||
} else {
|
} else {
|
||||||
this.$error(this.$t('load_test.project_file_exist'));
|
this.$error(this.$t('load_test.project_file_exist'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return valid;
|
|
||||||
},
|
},
|
||||||
handleUpload(uploadResources) {
|
handleUpload(uploadResources) {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
let file = uploadResources.file;
|
let file = uploadResources.file;
|
||||||
self.uploadList.push(file);
|
this.checkFileExist(file, () => {
|
||||||
let type = file.name.substring(file.name.lastIndexOf(".") + 1);
|
self.uploadList.push(file);
|
||||||
if (type.toLowerCase() !== 'jmx') {
|
let type = file.name.substring(file.name.lastIndexOf(".") + 1);
|
||||||
return;
|
if (type.toLowerCase() !== 'jmx') {
|
||||||
}
|
return;
|
||||||
let jmxReader = new FileReader();
|
}
|
||||||
jmxReader.onload = (event) => {
|
let jmxReader = new FileReader();
|
||||||
let threadGroups = findThreadGroup(event.target.result, file.name);
|
jmxReader.onload = (event) => {
|
||||||
threadGroups.forEach(tg => {
|
let threadGroups = findThreadGroup(event.target.result, file.name);
|
||||||
tg.options = {};
|
threadGroups.forEach(tg => {
|
||||||
this.scenarios.push(tg);
|
tg.options = {};
|
||||||
});
|
self.scenarios.push(tg);
|
||||||
self.$emit('fileChange', self.scenarios);
|
});
|
||||||
};
|
self.$emit('fileChange', self.scenarios);
|
||||||
jmxReader.readAsText(file);
|
};
|
||||||
|
jmxReader.readAsText(file);
|
||||||
|
})
|
||||||
},
|
},
|
||||||
handleExceed() {
|
handleExceed() {
|
||||||
this.$error(this.$t('load_test.file_size_limit'));
|
this.$error(this.$t('load_test.file_size_limit'));
|
||||||
|
|
Loading…
Reference in New Issue