refactor(性能测试): 新建和编辑性能测试上传文件逻辑修改

This commit is contained in:
Captain.B 2021-03-24 13:20:32 +08:00
parent 1b5288756a
commit b6ec991ce7
2 changed files with 15 additions and 23 deletions

View File

@ -148,5 +148,6 @@
<if test="request.name!=null"> <if test="request.name!=null">
AND file_metadata.name LIKE CONCAT('%', #{request.name}, '%') AND file_metadata.name LIKE CONCAT('%', #{request.name}, '%')
</if> </if>
order by update_time DESC
</select> </select>
</mapper> </mapper>

View File

@ -221,15 +221,6 @@ export default {
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);
this.tableData.push({
name: file.name,
size: (file.size / 1024).toFixed(2) + ' KB',
type: type.toUpperCase(),
updateTime: file.lastModified,
});
callback(); callback();
} else { } else {
this.$error(this.$t('load_test.project_file_exist') + ', name: ' + file.name); this.$error(this.$t('load_test.project_file_exist') + ', name: ' + file.name);
@ -241,21 +232,21 @@ export default {
let file = uploadResources.file; let file = uploadResources.file;
this.checkFileExist(file, () => { this.checkFileExist(file, () => {
self.uploadList.push(file); let formData = new FormData();
let type = file.name.substring(file.name.lastIndexOf(".") + 1); let url = '/project/upload/files/' + getCurrentProjectID()
if (type.toLowerCase() !== 'jmx') { formData.append("file", file);
return; let options = {
method: 'POST',
url: url,
data: formData,
headers: {
'Content-Type': undefined
} }
let jmxReader = new FileReader(); }
jmxReader.onload = (event) => { self.$request(options, (response) => {
let threadGroups = findThreadGroup(event.target.result, file.name); self.$success(this.$t('commons.save_success'));
threadGroups.forEach(tg => { self.getProjectFiles();
tg.options = {};
self.scenarios.push(tg);
}); });
self.$emit('fileChange', self.scenarios);
};
jmxReader.readAsText(file);
}) })
}, },
handleExceed() { handleExceed() {