<template>
    <el-form :model="stepData1" :rules="rules" ref="step1" label-width="180px">
        <p class="text-right">
            <el-link type="primary" @click="$emit('child-event','show')"><i class="el-icon-back"></i>返回</el-link>
        </p>
        <div class="step-title">
            <span>企业资质信息</span>
        </div>
        <div class="title">
            <span>单位信息</span>
        </div>
        <el-row>
            <el-col :span="10">
                <el-form-item label="单位名称：" prop="orgName">
                    <el-input v-model="stepData1.orgName"></el-input>
                </el-form-item>
                <el-form-item label="单位证件类型：" prop="orgCrtType">
                    <el-select v-model="stepData1.orgCrtType" placeholder="请选择单位证件类型">
                        <el-option
                        v-for="item in creditCodeOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>
                <div class="linkage">
                    <el-form-item label="行业类型：" class="is-required"></el-form-item>
                    <el-form-item prop="industryCategory" class="linkageItem">
                        <el-select v-model="stepData1.industryCategory" placeholder="请选择门类"
                                @change="getIndustryType(stepData1.industryCategory)">
                        <el-option
                            v-for="item in bigTypeOptions"
                            :key="item.id"
                            :label="item.dictValue"
                            :value="item.id">
                        </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item prop="industrySpecific" class="linkageItem">
                        <el-select v-model="stepData1.industrySpecific" placeholder="请选择大类">
                        <el-option
                            v-for="item in smallTypeOptions"
                            :key="item.id"
                            :label="item.dictValue"
                            :value="item.id">
                        </el-option>
                        </el-select>
                    </el-form-item>
                </div>
                <el-form-item label="注册机关：">
                    <el-input v-model="stepData1.regAuthority"></el-input>
                </el-form-item>
                <el-form-item label="成立日期：">
                    <el-date-picker
                    v-model="stepData1.establishDate"
                    type="date"
                    placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="官网地址：">
                    <el-input v-model="stepData1.website" placeholder="请输入官网地址" />
                </el-form-item>
                <el-form-item label="认证资料：" prop="orgCrtImgRid">
                    <el-upload
                        ref="companyFileRef"
                        :class="{hide:hideUpCompany}"
                        :action=action
                        :data="faceId"
                        list-type="picture-card"
                        :limit=limitCount
                        :file-list="orgCrtImgFile"
                        :headers="headers"
                        :on-change="handleChangeCompany"
                        :on-preview="handlePictureCardPreviewCompany"
                        :on-success="handSuccessCompany"
                        :before-upload="handleBeforePictureUpload"
                        :on-remove="handleRemoveCompany">
                        <i class="el-icon-plus"></i>
                    </el-upload>
                    <el-dialog :visible.sync="dialogVisible">
                        <img width="100%" :src="dialogImageUrl" alt="">
                    </el-dialog>
                </el-form-item>
            </el-col>
            <el-col :span="10" :offset="1">
                <el-form-item label="单位性质" prop="orgNature">
                    <el-select v-model="stepData1.orgNature" placeholder="请选择单位性质">
                        <el-option
                        v-for="item in enterpriseTypeOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="信用代码：" prop="orgCrtCode" >
                    <el-input v-model="stepData1.orgCrtCode"></el-input>
                </el-form-item>
                <el-form-item label="单位地址：" class="is-required">
                    <el-cascader
                    v-model="value"
                    :options="optionsArea"
                    @change="handleChangeArea"></el-cascader>
                </el-form-item>
                <el-form-item label="详细地址：" prop="orgAddr">
                    <el-input v-model="stepData1.orgAddr"></el-input>
                </el-form-item>
                <el-form-item label="注册资本：">
                    <el-input v-model="stepData1.regCapital">
                        <template slot="append">万元</template>
                    </el-input>
                </el-form-item>
                <el-form-item label="有效期：">
                    <el-date-picker
                    v-model="stepData1.periodValidity"
                    type="date"
                    placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="单位简介：">
                    <el-input v-model="stepData1.orgDesc" type="textarea" rows=6 placeholder="请输入内容" />
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <div class="title">
                <span>法人信息</span>
            </div>
            <el-col :span="10">
                <el-form-item label="法人或代表人姓名：" prop="legalName">
                    <el-input v-model="stepData1.legalName"></el-input>
                </el-form-item>
                <el-form-item label="法人或代表人电话：">
                    <el-input v-model="stepData1.legalPhone"></el-input>
                </el-form-item>
                <el-form-item label="法人或代表人传真：">
                    <el-input v-model="stepData1.legalFax"></el-input>
                </el-form-item>
                <div class="linkage">
                    <el-form-item label="法人或代表人证件照：" class="is-required"></el-form-item>
                    <el-form-item prop="legalCrtFrontImgRid" class="linkageItem">
                        <el-upload
                            ref="faceIDFileRef"
                            :class="{hide:hideUploadF}"
                            :action=action
                            :data="faceId"
                            list-type="picture-card"
                            :limit=limitCount
                            :file-list="legalCrtFrontImgFile"
                            :headers="headers"
                            :on-change="handleChangeLegalId"
                            :on-exceed="handleExceedId"
                            :on-preview="handlePictureCardPreviewId"
                            :on-success="handSuccessLegalId"
                            :before-upload="handleBeforePictureUpload"
                            :on-remove="handleRemoveLegalId">
                            <i class="el-icon-plus"></i>
                        </el-upload>
                        <el-dialog :visible.sync="dialogVisible">
                            <img width="100%" :src="dialogImageUrlFace" alt="">
                        </el-dialog>
                    </el-form-item>
                    <el-form-item prop="legalCrtBackImgRid" class="linkageItem">
                        <el-upload
                            ref="rearIDRef"
                            :class="{hide:hideUploadR}"
                            :action=action
                            :data="rearId"
                            list-type="picture-card"
                            :limit=limitCount
                            :file-list="legalCrtBackImgFile"
                            :headers="headers"
                            :on-change="handleChangeRearLegalID"
                            :on-exceed="handleExceedId"
                            :on-preview="handlePictureCardPreviewId"
                            :on-success="handSuccessRearLegalID"
                            :before-upload="handleBeforePictureUpload"
                            :on-remove="handleRemoveRearLegalID">
                            <i class="el-icon-plus"></i>
                        </el-upload>
                        <el-dialog :visible.sync="dialogVisible">
                            <img width="100%" :src="dialogImageUrlRear" alt="">
                        </el-dialog>
                    </el-form-item>
                    <div class="upload-tip linkageItem">
                        注意事项：<br>
                        支持.jpg .jpeg .png .bmp<br>
                        身份证的人像面请传入左框<br>
                        身份证的国徽面请传入右框
                    </div>
                </div>
                
            </el-col>
            <el-col :span="10" :offset="1">
                <el-form-item label="法人或代表人证件类型：" prop="legalCrtType">
                    <el-select v-model="stepData1.legalCrtType" placeholder="请选择">
                        <el-option
                        v-for="item in legalPersonOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="法人或代表人证件号码：" prop="legalCrtNo">
                    <el-input v-model="stepData1.legalCrtNo"></el-input>
                </el-form-item>
                <el-form-item label="法人或代表人邮箱：">
                    <el-input  v-model="stepData1.legalEmail" placeholder="请输入邮箱" />
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <div class="title">
                <span>联系人信息</span>
            </div>
            <el-col :span="10">
                <el-form-item label="联系人姓名：" prop="contactName">
                    <el-input v-model="stepData1.contactName"></el-input>
                </el-form-item>
                <el-form-item label="联系人证件类型：" prop="contactCrtType">
                    <el-select v-model="stepData1.contactCrtType" placeholder="请选择">
                        <el-option
                        v-for="item in legalPersonOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>
                <div class="linkage">
                    <el-form-item label="联系人证件照："></el-form-item>
                    <el-form-item class="linkageItem">
                        <el-upload
                            ref="faceIDFileRef"
                            :class="{hide:hideContactsF}"
                            :action=action
                            :data="faceId"
                            list-type="picture-card"
                            :limit=limitCount
                            :file-list="contactCrtFrontImgFile"
                            :headers="headers"
                            :on-change="handleChangeContactsId"
                            :on-exceed="handleExceedId"
                            :on-preview="handlePictureCardPreviewId"
                            :on-success="handSuccessContactsId"
                            :before-upload="handleBeforePictureUpload"
                            :on-remove="handleRemoveContactsId">
                            <i class="el-icon-plus"></i>
                        </el-upload>
                        <el-dialog :visible.sync="dialogVisible">
                            <img width="100%" :src="dialogImageUrlContactsFace" alt="">
                        </el-dialog>
                    </el-form-item>
                    <el-form-item class="linkageItem">
                        <el-upload
                            ref="rearIDRef"
                            :class="{hide:hideContactsR}"
                            :action=action
                            :data="rearId"
                            list-type="picture-card"
                            :limit=limitCount
                            :file-list="contactCrtBackImgFile"
                            :headers="headers"
                            :on-change="handleChangeRearContactsId"
                            :on-exceed="handleExceedId"
                            :on-preview="handlePictureCardPreviewId"
                            :on-success="handSuccessRearContactsId"
                            :before-upload="handleBeforePictureUpload"
                            :on-remove="handleRemoveRearContactsId">
                            <i class="el-icon-plus"></i>
                        </el-upload>
                        <el-dialog :visible.sync="dialogVisible">
                            <img width="100%" :src="dialogImageUrlContactsRear" alt="">
                        </el-dialog>
                    </el-form-item>
                    <div class="upload-tip linkageItem">
                        注意事项：<br>
                        支持.jpg .jpeg .png .bmp<br>
                        身份证的人像面请传入左框<br>
                        身份证的国徽面请传入右框
                    </div>
                </div>
            </el-col>
            <el-col :span="10" :offset="1">
                <el-form-item label="联系人电话：" prop="contactPhone">
                    <el-input v-model="stepData1.contactPhone"></el-input>
                </el-form-item>
                <el-form-item label="联系人证件号码：" prop="contactCrtNo">
                    <el-input v-model="stepData1.contactCrtNo"></el-input>
                </el-form-item>
                <el-form-item label="联系人邮箱：" prop="contactEmail">
                    <el-input  v-model="stepData1.contactEmail" placeholder="请输入邮箱" />
                </el-form-item>
            </el-col>
        </el-row>
        <div class="btn_group">
            <el-button size="medium" type="primary" @click="submitForm(0)">保存</el-button>
            <el-button size="medium" type="primary" @click="submitForm(1)">下一页</el-button>
        </div>
    </el-form>
</template>

<script>
import {UPLOAD} from "@/api/api"
import {validatePhone, validateIDCard,validateEmail} from "@/utils/validate";
import {enterpriseAuthNew, registerArea,selectTypeNew, industryType,selectOtherTypeNew,enterpriseInfoNew, informationModify} from "@/api/enterpriseManagement";
export default {
    name:"step1",
    data(){
        const checkIDCard = (rule, value, callback) => {
            if (!validateIDCard(value)) {
                return callback(new Error("请输入正确的身份证"));
            } else {
                callback();
            }
        };
        const checkPhone = (rule, value, callback) => {
            if (!validatePhone(value)) {
              return callback(new Error("请输入正确的手机号码"));
            } else {
              callback();
            }
        };
        const checkEmail = (rule, value, callback) => {
            if (!validateEmail(value)) {
              return callback(new Error("请输入正确的邮箱"));
            } else {
              callback();
            }
        };
        return {
            provinceOptions: [],//省份下拉框数据
            cityOptions: [],//市下拉框数据
            areaOptions: [],//区下拉框数据
            bigTypeOptions: [],//行业门类下拉框数据
            smallTypeOptions: [],//行业大类下拉框数据
            creditCodeOptions: [],//信用代码类型下拉框数据
            legalPersonOptions: [],//法人下拉框数据
            enterpriseTypeOptions: [],//企业类型下拉框数据
            hideUploadF: false,
            hideUploadR: false,
            hideContactsF: false,
            hideContactsR: false,
            hideUpCompany: false,
            limitCount: 1,
            dialogVisible: false,
            dialogImageUrlFace: '',
            dialogImageUrlRear: '',
            dialogImageUrlContactsFace:"",
            dialogImageUrlContactsRear:"",
            dialogImageUrl: '',
            faceId: {
                bizType: 'FACE_ID',
                fileName: '',
                sequence: 0,
                url: ''
            },
            rearId: {
                bizType: 'REAR_ID',
                fileName: '',
                sequence: 0,
                url: ''
            },
            company: {
                bizType: 'COMPANY',
                fileName: '',
                sequence: 0,
                url: ''
            },
            action: UPLOAD,
            stepData1: {
                orgName:"",	                 //单位名称
                orgNature:"",                //单位性质[枚举值:1国有控股 2民营控股 3外商控股 4事业单位 5民营非盈利组织]
                orgAddr:"",	                 //单位地址-详细地址
                orgAddrProvince:"",	         //单位地址-省
                orgAddrCity:"",	             //单位地址-市
                orgAddrCounty:"",	         //单位地址-区
                orgCrtType:"",	             //单位证件类型[枚举值:1统一社会信用代码 2其他]
                orgCrtCode:"",	             //单位证件号
                orgCrtImgRid:"",	         //营业执照
                orgCrtImgUrl:"",	         //营业执照
                orgDesc:"",	                 //单位简介	
                industryCategory:"",	     //行业门类
                industrySpecific:"",	     //行业大类
                website:"",	                 //官方网站
                regAuthority:"",	         //注册机关
                regCapital:"",	             //注册资本
                establishDate:"",	         //成立日期
                periodValidity:"",	         //有效期
                contactName:"",	             //联系人名称
                contactCrtType:"",	         //联系人证件类型[枚举值:1中国居民身份证 2护照 3其他]	
                contactCrtNo:"",	         //联系人证件号
                contactCrtBackImgRid:"",	 //联系人证件反面照片
                contactCrtBackImgUrl:"",	 //联系人证件反面照片
                contactCrtFrontImgRid:"",	 //联系人证件正面照片
                contactCrtFrontImgUrl:"",	 //联系人证件正面照片
                contactEmail:"",	         //联系人邮箱
                contactPhone:"",	         //联系人手机
                legalName:"",	             //法定代表人姓名
                legalCrtType:"",	         //法定代表人证件类型
                legalCrtNo:"",	             //法定代表人证件号
                legalCrtBackImgRid:"",	     //法定代表人证件照片反面	
                legalCrtBackImgUrl:"",	     //法定代表人证件照片反面	
                legalCrtFrontImgRid:"",	     //法定代表人证件正面照片
                legalCrtFrontImgUrl:"",	     //法定代表人证件正面照片
                legalEmail:"",	             //法定代表人邮箱
                legalFax:"",	             //法定代表人传真
                legalPhone:""	             //法定代表人手机号
            },
            orgCrtImgFile:[],
            legalCrtFrontImgFile:[],
            legalCrtBackImgFile:[],
            contactCrtFrontImgFile:[],
            contactCrtBackImgFile:[],
            rules: {
                //企业信息
                orgName: [
                {required: true, message: '请输入单位名称', trigger: 'blur'},
                {min: 1, max: 20, message: '长度在 1 到 30 个字符', trigger: 'blur'}
                ],
                orgNature: [
                {required: true, message: '请选择单位性质', trigger: "change"},
                ],
                orgAddr: [
                {required: true, message: '请输入详细地址', trigger: 'blur'},
                {min: 1, max: 20, message: '长度在 1 到 50 个字符', trigger: 'blur'}
                ],
                orgAddrProvince: [
                {required: true, message: '请选择省', trigger: "change"},
                ],
                orgAddrCity: [
                {required: true, message: '请选择市', trigger: "change"},
                ],
                // orgAddrCounty: [
                // {required: true, message: '请选择区县', trigger: "change"},
                // ],
                orgCrtType: [
                {required: true, message: '请选择单位证件类型', trigger: 'change'}
                ],
                orgCrtCode: [
                {required: true, message: '请输入信用代码', trigger: 'blur'},
                ],
                orgCrtImgRid: [
                {required: true, message: '请上传认证资料', trigger: 'blur'},
                ],
                industrySpecific: [
                {required: true, message: '请选择行业大类', trigger: 'change'}
                ],
                industryCategory: [
                {required: true, message: '请选择行业门类', trigger: 'change'}
                ],
                //联系人
                contactName: [
                {required: true, message: '请输入联系人姓名', trigger: 'blur'},
                ],
                contactCrtType: [
                {required: true, message: '请选择联系人证件类型', trigger: 'change'}
                ],
                contactCrtNo: [
                {required: true, message: "请输入联系人证件号", trigger: "blur"},
                {validator: checkIDCard, trigger: "blur"},
                ],
                contactPhone: [
                {required: true, message: '请输入联系电话'},
                {validator: checkPhone, trigger: "blur"}
                ],
                contactEmail: [
                {required: true, message: '请输入联系人邮箱'},
                {validator: checkEmail, trigger: "blur"}
                ],
                //联系人
                legalName: [
                {required: true, message: '请输入法人或代表人姓名', trigger: 'blur'},
                ],
                legalCrtType: [
                {required: true, message: '请选择法人或代表人证件类型', trigger: 'change'}
                ],
                legalCrtNo: [
                {required: true, message: "请输入法人或代表人证件号码", trigger: "blur"},
                {validator: checkIDCard, trigger: "blur"},
                ],
                legalCrtFrontImgRid: [
                {required: true, message: '请上传证件照正面', trigger: 'blur'},
                ],
                legalCrtBackImgRid: [
                {required: true, message: '请上传证件照反面', trigger: 'blur'},
                ]
            },
            value:[],
            optionsArea:[],
            aAreaList:{}
        }
    },
    computed: {
        headers() {
            return {
                token: 'Bearer ' + this.$db.get("TOKEN", ""),
                tenant: this.$db.get("TENANT", "") || "",
                Authorization: `Basic ${this.$Base64.encode(`${process.env.VUE_APP_CLIENT_ID}:${process.env.VUE_APP_CLIENT_SECRET}`)}`
            };
        },
    },
    mounted(){
        this.getAreaAll()
        this.getType(0);
        this.getEnterpriseInfo()
    },
    methods: {
        getEnterpriseInfo(){
            const code = `${this.$Base64.decode(this.$db.get('TENANT'))}` || null
            if(code)
            {
                enterpriseInfoNew(code).then(res => {
                    this.stepData1 = res.data.data
                    this.value = [this.stepData1.orgAddrProvince,this.stepData1.orgAddrCity,this.stepData1.orgAddrCounty||null]
                    if(this.stepData1.industryCategory)
                    {
                        this.getIndustryType(this.stepData1.industryCategory,true)
                    }
                    if(this.stepData1.orgCrtImgUrl)
                    {
                        this.orgCrtImgFile = [{name: this.stepData1.orgCrtImgUrl, url: this.stepData1.orgCrtImgUrl}]
                        this.hideUpCompany = true
                    }
                    if(this.stepData1.legalCrtFrontImgUrl){
                        this.legalCrtFrontImgFile = [{name: this.stepData1.legalCrtFrontImgUrl, url: this.stepData1.legalCrtFrontImgUrl}]
                        this.hideUploadF = true
                    }
                    if(this.stepData1.legalCrtBackImgUrl){
                        this.legalCrtBackImgFile = [{name: this.stepData1.legalCrtBackImgUrl, url: this.stepData1.legalCrtBackImgUrl}]
                        this.hideUploadR = true
                    }
                    if(this.stepData1.contactCrtFrontImgUrl) {
                        this.contactCrtFrontImgFile = [{name: this.stepData1.contactCrtFrontImgUrl, url: this.stepData1.contactCrtFrontImgUrl}]
                        this.hideContactsF = true
                    }
                    if(this.stepData1.contactCrtBackImgUrl) {
                        this.contactCrtBackImgFile = [{name: this.stepData1.contactCrtBackImgUrl, url: this.stepData1.contactCrtBackImgUrl}]
                        this.hideContactsR = true
                    }
                })
            }
            
        },
        
        handleChangeArea(value){
            this.stepData1.orgAddrProvince = value[0]
            this.stepData1.orgAddrCity = value[1]
            if(value[2])
            {
                this.stepData1.orgAddrCounty = value[2]
            }
        },
        //获取省市区--新
        getAreaAll() {
            return registerArea().then((res) => {
                this.aAreaList = res?.data?.data ? res.data.data:{}
                for (const key in this.aAreaList[86]) {
                    if (Object.hasOwnProperty.call(this.aAreaList[86], key)) {
                        const element = this.aAreaList[86][key];
                        this.optionsArea.push({value:key,label:element})
                    }
                }
                for (let i = 0; i < this.optionsArea.length; i++) {
                    const node = this.optionsArea[i];
                    node.children = this.formatArea(this.aAreaList[node.value])
                }
            })
        },
        //递归深度优先处理children
        formatArea(option){
            let children = []
            for (const key in option) {
                if (Object.hasOwnProperty.call(option, key)) {
                    const element2 = option[key];
                    if(this.aAreaList[key]){
                        children.push({
                            value:key,
                            label:element2,
                            children : this.formatArea(this.aAreaList[key])
                        }) 
                    } else {
                        children.push({value:key,label:element2})
                    }
                }
            }
            return children
        },
        //获取省市区之外的下拉框数据
        getType(parentId) {
            selectTypeNew(parentId).then((res) => {
                this.bigTypeOptions = res.data.data;
            })
            selectOtherTypeNew().then((res) => {
                for(let i in res.data.data.orgCrtType){
                    this.creditCodeOptions.push({label:i,value:res.data.data.orgCrtType[i]})
                }
                for(let i in res.data.data.contactCrtType){
                    this.legalPersonOptions.push({label:i,value:res.data.data.contactCrtType[i]})
                }
                for(let i in res.data.data.orgNature){
                    this.enterpriseTypeOptions.push({label:i,value:res.data.data.orgNature[i]})
                }
            })
        },
        //获取行业大类
        getIndustryType(parentId,isShow = false) {
            
            if(!isShow)
            {
                this.stepData1.industrySpecific = ""
            }
            selectTypeNew(parentId).then((res) => {
                this.smallTypeOptions = res.data.data;
            })
        },

        
        //联系人正面照成功
        handSuccessContactsId(file) {
            this.stepData1.contactCrtFrontImgRid = file.data.idisResult
            this.stepData1.contactCrtFrontImgUrl = file.data.url
            this.contactCrtFrontImgFile.push({name: file.data.filename, url: file.data.url, bizType: file.data.bizType})
            this.$refs.step1.validateField('contactCrtFrontImgRid')
        },
        //联系人正面照删除
        handleRemoveContactsId(file, fileList) {
            this.stepData1.contactCrtFrontImgRid = fileList
            this.$refs.step1.validateField('contactCrtFrontImgRid')
            this.hideContactsF = fileList.length >= this.limitCount;
        },
        //联系人正面变更
        handleChangeContactsId(files, fileList) {
            this.hideContactsF = fileList.length >= this.limitCount;
        },
        //联系人反面照成功
        handSuccessRearContactsId(file) {
            this.stepData1.contactCrtBackImgRid = file.data.idisResult
            this.stepData1.contactCrtBackImgUrl = file.data.url
            this.contactCrtBackImgFile.push({name: file.data.filename, url: file.data.url, bizType: file.data.bizType})
            this.$refs.step1.validateField('contactCrtBackImgRid')
        },
        //联系人反面照删除
        handleRemoveRearContactsId(file, fileList) {
            this.stepData1.contactCrtBackImgRid = fileList
            this.$refs.step1.validateField('contactCrtBackImgRid')
            this.hideContactsR = fileList.length >= this.limitCount;
        },
        //联系人反面变更
        handleChangeRearContactsId(files, fileList) {
            this.hideContactsR = fileList.length >= this.limitCount;
        },
        
        
        //法人相关
        //法人正面照成功
        handSuccessLegalId(file) {
            this.stepData1.legalCrtFrontImgRid = file.data.idisResult
            this.stepData1.legalCrtFrontImgUrl = file.data.url
            this.legalCrtFrontImgFile.push({name: file.data.filename, url: file.data.url, bizType: file.data.bizType})
            this.$refs.step1.validateField('legalCrtFrontImgRid')
        },
        //法人正面照删除
        handleRemoveLegalId(file, fileList) {
            this.stepData1.legalCrtFrontImgRid = fileList
            this.$refs.step1.validateField('legalCrtFrontImgRid')
            this.hideUploadF = fileList.length >= this.limitCount;
        },
        //法人正面图片变更
        handleChangeLegalId(files, fileList){
            this.hideUploadF = fileList.length >= this.limitCount;
        },
        //法人反面成功
        handSuccessRearLegalID(file) {
            this.stepData1.legalCrtBackImgRid = file.data.idisResult
            this.stepData1.legalCrtBackImgUrl = file.data.url
            this.legalCrtBackImgFile.push({name: file.data.filename, url: file.data.url, bizType: file.data.bizType})
            this.$refs.step1.validateField('legalCrtBackImgRid')
        },
        //法人反面删除
        handleRemoveRearLegalID(file, fileList) {
            this.stepData1.legalCrtBackImgRid = fileList
            this.$refs.step1.validateField('legalCrtBackImgRid')
            this.hideUploadR = fileList.length >= this.limitCount;
        },
        //法人反面变更
        handleChangeRearLegalID(files, fileList) {
        this.hideUploadR = fileList.length >= this.limitCount;
        },


        //企业相关
        //企业图片变更
        handleChangeCompany(files, fileList) {
            this.hideUpCompany = fileList.length >= this.limitCount;
            // this.dialogImageUrl = URL.createObjectURL(files.raw);
        },
        //企业认证资料删除
        handleRemoveCompany(file, fileList) {
            this.stepData1.orgCrtImgRid = ''
            this.orgCrtImgFile = fileList
            this.$refs.step1.validateField('orgCrtImgRid')
            this.hideUpCompany = fileList.length >= this.limitCount;
        },
        //企业图片放大
        handlePictureCardPreviewCompany(file) {
            this.dialogImageUrl = file.url;
            this.dialogVisible = true;
        },
        //企业认证资料成功
        handSuccessCompany(file) {
            this.stepData1.orgCrtImgRid = file.data.idisResult
            this.stepData1.orgCrtImgUrl = file.data.url
            this.orgCrtImgFile.push({name: file.data.filename, url: file.data.url, bizType: file.data.bizType})
            this.$refs.step1.validateField('orgCrtImgRid')
        },


        //公共
        //图片上传前的验证
        handleBeforePictureUpload(file) {
            const isLt1M = file.size / 1024 / 1024 < 5;
            const fileType = ['image/jpeg', 'image/png', 'image/jpg', 'image/gif', 'image/bmp']
            const isJPG = fileType.indexOf(file.type) != -1

            if (!isJPG) {
                this.$message.error('上传图片只能是 JPEG、JPG、PNG、GIF、BMP 格式!');
            }
            if (!isLt1M) {
                this.$message.error("上传图片大小不能超过 5MB!");
            }
            return isJPG && isLt1M;
        },
        //点击图片放大
        handlePictureCardPreviewId(file) {
            this.dialogImageUrl = file.url;
            this.dialogVisible = true;
        },
        //上传限制
        handleExceedId(files, fileList) {
            this.$message.warning(`当前限制选择 1个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
        },

        //点击提交检验
        submitForm(type) {
            this.$refs.step1.validate((valid) => {
                if (valid) {
                    this.saveSubmit(type);
                } else {
                    return false;
                }
            });
        },
        //保存提交并下一步
        saveSubmit(type) {
            this.stepData1.code = `${this.$Base64.decode(this.$db.get('TENANT'))}`;
            this.stepData1.currentPage = type
            enterpriseAuthNew(this.stepData1).then(response => {
                const res = response.data;
                if (res.data) {
                    this.$message({
                        message: "操作成功",
                        type: "success"
                    });
                    // this.$refs.step1.resetFields();
                    this.$emit('child-event','step'+parseInt(type+1))
                }
            })
        },
    }
}
</script>

<style lang="scss" scoped>
.el-select,.el-cascader {
    width: 100%;
}
</style>