fix(接口定义): 测试接口时不更新原接口数据
This commit is contained in:
parent
0d278cf20b
commit
deac357040
|
@ -57,7 +57,7 @@
|
|||
|
||||
<!-- 添加/编辑测试窗口-->
|
||||
<div v-else-if="item.type=== 'ADD'" class="ms-api-div">
|
||||
<ms-api-config @runTest="runTest" @saveApi="saveApi" @createRootModel="createRootModel" ref="apiConfig"
|
||||
<ms-api-config :syncTabs="syncTabs" @runTest="runTest" @saveApi="saveApi" @createRootModel="createRootModel" ref="apiConfig"
|
||||
:current-api="item.api"
|
||||
:currentProtocol="currentProtocol"
|
||||
:moduleOptions="moduleOptions"/>
|
||||
|
@ -76,13 +76,13 @@
|
|||
|
||||
<!-- 测试-->
|
||||
<div v-else-if="item.type=== 'TEST'" class="ms-api-div">
|
||||
<ms-run-test-http-page :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
<ms-run-test-http-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
@refresh="refresh" v-if="currentProtocol==='HTTP'"/>
|
||||
<ms-run-test-tcp-page :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
<ms-run-test-tcp-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
@refresh="refresh" v-if="currentProtocol==='TCP'"/>
|
||||
<ms-run-test-sql-page :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
<ms-run-test-sql-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
@refresh="refresh" v-if="currentProtocol==='SQL'"/>
|
||||
<ms-run-test-dubbo-page :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
<ms-run-test-dubbo-page :syncTabs="syncTabs" :currentProtocol="currentProtocol" :api-data="item.api" @saveAsApi="editApi"
|
||||
@refresh="refresh" v-if="currentProtocol==='DUBBO'"/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
@ -184,7 +184,8 @@
|
|||
type: "list",
|
||||
closable: false
|
||||
}],
|
||||
isApiListEnable: true
|
||||
isApiListEnable: true,
|
||||
syncTabs: [],
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
<div class="card-container">
|
||||
<!-- HTTP 请求参数 -->
|
||||
<ms-edit-complete-http-api @runTest="runTest" @saveApi="saveApi" @createRootModelInTree="createRootModelInTree" :request="request" :response="response"
|
||||
:basisData="currentApi" :moduleOptions="moduleOptions" v-if="currentProtocol === 'HTTP'"/>
|
||||
:basisData="currentApi" :moduleOptions="moduleOptions" :syncTabs="syncTabs" v-if="currentProtocol === 'HTTP'"/>
|
||||
<!-- TCP -->
|
||||
<ms-edit-complete-tcp-api :request="request" @runTest="runTest" @createRootModelInTree="createRootModelInTree" @saveApi="saveApi" :basisData="currentApi"
|
||||
:moduleOptions="moduleOptions" v-if="currentProtocol === 'TCP'"/>
|
||||
:moduleOptions="moduleOptions" :syncTabs="syncTabs" v-if="currentProtocol === 'TCP'"/>
|
||||
<!--DUBBO-->
|
||||
<ms-edit-complete-dubbo-api :request="request" @runTest="runTest" @createRootModelInTree="createRootModelInTree" @saveApi="saveApi" :basisData="currentApi"
|
||||
:moduleOptions="moduleOptions" v-if="currentProtocol === 'DUBBO'"/>
|
||||
:moduleOptions="moduleOptions" :syncTabs="syncTabs" v-if="currentProtocol === 'DUBBO'"/>
|
||||
<!--SQL-->
|
||||
<ms-edit-complete-sql-api :request="request" @runTest="runTest" @createRootModelInTree="createRootModelInTree" @saveApi="saveApi" :basisData="currentApi"
|
||||
:moduleOptions="moduleOptions" v-if="currentProtocol === 'SQL'"/>
|
||||
:moduleOptions="moduleOptions" :syncTabs="syncTabs" v-if="currentProtocol === 'SQL'"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
|||
currentApi: {},
|
||||
moduleOptions: {},
|
||||
currentProtocol: String,
|
||||
syncTabs: Array,
|
||||
},
|
||||
created() {
|
||||
this.projectId = getCurrentProjectID();
|
||||
|
@ -75,7 +76,7 @@
|
|||
this.$emit('runTest', data);
|
||||
})
|
||||
},
|
||||
createRootModelInTree(){
|
||||
createRootModelInTree() {
|
||||
this.$emit("createRootModel");
|
||||
},
|
||||
getMaintainerOptions() {
|
||||
|
|
|
@ -44,8 +44,30 @@
|
|||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
syncTabs: Array,
|
||||
},
|
||||
watch: {
|
||||
syncTabs() {
|
||||
if (this.basisData && this.syncTabs && this.syncTabs.includes(this.basisData.id)) {
|
||||
// 标示接口在其他地方更新过,当前页面需要同步
|
||||
let url = "/api/definition/get/";
|
||||
this.$get(url + this.basisData.id, response => {
|
||||
if (response.data) {
|
||||
let request = JSON.parse(response.data.request);
|
||||
let index = this.syncTabs.findIndex(item => {
|
||||
if (item === this.basisData.id) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
this.syncTabs.splice(index, 1);
|
||||
Object.assign(this.request, request);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {validated: false}
|
||||
},
|
||||
|
|
|
@ -149,7 +149,29 @@
|
|||
options: API_STATUS,
|
||||
}
|
||||
},
|
||||
props: {moduleOptions: {}, request: {}, response: {}, basisData: {}},
|
||||
props: {moduleOptions: {}, request: {}, response: {}, basisData: {}, syncTabs: Array},
|
||||
watch: {
|
||||
syncTabs() {
|
||||
if (this.basisData && this.syncTabs && this.syncTabs.includes(this.basisData.id)) {
|
||||
// 标示接口在其他地方更新过,当前页面需要同步
|
||||
let url = "/api/definition/get/";
|
||||
this.$get(url + this.basisData.id, response => {
|
||||
if (response.data) {
|
||||
let request = JSON.parse(response.data.request);
|
||||
let index = this.syncTabs.findIndex(item => {
|
||||
if (item === this.basisData.id) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
this.syncTabs.splice(index, 1);
|
||||
this.httpForm.path = response.data.path;
|
||||
this.httpForm.method = response.data.method;
|
||||
Object.assign(this.request, request);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
runTest() {
|
||||
this.$refs['httpForm'].validate((valid) => {
|
||||
|
|
|
@ -43,9 +43,29 @@ export default {
|
|||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
syncTabs:{},
|
||||
},
|
||||
watch: {
|
||||
syncTabs() {
|
||||
if (this.basisData && this.syncTabs && this.syncTabs.includes(this.basisData.id)) {
|
||||
// 标示接口在其他地方更新过,当前页面需要同步
|
||||
let url = "/api/definition/get/";
|
||||
this.$get(url + this.basisData.id, response => {
|
||||
if (response.data) {
|
||||
let request = JSON.parse(response.data.request);
|
||||
let index = this.syncTabs.findIndex(item => {
|
||||
if (item === this.basisData.id) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
this.syncTabs.splice(index, 1);
|
||||
Object.assign(this.request, request);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {validated: false}
|
||||
},
|
||||
|
|
|
@ -42,14 +42,34 @@ export default {
|
|||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
syncTabs:Array,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
validated: false,
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
syncTabs() {
|
||||
if (this.basisData && this.syncTabs && this.syncTabs.includes(this.basisData.id)) {
|
||||
// 标示接口在其他地方更新过,当前页面需要同步
|
||||
let url = "/api/definition/get/";
|
||||
this.$get(url + this.basisData.id, response => {
|
||||
if (response.data) {
|
||||
let request = JSON.parse(response.data.request);
|
||||
let index = this.syncTabs.findIndex(item => {
|
||||
if (item === this.basisData.id) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
this.syncTabs.splice(index, 1);
|
||||
Object.assign(this.request, request);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
callback() {
|
||||
this.validated = true;
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
reportId: "",
|
||||
}
|
||||
},
|
||||
props: {apiData: {}, currentProtocol: String,},
|
||||
props: {apiData: {}, currentProtocol: String,syncTabs: Array},
|
||||
methods: {
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
|
@ -173,6 +173,9 @@
|
|||
let bodyFiles = this.getBodyUploadFiles();
|
||||
this.$fileUpload(url, null, bodyFiles, this.api, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
if (this.syncTabs.indexOf(this.api.id) === -1) {
|
||||
this.syncTabs.push(this.api.id);
|
||||
}
|
||||
this.$emit('saveApi', this.api);
|
||||
});
|
||||
},
|
||||
|
@ -228,7 +231,8 @@
|
|||
}
|
||||
},
|
||||
created() {
|
||||
this.api = this.apiData;
|
||||
// 深度复制
|
||||
this.api = JSON.parse(JSON.stringify(this.apiData));
|
||||
this.api.protocol = this.currentProtocol;
|
||||
this.currentRequest = this.api.request;
|
||||
this.getEnvironments();
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
projectId: "",
|
||||
}
|
||||
},
|
||||
props: {apiData: {}, currentProtocol: String,},
|
||||
props: {apiData: {}, currentProtocol: String, syncTabs: Array},
|
||||
methods: {
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
|
@ -205,6 +205,9 @@
|
|||
this.$fileUpload(url, null, bodyFiles, this.api, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.$emit('saveApi', this.api);
|
||||
if (this.syncTabs.indexOf(this.api.id) === -1) {
|
||||
this.syncTabs.push(this.api.id);
|
||||
}
|
||||
});
|
||||
},
|
||||
selectTestCase(item) {
|
||||
|
@ -230,7 +233,8 @@
|
|||
},
|
||||
created() {
|
||||
this.projectId = getCurrentProjectID();
|
||||
this.api = this.apiData;
|
||||
// 深度复制
|
||||
this.api = JSON.parse(JSON.stringify(this.apiData));
|
||||
this.api.protocol = this.currentProtocol;
|
||||
this.currentRequest = this.api.request;
|
||||
this.getResult();
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
reportId: "",
|
||||
}
|
||||
},
|
||||
props: {apiData: {}, currentProtocol: String,},
|
||||
props: {apiData: {}, currentProtocol: String,syncTabs: Array},
|
||||
methods: {
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
|
@ -172,6 +172,9 @@
|
|||
let bodyFiles = this.getBodyUploadFiles();
|
||||
this.$fileUpload(url, null, bodyFiles, this.api, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
if (this.syncTabs.indexOf(this.api.id) === -1) {
|
||||
this.syncTabs.push(this.api.id);
|
||||
}
|
||||
this.$emit('saveApi', this.api);
|
||||
});
|
||||
},
|
||||
|
@ -227,7 +230,8 @@
|
|||
}
|
||||
},
|
||||
created() {
|
||||
this.api = this.apiData;
|
||||
// 深度复制
|
||||
this.api = JSON.parse(JSON.stringify(this.apiData));
|
||||
this.api.protocol = this.currentProtocol;
|
||||
this.currentRequest = this.api.request;
|
||||
this.getEnvironments();
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
projectId: ""
|
||||
}
|
||||
},
|
||||
props: {apiData: {}, currentProtocol: String,},
|
||||
props: {apiData: {}, currentProtocol: String,syncTabs: Array},
|
||||
methods: {
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
|
@ -173,6 +173,9 @@
|
|||
let bodyFiles = this.getBodyUploadFiles();
|
||||
this.$fileUpload(url, null, bodyFiles, this.api, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
if (this.syncTabs.indexOf(this.api.id) === -1) {
|
||||
this.syncTabs.push(this.api.id);
|
||||
}
|
||||
this.$emit('saveApi', this.api);
|
||||
});
|
||||
},
|
||||
|
@ -194,7 +197,8 @@
|
|||
}
|
||||
},
|
||||
created() {
|
||||
this.api = this.apiData;
|
||||
// 深度复制
|
||||
this.api = JSON.parse(JSON.stringify(this.apiData));
|
||||
this.api.protocol = this.currentProtocol;
|
||||
this.currentRequest = this.api.request;
|
||||
this.projectId = getCurrentProjectID();
|
||||
|
|
Loading…
Reference in New Issue