fix(接口定义): 修复场景导入场景页面模块错位的缺陷 (#17459)

--bug=1016345 --user=王孝刚 【接口测试】github#17432,场景接口列表导入左侧切换项目显示错行
https://www.tapd.cn/55049933/s/1233950

Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
MeterSphere Bot 2022-08-26 13:42:06 +08:00 committed by GitHub
parent ec5d0f2c7c
commit abe5f61d3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 16 deletions

View File

@ -6,7 +6,6 @@
ref="baseRelevance"> ref="baseRelevance">
<template v-slot:aside> <template v-slot:aside>
<ms-api-module <ms-api-module
style="margin-top: 5px;"
@nodeSelectEvent="nodeChange" @nodeSelectEvent="nodeChange"
@protocolChange="handleProtocolChange" @protocolChange="handleProtocolChange"
@refreshTable="refresh" @refreshTable="refresh"

View File

@ -5,14 +5,17 @@
<el-select v-model="request.method" class="ms-select" size="small" :disabled="request.disabled"> <el-select v-model="request.method" class="ms-select" size="small" :disabled="request.disabled">
<el-option v-for="item in reqOptions" :key="item.id" :label="item.label" :value="item.id"/> <el-option v-for="item in reqOptions" :key="item.id" :label="item.label" :value="item.id"/>
</el-select> </el-select>
<el-input v-model="request.domain" v-if="request.isRefEnvironment && request.domain" size="small" readonly class="ms-input"/> <el-input v-model="request.domain" v-if="request.isRefEnvironment && request.domain" size="small" readonly
class="ms-input"/>
<el-input :placeholder="$t('api_test.definition.request.path_all_info')" v-model="request.path" <el-input :placeholder="$t('api_test.definition.request.path_all_info')" v-model="request.path"
style="width: 50%" size="small" @blur="urlChange" :disabled="request.disabled" v-if="request.isRefEnvironment"/> style="width: 50%" size="small" @blur="urlChange" :disabled="request.disabled"
v-if="request.isRefEnvironment"/>
<el-input :placeholder="$t('api_test.definition.request.path_all_info')" v-model="request.url" <el-input :placeholder="$t('api_test.definition.request.path_all_info')" v-model="request.url"
style="width: 50%" size="small" @blur="urlChange" :disabled="request.disabled" v-else/> style="width: 50%" size="small" @blur="urlChange" :disabled="request.disabled" v-else/>
<el-checkbox v-if="isCustomizeReq" class="is-ref-environment" v-model="request.isRefEnvironment" @change="setDomain" :disabled="request.disabled"> <el-checkbox v-if="isCustomizeReq" class="is-ref-environment" v-model="request.isRefEnvironment"
@change="setDomain" :disabled="request.disabled">
{{ $t('api_test.request.refer_to_environment') }} {{ $t('api_test.request.refer_to_environment') }}
</el-checkbox> </el-checkbox>
</div> </div>
@ -20,7 +23,8 @@
<el-select v-model="request.method" class="ms-select" size="small" :disabled="request.disabled"> <el-select v-model="request.method" class="ms-select" size="small" :disabled="request.disabled">
<el-option v-for="item in reqOptions" :key="item.id" :label="item.label" :value="item.id"/> <el-option v-for="item in reqOptions" :key="item.id" :label="item.label" :value="item.id"/>
</el-select> </el-select>
<el-input v-model="request.domain" v-if="request.domain" size="small" readonly class="ms-input" :disabled="request.disabled"/> <el-input v-model="request.domain" v-if="request.domain" size="small" readonly class="ms-input"
:disabled="request.disabled"/>
<el-input :placeholder="$t('api_test.definition.request.path_all_info')" style="width: 50%" <el-input :placeholder="$t('api_test.definition.request.path_all_info')" style="width: 50%"
v-model="request.path" size="small" @blur="pathChange" :disabled="request.disabled"/> v-model="request.path" size="small" @blur="pathChange" :disabled="request.disabled"/>
</div> </div>
@ -115,6 +119,16 @@ export default {
} }
}, },
setDomain() { setDomain() {
let urlStr = this.addProtocol(this.request.url);
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/g;
if (reg.test(urlStr)) {
let url = this.getURL(urlStr);
if (url && url.pathname) {
this.request.path = url.pathname;
}
} else {
this.request.path = this.request.url
}
this.$emit("setDomain"); this.$emit("setDomain");
} }
} }

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<el-row> <el-row>
<el-col class="protocol-col" :span="9"> <el-col :span="8">
<el-select class="protocol-select" size="small" v-model="condition.protocol"> <el-select class="protocol-select" size="small" v-model="condition.protocol">
<el-option <el-option
v-for="item in options" v-for="item in options"
@ -221,7 +221,7 @@ export default {
<style scoped> <style scoped>
.protocol-select { .protocol-select {
width: 92px; width: 85px;
height: 30px; height: 30px;
} }

View File

@ -12,23 +12,27 @@
<table-select-count-bar :count="selectCounts" style="float: left; margin: 5px;"/> <table-select-count-bar :count="selectCounts" style="float: left; margin: 5px;"/>
<div v-if="flag" style="margin: 5px; float: left;"> <div v-if="flag" style="margin: 5px; float: left;">
<el-checkbox v-model="checked" class="el-checkbox__label">{{ $t('test_track.sync_add_api_load') }}</el-checkbox> <el-checkbox v-model="checked" class="el-checkbox__label">{{
$t('test_track.sync_add_api_load')
}}
</el-checkbox>
</div> </div>
</template> </template>
</ms-dialog-header> </ms-dialog-header>
</template> </template>
<template v-slot:aside> <template v-slot:aside>
<span v-if="isAcrossSpace" class="menu-title">{{'[' + $t('project.version.checkout') + $t('commons.space') +']'}}</span> <span v-if="isAcrossSpace"
class="menu-title">{{ '[' + $t('project.version.checkout') + $t('commons.space') + ']' }}</span>
<el-select v-if="isAcrossSpace" filterable slot="prepend" v-model="workspaceId" @change="changeWorkspace" <el-select v-if="isAcrossSpace" filterable slot="prepend" v-model="workspaceId" @change="changeWorkspace"
style="width: 160px" class="ms-header-workspace"
size="small"> size="small">
<el-option v-for="(item,index) in workspaceList" :key="index" :label="item.name" :value="item.id"/> <el-option v-for="(item,index) in workspaceList" :key="index" :label="item.name" :value="item.id"/>
</el-select> </el-select>
<select-menu <select-menu
:data="projects" :data="projects"
v-if="multipleProject" v-if="multipleProject"
width="64.5%" width="155px"
:current-data="currentProject" :current-data="currentProject"
:title="$t('test_track.switch_project')" :title="$t('test_track.switch_project')"
@dataChange="changeProject"/> @dataChange="changeProject"/>
@ -140,14 +144,14 @@ export default {
this.projectName = data[0].name; this.projectName = data[0].name;
this.changeProject(data[0]); this.changeProject(data[0]);
} }
}else { } else {
this.$message.warning(this.$t('commons.current_workspace') + this.$t('commons.not_exist') + this.$t('commons.project') + "!"); this.$message.warning(this.$t('commons.current_workspace') + this.$t('commons.not_exist') + this.$t('commons.project') + "!");
} }
}) })
}, },
changeProject(project) { changeProject(project) {
if(project){ if (project) {
this.currentProject = project; this.currentProject = project;
this.$emit('setProject', project.id); this.$emit('setProject', project.id);
// //
@ -181,7 +185,9 @@ export default {
margin-left: 10px; margin-left: 10px;
margin-right: 10px; margin-right: 10px;
} }
/*.el-checkbox__label {*/
/* float: right;*/ .ms-header-workspace {
/*}*/ width: 155px;
margin-bottom: 10px;
}
</style> </style>