优化表单校验

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();
},
methods:{
validate(){
return new Promise((resolve, reject)=>{
this.$refs.districtForm.validate().then(res=>{
if(res)resolve(true);
else reject(false);
})
})
async validate(){
return await this.$refs.districtForm.validate();
},
//
async initProvinceAndCity() {

View File

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

View File

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