<template>
    <div>
        <div class="basic-info-title">
            <img src="@/assets/enterpriseLibrary/basic-info.png" alt="基本信息">
            <span>基本信息</span>
        </div>
        <el-form :model="form" :rules="rules" ref="basicInfoForm" label-width="110px" label-position="top">
            <!-- 营业执照 -->
            <el-form-item label="营业执照" prop="fileList">
                <UploadFile :fileList="form.fileList" />
            </el-form-item>
            <el-form-item label="企业名称" prop="enterpriseName">
                <el-input v-model="form.enterpriseName" placeholder="自动提取"></el-input>
            </el-form-item>
            <el-form-item label="统一社会信用代码" prop="enterpriseCode">
                <el-input v-model="form.enterpriseCode" placeholder="自动提取"></el-input>
            </el-form-item>
            <el-form-item label="注册资本" prop="registeredCapital">
                <el-input v-model="form.registeredCapital" placeholder="自动提取"></el-input>
            </el-form-item>
            <el-form-item label="营业期限" prop="businessTerm">
                <el-input v-model="form.businessTerm" placeholder="自动提取"></el-input>
            </el-form-item>
            <el-form-item label="住所" prop="residence">
                <el-input v-model="form.residence" placeholder="自动提取"></el-input>
            </el-form-item>
            <el-form-item label="经营范围" prop="businessScope">
                <el-input v-model="form.businessScope" placeholder="自动提取"></el-input>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
import UploadFile from '@/views/common/UploadFile.vue'
export default {
    name: 'BasicInfo',
    components: {
        UploadFile
    },
    data() {
        return {
            form: {
                name: '',
                enterpriseName: '',
                enterpriseCode: '',
                registeredCapital: '',
                businessTerm: '',
                residence: '',
                businessScope: '',
                fileList: []
            },
            rules: {
                fileList: [
                    { required: true, message: '请上传营业执照', trigger: 'blur' }
                ],
                enterpriseName: [
                    { required: true, message: '请输入企业名称', trigger: 'blur' }
                ],
                enterpriseCode: [
                    { required: true, message: '请输入统一社会信用代码', trigger: 'blur' }
                ],
                registeredCapital: [
                    { required: true, message: '请输入注册资本', trigger: 'blur' }
                ],
                businessTerm: [
                    { required: true, message: '请输入营业期限', trigger: 'blur' }
                ],
                residence: [
                    { required: true, message: '请输入住所', trigger: 'blur' }
                ],
                businessScope: [
                    { required: true, message: '请输入经营范围', trigger: 'blur' }
                ],

            }
        }
    },
    methods: {
        // 校验规则
        validate() {
            return new Promise((resolve, reject) => {
                this.$refs.basicInfoForm.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;
        font-size: 20px;
    }
}
</style>