diff --git a/src/views/System/dataDictionary.vue b/src/views/System/dataDictionary.vue index b1d41cc..2ce7d25 100644 --- a/src/views/System/dataDictionary.vue +++ b/src/views/System/dataDictionary.vue @@ -163,6 +163,16 @@ export default { this.q.pageNo = val this.sysUserList() }, + checkUserForm () { + if (!this.form.dicCode) { + return this.$message.warning('请检查数据字典编码') && false + } + if (!this.form.dicName) { + return this.$message.warning('请检查数据字典名称') && false + } + + return true + }, // 新增 add () { @@ -200,8 +210,8 @@ export default { }, // 新增用户 sysUserAddUser () { - this.$refs.dicRef.validate(v=>{ - if(v){ + if(this.checkUserForm()){ + if(this.mode=='add'){ this.$api.dictionary.addDic(this.form).then((res)=>{ this.$message.success("新增成功") @@ -213,12 +223,8 @@ export default { this.sysUserList() }) } - this.dialogUser = false - }else{ - this.$message.warning("请检查表单") } - }) }, // 编辑查看用户 diff --git a/src/views/System/dictionaryDetail.vue b/src/views/System/dictionaryDetail.vue index 1c9b4b3..374ed4b 100644 --- a/src/views/System/dictionaryDetail.vue +++ b/src/views/System/dictionaryDetail.vue @@ -73,19 +73,19 @@
- + - + - + - + @@ -163,8 +163,8 @@ export default { this.dialogUser = true }, sysUserAddUser(){ - this.$refs.addForm.validate(v=>{ - if(v){ + + if( this.checkUserForm()){ if(this.mode=='add'){ this.$api.dictionary.addItemDic(this.form).then((res)=>{ this.$message.success("新增成功") @@ -178,13 +178,22 @@ export default { } this.dialogUser = false - }else{ - this.$message.warning("请检查表单") } - }) + }, + checkUserForm () { + if (!this.form.itemName) { + return this.$message.warning('请检查选项') && false + } + if (!this.form.itemValue) { + return this.$message.warning('请检查选项值') && false + } + if (this.form.itemOrder && !(/^[0-9]*$/.test(this.form.itemOrder))) { + return this.$message.warning('请检查排序') && false + } + return true }, // 新增 add () {