<template>
  <div class="dashboard-container">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
      <el-row>
        <el-col :span="8">
          <el-form-item label="监测点等级" prop="name">
            <el-select v-model="ruleForm.value" placeholder="请选择">
              <el-option v-for="item in levelOptions" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="开始时间" prop="name">
            <el-select v-model="ruleForm.value" placeholder="请选择">
              <el-option v-for="item in startOptions" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">

          <el-form-item label="结束时间">
            <el-select v-model="ruleForm.value1" placeholder="请选择">
              <el-option v-for="item in startOptions" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-form-item>
        <el-button type="primary"  @click="submitForm('ruleForm')">
          <i class="iconfont">&#xe681;</i>
          <span>增加</span>
        </el-button>
        <!-- <el-button  @click="resetForm('ruleForm')">关闭</el-button> -->
        <el-button type="primary"  @click="resetForm('ruleForm')" :disabled="false">
          <i class="iconfont">
            &#xe688;
          </i>
          <span>
            取消
          </span>
        </el-button>
      </el-form-item>
    </el-form>

  </div>
</template>
<script>
export default {
  data() {
    return {
      levelOptions: [{
        value: '1',
        label: '一级监测点'
      }, {
        value: '2',
        label: '二级监测点'
      }, {
        value: '3',
        label: '三级监测点'
      }],
      startOptions: [{
        value: '1',
        label: '周一'
      }, {
        value: '2',
        label: '周二'
      }, {
        value: '3',
        label: '周三'
      }, {
        value: '3',
        label: '周四'
      }, {
        value: '3',
        label: '周五'
      }],
      ruleForm: {

      },
      rules: {
        name: [
          { required: true, message: '指标标准名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        region: [
          { required: true, message: '请输入显示顺序', trigger: 'blur' }
        ]
      }
    };
  },
  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();
      this.$router.go(-1)
    }
  }
}
</script>

