fix(Mock自定义脚本): 修复创建/更新mock时必填项的检查失效问题

修复创建/更新mock时必填项的检查失效问题
This commit is contained in:
song-tianyang 2021-10-21 14:48:58 +08:00 committed by song-tianyang
parent 794c663502
commit 21331112db
2 changed files with 19 additions and 1 deletions

View File

@ -105,6 +105,12 @@ export default {
if (!this.response || !this.response || !this.response.headers) {
return;
}
if(!this.response.httpCode || this.response.httpCode === ''){
this.$set(this.response,"httpCode","200");
}
if(!this.response.delayed){
this.response.delayed = 0;
}
if (Object.prototype.toString.call(this.response).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object') {
this.response = JSON.parse(this.response);
}

View File

@ -100,10 +100,10 @@ export default {
},
response: {
httpCode: "",
delayed: "",
httpHeads: [],
body: "",
responseResult:{
delayed: 0,
headers:[],
arguments:[],
rest:[],
@ -234,6 +234,18 @@ export default {
uploadMockExpectConfig(clearForm) {
let url = "/mockConfig/updateMockExpectConfig";
let param = this.mockExpectConfig;
if(!param.name || param.name === ''){
this.$error(this.$t('test_track.case.input_name'));
return false;
}else if(param.name.length > 100){
this.$error(this.$t('test_track.length_less_than')+100);
return false;
}
if(!param.response.responseResult.httpCode){
param.response.responseResult.httpCode = 200;
}
if(!param.request.params.id){
param.request.params.id = getUUID();
}