<template>
  <div id="check-1">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="one">
          <el-form ref="form" :model="form" :rules="rules" label-width="130px">
            <el-col :span="24">
              <el-form-item label="保安员证编码" prop="baoan_num">
                <el-input v-model="form.baoan_num" readonly></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="保安员姓名" prop="name">
                <el-input v-model="form.name" readonly></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="公民身份证号" prop="card">
                <el-input v-model="form.card" readonly></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="保安员等级" prop="exam_grade">
                <el-input v-model="form.exam_grade" readonly></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="打印公安机关名称" prop="cert_police">
                <el-input v-model="form.cert_police" readonly></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="申领原因" prop="receive_reason">
                <el-input v-model="form.receive_reason" type="textarea" rows="2" placeholder="请输入申领原因"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="打印人" prop="print_personal">
                <el-input v-model="form.print_personal" placeholder="请输入打印人"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="打印时间" prop="print_date">
                <el-date-picker v-model="form.print_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="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="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="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="close">取消保存</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: {
        baoan_num: [{ required: false, message: '请输入', trigger: 'blur' }],
        name: [{ required: false, message: '请输入', trigger: 'blur' }],
        card: [{ required: false, message: '请输入', trigger: 'blur' }],
        exam_grade: [{ required: false, message: '请输入', trigger: 'blur' }],
        cert_police: [{ required: false, message: '请输入', trigger: 'blur' }],
        receive_reason: [{ required: true, message: '请输入申领原因', trigger: 'blur' }],
        print_personal: [{ required: true, message: '请输入打印人', trigger: 'blur' }],
        print_date: [{ required: true, message: '请选择', trigger: 'change' }],
        receive_date: [{ required: true, message: '请选择', trigger: 'change' }],
        receive_name: [{ required: true, message: '请输入领取姓名', trigger: 'blur' }],
        receive_card: [{ required: true, message: '请输入领取人身份证号', trigger: 'blur' }],
        receive_phone: [{ required: true, message: '请输入领取人联系电话', trigger: 'blur' }],
        register_personal: [{ required: true, message: '请输入登记人', trigger: 'blur' }],
        register_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>
