fix(接口自动化): 新导入id显示

--user=郭雨琦 【接口自动化】新引用的也显示
This commit is contained in:
guoyuqi 2021-11-23 20:26:59 +08:00 committed by 刘瑞斌
parent 64451f7f89
commit 721815e8d6
3 changed files with 23 additions and 69 deletions

View File

@ -556,7 +556,6 @@ export default {
let data = JSON.parse(res.data);
if (data.hashTree) {
this.sort(data.hashTree);
this.addNum(data.hashTree);
this.scenarioDefinition = data.hashTree;
}
}
@ -1401,7 +1400,6 @@ export default {
this.onSampleError = obj.onSampleError;
}
this.dataProcessing(obj.hashTree);
this.addNum(obj.hashTree);
this.scenarioDefinition = obj.hashTree;
}
}
@ -1671,69 +1669,6 @@ export default {
}
}
},
addNum(hashTree) {
let funcs = [];
for (let i = 0; i < hashTree.length; i++) {
let data = hashTree[i];
if (!data.num) {
if (data.refType) {
if (data.refType === 'API') {
funcs.push(this.getApiDefinitionNumById(data.id));
} else if (data.refType === 'CASE') {
funcs.push(this.getApiTestCaseNumById(data.id));
}
} else if (data.type === 'scenario') {
funcs.push(this.getScenarioNumById(data.id));
}
}
}
Promise.all(funcs).then(([result1, result2, result3]) => {
for (let i = 0; i < hashTree.length; i++) {
let data = hashTree[i];
if (!data.num) {
if (data.refType) {
if (data.refType === 'API') {
this.$set(data, 'num', result1);
} else if (data.refType === 'CASE') {
this.$set(data, 'num', result2);
}
} else {
this.$set(data, 'num', result3);
}
}
}
});
},
getApiDefinitionNumById(id) {
return new Promise((resolve) => {
let url = '/api/definition/get/' + id;
this.$get(url, response => {
if (response.data && response.data.num) {
resolve(response.data.num);
}
});
});
},
getApiTestCaseNumById(id) {
return new Promise((resolve) => {
let url = '/api/testcase/get/' + id;
this.$get(url, response => {
if (response.data && response.data.num) {
resolve(response.data.num);
}
});
});
},
getScenarioNumById(id) {
return new Promise((resolve) => {
let url = '/api/automation/getApiScenario/' + id;
this.$get(url, response => {
if (response.data && response.data.num) {
resolve(response.data.num);
}
});
});
}
}
}
</script>

View File

@ -17,7 +17,7 @@
</template>
<template v-slot:afterTitle v-if="request.refType==='API'|| request.refType==='CASE'">
<span v-if="request.num" @click = "clickResource(request)">{{" ID: "+request.num+""}}</span>
<span v-if="isShowNum" @click = "clickResource(request)">{{" ID: "+request.num+""}}</span>
<span v-else >
<el-tooltip class="ms-num" effect="dark" :content="request.refType==='API'?$t('api_test.automation.scenario.api_none'):$t('api_test.automation.scenario.case_none')" placement="top">
<i class="el-icon-warning"/>
@ -202,7 +202,8 @@ export default {
apiActive: false,
reqSuccess: true,
envType: this.environmentType,
environmentMap: this.envMap
environmentMap: this.envMap,
isShowNum:false,
}
},
created() {
@ -408,11 +409,17 @@ export default {
}
},
getApiInfo() {
console.log("看看num")
console.log(this.request.id);
console.log(this.request.referenced);
if (this.request.id && this.request.referenced === 'REF') {
console.log(this.request.id);
console.log(this.request.referenced);
let requestResult = this.request.requestResult;
let enable = this.request.enable;
this.$get("/api/testcase/get/" + this.request.id, response => {
if (response.data) {
console.log(response.data)
let hashTree = [];
if (this.request.hashTree) {
hashTree = JSON.parse(JSON.stringify(this.request.hashTree));
@ -433,6 +440,10 @@ export default {
} else {
this.request.requestResult = requestResult;
}
if(response.data.num){
this.request.num = response.data.num;
this.isShowNum = true;
}
this.request.id = response.data.id;
this.request.disabled = true;
this.request.root = true;
@ -614,6 +625,10 @@ export default {
response.data.sourceId = resource.resourceId;
response.data.type = resource.type;
response.data.refType = resource.refType;
if(response.data.num){
this.request.num = response.data.num;
this.isShowNum = true;
}
this.clickCase(response.data)
} else {
this.$error("接口用例场景场景已经被删除");

View File

@ -16,7 +16,7 @@
title='场景'>
<template v-slot:afterTitle>
<span v-if="scenario.num" @click = "clickResource(scenario)">{{" ID: "+scenario.num+""}}</span>
<span v-if="isShowNum" @click = "clickResource(scenario)">{{" ID: "+scenario.num+""}}</span>
<span v-else >
<el-tooltip class="ms-num" effect="dark" :content="$t('api_test.automation.scenario.num_none')" placement="top">
<i class="el-icon-warning"/>
@ -119,7 +119,10 @@ export default {
if (this.scenario.hashTree) {
this.setDisabled(this.scenario.hashTree, this.scenario.projectId);
}
//this.scenario.disabled = true;
if(response.data.num){
this.scenario.num = response.data.num;
this.isShowNum = true;
}
this.scenario.name = response.data.name;
this.scenario.headers = obj.headers;
this.scenario.variables = obj.variables;
@ -136,6 +139,7 @@ export default {
return {
loading: false,
isShowInput: false,
isShowNum:false,
}
},
computed: {