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 af7d10a8bb
commit 3a7c9540d6
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,148 +59,160 @@
</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 {
name: "MsBasisApi",
components: {MsInputTag, MsSelectTree},
props: {
currentProtocol: {
type: String,
default: "HTTP"
},
moduleOptions: Array,
basisData: {},
isReadOnly:{
type: Boolean,
default: false
},
export default {
name: "MsBasisApi",
components: {MsInputTag, MsSelectTree},
props: {
currentProtocol: {
type: String,
default: "HTTP"
},
watch: {
'basicForm.name': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.moduleId': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.status': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.follows': {
handler(v, v1) {
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1)) {
this.apiMapStatus();
}
}
},
'basicForm.description': {
handler(v, v1) {
if (v && v1 !== undefined && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.tags': {
handler(v, v1) {
this.tagCount++;
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1) && this.tagCount > 1) {
this.apiMapStatus();
}
}
},
moduleOptions: Array,
basisData: {},
isReadOnly: {
type: Boolean,
default: false
},
created() {
this.getMaintainerOptions();
this.basicForm = this.basisData;
this.$get('/api/definition/follow/' + this.basisData.id, response => {
this.basicForm.follows = response.data;
});
},
data() {
let validateModuleId = (rule, value, callback) => {
if (this.basicForm.moduleId.length === 0 || !this.basicForm.moduleId) {
callback(this.$t('test_track.case.input_module'));
} else {
callback();
},
watch: {
'basicForm.name': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
};
return {
basicForm: {},
httpVisible: false,
currentModule: {},
maintainerOptions: [],
moduleObj: {
id: 'id',
label: 'name',
},
loading: false,
rule: {
name: [
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
moduleId: [{required: true, validator: validateModuleId, trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
},
value: API_STATUS[0].id,
options: API_STATUS,
tagCount: 0
}
},
methods: {
apiMapStatus() {
this.$store.state.apiStatus.set("fromChange", true);
if (this.basicForm.id) {
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus);
'basicForm.moduleId': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.status': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.follows': {
handler(v, v1) {
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1)) {
this.apiMapStatus();
}
}
},
'basicForm.description': {
handler(v, v1) {
if (v && v1 !== undefined && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.tags': {
handler(v, v1) {
this.tagCount++;
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1) && this.tagCount > 1) {
this.apiMapStatus();
}
}
},
moduleOptions: {
handler(v, v1) {
if (!this.basicForm.moduleId) {
this.basicForm.moduleId = this.basisData.moduleId;
}
},
getMaintainerOptions() {
getProjectMemberOption(data => {
this.maintainerOptions = data;
});
deep: true
},
},
created() {
this.getMaintainerOptions();
this.basicForm = this.basisData;
this.$get('/api/definition/follow/' + this.basisData.id, response => {
this.basicForm.follows = response.data;
});
},
data() {
let validateModuleId = (rule, value, callback) => {
if (this.basicForm.moduleId.length === 0 || !this.basicForm.moduleId) {
callback(this.$t('test_track.case.input_module'));
} else {
callback();
}
};
return {
basicForm: {},
httpVisible: false,
currentModule: {},
maintainerOptions: [],
moduleObj: {
id: 'id',
label: 'name',
},
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false;
this.$store.state.apiStatus.set("fromChange", false);
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus);
})
},
setModule(id,data) {
this.basicForm.moduleId = id;
this.basisData.modulePath = data.path;
},
validate() {
this.$refs['basicForm'].validate((valid) => {
if (valid) {
this.$emit('callback');
}
})
this.tagCount = 0;
},
createModules() {
this.$emit("createRootModelInTree");
loading: false,
rule: {
name: [
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
moduleId: [{required: true, validator: validateModuleId, trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
},
value: API_STATUS[0].id,
options: API_STATUS,
tagCount: 0
}
},
methods: {
apiMapStatus() {
this.$store.state.apiStatus.set("fromChange", true);
if (this.basicForm.id) {
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus);
}
},
getMaintainerOptions() {
getProjectMemberOption(data => {
this.maintainerOptions = data;
});
},
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false;
this.$store.state.apiStatus.set("fromChange", false);
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus);
})
},
setModule(id, data) {
if (data) {
this.basisData.modulePath = data.path;
}
if (id) {
this.basicForm.moduleId = id;
}
},
validate() {
this.$refs['basicForm'].validate((valid) => {
if (valid) {
this.$emit('callback');
}
})
this.tagCount = 0;
},
createModules() {
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,160 +68,174 @@
</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 {
name: "MsTcpBasicApi",
components: {MsInputTag, MsSelectTree},
props: {
currentProtocol: {
type: String,
default: "HTTP"
},
moduleOptions: Array,
methodTypes: Array,
basisData: {},
isDiff:{
type: Boolean,
default: false
},
export default {
name: "MsTcpBasicApi",
components: {MsInputTag, MsSelectTree},
props: {
currentProtocol: {
type: String,
default: "HTTP"
},
created() {
this.getMaintainerOptions();
this.basicForm = this.basisData;
if (this.basicForm.protocol == null) {
this.basicForm.protocol = "TCP";
moduleOptions: Array,
methodTypes: Array,
basisData: {},
isDiff: {
type: Boolean,
default: false
},
},
created() {
this.getMaintainerOptions();
this.basicForm = this.basisData;
if (this.basicForm.protocol == null) {
this.basicForm.protocol = "TCP";
}
this.$get('/api/definition/follow/' + this.basisData.id, response => {
this.basicForm.follows = response.data;
});
},
data() {
let validateModuleId = (rule, value, callback) => {
if (this.basicForm.moduleId.length === 0 || !this.basicForm.moduleId) {
callback(this.$t('test_track.case.input_module'));
} else {
callback();
}
this.$get('/api/definition/follow/' + this.basisData.id, response => {
this.basicForm.follows = response.data;
};
return {
basicForm: {},
httpVisible: false,
currentModule: {},
maintainerOptions: [],
loading: false,
rule: {
name: [
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
moduleId: [{required: true, validator: validateModuleId, trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
},
value: API_STATUS[0].id,
options: API_STATUS,
moduleObj: {
id: 'id',
label: 'name',
},
tagCount: 0
}
},
watch: {
'basicForm.name': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.userId': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.moduleId': {
handler(v, v1) {
if (this.basicForm.moduleId) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
}
},
'basicForm.status': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.follows': {
handler(v, v1) {
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1)) {
this.apiMapStatus();
}
}
},
'basicForm.description': {
handler(v, v1) {
if (v && v1 !== undefined && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.tags': {
handler(v, v1) {
this.tagCount++;
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1) && this.tagCount > 1) {
this.apiMapStatus();
}
}
},
moduleOptions: {
handler(v, v1) {
if (!this.basicForm.moduleId) {
this.basicForm.moduleId = this.basisData.moduleId;
}
},
deep: true
}
},
methods: {
apiMapStatus() {
this.$store.state.apiStatus.set("fromChange", true);
if (this.basicForm.id) {
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus);
}
},
getMaintainerOptions() {
getProjectMemberOption(data => {
this.maintainerOptions = data;
});
},
data() {
let validateModuleId = (rule, value, callback) => {
if (this.basicForm.moduleId.length === 0 || !this.basicForm.moduleId) {
callback(this.$t('test_track.case.input_module'));
} else {
callback();
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false
})
},
validate() {
this.$refs['basicForm'].validate((valid) => {
if (valid) {
this.$emit('callback');
}
};
return {
basicForm: {},
httpVisible: false,
currentModule: {},
maintainerOptions: [],
loading: false,
rule: {
name: [
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
moduleId: [{required: true, validator: validateModuleId, trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
},
value: API_STATUS[0].id,
options: API_STATUS,
moduleObj: {
id: 'id',
label: 'name',
},
tagCount: 0
})
this.tagCount = 0;
},
createModules() {
this.$emit("createRootModelInTree");
},
methodChange() {
this.$emit("changeApiProtocol", this.basicForm.method);
},
setModule(id, data) {
if (data) {
this.basisData.modulePath = data.path;
}
if (id) {
this.basisData.moduleId = id;
}
},
watch: {
'basicForm.name': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.userId': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.moduleId': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.status': {
handler(v, v1) {
if (v && v1 && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.follows': {
handler(v, v1) {
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1)) {
this.apiMapStatus();
}
}
},
'basicForm.description': {
handler(v, v1) {
if (v && v1 !== undefined && v !== v1) {
this.apiMapStatus();
}
}
},
'basicForm.tags': {
handler(v, v1) {
this.tagCount++;
if (v && v1 && JSON.stringify(v) !== JSON.stringify(v1) && this.tagCount > 1) {
this.apiMapStatus();
}
}
},
},
methods: {
apiMapStatus() {
this.$store.state.apiStatus.set("fromChange", true);
if (this.basicForm.id) {
this.$store.state.apiMap.set(this.basicForm.id, this.$store.state.apiStatus);
}
},
getMaintainerOptions() {
getProjectMemberOption(data => {
this.maintainerOptions = data;
});
},
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false
})
},
validate() {
this.$refs['basicForm'].validate((valid) => {
if (valid) {
this.$emit('callback');
}
})
this.tagCount = 0;
},
createModules() {
this.$emit("createRootModelInTree");
},
methodChange() {
this.$emit("changeApiProtocol", this.basicForm.method);
},
setModule(id,data) {
this.basisData.modulePath = data.path;
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;