refactor(接口测试): 优化加载用例列表的确认按钮

--bug=1011858 --user=宋天阳 【接口测试】test,加载用例,建议把加载用例列表的保存按钮改成确定按钮
https://www.tapd.cn/55049933/s/1129116
This commit is contained in:
song-tianyang 2022-04-01 18:36:43 +08:00 committed by CountryBuilder
parent 508f26e625
commit 616bcdb51d
6 changed files with 261 additions and 240 deletions

View File

@ -27,7 +27,7 @@
<el-button type="primary" size="small" @click="saveTestCase()" <el-button type="primary" size="small" @click="saveTestCase()"
v-prevent-re-click v-prevent-re-click
v-permission="['PROJECT_API_DEFINITION:READ+EDIT_CASE']"> v-permission="['PROJECT_API_DEFINITION:READ+EDIT_CASE']">
{{ $t('commons.save') }} {{ saveButtonText }}
</el-button> </el-button>
</el-col> </el-col>
</el-row> </el-row>
@ -50,6 +50,7 @@ export default {
data() { data() {
return { return {
methodColorMap: new Map(API_METHOD_COLOUR), methodColorMap: new Map(API_METHOD_COLOUR),
saveButtonText: this.$t('commons.save'),
} }
}, },
props: { props: {
@ -59,6 +60,7 @@ export default {
isReadOnly: Boolean, isReadOnly: Boolean,
useEnvironment: String, useEnvironment: String,
isCaseEdit: Boolean, isCaseEdit: Boolean,
buttonText: String,
condition: { condition: {
type: Object, type: Object,
default() { default() {
@ -78,6 +80,11 @@ export default {
beforeDestroy() { beforeDestroy() {
window.removeEventListener('keydown', this.keyDown) // window.removeEventListener('keydown', this.keyDown) //
}, },
created() {
if (this.buttonText) {
this.saveButtonText = this.buttonText;
}
},
methods: { methods: {
keyDown(e) { keyDown(e) {
if (!(e.keyCode === 83 && (e.ctrlKey || e.metaKey))) { if (!(e.keyCode === 83 && (e.ctrlKey || e.metaKey))) {

View File

@ -12,6 +12,7 @@
:project-id="projectId" :project-id="projectId"
:useEnvironment="environment" :useEnvironment="environment"
:is-case-edit="isCaseEdit" :is-case-edit="isCaseEdit"
:button-text="saveButtonText"
ref="header"/> ref="header"/>
</template> </template>
@ -68,6 +69,7 @@ export default {
type: Boolean, type: Boolean,
default: false default: false
}, },
saveButtonText:String,
refreshSign: String, refreshSign: String,
currentApi: { currentApi: {
type: Object type: Object

View File

@ -18,7 +18,9 @@
<el-dropdown-item command="save_as_api">{{ $t('api_test.definition.request.save_as') }}</el-dropdown-item> <el-dropdown-item command="save_as_api">{{ $t('api_test.definition.request.save_as') }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<el-button size="small" type="primary" v-else @click.once="stop" style="float: right;margin-right: 20px">{{ $t('report.stop_btn') }}</el-button> <el-button size="small" type="primary" v-else @click.once="stop" style="float: right;margin-right: 20px">
{{ $t('report.stop_btn') }}
</el-button>
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p> <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<div v-loading="loading"> <div v-loading="loading">
@ -35,6 +37,7 @@
<!-- 加载用例 --> <!-- 加载用例 -->
<ms-api-case-list @apiCaseClose="apiCaseClose" @refresh="refresh" @selectTestCase="selectTestCase" :currentApi="api" <ms-api-case-list @apiCaseClose="apiCaseClose" @refresh="refresh" @selectTestCase="selectTestCase" :currentApi="api"
:loaded="loaded" :refreshSign="refreshSign" :createCase="createCase" :loaded="loaded" :refreshSign="refreshSign" :createCase="createCase"
:save-button-text="loadCaseConfirmButton"
ref="caseList"/> ref="caseList"/>
<!-- 环境 --> <!-- 环境 -->
@ -77,6 +80,7 @@ export default {
loaded: false, loaded: false,
loading: false, loading: false,
currentRequest: {}, currentRequest: {},
loadCaseConfirmButton: this.$t("commons.confirm"),
createCase: "", createCase: "",
refreshSign: "", refreshSign: "",
responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []}, responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []},

View File

@ -78,6 +78,7 @@
:refreshSign="refreshSign" :refreshSign="refreshSign"
:createCase="createCase" :createCase="createCase"
:currentApi="api" :currentApi="api"
:save-button-text="loadCaseConfirmButton"
ref="caseList"/> ref="caseList"/>
<!-- 执行组件 --> <!-- 执行组件 -->
@ -118,6 +119,7 @@ export default {
createCase: "", createCase: "",
currentRequest: {}, currentRequest: {},
refreshSign: "", refreshSign: "",
loadCaseConfirmButton:this.$t("commons.confirm"),
responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []}, responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []},
reqOptions: REQ_METHOD, reqOptions: REQ_METHOD,
rules: { rules: {

View File

@ -8,33 +8,36 @@
<!-- 操作按钮 --> <!-- 操作按钮 -->
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')" <el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand('add')"
@command="handleCommand" size="small" style="float: right;margin-right: 20px" v-if="!runLoading"> @command="handleCommand" size="small" style="float: right;margin-right: 20px" v-if="!runLoading">
{{$t('commons.test')}} {{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="load_case">{{$t('api_test.definition.request.load_case')}} <el-dropdown-item command="load_case">{{ $t('api_test.definition.request.load_case') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="save_as_case">{{$t('api_test.definition.request.save_as_case')}} <el-dropdown-item command="save_as_case">{{ $t('api_test.definition.request.save_as_case') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="update_api">{{$t('api_test.definition.request.update_api')}}</el-dropdown-item> <el-dropdown-item command="update_api">{{ $t('api_test.definition.request.update_api') }}</el-dropdown-item>
<el-dropdown-item command="save_as_api">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item> <el-dropdown-item command="save_as_api">{{ $t('api_test.definition.request.save_as') }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<el-button size="small" type="primary" v-else @click.once="stop" style="float: right;margin-right: 20px">{{ $t('report.stop_btn') }}</el-button> <el-button size="small" type="primary" v-else @click.once="stop" style="float: right;margin-right: 20px">
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p> {{ $t('report.stop_btn') }}
</el-button>
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<div v-loading="loading"> <div v-loading="loading">
<!-- TCP 请求参数 --> <!-- TCP 请求参数 -->
<ms-basis-parameters :request="api.request" @callback="runTest" ref="requestForm" :response="responseData"/> <ms-basis-parameters :request="api.request" @callback="runTest" ref="requestForm" :response="responseData"/>
<!--返回结果--> <!--返回结果-->
<!-- HTTP 请求返回数据 --> <!-- HTTP 请求返回数据 -->
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p> <p class="tip">{{ $t('api_test.definition.request.res_param') }} </p>
<ms-request-result-tail :response="responseData" :currentProtocol="currentProtocol" ref="runResult"/> <ms-request-result-tail :response="responseData" :currentProtocol="currentProtocol" ref="runResult"/>
</div> </div>
</el-card> </el-card>
<!-- 加载用例 --> <!-- 加载用例 -->
<ms-api-case-list @apiCaseClose="apiCaseClose" @refresh="refresh" @selectTestCase="selectTestCase" :currentApi="api" :refreshSign="refreshSign" <ms-api-case-list @apiCaseClose="apiCaseClose" @refresh="refresh" @selectTestCase="selectTestCase" :currentApi="api"
:loaded="loaded" :createCase="createCase" :refreshSign="refreshSign"
:loaded="loaded" :createCase="createCase" :save-button-text="loadCaseConfirmButton"
ref="caseList"/> ref="caseList"/>
<!-- 环境 --> <!-- 环境 -->
@ -72,6 +75,7 @@ export default {
}, },
data() { data() {
return { return {
loadCaseConfirmButton: this.$t("commons.confirm"),
visible: false, visible: false,
api: {}, api: {},
loaded: false, loaded: false,
@ -93,7 +97,7 @@ export default {
versionEnable: false, versionEnable: false,
} }
}, },
props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String}, props: {apiData: {}, currentProtocol: String, syncTabs: Array, projectId: String},
methods: { methods: {
handleCommand(e) { handleCommand(e) {
switch (e) { switch (e) {
@ -109,10 +113,10 @@ export default {
return this.$refs['requestForm'].validate(); return this.$refs['requestForm'].validate();
} }
}, },
refresh(){ refresh() {
this.$emit('refresh'); this.$emit('refresh');
}, },
errorRefresh(){ errorRefresh() {
this.loading = false; this.loading = false;
this.runLoading = false; this.runLoading = false;
}, },
@ -293,11 +297,11 @@ export default {
this.getResult(); this.getResult();
this.checkVersionEnable(); this.checkVersionEnable();
} }
} }
</script> </script>
<style scoped> <style scoped>
/deep/ .el-drawer { /deep/ .el-drawer {
overflow: auto; overflow: auto;
} }
</style> </style>

View File

@ -62,6 +62,7 @@
<ms-api-case-list @apiCaseClose="apiCaseClose" @refresh="refresh" @selectTestCase="selectTestCase" :currentApi="api" <ms-api-case-list @apiCaseClose="apiCaseClose" @refresh="refresh" @selectTestCase="selectTestCase" :currentApi="api"
:refreshSign="refreshSign" :refreshSign="refreshSign"
:loaded="loaded" :createCase="createCase" :loaded="loaded" :createCase="createCase"
:save-button-text="loadCaseConfirmButton"
ref="caseList"/> ref="caseList"/>
<!-- 执行组件 --> <!-- 执行组件 -->
@ -103,6 +104,7 @@ export default {
}, },
data() { data() {
return { return {
loadCaseConfirmButton: this.$t("commons.confirm"),
visible: false, visible: false,
api: {}, api: {},
loaded: false, loaded: false,