refactor(接口测试): 优化接口定义编辑页面模块的校验

--bug=1014477 --user=王孝刚 【接口测试】TEST-另存为新接口,第一次不选择模块保存后,提示信息不会消失
https://www.tapd.cn/55049933/s/1192849
This commit is contained in:
wxg0103 2022-07-01 13:41:25 +08:00 committed by f2c-ci-robot[bot]
parent 056558a871
commit 725be95ca7
3 changed files with 25 additions and 4 deletions

View File

@ -131,6 +131,13 @@
}, },
data() { data() {
let validateModuleId = (rule, value, callback) => {
if (this.basicForm.moduleId.length === 0 || !this.basicForm.moduleId) {
callback(this.$t('test_track.case.input_module'));
} else {
callback();
}
};
return { return {
basicForm: {}, basicForm: {},
httpVisible: false, httpVisible: false,
@ -147,7 +154,7 @@
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'} {max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
], ],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}], userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
moduleId: [{required: true, message: this.$t('test_track.case.input_module'), trigger: 'change'}], moduleId: [{required: true, validator: validateModuleId, trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}], status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
}, },
value: API_STATUS[0].id, value: API_STATUS[0].id,

View File

@ -70,7 +70,7 @@
<el-col :span="8"> <el-col :span="8">
<el-form-item :label="$t('test_track.module.module')" prop="moduleId"> <el-form-item :label="$t('test_track.module.module')" prop="moduleId">
<ms-select-tree size="small" :data="moduleOptions" :defaultKey="httpForm.moduleId" @getValue="setModule" <ms-select-tree size="small" :data="moduleOptions" :defaultKey="httpForm.moduleId" @getValue="setModule"
:obj="moduleObj" clearable checkStrictly/> :obj="moduleObj" clearable checkStrictly ref="msTree"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -226,6 +226,13 @@ export default {
} }
callback(); callback();
}; };
let validateModuleId = (rule, value, callback) => {
if (this.httpForm.moduleId.length === 0 || !this.httpForm.moduleId) {
callback(this.$t('test_track.case.input_module'));
} else {
callback();
}
};
return { return {
rule: { rule: {
name: [ name: [
@ -237,7 +244,7 @@ export default {
trigger: 'blur' trigger: 'blur'
}], }],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}], userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
moduleId: [{required: true, message: this.$t('test_track.case.input_module'), trigger: 'change'}], moduleId: [{required: true, validator: validateModuleId, trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}], status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
}, },
httpForm: {environmentId: "", path: "", tags: []}, httpForm: {environmentId: "", path: "", tags: []},

View File

@ -96,6 +96,13 @@
}); });
}, },
data() { data() {
let validateModuleId = (rule, value, callback) => {
if (this.basicForm.moduleId.length === 0 || !this.basicForm.moduleId) {
callback(this.$t('test_track.case.input_module'));
} else {
callback();
}
};
return { return {
basicForm: {}, basicForm: {},
httpVisible: false, httpVisible: false,
@ -108,7 +115,7 @@
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'} {max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
], ],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}], userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
moduleId: [{required: true, message: this.$t('test_track.case.input_module'), trigger: 'change'}], moduleId: [{required: true, validator: validateModuleId, trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}], status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
}, },
value: API_STATUS[0].id, value: API_STATUS[0].id,