<template>
  <div class="el-query-box">
    <el-form :model="ruleForm" :inline="true" status-icon ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="密码" prop="pass">
        <el-input type="password" v-model="ruleForm.pass" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="确认密码" prop="checkPass">
        <el-input type="password" v-model="ruleForm.checkPass" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="年龄" prop="age">
        <el-input v-model.number="ruleForm.age"></el-input>
      </el-form-item>
      {{testRender()}}
      <div class="el-query-box--button-wrap">
        <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </div>
    </el-form>
  </div>
</template>

<script>
import ElButton from 'element-ui-for-gov/packages/button';
import ELForm from 'element-ui-for-gov/packages/form/src/form';
import ElFormItem from 'element-ui-for-gov/packages/form-item';
import ElInput from 'element-ui-for-gov/packages/input';

export default {
  name: 'QueryBox',
  props: {
    test: Object
  },
  components: {
    ElButton,
    ELForm,
    ElFormItem,
    ElInput
  },
  data() {
    return {
      ruleForm: {
        pass: '',
        checkPass: '',
        age: ''
      }
    };
  },
  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();
    },
    testRender() {
      return <ElButton>222</ElButton>;
    }
  }
};
</script>
