fix(接口定义): 修复接口定义esb,sql保存失败的缺陷 (#17965)

--bug=1016832 --user=王孝刚 【接口测试】创建、编辑 TCP-ESB / SQL / DUBBO 接口报错
https://www.tapd.cn/55049933/s/1244488

Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
MeterSphere Bot 2022-09-19 10:25:17 +08:00 committed by GitHub
parent 2a710d365d
commit 9b8d5a8da1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 39 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div v-loading="isloading"> <div v-loading="isloading">
<el-form ref="apiForm" :model="basicForm" :rules="rules" class="case-form" label-position="right" <el-form ref="apiForm" :model="basicForm" :rules="rules" class="case-form" label-position="right"
label-width="100px" label-width="80px"
size="small" size="small"
style="margin-left: 5px;margin-right: 5px"> style="margin-left: 5px;margin-right: 5px">
<ms-form-divider :title="$t('test_track.plan_view.base_info')"/> <ms-form-divider :title="$t('test_track.plan_view.base_info')"/>
@ -64,10 +64,9 @@
size="small" type="textarea"/> size="small" type="textarea"/>
</el-form-item> </el-form-item>
</el-row> </el-row>
<!-- 自定义字段 --> <!-- 自定义字段 -->
<el-form v-if="isFormAlive" ref="customFieldForm" :model="customFieldForm" :rules="customFieldRules" <el-form v-if="isFormAlive" ref="customFieldForm" :model="customFieldForm" :rules="customFieldRules"
class="case-form" label-position="right" label-width="100px" class="case-form" label-position="right" label-width="80px"
size="small"> size="small">
<custom-filed-form-row :default-open="defaultOpen" <custom-filed-form-row :default-open="defaultOpen"
:disabled="readOnly" :disabled="readOnly"

View File

@ -165,26 +165,18 @@ export default {
callback() { callback() {
this.validated = true; this.validated = true;
}, },
validateApi() {
this.validated = false;
this.basisData.method = this.request.protocol;
this.$refs['basicForm'].validate();
},
saveApi() { saveApi() {
this.validateApi(); this.basisData.request = this.request;
if (this.validated) { if (this.basisData.tags instanceof Array) {
this.basisData.request = this.request; this.basisData.tags = JSON.stringify(this.basisData.tags);
if (this.basisData.tags instanceof Array) {
this.basisData.tags = JSON.stringify(this.basisData.tags);
}
this.$emit('saveApi', this.basisData);
this.$store.state.apiStatus.set("fromChange", false);
this.$store.state.apiMap.set(this.basisData.id, this.$store.state.apiStatus);
} else {
if (this.$refs.versionHistory) {
this.$refs.versionHistory.loading = false;
}
} }
this.$emit('saveApi', this.basisData);
this.$store.state.apiStatus.set("fromChange", false);
this.$store.state.apiMap.set(this.basisData.id, this.$store.state.apiStatus);
if (this.$refs.versionHistory) {
this.$refs.versionHistory.loading = false;
}
}, },
runTest() { runTest() {
this.validateApi(); this.validateApi();

View File

@ -172,24 +172,16 @@ export default {
callback() { callback() {
this.validated = true; this.validated = true;
}, },
validateApi() {
this.validated = false;
this.$refs['basicForm'].validate();
},
saveApi() { saveApi() {
this.validateApi(); this.basisData.method = this.basisData.protocol;
if (this.validated) { if (this.basisData.tags instanceof Array) {
this.basisData.method = this.basisData.protocol; this.basisData.tags = JSON.stringify(this.basisData.tags);
if (this.basisData.tags instanceof Array) { }
this.basisData.tags = JSON.stringify(this.basisData.tags); this.$emit('saveApi', this.basisData);
} this.$store.state.apiStatus.set("fromChange", false);
this.$emit('saveApi', this.basisData); this.$store.state.apiMap.set(this.basisData.id, this.$store.state.apiStatus);
this.$store.state.apiStatus.set("fromChange", false); if (this.$refs.versionHistory) {
this.$store.state.apiMap.set(this.basisData.id, this.$store.state.apiStatus); this.$refs.versionHistory.loading = false;
} else {
if (this.$refs.versionHistory) {
this.$refs.versionHistory.loading = false;
}
} }
}, },
runTest() { runTest() {

View File

@ -215,12 +215,49 @@ export default {
callback() { callback() {
this.validated = true; this.validated = true;
}, },
refreshEsbDataStruct(esbDataStruct) {
if (esbDataStruct && esbDataStruct.length > 0) {
esbDataStruct.forEach(row => {
row.status = "";
if (row.children == null || row.children.length === 0) {
row.children = [];
} else if (row.children.length > 0) {
this.refreshEsbDataStruct(row.children);
}
});
}
},
checkEsbDataStructData(esbDataStruct) {
let allCheckResult = true;
if (esbDataStruct && esbDataStruct.length > 0) {
for (let i = 0; i < esbDataStruct.length; i++) {
let row = esbDataStruct[i];
allCheckResult = this.$refs.esbTable.validateRowData(row);
if (allCheckResult) {
if (row.children != null && row.children.length > 0) {
allCheckResult = this.checkEsbDataStructData(row.children);
if (!allCheckResult) {
return false;
}
}
} else {
return false;
}
}
}
return allCheckResult;
},
validateEsbDataStruct(esbDataStruct) {
this.refreshEsbDataStruct(esbDataStruct);
const result = this.checkEsbDataStructData(esbDataStruct);
return result;
},
saveApi() { saveApi() {
if (this.basisData.tags instanceof Array) { if (this.basisData.tags instanceof Array) {
this.basisData.tags = JSON.stringify(this.basisData.tags); this.basisData.tags = JSON.stringify(this.basisData.tags);
} }
if (this.basisData.method == 'ESB') { if (this.basisData.method == 'ESB') {
let validataResult = this.$refs.esbDefinition.validateEsbDataStruct(this.request.esbDataStruct); let validataResult = this.validateEsbDataStruct(this.request.esbDataStruct);
if (!validataResult) { if (!validataResult) {
return; return;
} }