refactor(性能测试): 引入自动化场景显示csv等文件

This commit is contained in:
Captain.B 2021-06-28 13:14:44 +08:00 committed by 刘瑞斌
parent df9f214b19
commit ab44bd0183
2 changed files with 16 additions and 10 deletions

View File

@ -21,7 +21,8 @@
<el-table-column prop="tags" min-width="120px" <el-table-column prop="tags" min-width="120px"
:label="$t('api_test.automation.tag')"> :label="$t('api_test.automation.tag')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
:content="itemName"
style="margin-left: 0px; margin-right: 2px"/> style="margin-left: 0px; margin-right: 2px"/>
</template> </template>
</el-table-column> </el-table-column>
@ -66,7 +67,7 @@ export default {
total: 0, total: 0,
apiScenarios: [], apiScenarios: [],
selectIds: new Set, selectIds: new Set,
} };
}, },
methods: { methods: {
open() { open() {
@ -101,7 +102,7 @@ export default {
let condition = { let condition = {
projectId: getCurrentProjectID(), projectId: getCurrentProjectID(),
filters: {status: ["Prepare", "Underway", "Completed"]} filters: {status: ["Prepare", "Underway", "Completed"]}
} };
this.projectLoadingResult = this.$post('/api/automation/list/' + this.currentPage + "/" + this.pageSize, condition, res => { this.projectLoadingResult = this.$post('/api/automation/list/' + this.currentPage + "/" + this.pageSize, condition, res => {
let data = res.data; let data = res.data;
this.total = data.itemCount; this.total = data.itemCount;
@ -111,7 +112,7 @@ export default {
item.tags = JSON.parse(item.tags); item.tags = JSON.parse(item.tags);
} }
}); });
}) });
}, },
handleImport() { handleImport() {
if (this.selectIds.size === 0) { if (this.selectIds.size === 0) {
@ -133,7 +134,7 @@ export default {
let data = response.data; let data = response.data;
data.forEach(d => { data.forEach(d => {
let jmxName = d.name + "_" + new Date().getTime() + ".jmx"; let jmxName = d.name + "_" + new Date().getTime() + ".jmx";
let threadGroups = findThreadGroup(d.jmx, jmxName) let threadGroups = findThreadGroup(d.jmx, jmxName);
threadGroups.forEach(tg => { threadGroups.forEach(tg => {
tg.options = {}; tg.options = {};
this.scenarios.push(tg); this.scenarios.push(tg);
@ -146,16 +147,21 @@ export default {
type: 'JMX', type: 'JMX',
updateTime: file.lastModified, updateTime: file.lastModified,
}); });
}) // csv
d.fileMetadataList?.forEach(f => {
this.fileList.push(f);
this.tableData.push(f);
});
});
this.$emit('fileChange', this.scenarios); this.$emit('fileChange', this.scenarios);
this.$success(this.$t('test_track.case.import.success')); this.$success(this.$t('test_track.case.import.success'));
this.loadApiAutomationVisible = false; this.loadApiAutomationVisible = false;
}) });
this.selectIds.clear(); this.selectIds.clear();
}, },
} }
} };
</script> </script>
<style scoped> <style scoped>

View File

@ -295,8 +295,8 @@ export default {
csvFiles() { csvFiles() {
if (this.csvConfig && this.csvFiles) { if (this.csvConfig && this.csvFiles) {
this.csvFiles.forEach(f => { this.csvFiles.forEach(f => {
f.csvSplit = this.csvConfig[f.name].csvSplit; f.csvSplit = this.csvConfig[f.name]?.csvSplit;
f.csvHasHeader = this.csvConfig[f.name].csvHasHeader; f.csvHasHeader = this.csvConfig[f.name]?.csvHasHeader;
}); });
} }
} }