优化表单校验

This commit is contained in:
weipengfei 2023-07-29 14:14:48 +08:00
parent b6ea349217
commit 201fed4ae0
3 changed files with 7 additions and 17 deletions

View File

@ -101,13 +101,8 @@
this.initProvinceAndCity(); this.initProvinceAndCity();
}, },
methods:{ methods:{
validate(){ async validate(){
return new Promise((resolve, reject)=>{ return await this.$refs.districtForm.validate();
this.$refs.districtForm.validate().then(res=>{
if(res)resolve(true);
else reject(false);
})
})
}, },
// //
async initProvinceAndCity() { async initProvinceAndCity() {

View File

@ -138,13 +138,8 @@
} }
}, },
methods: { methods: {
validate() { async validate() {
return new Promise((resolve, reject) => { return this.$refs.residentsForm.validate();
this.$refs.residentsForm.validate().then(res => {
if (res) resolve(true);
else reject(false);
})
})
}, },
// //
changebirth_time(e) { changebirth_time(e) {

View File

@ -150,9 +150,9 @@
async addArchives() { async addArchives() {
Toast('开发中') Toast('开发中')
let flag = true; let flag = true;
// flag = await this.$refs.districtSelectorRef.validate(); flag = this.$refs.districtSelectorRef.validate();
// if(flag) flag = await this.$refs.residentsRef.validate(); if(flag) flag = this.$refs.residentsRef.validate();
if(flag) flag = await this.$refs.breedingRef.validate(); if(flag) flag = this.$refs.breedingRef.validate();
if(flag) this.$refs.archives.validate().then(async (e) => { if(flag) this.$refs.archives.validate().then(async (e) => {
if (e) { if (e) {
uni.showLoading() uni.showLoading()