fix(接口测试): 修复非http的更新用例跳转出现的模块树不是对应的请求类型以及接口中的模块查询不出来的缺陷

--bug=1016214 --user=宋天阳 【接口测试】首页-过去7天有更新的接口跳转链接页面显示模块信息为空。
https://www.tapd.cn/55049933/s/1234369
This commit is contained in:
song-tianyang 2022-08-26 11:57:47 +08:00 committed by 建国
parent af91f9efc6
commit ca1429c45e
4 changed files with 353 additions and 282 deletions

View File

@ -4,6 +4,8 @@
<ms-aside-container>
<ms-api-module
:show-operator="true"
:default-protocol="defaultProtocol"
:select-default-protocol="isSelectDefaultProtocol"
@nodeSelectEvent="nodeChange"
@protocolChange="handleProtocolChange"
@refreshTable="refresh"
@ -180,7 +182,6 @@
@changeSelectDataRangeAll="changeSelectDataRangeAll"
@handleCase="handleCase"
@showExecResult="showExecResult"
v-if="moduleOptions && moduleOptions.length > 0"
ref="apiConfig"
/>
</div>
@ -284,6 +285,34 @@ export default {
projectId() {
return getCurrentProjectID();
},
isSelectDefaultProtocol() {
let selectDefaultProtocol = true;
let routeParamObj = this.$route.params.paramObj;
if (routeParamObj) {
let dataRange = routeParamObj.dataSelectRange;
let dataType = routeParamObj.dataType;
if (dataRange && typeof dataRange === 'string') {
let selectParamArr = dataRange.split("edit:");
if (selectParamArr.length === 2) {
if (dataType === 'api') {
selectDefaultProtocol = false;
}
}
}
} else {
let dataRange = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
if (dataRange && typeof dataRange === 'string') {
let selectParamArr = dataRange.split("edit:");
if (selectParamArr.length === 2) {
if (dataType === 'api') {
selectDefaultProtocol = false;
}
}
}
}
return selectDefaultProtocol;
},
},
components: {
'VersionSelect': VersionSelect.default,
@ -331,6 +360,7 @@ export default {
selectNodeIds: [],
currentApi: {},
moduleOptions: [],
defaultProtocol: null,
trashEnable: false,
apiTabs: [{
title: this.$t('api_test.definition.api_title'),
@ -765,6 +795,7 @@ export default {
let scenarioId = selectParamArr[1];
if (dataType === 'api') {
this.$get('/api/definition/get/' + scenarioId, (response) => {
this.defaultProtocol = response.data.protocol;
this.editApi(response.data);
});
}
@ -779,6 +810,7 @@ export default {
let scenarioId = selectParamArr[1];
if (dataType === 'api') {
this.$get('/api/definition/get/' + scenarioId, (response) => {
this.defaultProtocol = response.data.protocol;
this.editApi(response.data);
});
}

View File

@ -1,6 +1,7 @@
<template>
<div v-loading="loading">
<el-form :model="basicForm" label-position="right" label-width="80px" size="small" :rules="rule" ref="basicForm" style="margin-right: 20px" :disabled="isReadOnly">
<el-form :model="basicForm" label-position="right" label-width="80px" size="small" :rules="rule" ref="basicForm"
style="margin-right: 20px" :disabled="isReadOnly">
<!-- 基础信息 -->
<el-row>
<el-col :span="8">
@ -10,7 +11,8 @@
</el-col>
<el-col :span="8">
<el-form-item :label="$t('test_track.module.module')" prop="moduleId">
<ms-select-tree size="small" :data="moduleOptions" :defaultKey="basicForm.moduleId" @getValue="setModule" :obj="moduleObj" clearable checkStrictly/>
<ms-select-tree size="small" :data="moduleOptions" :defaultKey="basicForm.moduleId" @getValue="setModule"
:obj="moduleObj" clearable checkStrictly/>
</el-form-item>
</el-col>
<el-col :span="8">
@ -57,12 +59,12 @@
</template>
<script>
import {API_STATUS} from "../../model/JsonData";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
import MsSelectTree from "../../../../common/select-tree/SelectTree";
import {getProjectMemberOption} from "@/network/user";
import {API_STATUS} from "../../model/JsonData";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
import MsSelectTree from "../../../../common/select-tree/SelectTree";
import {getProjectMemberOption} from "@/network/user";
export default {
export default {
name: "MsBasisApi",
components: {MsInputTag, MsSelectTree},
props: {
@ -72,7 +74,7 @@
},
moduleOptions: Array,
basisData: {},
isReadOnly:{
isReadOnly: {
type: Boolean,
default: false
},
@ -121,6 +123,14 @@
}
}
},
moduleOptions: {
handler(v, v1) {
if (!this.basicForm.moduleId) {
this.basicForm.moduleId = this.basisData.moduleId;
}
},
deep: true
},
},
created() {
this.getMaintainerOptions();
@ -182,9 +192,13 @@
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus);
})
},
setModule(id,data) {
this.basicForm.moduleId = id;
setModule(id, data) {
if (data) {
this.basisData.modulePath = data.path;
}
if (id) {
this.basicForm.moduleId = id;
}
},
validate() {
this.$refs['basicForm'].validate((valid) => {
@ -198,7 +212,7 @@
this.$emit("createRootModelInTree");
},
}
}
}
</script>
<style scoped>

View File

@ -1,13 +1,15 @@
<template>
<div v-loading="loading">
<el-form :model="basicForm" label-position="right" label-width="80px" size="small" :rules="rule" ref="basicForm" style="margin-right: 20px" :disabled="isDiff">
<el-form :model="basicForm" label-position="right" label-width="80px" size="small" :rules="rule" ref="basicForm"
style="margin-right: 20px" :disabled="isDiff">
<!-- 基础信息 -->
<el-row>
<el-col :span="isDiff?16:8">
<el-form-item :label="$t('commons.name')" prop="name">
<!-- <el-input class="ms-http-input" size="small" v-model="basicForm.name"/>-->
<el-input v-model="basicForm.name" class="ms-http-input" size="small">
<el-select v-model="basicForm.method" slot="prepend" style="width: 100px" size="small" @change="methodChange">
<el-select v-model="basicForm.method" slot="prepend" style="width: 100px" size="small"
@change="methodChange">
<el-option v-for="item in methodTypes" :key="item.key" :label="item.value" :value="item.key"/>
</el-select>
</el-input>
@ -16,7 +18,9 @@
</el-col>
<el-col :span="8">
<el-form-item :label="$t('test_track.module.module')" prop="moduleId">
<ms-select-tree size="small" :data="moduleOptions" :defaultKey="basicForm.moduleId" @getValue="setModule" :obj="moduleObj" clearable checkStrictly/>
<ms-select-tree size="small" :data="moduleOptions"
:defaultKey="basicForm.moduleId" @getValue="setModule"
:obj="moduleObj" clearable checkStrictly/>
</el-form-item>
</el-col>
@ -64,12 +68,12 @@
</template>
<script>
import {API_STATUS} from "../../model/JsonData";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
import MsSelectTree from "../../../../common/select-tree/SelectTree";
import {getProjectMemberOption} from "@/network/user";
import {API_STATUS} from "../../model/JsonData";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
import MsSelectTree from "../../../../common/select-tree/SelectTree";
import {getProjectMemberOption} from "@/network/user";
export default {
export default {
name: "MsTcpBasicApi",
components: {MsInputTag, MsSelectTree},
props: {
@ -80,7 +84,7 @@
moduleOptions: Array,
methodTypes: Array,
basisData: {},
isDiff:{
isDiff: {
type: Boolean,
default: false
},
@ -145,10 +149,12 @@
},
'basicForm.moduleId': {
handler(v, v1) {
if (this.basicForm.moduleId) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
}
},
'basicForm.status': {
handler(v, v1) {
@ -179,6 +185,14 @@
}
}
},
moduleOptions: {
handler(v, v1) {
if (!this.basicForm.moduleId) {
this.basicForm.moduleId = this.basisData.moduleId;
}
},
deep: true
}
},
methods: {
apiMapStatus() {
@ -212,12 +226,16 @@
methodChange() {
this.$emit("changeApiProtocol", this.basicForm.method);
},
setModule(id,data) {
setModule(id, data) {
if (data) {
this.basisData.modulePath = data.path;
}
if (id) {
this.basisData.moduleId = id;
}
},
}
}
}
</script>
<style scoped>

View File

@ -88,6 +88,7 @@ export default {
return false;
}
},
defaultProtocol: String,
showCaseNum: {
type: Boolean,
default() {
@ -106,6 +107,7 @@ export default {
relevanceProjectId: String,
reviewId: String,
pageSource: String,
selectDefaultProtocol: Boolean,
total: Number,
isRelevance: Boolean,
options: {
@ -156,6 +158,11 @@ export default {
isTrashData() {
this.condition.trashEnable = this.isTrashData;
this.list();
},
defaultProtocol() {
if (this.condition.protocol !== this.defaultProtocol) {
this.condition.protocol = this.defaultProtocol;
}
}
},
methods: {
@ -166,7 +173,7 @@ export default {
this.condition.protocol = this.$route.params.type;
this.$emit('protocolChange', this.condition.protocol);
this.list();
} else if (!this.isRelevance && !isRedirectPage) {
} else if (!this.isRelevance && !isRedirectPage && this.selectDefaultProtocol) {
//
this.$get('/api/module/getUserDefaultApiType/', response => {
this.condition.protocol = response.data;