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

@ -29,133 +29,257 @@
</template>
<script>
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
import ApiEnvironmentConfig from "@/business/components/api/definition/components/environment/ApiEnvironmentConfig";
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",
components: {ApiEnvironmentConfig},
props: {
envMap: Map,
projectIds: Set,
projectList: Array
},
data() {
return {
data: [],
result: {},
projects: [],
environments: [],
dialogVisible: false
}
},
methods: {
init() {
this.projectIds.forEach(id => {
let item = {id: id, envs: [], selectEnv: ""};
this.data.push(item);
this.result = this.$get('/api/environment/list/' + id, res => {
let envs = res.data;
envs.forEach(environment => {
parseEnvironment(environment);
});
//
let temp = this.data.find(dt => dt.id === id);
temp.envs = envs;
let envId = this.envMap.get(id);
//
temp.selectEnv = envs.filter(e =>e.id === envId).length === 0 ? null : envId;
export default {
name: "EnvironmentSelect",
components: {ApiEnvironmentConfig},
props: {
envMap: Map,
projectIds: Set,
projectList: Array
},
data() {
return {
data: [],
result: {},
projects: [],
environments: [],
dialogVisible: false,
isFullUrl: true,
}
},
methods: {
init() {
this.projectIds.forEach(id => {
let item = {id: id, envs: [], selectEnv: ""};
this.data.push(item);
this.result = this.$get('/api/environment/list/' + id, res => {
let envs = res.data;
envs.forEach(environment => {
parseEnvironment(environment);
});
//
let temp = this.data.find(dt => dt.id === id);
temp.envs = envs;
let envId = this.envMap.get(id);
//
temp.selectEnv = envs.filter(e => e.id === envId).length === 0 ? null : envId;
})
})
})
},
open() {
this.data = [];
if (this.projectIds.size > 0) {
this.init();
}
},
getProjectName(id) {
const project = this.projectList.find(p => p.id === id);
return project ? project.name : "";
},
openEnvironmentConfig(projectId, envId) {
if (!projectId) {
this.$error(this.$t('api_test.select_project'));
return;
}
this.$refs.environmentConfig.open(projectId, envId);
},
handleConfirm() {
let map = new Map();
let sign = true;
this.data.forEach(dt => {
if (!dt.selectEnv) {
sign = false;
},
open() {
this.data = [];
if (this.projectIds.size > 0) {
this.init();
}
},
getProjectName(id) {
const project = this.projectList.find(p => p.id === id);
return project ? project.name : "";
},
openEnvironmentConfig(projectId, envId) {
if (!projectId) {
this.$error(this.$t('api_test.select_project'));
return;
}
map.set(dt.id, dt.selectEnv);
})
if (!sign) {
this.$warning("请为每个项目选择一个运行环境!");
return;
}
this.$emit('setProjectEnvMap', map);
this.$emit('close');
},
checkEnv() {
let sign = true;
if (this.data.length > 0) {
this.$refs.environmentConfig.open(projectId, envId);
},
handleConfirm() {
let map = new Map();
let sign = true;
this.data.forEach(dt => {
if (!dt.selectEnv) {
sign = false;
return false;
return;
}
map.set(dt.id, dt.selectEnv);
})
if (!sign) {
this.$warning("请为每个项目选择一个运行环境!");
return;
}
this.$emit('setProjectEnvMap', map);
this.$emit('close');
},
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";
}
})
} else {
//
if (this.envMap && this.envMap.size > 0) {
this.projectIds.forEach(id => {
if (!this.envMap.get(id)) {
},
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) {
sign = false;
return false;
}
})
} else {
sign = false;
}
}
//
if (this.envMap && this.envMap.size > 0) {
this.projectIds.forEach(id => {
if (!this.envMap.get(id)) {
sign = false;
return false;
}
})
} else {
// this.checkFullUrl(data);
// sign = this.isFullUrl;
sign = false;
}
if (!sign) {
this.$warning("请为每个项目选择一个运行环境!");
return false;
//
}
if (!sign) {
this.$warning("请为每个项目选择一个运行环境!");
return false;
}
return true;
},
environmentConfigClose() {
// todo
}
return true;
},
environmentConfigClose() {
// todo
}
}
}
</script>
<style scoped>
.ms-scenario-button {
margin-left: 20px;
}
.ms-scenario-button {
margin-left: 20px;
}
.env-confirm {
margin-left: 20px;
width: 360px;
margin-top: 10px;
}
.env-confirm {
margin-left: 20px;
width: 360px;
margin-top: 10px;
}
.project-name {
display:inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 150px;
margin-left: 8px;
vertical-align:middle;
}
.project-name {
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 150px;
margin-left: 8px;
vertical-align: middle;
}
</style>

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