<template>
  <el-form ref="ruleForm" :model="ruleForm" label-width="100px" class="demo-ruleForm">
    <el-form-item label="问题1" prop="name">
      <el-input v-model="ruleForm.name" />
    </el-form-item>
    <el-form-item label="问题2" prop="region">
      <el-select v-model="ruleForm.region" placeholder="请选择">
        <el-option label="区域一" value="shanghai" />
        <el-option label="区域二" value="beijing" />
      </el-select>
    </el-form-item>
    <el-form-item label="问题3" required>
      <el-date-picker v-model="ruleForm.date1" type="date" placeholder="选择日期" style="width: 100%;" />
    </el-form-item>
    <el-form-item label="问题4" prop="delivery">
      <el-switch v-model="ruleForm.delivery" />
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
      <el-button @click="resetForm('ruleForm')">重置</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
export default {
  data() {
    return {
      ruleForm: {
        name: '',
        region: '',
        date1: '',
        delivery: false
      }

    }
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>
