<template>
  <div id="form-1">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="one">
          <el-form :model="form" :rules="rules" ref="form" label-width="140px">
            <el-col :span="24">
              <el-form-item label="审核结果" prop="status">
                <el-select v-model="form.status" clearable placeholder="请选择">
                  <el-option label="待审中" value="0"></el-option>
                  <el-option label="通过" value="1"></el-option>
                  <el-option label="拒绝" value="2"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="审核意见" prop="resaon">
                <el-input v-model="form.resaon" type="textarea" rows="2" placeholder="请输入审核意见"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="审核人" prop="examine_prsonal">
                <el-input v-model="form.examine_prsonal" placeholder="请输入审核人"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="审核时间" prop="examine_date">
                <el-date-picker v-model="form.examine_date" placeholder="请选择" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date" style="width: 100%">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="24" class="btn">
              <el-button type="danger" size="small" @click="close('form')">取消提交</el-button>
              <el-button type="primary" size="small" @click="onSubmit('form')">提交保存</el-button>
            </el-col>
          </el-form>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'form-1',
  props: { form: { type: Object } },
  components: {},
  data: function () {
    return {
      rules: {
        status: [{ required: true, message: '请选择', trigger: 'change' }],
        resaon: [{ required: true, message: '请输入审核意见', trigger: 'blur' }],
        examine_prsonal: [{ required: true, message: '请输入审核人', trigger: 'blur' }],
        examine_date: [{ required: true, message: '请选择', trigger: 'change' }],
      },
    };
  },
  created() {},
  methods: {
    close() {
      this.$emit('close');
    },
    onSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('onSubmit', { data: this.form });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  .one {
    .btn {
      text-align: center;
    }
  }
}
</style>
