elementui中手写form表单验证提交

80 阅读1分钟
 submit() {

      if (this.dataForm.subLineName == '') {
        this.$message({
          message: '请输入线路名称',
          showClose: true,
          duration: 2000,
          type: 'warn',
        })
        return false
      }
      
      
      if (this.dataForm.line_element_id == '') {
        this.$message({
          message: '请选择线路点',
          showClose: true,
          duration: 2000,
          type: 'warn',
        })
        return false
      }

      const options = {
        ...this.dataForm,
        points: this.selectedPoint.join(','),
      }
      
     
      this.$request('NEW_ROUTE', options)
        .then(res => {
          this.$message({
            message: `${this.modeName}成功`,
            showClose: true,
            duration: 2000,
            type: 'success',
          })
          this.$router.push(`/system/route`)
        })
        .catch(error => {
          this.$message({
            message: `${this.modeName}失败`,
            showClose: true,
            duration: 2000,
            type: 'error',
          })
        })
    }