fix (接口定义): 修复sql类型结果只显示一个的问题

--bug=1007307 --user=赵勇 【接口定义】-编辑SQL接口-test-添加多条SQL语句执行不生效仅执行一条 https://www.tapd.cn/55049933/s/1057511
This commit is contained in:
fit2-zhao 2021-10-21 18:51:41 +08:00 committed by fit2-zhao
parent c73e5bccf0
commit 18f3b2b082
2 changed files with 62 additions and 85 deletions

View File

@ -55,7 +55,6 @@ public class TestResultService {
try { try {
ApiTestReport report = null; ApiTestReport report = null;
ApiTestReportVariable reportTask = null; ApiTestReportVariable reportTask = null;
String reportUrl = null;
String planScenarioId = null; String planScenarioId = null;
// 这部分后续优化只留 DEFINITION SCENARIO 两部分 // 这部分后续优化只留 DEFINITION SCENARIO 两部分
if (StringUtils.equals(runMode, ApiRunMode.DEBUG.name())) { if (StringUtils.equals(runMode, ApiRunMode.DEBUG.name())) {
@ -129,9 +128,6 @@ public class TestResultService {
reportTask.setExecutionEnvironment(name); reportTask.setExecutionEnvironment(name);
SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class); SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class);
assert systemParameterService != null; assert systemParameterService != null;
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
reportUrl = baseSystemConfigDTO.getUrl() + "/#/api/automation/report";
} }
testResult.setTestId(scenarioReport.getScenarioId()); testResult.setTestId(scenarioReport.getScenarioId());
planScenarioId = scenarioReport.getTestPlanScenarioId(); planScenarioId = scenarioReport.getTestPlanScenarioId();

View File

@ -24,102 +24,83 @@
</template> </template>
<script> <script>
export default { export default {
name: "MsSqlResultTable", name: "MsSqlResultTable",
data() { data() {
return { return {
tables: [], tables: [],
titles: [] titles: []
} }
}, },
props: { props: {
body: String body: String
}, },
created() { created() {
if (!this.body) { if (!this.body) {
return; return;
} }
let rowArry = this.body.split("\n"); let rowArray = this.body.split("\n");
// //
if (rowArry.length > 100) { if (rowArray.length > 100) {
rowArry = rowArry.slice(0, 100); rowArray = rowArray.slice(0, 100);
} }
this.getTableData(rowArry); this.getTableData(rowArray);
if (this.tables.length > 1) { },
for (let i = 0; i < this.tables.length; i++) { methods: {
if (this.tables[i].titles.length === 1 && i < this.tables.length - 1) { getTableData(rowArray) {
this.tables[i].tableData.splice(this.tables[i].tableData.length - 1, 1); let titles;
} let result = [];
} for (let i = 0; i < rowArray.length; i++) {
let colArray = rowArray[i].split("\t");
let lastTable = this.tables[this.tables.length - 1]; if (i === 0) {
if (lastTable.titles.length === 1) { titles = colArray;
if (lastTable.tableData.length > 4) {
lastTable.tableData.splice(lastTable.tableData.length - 4, 4);
} else {
this.tables.splice(this.tables.length - 1, 1);
}
} else { } else {
this.tables.splice(this.tables.length - 1, 1); if (colArray.length != titles.length) {
} //
} else { if (colArray.length === 1 && colArray[0] === '') {
let table = this.tables[0]; this.getTableData(rowArray.slice(i + 1));
table.tableData.splice(table.tableData.length - 4, 4);
}
},
methods: {
getTableData(rowArry) {
let titles;
let result = [];
for (let i = 0; i < rowArry.length; i++) {
let colArray = rowArry[i].split("\t");
if (i === 0) {
titles = colArray;
} else {
if (colArray.length != titles.length) {
//
if (colArray.length === 1 && colArray[0] === '') {
this.getTableData(rowArry.slice(i + 1));
} else {
this.getTableData(rowArry.slice(i));
}
break;
} else { } else {
let item = {}; this.getTableData(rowArray.slice(i));
for (let j = 0; j < colArray.length; j++) { }
item[titles[j]] = (colArray[j] ? colArray[j] : ""); break;
} } else {
let item = {};
for (let j = 0; j < colArray.length; j++) {
item[titles[j]] = (colArray[j] ? colArray[j] : "");
}
//
if (result.length < 100) {
result.push(item); result.push(item);
} }
} }
} }
this.tables.splice(0, 0, {
titles: titles,
tableData: result
});
} }
this.tables.splice(0, 0, {
titles: titles,
tableData: result
});
} }
} }
}
</script> </script>
<style scoped> <style scoped>
.el-table { .el-table {
margin-bottom: 20px; margin-bottom: 20px;
} }
.el-table >>> .cell { .el-table >>> .cell {
white-space: nowrap; white-space: nowrap;
} }
.table-content { .table-content {
cursor: pointer; cursor: pointer;
} }
.el-container { .el-container {
overflow: auto; overflow: auto;
max-height: 500px; max-height: 500px;
} }
</style> </style>