<template>
  <div id="check-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="170px">
            <el-col :span="12">
              <el-form-item label="领取人姓名" prop="receive_name">
                <el-input v-model="form.receive_name" placeholder="请输入领取人姓名"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="领取人身份证号" prop="receive_card">
                <el-input v-model="form.receive_card" placeholder="请输入领取人身份证号"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="领取人联系电话" prop="receive_phone">
                <el-input v-model="form.receive_phone" placeholder="请输入领取人联系电话"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="领取时间" prop="receive_date">
                <el-date-picker v-model="form.receive_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="12">
              <el-form-item label="登记人" prop="register_personal">
                <el-input v-model="form.register_personal" placeholder="请输入登记人"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="登记时间" prop="register_date">
                <el-date-picker v-model="form.register_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="reseatBtn('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: 'check-1',
  props: { form: { type: Object } },
  components: {},
  data: function () {
    return {
      rules: {
        receive_name: [{ required: false, message: '请输入领取人姓名', trigger: 'blur' }],
        receive_card: [{ required: false, message: '请输入领取人身份证号', trigger: 'blur' }],
        receive_phone: [{ required: false, message: '请输入领取人联系电话', trigger: 'blur' }],
        receive_date: [{ required: false, message: '请选择', trigger: 'change' }],
        register_personal: [{ required: false, message: '请输入登记人', trigger: 'blur' }],
        register_date: [{ required: false, message: '请选择', trigger: 'change' }],
      },
    };
  },
  created() {},
  methods: {
    // 取消保存
    reseatBtn() {
      this.$emit('reseatBtn');
    },
    // 提交保存

    onSubmit(formName) {
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          this.$emit('onSubmit', 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>
