fix(接口自动化): 跨空间不显示ID

--user=郭雨琦 场景编辑跨空间不显示ID
This commit is contained in:
guoyuqi 2021-12-02 19:27:04 +08:00 committed by xiaomeinvG
parent 4538655646
commit 2782141b7b
2 changed files with 38 additions and 12 deletions

View File

@ -13,7 +13,7 @@
:show-btn="showBtn"
:title="displayTitle">
<template v-slot:afterTitle v-if="request.refType==='API'|| request.refType==='CASE'">
<template v-slot:afterTitle v-if="(request.refType==='API'|| request.refType==='CASE')&&isSameSpace">
<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">
@ -142,7 +142,7 @@ import MsDubboBasisParameters from "../../../definition/components/request/dubbo
import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm";
import MsRequestResultTail from "../../../definition/components/response/RequestResultTail";
import MsRun from "../../../definition/components/Run";
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
import {getUUID, getCurrentProjectID, getCurrentWorkspaceId} from "@/common/js/utils";
import ApiBaseComponent from "../common/ApiBaseComponent";
import ApiResponseComponent from "./ApiResponseComponent";
import CustomizeReqInfo from "@/business/components/api/automation/scenario/common/CustomizeReqInfo";
@ -202,6 +202,7 @@ export default {
envType: this.environmentType,
environmentMap: this.envMap,
isShowNum:false,
isSameSpace:true,
}
},
created() {
@ -437,7 +438,7 @@ export default {
}
if(response.data.num){
this.request.num = response.data.num;
this.isShowNum = true;
this.getWorkspaceId(response.data.projectId);
}
this.request.id = response.data.id;
this.request.disabled = true;
@ -457,10 +458,9 @@ export default {
if(this.request.refType==='CASE'){
this.$get("/api/testcase/get/" + this.request.id, response => {
if (response.data) {
if(response.data.num){
this.request.num = response.data.num;
this.isShowNum = true;
this.getWorkspaceId(response.data.projectId);
}
this.request.id = response.data.id;
}
@ -471,7 +471,7 @@ export default {
if (response.data) {
if(response.data.num){
this.request.num = response.data.num;
this.isShowNum = true;
this.getWorkspaceId(response.data.projectId);
}
this.request.id = response.data.id;
}
@ -679,6 +679,17 @@ export default {
let element = document.getElementById(id);
element.parentNode.removeChild(element);
},
getWorkspaceId(projectId){
this.$get("/project/get/" + projectId, response => {
if(response.data){
if(response.data.workspaceId===getCurrentWorkspaceId()){
this.isShowNum = true;
}else {
this.isSameSpace = false;
}
}
});
}
}
}
</script>

View File

@ -15,7 +15,7 @@
background-color="#F4F4F5"
title='场景'>
<template v-slot:afterTitle>
<template v-slot:afterTitle v-if="isSameSpace">
<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">
@ -66,7 +66,7 @@ import MsTcpBasisParameters from "../../../definition/components/request/tcp/Tcp
import MsDubboBasisParameters from "../../../definition/components/request/dubbo/BasisParameters";
import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm";
import ApiBaseComponent from "../common/ApiBaseComponent";
import {getCurrentProjectID, getUUID, strMapToObj} from "@/common/js/utils";
import {getCurrentProjectID, getCurrentWorkspaceId, getUUID, strMapToObj} from "@/common/js/utils";
export default {
name: "ApiScenarioComponent",
@ -126,7 +126,7 @@ export default {
}
if(response.data.num){
this.scenario.num = response.data.num;
this.isShowNum = true;
this.getWorkspaceId(response.data.projectId);
}
this.scenario.name = response.data.name;
this.scenario.headers = obj.headers;
@ -136,13 +136,17 @@ export default {
}
})
}
else if(this.scenario.id && this.scenario.referenced === 'Copy' && !this.scenario.loaded){
else if(this.scenario.id && (this.scenario.referenced === 'Copy'||this.scenario.referenced === 'Created') && !this.scenario.loaded){
this.result = this.$get("/api/automation/getApiScenario/" + this.scenario.id, response => {
if (response.data) {
if(response.data.num){
this.scenario.num = response.data.num;
this.isShowNum = true;
this.getWorkspaceId(response.data.projectId);
}else {
this.isSameSpace = false
}
} else {
this.isSameSpace = false
}
})
}
@ -153,6 +157,7 @@ export default {
loading: false,
isShowInput: false,
isShowNum:false,
isSameSpace:true
}
},
computed: {
@ -269,7 +274,6 @@ export default {
}
},
clickResource(resource) {
let automationData = this.$router.resolve({
name: 'ApiAutomation',
@ -277,6 +281,17 @@ export default {
});
window.open(automationData.href, '_blank');
},
getWorkspaceId(projectId){
this.$get("/project/get/" + projectId, response => {
if(response.data){
if(response.data.workspaceId===getCurrentWorkspaceId()){
this.isShowNum = true;
}else {
this.isSameSpace = false;
}
}
});
}
}
}
</script>