Merge branch 'v1.8' into master

This commit is contained in:
Captain.B 2021-03-31 08:17:27 +08:00
commit 13386da0af
9 changed files with 239 additions and 115 deletions

View File

@ -447,7 +447,7 @@ export default {
this.$nextTick(function () {
if (this.$refs.scenarioTable) {
this.$refs.scenarioTable.doLayout();
setTimeout(this.$refs.scenarioTable.doLayout, 200)
}
this.checkTableRowIsSelect();
})

View File

@ -767,7 +767,7 @@
},
runDebug() {
/*触发执行操作*/
let sign = this.$refs.envPopover.checkEnv();
let sign = this.$refs.envPopover.checkEnv(this.scenarioDefinition);
if (!sign) {
return;
}

View File

@ -44,8 +44,8 @@ export default {
setProjectEnvMap(map) {
this.$emit("setProjectEnvMap", map);
},
checkEnv() {
return this.$refs.envSelect.checkEnv();
checkEnv(data) {
return this.$refs.envSelect.checkEnv(data);
}
}

View File

@ -31,6 +31,7 @@
<script>
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
import ApiEnvironmentConfig from "@/business/components/api/definition/components/environment/ApiEnvironmentConfig";
import {ELEMENTS} from "./Setting";
export default {
name: "EnvironmentSelect",
@ -46,7 +47,8 @@ export default {
result: {},
projects: [],
environments: [],
dialogVisible: false
dialogVisible: false,
isFullUrl: true,
}
},
methods: {
@ -102,8 +104,125 @@ export default {
this.$emit('setProjectEnvMap', map);
this.$emit('close');
},
checkEnv() {
getApiInfo(request) {
if (request.id && request.referenced === 'REF') {
let requestResult = request.requestResult;
let url = request.refType && request.refType === 'CASE' ? "/api/testcase/get/" : "/api/definition/get/";
let enable = request.enable;
this.$get(url + request.id, response => {
if (response.data) {
Object.assign(request, JSON.parse(response.data.request));
request.name = response.data.name;
request.enable = enable;
if (response.data.path && response.data.path != null) {
request.path = response.data.path;
request.url = response.data.url;
this.setUrl(request.path);
}
if (response.data.method && response.data.method != null) {
request.method = response.data.method;
}
request.requestResult = requestResult;
request.id = response.data.id;
request.disabled = true;
request.root = true;
if (!request.projectId) {
request.projectId = response.data.projectId;
}
this.reload();
this.sort();
} else {
request.referenced = "Deleted";
}
})
}
},
getScenario(scenario) {
this.result = this.$get("/api/automation/getApiScenario/" + scenario.id, response => {
if (response.data) {
scenario.loaded = true;
let obj = {};
if (response.data.scenarioDefinition) {
obj = JSON.parse(response.data.scenarioDefinition);
scenario.hashTree = obj.hashTree;
}
//scenario.disabled = true;
scenario.name = response.data.name;
if (!scenario.projectId) {
scenario.projectId = response.data.projectId;
}
scenario.headers = obj.headers;
scenario.variables = obj.variables;
scenario.environmentMap = obj.environmentMap;
this.$emit('refReload');
} else {
scenario.referenced = "Deleted";
}
})
},
recursiveSorting(arr) {
for (let i in arr) {
if (arr[i].referenced === 'REF') {
//
if (arr[i].type === "HTTPSamplerProxy") {
//
this.getApiInfo(arr[i]);
//
if (!arr[i].url || (!arr[i].url.startsWith("http://") && !arr[i].url.startsWith("https://"))) {
this.isFullUrl = false;
}
} else if (arr[i].type === "scenario") {
this.getScenario(arr[i]);
}
} else {
if (arr[i].type === "HTTPSamplerProxy") {
//
if (arr[i].enable) {
if (!arr[i].url || (!arr[i].url.startsWith("http://") && !arr[i].url.startsWith("https://"))) {
this.isFullUrl = false;
}
}
}
}
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
this.recursiveSorting(arr[i].hashTree);
}
}
},
checkFullUrl(scenarioDefinition) {
for (let i in scenarioDefinition) {
// ID
let request = scenarioDefinition[i];
if (request.referenced === 'REF') {
if (request.type === "HTTPSamplerProxy") {
this.getApiInfo(request);
//
if (!request.url || (!request.url.startsWith("http://") && !request.url.startsWith("https://"))) {
this.isFullUrl = false;
}
} else if (request.type === "scenario") {
this.getScenario(request);
}
} else {
if (request.type === "HTTPSamplerProxy") {
//
if (request.enable) {
if (!request.url || (!request.url.startsWith("http://") && !request.url.startsWith("https://"))) {
this.isFullUrl = false;
}
}
}
}
if (scenarioDefinition[i].hashTree != undefined && scenarioDefinition[i].hashTree.length > 0) {
this.recursiveSorting(scenarioDefinition[i].hashTree);
}
}
},
checkEnv(data) {
let sign = true;
this.isFullUrl = true;
if (this.data.length > 0) {
this.data.forEach(dt => {
if (!dt.selectEnv) {
@ -121,8 +240,13 @@ export default {
}
})
} else {
// this.checkFullUrl(data);
// sign = this.isFullUrl;
sign = false;
}
//
}
if (!sign) {

View File

@ -354,7 +354,7 @@ export default {
this.$nextTick(function () {
if (this.$refs.caseTable) {
this.$refs.caseTable.doLayout();
setTimeout(this.$refs.caseTable.doLayout, 200)
}
this.checkTableRowIsSelect();
})

View File

@ -463,7 +463,7 @@ export default {
// nexttick:
this.$nextTick(function () {
if (this.$refs.apiDefinitionTable) {
this.$refs.apiDefinitionTable.doLayout();
setTimeout(this.$refs.apiDefinitionTable.doLayout, 200)
}
this.checkTableRowIsSelect();
})

View File

@ -397,7 +397,7 @@ export default {
this.$nextTick(() => {
if (this.$refs.table) {
this.$refs.table.doLayout();
setTimeout(this.$refs.table.doLayout, 200)
}
this.checkTableRowIsSelect();
})

View File

@ -473,7 +473,7 @@ export default {
}
this.selectRows.clear();
if (this.$refs.table) {
this.$refs.table.doLayout();
setTimeout(this.$refs.table.doLayout, 200)
}
});
}

@ -1 +1 @@
Subproject commit afb50f22464b832e4f458f3f7947e6d8f982707e
Subproject commit a37e6bb56ffaa7ecc4ee128640e9415304ad41b6