v-for+多表单校验

38 阅读1分钟
    async emrForeSubmit() {
      let list = []
      const forms = ['firstTyperule', 'secondTyperule', 'thirdTyperule', 'forthTyperule']
      forms.map(form => {
        list.push(...this.validateForm(form))
      })
      Promise.all(list).then(async() => {
        const params = {
          diseaseCode: this.infectious1.slice(-1)[0] || "",
          ruleList: this.rulesList.map(p=>{
            return {
              ...p,
              id: undefined,
              value: undefined
            }
          }),
          warnUserIdList: this.selectchooseuser,
        }
        await emrForewarningRuleadd(params)   
      })
        .catch(() => {
          console.log("未通过")
        })
    },
    validateForm(formName) {
      const validateFormList = []
      for (let index = 0; index < this.$refs[formName].length  ; index++) {
        validateFormList.push(
          this.checkForm(formName,index),
        )
      }
      return validateFormList
    },
   checkForm(formName,i) {
      return this.$refs[formName][i].validate()
    },