<template>
    <div>
        <div class="basic-info-title">
            <img src="@/assets/enterpriseLibrary/legalperson.png" alt="法人信息">
            <span>法人信息</span>
        </div>
        <el-form :model="form" :rules="rules" ref="legalPersonForm" label-width="110px" label-position="top">
            <!-- 身份证人像面 -->
            <el-form-item label="身份证人像面" prop="fileList">
                <UploadFile :fileList="form.fileList" />
            </el-form-item>
            <!-- 身份证国徽面 -->
            <el-form-item label="身份证国徽面" prop="fileList2">
                <UploadFile :fileList="form.fileList2" />
            </el-form-item>
            <el-form-item label="法人姓名" prop="legalPersonName">
                <el-input v-model="form.legalPersonName" placeholder="自动提取"></el-input>
            </el-form-item>
            <el-form-item label="法人身份证号" prop="legalPersonIdCard">
                <el-input v-model="form.legalPersonIdCard" placeholder="自动提取"></el-input>
            </el-form-item>
            <el-form-item label="身份证有效期" prop="idCardStartDate">
                <el-input v-model="form.idCardStartDate" placeholder="自动提取"></el-input>
            </el-form-item>
            <el-form-item label="法人职务" prop="legalPersonPosition">
                <el-input v-model="form.legalPersonPosition" placeholder="请输入法人职务"></el-input>
            </el-form-item>
            <el-form-item label="法人联系方式" prop="legalPersonPhone">
                <el-input v-model="form.legalPersonPhone" placeholder="请输入法人联系方式"></el-input>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
import UploadFile from '@/views/common/UploadFile.vue'
export default {
    name: 'LegalPerson',
    components: { UploadFile },
    data() {
        return {
            form: {
                legalPersonName: '',
                legalPersonIdCard: '',
                idCardStartDate: '',
                legalPersonPosition: '',
                legalPersonPhone: '',
                fileList: [],
                fileList2: [],
            },
            rules: {
                fileList: [
                    { required: true, message: '请上传身份证人像面', trigger: 'blur' }
                ],
                fileList2: [
                    { required: true, message: '请上传身份证国徽面', trigger: 'blur' }
                ],
                legalPersonName: [
                    { required: true, message: '请输入法人姓名', trigger: 'blur' }
                ],
                legalPersonIdCard: [
                    { required: true, message: '请输入法人身份证号', trigger: 'blur' }
                ],
                idCardStartDate: [
                    { required: true, message: '请输入身份证有效期', trigger: 'blur' }
                ],

            }
        }
    },
    methods: {
        // 校验规则
        validate() {
            return new Promise((resolve, reject) => {
                this.$refs.legalPersonForm.validate((valid) => {
                    if (valid) {
                        resolve(this.form) // 校验成功返回表单数据
                    } else {
                        reject(new Error('法人信息未填写完整'))
                    }
                })
            })
        },
    },
}
</script>

<style scoped lang="scss">
.basic-info-title {
    display: flex;
    align-items: center;
    margin: 10px 0;

    span {
        margin: 0 5px;
    }
}
</style>