fix(接口测试): API多次保存数据重复问题

--bug=1028246 --user=宋昌昌 【接口测试】api列表-操作-点击复制按钮-保存点击2次-生成数据接口数据重复 https://www.tapd.cn/55049933/s/1401924
This commit is contained in:
song-cc-rock 2023-08-09 10:39:54 +08:00 committed by 刘瑞斌
parent b52c642414
commit 3822c100ac
5 changed files with 28 additions and 5 deletions

View File

@ -362,7 +362,9 @@ export default {
if (data.response) { if (data.response) {
this.parseResponseStructureDefaultKeyValue(data.response); this.parseResponseStructureDefaultKeyValue(data.response);
} }
this.setProtocolBtn(true);
updateDefinition(this.reqUrl, null, bodyFiles, data).then((response) => { updateDefinition(this.reqUrl, null, bodyFiles, data).then((response) => {
this.setProtocolBtn(false);
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.reqUrl = '/api/definition/update'; this.reqUrl = '/api/definition/update';
this.currentApi.isCopy = false; this.currentApi.isCopy = false;
@ -379,6 +381,22 @@ export default {
this.responseCount = 0; this.responseCount = 0;
this.count = 0; this.count = 0;
}, },
setProtocolBtn(disable) {
switch (this.currentProtocol) {
case Request.TYPES.SQL:
this.$refs.sqlApi.disableSaveBtn = disable;
break;
case Request.TYPES.DUBBO:
this.$refs.dubboApi.disableSaveBtn = disable;
break;
case Request.TYPES.TCP:
this.$refs.tcpApi.disableSaveBtn = disable;
break;
default:
this.$refs.httpApi.disableSaveBtn = disable;
break;
}
},
parseResponseStructureDefaultKeyValue(response) { parseResponseStructureDefaultKeyValue(response) {
if (response.headers && response.headers.length === 1) { if (response.headers && response.headers.length === 1) {
let kv = response.headers[0]; let kv = response.headers[0];

View File

@ -46,7 +46,7 @@
@checkout="checkout" @checkout="checkout"
@create="create" @create="create"
@del="del"/> @del="del"/>
<el-button type="primary" size="small" @click="saveApi" v-prevent-re-click title="ctrl + s" <el-button type="primary" size="small" @click="saveApi" :disabled="disableSaveBtn" v-prevent-re-click title="ctrl + s"
v-permission="[ v-permission="[
'PROJECT_API_DEFINITION:READ+EDIT_API', 'PROJECT_API_DEFINITION:READ+EDIT_API',
'PROJECT_API_DEFINITION:READ+CREATE_API', 'PROJECT_API_DEFINITION:READ+CREATE_API',
@ -184,7 +184,8 @@ export default {
newResponse: {}, newResponse: {},
createNewVersionVisible: false, createNewVersionVisible: false,
latestVersionId: '', latestVersionId: '',
hasLatest: false hasLatest: false,
disableSaveBtn: false
}; };
}, },
methods: { methods: {

View File

@ -49,6 +49,7 @@
v-if="!isXpack || !apiSyncRuleRelation.showUpdateRule" v-if="!isXpack || !apiSyncRuleRelation.showUpdateRule"
type="primary" type="primary"
size="small" size="small"
:disabled="disableSaveBtn"
@click="saveApi" @click="saveApi"
v-prevent-re-click v-prevent-re-click
title="ctrl + s" title="ctrl + s"
@ -313,6 +314,7 @@ export default {
citedScenarioCount: 0, citedScenarioCount: 0,
latestVersionId: '', latestVersionId: '',
hasLatest: false, hasLatest: false,
disableSaveBtn: false,
}; };
}, },
props: { props: {

View File

@ -46,7 +46,7 @@
@create="create" @create="create"
@setLatest="setLatest" @setLatest="setLatest"
@del="del" /> @del="del" />
<el-button type="primary" size="small" @click="saveApi" title="ctrl + s" v-prevent-re-click <el-button type="primary" size="small" @click="saveApi" title="ctrl + s" :disabled="disableSaveBtn" v-prevent-re-click
v-permission="[ v-permission="[
'PROJECT_API_DEFINITION:READ+EDIT_API', 'PROJECT_API_DEFINITION:READ+EDIT_API',
'PROJECT_API_DEFINITION:READ+CREATE_API', 'PROJECT_API_DEFINITION:READ+CREATE_API',
@ -173,7 +173,8 @@ export default {
newResponse: {}, newResponse: {},
createNewVersionVisible: false, createNewVersionVisible: false,
latestVersionId: '', latestVersionId: '',
hasLatest: false hasLatest: false,
disableSaveBtn: false
}; };
}, },
created() { created() {

View File

@ -46,7 +46,7 @@
@create="create" @create="create"
@setLatest="setLatest" @setLatest="setLatest"
@del="del" /> @del="del" />
<el-button type="primary" size="small" @click="saveApi" title="ctrl + s" v-prevent-re-click <el-button type="primary" size="small" @click="saveApi" title="ctrl + s" :disabled="disableSaveBtn" v-prevent-re-click
v-permission="[ v-permission="[
'PROJECT_API_DEFINITION:READ+EDIT_API', 'PROJECT_API_DEFINITION:READ+EDIT_API',
'PROJECT_API_DEFINITION:READ+CREATE_API', 'PROJECT_API_DEFINITION:READ+CREATE_API',
@ -172,6 +172,7 @@ export default {
createNewVersionVisible: false, createNewVersionVisible: false,
latestVersionId: '', latestVersionId: '',
hasLatest: false, hasLatest: false,
disableSaveBtn: false
}; };
}, },
created: function () { created: function () {