<template>
    <section class="RegisterContainerBox">
        <section v-if="!infoFlag">
            <el-form ref="ruleForm" :model="form" :rules="rules">
                <!-- <div class="headerInfo">
                    注册指南<br />
                    1. 本系统由各地监管机构通知企业申请入驻，根据行业类型和机构类型的选择，填写相关注册信息；<br />

                    2.注册信息涉及营业执照、保安服务许可证、登记证书等资质证照的上传，请提前准备；<br />

                    3.信息填写完成后将自动带入系统【从业单位】信息，部分信息提交后无法自行修改，需通过申请变更由监管机构调整，请提交前仔细核对填报信息；<br />

                    4.信息填报提交后，经审核开通系统管理员账号，开通后请尽快登录系统按照要求完善其他信息，具体功能操作详见系统左下角客服与帮助。<br />
                </div> -->
                <div class="headerInfo">
                    注册指南<br />
                    1. 本系统为邀请入驻，各单位请选择相应的行业类型和机构类型，再填写相关注册信息；<br />

                    2. 需填写基本信息和上传主体证明材料，请提前准备；<br />

                    3. 信息填写完成后将自动带入系统，部分信息提交后无法自行修改，请提交前仔细核对填报信息；<br />

                    4. 信息填报提交后，经审核开通系统管理员账号，开通后请尽快登录系统按照要求完善其他信息，具体功能操作详见系统左下角客服与帮助。<br />
                </div>
                <!-- 组织类型 区域 start-->
                <div class="contentMainBox">
                    <span class="title"><i></i><strong>组织类型</strong></span>
                    <!-- 行业类型 -->
                    <template>
                        <el-form-item label="行业类型" class="formItem" prop="industryCode">
                            <el-select v-model="form.industryCode" placeholder="请选择" :disabled="disabledIndustryCode"
                                @change="industryCodeSelect(form.industryCode)">
                                <el-option :label="item.label" :value="item.value"
                                    v-for="(item, index) in dictRegisterListObj.industryType" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 机构类型 -->
                    <template v-if="form.industryCode">
                        <el-form-item label="机构类型" class="formItem" prop="institutionalCode">
                            <el-select v-model="form.institutionalCode" placeholder="请选择" :disabled="queryNumberDisabled || form.industryCode == '02'" @change="changeInstitutionalCode(form.institutionalCode)">
                                <el-option :label="item.label" :value="item.value" :disabled="item.value == '0301'"
                                    v-for="(item, index) in institutionalCodeType" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 保安服务公司类型 -->
                    <template v-if="form.institutionalCode == '0102'">
                        <el-form-item label="保安服务公司类型" class="formItem" prop="industryDetailType">
                            <el-select v-model="form.industryDetailType" placeholder="请选择">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="(item, index) in dictRegisterListObj.industryDetailType" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 内保行业保安来源 -->
                    <template v-if="form.industryCode === '04'">
                      <el-form-item label="保安来源" class="formItem" :rules="{ required: true }">
                        <el-select placeholder="请选择" v-model="securitySource" @change="changeSecuritySource">
                          <el-option label="自招" :value="1"></el-option>
                          <el-option label="外聘" :value="2"></el-option>
                        </el-select>
                      </el-form-item>
                    </template>
                </div>
                <!-- 组织类型 区域 end-->

                <!-- 基本信息 区域 start-->
                <div class="contentMainBox"
                    v-if="(form.institutionalCode == '0102') || (form.institutionalCode == '0103') || (form.institutionalCode == '0104') || form.institutionalCode.startsWith('03') || form.institutionalCode.startsWith('04') || form.institutionalCode.startsWith('05') || form.institutionalCode.startsWith('06')">
                    <span class="title"><i></i><strong>基本信息</strong></span>
                    <!-- 公司名称 -->
                    <template>
                        <el-form-item :label="form.institutionalCode==='0406'?'单位名称':'公司名称'" class="formItem" prop="name">
                            <el-input v-model="form.name" :placeholder="form.institutionalCode.startsWith('06')||form.institutionalCode==='0406' ? '请输入' : '请与资质证照名称保持一致'"
                                :disabled="queryNumberDisabled" @blur="checkNameIsExist"></el-input>
                            <div style="width: 100%;text-align: left;color:#aaa" v-if="form.institutionalCode.startsWith('06')">派出所名称+社区警务组织，如双井社区警务组织</div>
                        </el-form-item>
                    </template>
                    <!-- 总/分/子公司 -->
                    <template>
                        <el-form-item label="总/分/子公司" class="formItem" prop="type" v-if="!form.institutionalCode.startsWith('03') && !form.institutionalCode.startsWith('04') && !form.institutionalCode.startsWith('05') && !form.institutionalCode.startsWith('06')">
                            <el-select v-model="form.type" placeholder="请选择">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="(item, index) in   dictRegisterListObj.parentSubsidiary" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    
                    <!-- 法定代表人 -->
                    <template>
                        <el-form-item :label="form.institutionalCode==='0406'?'负责人':'法定代表人'" class="formItem" prop="legalPersonName" v-if="form.institutionalCode.startsWith('03') || form.institutionalCode.startsWith('04') || form.institutionalCode.startsWith('05')">
                            <el-input v-model="form.legalPersonName" :placeholder="form.institutionalCode==='0406'?'请输入负责人名字':'请输入法定代表人名字'"
                                :disabled="queryNumberDisabled"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 证件类型 -->
                    <template>
                        <el-form-item label="证件类型" class="formItem" prop="legalPersonCredentialType" v-if="form.institutionalCode.startsWith('03') || form.institutionalCode.startsWith('04') || form.institutionalCode.startsWith('05')">
                            <el-select v-model.number="form.legalPersonCredentialType" placeholder="请选择">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="(item, index) in dictRegisterListObj.credentialType" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 证件号码 -->
                    <template>
                        <el-form-item label="证件号码" class="formItem" prop="legalPersonCredentialNumber" v-if="form.institutionalCode.startsWith('03') || form.institutionalCode.startsWith('04') || form.institutionalCode.startsWith('05')">
                            <el-input v-model="form.legalPersonCredentialNumber" placeholder="请输入法定代表人证件号码"
                                :disabled="queryNumberDisabled"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 手机号码 内保行业、合作行业和其他行业 -->
                    <template>
                        <el-form-item label="手机号码" class="formItem" prop="legalPersonTelephone" v-if="form.institutionalCode.startsWith('03') || form.institutionalCode.startsWith('04') || form.institutionalCode.startsWith('05')">
                            <el-input v-model="form.legalPersonTelephone" placeholder="请输入" :disabled="queryNumberDisabled"
                                oninput="value=value.replace(/[^\d]/g,'')"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 联系电话 保安行业 -->
                    <template>
                        <el-form-item label="联系电话" class="formItem" prop="telephone" v-if="!form.institutionalCode.startsWith('03') && !form.institutionalCode.startsWith('04') && !form.institutionalCode.startsWith('05') && !form.institutionalCode.startsWith('06')">
                            <el-input v-model="form.telephone" placeholder="请输入"
                                :disabled="queryNumberDisabled && form.institutionalCode == '0102'"
                                oninput="value=value.replace(/[^\d]/g,'')"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 经济类型 -->
                    <template>
                        <el-form-item label="经济类型" class="formItem" prop="economicType" v-if="!form.institutionalCode.startsWith('03') && !form.institutionalCode.startsWith('04') && !form.institutionalCode.startsWith('05') && !form.institutionalCode.startsWith('06')">
                            <el-select v-model.number="form.economicType" placeholder="请选择">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="(item, index) in    dictRegisterListObj.economicType" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 公司类型 -->
                    <template>
                        <el-form-item label="公司类型" class="formItem" prop="nature" v-if="!form.institutionalCode.startsWith('03') && !form.institutionalCode.startsWith('04') && !form.institutionalCode.startsWith('05') && !form.institutionalCode.startsWith('06')">
                            <el-select v-model.number="form.nature" placeholder="请选择">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="(item, index) in    dictRegisterListObj.companyNature" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 注册地区 55-->
                    <template>
                        <el-form-item label="注册地区" class="formItem" prop="placeOfRegisterCode" v-if="!form.institutionalCode.startsWith('06')&&form.institutionalCode!=='0406'">
                            <el-cascader v-model="form.placeOfRegisterCode" :options="areaCityListArr" class="areaItem"
                                style="width:100%" popper-class='myCascaderplaceClass'
                                @change="placeOfRegisterCodeChange"></el-cascader>
                        </el-form-item>
                    </template>
                    <!-- 注册地详细地址 55-->
                    <template>
                        <el-form-item label="注册地详细地址" class="formItem" prop="placeOfRegister.address" v-if="!form.institutionalCode.startsWith('06')&&form.institutionalCode!=='0406'">
                            <el-input v-model="form.placeOfRegister.address" placeholder="请与营业执照住所保持一致"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 经营地区 55-->
                    <template>
                        <el-form-item label="经营地区" class="formItem" prop="placeOfBusinessCode" v-if="!form.institutionalCode.startsWith('06')">
                            <el-cascader v-model="form.placeOfBusinessCode" :options="areaCityListArr" class="areaItem"
                                style="width:100%" popper-class='myCascaderplaceClass'
                                @change="placeOfBusinessCodeChange"></el-cascader>
                        </el-form-item>
                    </template>
                    <!-- 注册地详细地址 55-->
                    <template>
                        <el-form-item label="经营地详细地址" class="formItem" prop="placeOfBusiness.address" v-if="!form.institutionalCode.startsWith('06')">
                            <el-input v-model="form.placeOfBusiness.address" placeholder="请完整准确填写"></el-input>
                        </el-form-item>
                    </template>
                </div>
                <!-- 基本信息 区域 end-->

                <!-- 总公司信息 区域 start-->
                <div class="contentMainBox"
                    v-if="form.institutionalCode == '0102' && (form.type == '2' || form.type == '3')">
                    <span class="title"><i></i><strong>总公司信息</strong></span>
                    <!-- 总公司名称 -->
                    <template>
                        <el-form-item label="总公司名称" class="formItem" prop="parentName">
                            <el-input v-model="form.parentName" placeholder="请输入"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 总公司证件类型 -->
                    <template>
                        <el-form-item label="总公司证件类型" class="formItem" prop="parentCertificateType">
                            <el-select v-model.number="form.parentCertificateType" placeholder="请选择"
                                :disabled="queryNumberDisabled">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="(item, index) in   dictRegisterListObj.companyCertificateType" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 总公司证件号码 -->
                    <template>
                        <el-form-item label="总公司证件号码" class="formItem" prop="parentCertificateNumber">
                            <el-input v-model="form.parentCertificateNumber" placeholder="请输入"
                                oninput="value=value.replace(/[\W]/g,'')" maxlength="18"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 总公司法人姓名 -->
                    <template>
                        <el-form-item label="总公司法人姓名" class="formItem" prop="parentLegalPersonName">
                            <el-input v-model="form.parentLegalPersonName" placeholder="请输入"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 总公司联系电话 -->
                    <template>
                        <el-form-item label="总公司联系电话" class="formItem" prop="parentLegalPersonTelephone">
                            <el-input v-model="form.parentLegalPersonTelephone" placeholder="请输入"
                                oninput="value=value.replace(/[^\d]/g,'')"></el-input>
                        </el-form-item>
                    </template>
                </div>
                <!-- 总公司信息 区域 end-->

                <!-- 法人或负责人信息 区域 start-->
                <div class="contentMainBox"
                    v-if="(form.institutionalCode == '0102') || (form.institutionalCode == '0103') || (form.institutionalCode == '0104')">
                    <span class="title"><i></i><strong>法人或负责人信息</strong></span>
                    <!-- 法人或负责人姓名 -->
                    <template>
                        <el-form-item label="法人或负责人姓名" class="formItem" prop="legalPersonName">
                            <el-input v-model="form.legalPersonName" placeholder="请与营业执照保持一致"
                                :disabled="queryNumberDisabled"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 手机号码 -->
                    <template>
                        <el-form-item label="手机号码" class="formItem" prop="legalPersonTelephone">
                            <el-input v-model="form.legalPersonTelephone" placeholder="请输入" :disabled="queryNumberDisabled"
                                oninput="value=value.replace(/[^\d]/g,'')"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 证件类型 -->
                    <template>
                        <el-form-item label="证件类型" class="formItem" prop="legalPersonCredentialType">
                            <el-select v-model.number="form.legalPersonCredentialType" placeholder="请选择">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="(item, index) in dictRegisterListObj.credentialType" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 证件号码 -->
                    <template>
                        <el-form-item label="证件号码" class="formItem" prop="legalPersonCredentialNumber">
                            <el-input v-model="form.legalPersonCredentialNumber" placeholder="请输入"
                                :disabled="queryNumberDisabled"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 国籍 -->
                    <template>
                        <el-form-item label="国籍" class="formItem" prop="legalPersonNationality">
                            <el-select v-model="form.legalPersonNationality" placeholder="请选择">
                                <el-option :label="item.label" :value="item.value"
                                    v-for="(item, index) in  dictRegisterListObj.nationality" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>

                    <!-- 保安负责人姓名 -->
                    <template v-if="(form.institutionalCode == '0104')">
                        <el-form-item label="保安负责人姓名" class="formItem" prop="securityPersonName">
                            <el-input v-model="form.securityPersonName" placeholder="请输入"
                                :disabled="queryNumberDisabled && form.institutionalCode == '0104'"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 手机号码 -->
                    <template v-if="(form.institutionalCode == '0104')">
                        <el-form-item label="手机号码" class="formItem" prop="securityPersonTelephone">
                            <el-input v-model="form.securityPersonTelephone" placeholder="请输入"
                                :disabled="queryNumberDisabled && form.institutionalCode == '0104'"
                                oninput="value=value.replace(/[^\d]/g,'')"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 证件类型 -->
                    <template v-if="(form.institutionalCode == '0104')">
                        <el-form-item label="证件类型" class="formItem" prop="securityPersonCredentialType">
                            <el-select v-model.number="form.securityPersonCredentialType" placeholder="请选择">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="(item, index) in  dictRegisterListObj.credentialType" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 证件号码 -->
                    <template v-if="(form.institutionalCode == '0104')">
                        <el-form-item label="证件号码" class="formItem" prop="securityPersonCredentialNumber">
                            <el-input v-model="form.securityPersonCredentialNumber" placeholder="请输入"
                                :disabled="queryNumberDisabled && form.institutionalCode == '0104'"></el-input>
                        </el-form-item>
                    </template>

                </div>
                <!-- 法人或负责人信息 区域 end-->

                <!-- 注册信息 区域 start-->
                <div class="contentMainBox"
                    v-if="(form.institutionalCode == '0102') ||
                     (form.institutionalCode == '0103') || (form.institutionalCode == '0104') 
                     || form.institutionalCode.startsWith('03') || (form.institutionalCode.startsWith('04')&&form.institutionalCode!=='0406') || form.institutionalCode.startsWith('05')">
                    <span class="title"><i></i><strong>注册信息</strong></span>
                    <!-- 注册资本（万元） -->
                    <template>
                        <el-form-item label="注册资本（万元）" class="formItem" prop="registeredCapital" v-if="!form.institutionalCode.startsWith('03') && !form.institutionalCode.startsWith('04') && !form.institutionalCode.startsWith('05')">
                            <el-input type="number" v-model="form.registeredCapital" placeholder="请与营业执照保持一致"
                                :disabled="queryNumberDisabled && form.institutionalCode == '0102'"
                                @input="form.registeredCapital = formatDecimal(form.registeredCapital, '')"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 固定资产（万元） -->
                    <template>
                        <el-form-item label="固定资产（万元）" class="formItem"
                            :prop="(form.institutionalCode == '0102') ? 'fixedCapital' : ''" ref="fixedCapitalRef" v-if="!form.institutionalCode.startsWith('03') && !form.institutionalCode.startsWith('04') && !form.institutionalCode.startsWith('05')">
                            <el-input v-model="form.fixedCapital" placeholder="请输入"
                                @input="form.fixedCapital = formatDecimal(form.fixedCapital, '')"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 年营业额（万元） -->
                    <template>
                        <el-form-item label="年营业额（万元）" class="formItem"
                            :prop="(form.institutionalCode == '0102') ? 'annualSalesVolume' : ''"
                            ref="annualSalesVolumeRef" v-if="!form.institutionalCode.startsWith('03') && !form.institutionalCode.startsWith('04') && !form.institutionalCode.startsWith('05')">
                            <el-input v-model="form.annualSalesVolume" placeholder="请输入"
                                @input="form.annualSalesVolume = formatDecimal(form.annualSalesVolume, '')"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 年利税（万元） -->
                    <template>
                        <el-form-item label="年利税（万元）" class="formItem"
                            :prop="(form.institutionalCode == '0102') ? 'annualProfitTax' : ''" ref="annualProfitTaxRef" v-if="!form.institutionalCode.startsWith('03') && !form.institutionalCode.startsWith('04') && !form.institutionalCode.startsWith('05')">
                            <el-input v-model="form.annualProfitTax" placeholder="请输入"
                                @input="form.annualProfitTax = formatDecimal(form.annualProfitTax, '')"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 证件类型 -->
                    <template>
                        <el-form-item label="证件类型" class="formItem" prop="certificateType">
                            <el-select v-model.number="form.certificateType" placeholder="请选择"
                                :disabled="queryNumberDisabled">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="(item, index) in  dictRegisterListObj.companyCertificateType" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 统一社会信用代码 -->
                    <template>
                        <el-form-item label="统一社会信用代码" class="formItem" prop="unifySocialCreditCode">
                            <el-input v-model="form.unifySocialCreditCode" placeholder="请输入18位统一社会信用代码"
                                :disabled="queryNumberDisabled && form.institutionalCode == '0104'"
                                oninput="value=value.replace(/[\W]/g,'')" maxlength="18"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 营业执照扫描件 -->
                    <template>
                        <el-form-item
                            :label="(form.institutionalCode == '0102') || form.institutionalCode.startsWith('03') || form.institutionalCode.startsWith('04') || form.institutionalCode.startsWith('05') ? '营业执照扫描件' : (form.institutionalCode == '0103') ? '资质证照扫描件' : (form.institutionalCode == '0104') ? '资质证照扫描件' : ''"
                            class="formItem" ref="unifySocialCreditCodeFilefileListRef"
                            prop="unifySocialCreditCodeFilefileList">
                            <van-uploader v-model="form.unifySocialCreditCodeFilefileList"
                                :after-read="unifySocialCreditCodeFilefileuploadFile"
                                :before-delete="unifySocialCreditCodeFilefileuploadFileDel" :max-count="1"
                                :max-size="5 * 1024 * 1024" @oversize="onOversizeunifySocialCreditCodeFilefileuploadFile"
                                accept=".jpg,.png" />
                            <div class="img-tip">仅限jpg/png格式， 大小不超过5M。</div>
                        </el-form-item>
                    </template>
                </div>
                <!-- 注册信息 区域 end-->

                <!-- 资质信息--保安服务公司 区域 start-->
                <div class="contentMainBox" v-if="form.institutionalCode == '0102'">
                    <span class="title"><i></i><strong>资质信息</strong></span>
                    <!-- 保安服务许可证号 -->
                    <template>
                        <el-form-item label="保安服务许可证号" class="formItem" prop="servicePermitNumber">
                            <el-input v-model="form.servicePermitNumber" placeholder="请与保安服务许可证保持一致，例：*公保服****号"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 批准文号 -->
                    <template>
                        <el-form-item label="批准文号" class="formItem" prop="securityApprovalNumber">
                            <el-input v-model="form.securityApprovalNumber" placeholder="请与保安服务许可证保持一致"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 发证机关名称 -->
                    <template>
                        <el-form-item label="发证机关名称" class="formItem" prop="nameOfIssuingAuthority">
                            <el-input v-model="form.nameOfIssuingAuthority" placeholder="请输入"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 保安服务许可证首次发证日期 -->
                    <template>
                        <el-form-item label="保安服务许可证首次发证日期" class="formItem" prop="firstIssueServicePermit">
                            <el-date-picker v-model="form.firstIssueServicePermit" type="date" placeholder="选择年月日"
                                value-format="yyyy-MM-dd" format="yyyy-MM-dd" style="width:100%">
                            </el-date-picker>
                        </el-form-item>
                    </template>
                    <!-- 服务范围 -->
                    <template>
                        <el-form-item label="服务范围" class="formItem" prop="serviceScopeList">
                            <el-select multiple v-model="form.serviceScopeList" placeholder="请选择"
                                :disabled="queryNumberDisabled" @change="serviceScopeListChange">
                                <el-option :label="item.label" :value="item.value"
                                    v-for="(item, index) in  dictRegisterListObj.serviceScope" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 保安服务许可证扫描件 -->
                    <template>
                        <el-form-item label="保安服务许可证扫描件" class="formItem" ref="servicePermitAttachmentListRef"
                            prop="servicePermitAttachmentList">
                            <van-uploader v-model="form.servicePermitAttachmentList"
                                :after-read="servicePermitAttachmentuploadFile"
                                :before-delete="servicePermitAttachmentuploadFileDel" :max-count="1"
                                :max-size="5 * 1024 * 1024" @oversize="onOversizeservicePermitAttachmentuploadFile" />
                        </el-form-item>
                    </template>
                    <!-- 人力防范评定等级 -->
                    <template>
                        <el-form-item label="人力防范评定等级" class="formItem" prop="securityPreparednessRating">
                            <el-select v-model.number="form.securityPreparednessRating" placeholder="请选择">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="(item, index) in  dictRegisterListObj.securityPreparednessRating" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 武装守护押运评定等级 -->
                    <template>
                        <el-form-item label="武装守护押运评定等级" class="formItem" prop="securityArmedRating">
                            <el-select v-model.number="form.securityArmedRating" placeholder="请选择">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="(item, index ) in dictRegisterListObj.securityArmedRating" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 安全技术防范评定等级 -->
                    <template>
                        <el-form-item label="安全技术防范评定等级" class="formItem" prop="securitySafetyDefenseRating">
                            <el-select v-model.number="form.securitySafetyDefenseRating" placeholder="请选择">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="(item, index) in  dictRegisterListObj.securitySafetyDefenseRating" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 是否有风险评估资质 -->
                    <template>
                        <el-form-item label="是否有风险评估资质" class="formItem" prop="isRiskAssessment">
                            <el-select v-model="form.isRiskAssessment" placeholder="请选择" :disabled="true">
                                <el-option label="是" :value="true"></el-option>
                                <el-option label="否" :value="false"></el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                </div>
                <!-- 资质信息 区域 end-->

                <!-- 资质信息--保安培训单位 区域 start-->
                <div class="contentMainBox" v-if="form.institutionalCode == '0103'">
                    <span class="title"><i></i><strong>资质信息</strong></span>
                    <!-- 保安培训许可（备案）证号 -->
                    <template>
                        <el-form-item label="保安培训许可（备案）证号" class="formItem" prop="servicePermitNumber">
                            <el-input v-model="form.servicePermitNumber" placeholder="请输入"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 发证机关名称 -->
                    <template>
                        <el-form-item label="发证机关名称" class="formItem" prop="nameOfIssuingAuthority">
                            <el-input v-model="form.nameOfIssuingAuthority" placeholder="请输入"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 发证日期 -->
                    <template>
                        <el-form-item label="发证日期" class="formItem" prop="firstIssueServicePermit">
                            <el-date-picker v-model="form.firstIssueServicePermit" type="date" placeholder="选择年月日"
                                value-format="yyyy-MM-dd" format="yyyy-MM-dd" style="width:100%">
                            </el-date-picker>
                        </el-form-item>
                    </template>
                    <!-- 培训内容 -->
                    <template>
                        <el-form-item label="培训内容" class="formItem" prop="trainContent">
                            <el-input v-model="form.trainContent" placeholder="请输入"
                                :disabled="queryNumberDisabled"></el-input>
                        </el-form-item>
                    </template>

                    <!-- 保安服务许可证扫描件 -->
                    <template>
                        <el-form-item label="保安培训许可（备案）证扫描件" class="formItem" ref="servicePermitAttachmentListRef"
                            prop="servicePermitAttachmentList">
                            <van-uploader v-model="form.servicePermitAttachmentList"
                                :after-read="servicePermitAttachmentuploadFile"
                                :before-delete="servicePermitAttachmentuploadFileDel" :max-count="1"
                                :max-size="5 * 1024 * 1024" @oversize="onOversizeservicePermitAttachmentuploadFileDel" />
                        </el-form-item>
                    </template>
                </div>
                <!-- 资质信息--保安培训单位 区域 end-->

                <!-- 资质信息--自行招用保安员单位 区域 start-->
                <div class="contentMainBox" v-if="form.institutionalCode == '0104'">
                    <span class="title"><i></i><strong>资质信息</strong></span>
                    <!-- 拟自招保安员数 -->
                    <template>
                        <el-form-item label="拟自招保安员数" class="formItem" prop="numberOfSecurityGuards">
                            <el-input v-model.number="form.numberOfSecurityGuards" placeholder="请输入"
                                :disabled="queryNumberDisabled" oninput="value=value.replace(/[^\d]/g,'')"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 是否治安保卫重点单位 -->
                    <template>
                        <el-form-item class="formItem" prop="isPublicSecuritySecurity">
                            <template slot="label">
                                <span>是否治安保卫重点单位</span>
                                <!-- <i class="el-icon-question" @click="tips"></i> -->
                                <img src="~@/assets/common/tips.png" class="tipsImg" @click="tips" />
                            </template>
                            <el-select v-model="form.isPublicSecuritySecurity" placeholder="请选择">
                                <el-option label="是" :value="true"></el-option>
                                <el-option label="否" :value="false"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-dialog :visible.sync="showtips" title="" width="95%">
                            <div class="tipsContent">
                                (一)广播电台、电视台、通讯社等重要新闻单位；<br />
                                (二)机场、港口、大型车站等重要交通枢纽；<br />
                                (三)国防科技工业重要产品的研制、生产单位；<br />
                                (四)电信、邮政、金融单位；<br />
                                (五)大型能源动力设施、水利设施和城市水、电、燃气、热力供应设施；<br />
                                (六)大型物资储备单位和大型商贸中心；<br />
                                (七)教育、科研、医疗单位和大型文化、体育场所；<br />
                                (八)博物馆、档案馆和重点文物保护单位；<br />
                                (九)研制、生产、销售、储存危险物品或者实验、保藏传染性菌种、毒种的单位；<br />
                                (十)国家重点建设工程单位；<br />
                            </div>
                        </el-dialog>
                    </template>
                    <!-- 是否物业企业 -->
                    <template>
                        <el-form-item label="是否物业企业" class="formItem" prop="isPropertyEnterprise">
                            <el-select v-model="form.isPropertyEnterprise" placeholder="请选择">
                                <el-option label="是" :value="true"></el-option>
                                <el-option label="否" :value="false"></el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 自招保安单位性质 -->
                    <template>
                        <el-form-item label="自招保安单位性质" class="formItem" prop="natureOfSelfRecruitedUnits">
                            <el-select v-model="form.natureOfSelfRecruitedUnits" placeholder="请选择">
                                <el-option :label="item.label" :value="item.value"
                                    v-for="(item, index) in  dictRegisterListObj.natureOfSelfRecruitedUnits" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                </div>
                <!-- 资质信息--自行招用保安员单位 区域 end-->

                <!-- 监管归属 区域 start-->
                <div class="contentMainBox"
                    v-if="(form.institutionalCode == '0102') || (form.institutionalCode == '0103') || (form.institutionalCode == '0104') || form.institutionalCode.startsWith('06') || form.institutionalCode.startsWith('04')">
                    <span class="title"><i></i><strong>监管归属</strong></span>
                    <!-- 监管地区 -->
                    <template>
                        <el-form-item label="监管地区" class="formItem" prop="placeOfSuperviseCode">
                            <el-cascader v-model="form.placeOfSuperviseCode" :options="areaCityListArr" class="areaItem"
                                style="width:100%" @change="placeOfSuperviseCodeChange"
                                popper-class='myCascaderplaceClass'></el-cascader>
                        </el-form-item>
                    </template>
                    <!-- 监管机构 -->
                    <template v-if="form.superviseDepartIdoptions.length">
                        <el-form-item label="监管机构" class="formItem" prop="superviseDepartIdArr">
                            <el-cascader :options="form.superviseDepartIdoptions"
                                :props="{ checkStrictly: true, value: 'id', label: 'name' }" :show-all-levels="false"
                                v-model="form.superviseDepartIdArr" style="width:100%" @change="superviseDepartIdChange"
                                popper-class='myCascaderDepartClass' ref="myCascader" clearable></el-cascader>

                        </el-form-item>
                    </template>
                </div>

                <!-- 内保行业主管单位信息 区域 end-->
                <div class="contentMainBox"
                  v-if="form.institutionalCode.startsWith('04') && false">
                  <span class="title"><i></i><strong>主管单位信息</strong></span>
                  <!-- 所在地区 -->
                  <template>
                    <el-form-item label="所在地区" class="formItem" prop="placeOfCompetentUnitCode">
                      <el-cascader v-model="form.placeOfCompetentUnitCode" :options="areaCityListArr" class="areaItem"
                        style="width:100%" @change="placeOfCompetentUnitCodeChange"
                        popper-class='myCascaderplaceClass'></el-cascader>
                    </el-form-item>
                  </template>
                  <!-- 主管单位 -->
                  <template>
                    <el-form-item label="主管单位" class="formItem" prop="administrator.credentialType">
                      <el-input v-model="sponsorInfo.label" placeholder="请输入" disabled></el-input>
                    </el-form-item>
                  </template>
                </div>
                <!-- 内保行业主管单位信息 区域 end-->

                <!-- 系统管理员 区域 start-->
                <div class="contentMainBox"
                    v-if="(form.institutionalCode == '0102') || (form.institutionalCode == '0103') || (form.institutionalCode == '0104') || form.institutionalCode.startsWith('03') || form.institutionalCode.startsWith('04') || form.institutionalCode.startsWith('05') || form.institutionalCode.startsWith('06')">
                    <span class="title"><i></i><strong>系统管理员</strong></span>
                    <!-- 姓名 -->
                    <template>
                        <el-form-item label="姓名" class="formItem" prop="administrator.name">
                            <el-input v-model="form.administrator.name" placeholder="请输入"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 警号 -->
                    <template>
                      <el-form-item label="警号" class="formItem" prop="administrator.credentialNumber" v-if="form.institutionalCode.startsWith('06')">
                        <el-input v-model="form.administrator.credentialNumber" placeholder="请输入"></el-input>
                      </el-form-item>
                    </template>
                    <!-- 手机号码 -->
                    <template>
                        <el-form-item label="手机号码" class="formItem" prop="administrator.telephone">
                            <el-input v-model="form.administrator.telephone" placeholder="请输入"
                                oninput="value=value.replace(/[^\d]/g,'')"></el-input>
                        </el-form-item>
                    </template>
                    <!-- 证件类型 -->
                    <template>
                        <el-form-item label="证件类型" class="formItem" prop="administrator.credentialType" v-if="!form.institutionalCode.startsWith('06')">
                            <el-select v-model="form.administrator.credentialType" :disabled="true" placeholder="请选择">
                                <el-option :label="item.label" :value="Number(item.value)"
                                    v-for="( item, index) in dictRegisterListObj.credentialType" :key="index">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </template>
                    <!-- 证件号码 -->
                    <template>
                        <el-form-item label="证件号码" class="formItem" prop="administrator.credentialNumber" v-if="!form.institutionalCode.startsWith('06')">
                            <el-input v-model="form.administrator.credentialNumber" placeholder="请输入"></el-input>
                        </el-form-item>
                    </template>
                </div>
                <!-- 系统管理员 区域 end-->

                <!-- 提交按钮 -->
                <div class="footerSubmit">
                    <el-button type="primary" style="width: 100%;" @click="submitForm('ruleForm')" :disabled="securitySource === 1">提交</el-button>
                </div>
            </el-form>
        </section>
        <section v-if="infoFlag" class="successSection">
            <i class="el-icon-success" style="color:green"></i> <strong>注册成功</strong>
            <em></em>
        </section>


    </section>
</template>
<script>
import { Notify, Uploader } from "vant";
import mixins from './mixins.js';//注入省市区
import { industryCodeSelectOrgApi, registrationSubmitApi, placeOfSuperviseCodeChangeDepartIdApi, pre_registrationApi, getSponsorListApi, checkCompanyIsExistApi } from '@/api/registerApi'
import obsConfig from '@/utils/obsConfig'
import { CodeToText } from 'element-china-area-data'//省市区联动插件
import validation from '@/utils/validation'
export default {
    mixins: [mixins],
    components: {
        [Uploader.name]: Uploader,
    },
    watch: {
        'form.institutionalCode'() {
            console.log(this.form.institutionalCode)
            if ((this.form.institutionalCode == '0103') || (this.form.institutionalCode == '0104')) {
                console.log('watch')
                this.$refs.fixedCapitalRef && this.$refs.fixedCapitalRef.clearValidate()//清除校验--固定资产（万元）
                this.$refs.annualSalesVolumeRef && this.$refs.annualSalesVolumeRef.clearValidate()//清除校验--年营业额（万元）
                this.$refs.annualProfitTaxRef && this.$refs.annualProfitTaxRef.clearValidate()//清除校验--年利税（万元）
            }
        },
        'form.serviceScopeList'() {
            console.log('5599', this.form.serviceScopeList)
            if (this.form.serviceScopeList.indexOf('08') > -1) {
                this.$set(this.form, 'isRiskAssessment', true)
            } else {
                this.$set(this.form, 'isRiskAssessment', false)
            }
        }
    },
    data() {
        return {
            showtips: false,
            infoFlag: false,//注册成功flag
            form: {
                //组织类型
                industryCode: '',//行业类型
                institutionalCode: '',//机构类型编码
                industryDetailType: '',//保安服务公司类型

                //基本信息
                name: '',//公司名称
                type: '',//总/分/子公司
                telephone: '',//联系电话
                economicType: '',//经济类型
                nature: '',//公司类型
                placeOfRegister: { province: { code: '', name: '' }, city: { code: '', name: '' }, district: { code: '', name: '' }, address: '' },//注册地区
                placeOfBusiness: { province: { code: '', name: '' }, city: { code: '', name: '' }, district: { code: '', name: '' }, address: '' },//经营地区
                placeOfCompetentUnit: { province: { code: '', name: '' }, city: { code: '', name: '' }, district: { code: '', name: '' }, address: '' }, // 内保行业主管单位所在地区
                parentName: '',//总公司名称
                parentCertificateType: 0,//总公司证件类型
                placeOfSupervise: { province: { code: '', name: '' }, city: { code: '', name: '' }, district: { code: '', name: '' }, address: '' },//监管地区
                administrator: {
                    name: '',
                    telephone: '',
                    credentialType: 0,//默认居民身份证/户口簿
                    credentialNumber: '',
                },
                legalPersonInfonationality: 'CHN',//默认国籍中国
                unifySocialCreditCodeFile: '',//营业执照扫描件
                unifySocialCreditCodeFilefileList: [],//营业执照扫描件-定义空图片数组
                servicePermitAttachment: '',//保安服务许可证扫描件
                servicePermitAttachmentList: [],//保安服务许可证扫描件-定义空图片数组
                superviseDepartIdoptions: [],//监管机构数据数组

                //法人或负责人信息
                legalPersonName: '',
                legalPersonTelephone: '',
                legalPersonCredentialType: '',
                legalPersonCredentialNumber: '',
                legalPersonNationality: 'CHN',

                securityPreparednessRating: 0,//人力防范评定等级,默认无
                securityArmedRating: 0,//武装守护押运评定等级,默认无
                securitySafetyDefenseRating: 0,//安全技术防范评定等级,默认无
                placeOfSuperviseCode: [],//['440000', '441300', '441322'] 监管机构-省市区编码
                isRiskAssessment: false,//是否有风险评估资质
                certificateType: 0,//注册信息-证件类型,默认
                competentUnitCode: '' // 主管单位编码, 内保行业时使用
            },
            institutionalCodeType: {},//根据行业类型选择机构类型
            queryNumber: '',//url邀请注册根据number回显
            queryNumberDisabled: false,
            sponsorInfo: {}, // 内保行业主管单位信息
            disabledIndustryCode: false, // 分享链接默认选择内保行业并禁用
            allArea: [], // 全部地区
            securitySource: null // 内保行业保安来源, 1、自招 2、外聘
        }
    },
    // eslint-disable-next-line no-dupe-keys
    watch: {
        queryNumber() {
            if (this.queryNumber) {
                this.queryNumberDisabled = true
            } else {
                this.queryNumberDisabled = false
            }
        },

        areaCityListArr() {
          if (this.areaCityListArr.length > 1) {
            this.allArea = this.areaCityListArr;
          }
        }
    },

    mounted() {
      let { shareEmployeeId, shareOrganizationId } = this.$route.query;
      shareEmployeeId ? this.form.shareEmployeeId = shareEmployeeId : null;
      shareOrganizationId ? this.form.shareOrganizationId = shareOrganizationId : null;
      shareEmployeeId && shareOrganizationId ? (this.form.industryCode = '04', this.disabledIndustryCode = true, this.industryCodeSelect(this.form.industryCode)) : null;
    },

    methods: {
        pre_registration() { //邀请注册回显
            pre_registrationApi(this.queryNumber).then(response => {
                console.log(response)
                console.log('7回显对象', response.data)
                if (response.status == 200) {
                    this.$nextTick(() => {
                        this.form = response.data
                        if (!this.form.placeOfRegister) {
                            this.form.placeOfRegister = { province: { code: '', name: '' }, city: { code: '', name: '' }, district: { code: '', name: '' }, address: '' }
                        }
                        if (!this.form.placeOfBusiness) {
                            this.form.placeOfBusiness = { province: { code: '', name: '' }, city: { code: '', name: '' }, district: { code: '', name: '' }, address: '' }
                        }
                        if (!this.form.placeOfSupervise) {
                            this.form.placeOfSupervise = { province: { code: '', name: '' }, city: { code: '', name: '' }, district: { code: '', name: '' }, address: '' }
                        }
                        if (!this.form.placeOfSuperviseCode) {
                            // this.form.placeOfSuperviseCode = []
                        }
                        if (!this.form.administrator) {
                            this.form.administrator = {
                                name: '',
                                telephone: '',
                                credentialType: 0,
                                credentialNumber: '',
                            }
                        }
                        if (this.form.industryCode) {
                            this.industryCodeSelect(this.form.industryCode, this.form.institutionalCode) //传递第二个参数，机构类型
                        }
                        // console.log('887', this.areaCityListArr)
                        if (this.form.placeOfSupervise && Object.keys(this.form.placeOfSupervise)) {
                            console.log('keys', Object.keys(this.form.placeOfSupervise))
                            let arr = [this.form.placeOfSupervise.province.code, this.form.placeOfSupervise.city.code, this.form.placeOfSupervise.district.code]
                            this.$set(this.form, 'placeOfSuperviseCode', arr)
                        }
                        console.log('this.areaCityListArr', this.areaCityListArr)
                        console.log('96', this.form.placeOfSuperviseCode)
                        // placeOfSuperviseCode = ['450000', '450100', '450101']//造数据测试
                        if (this.form.placeOfSuperviseCode) {
                            this.placeOfSuperviseCodeChange(this.form.placeOfSuperviseCode)
                        }
                        if (!this.form.certificateType) {
                            this.$set(this.form, 'certificateType', 0)
                        }
                        if (!this.form.legalPersonNationality) {
                            this.$set(this.form, 'legalPersonNationality', 'CHN')
                        }
                        if (!this.form.parentCertificateType) {
                            this.$set(this.form, 'parentCertificateType', 0)
                        }
                        // this.form.serviceScopeList = ['01']//测试
                        if (this.form.serviceScopeList.indexOf('08') > -1) {//如果服务范围有‘风险安全评估’，则是否有风险评估资质，选择‘是’
                            this.$set(this.form, 'isRiskAssessment', true)
                        } else {
                            this.$set(this.form, 'isRiskAssessment', false)
                        }
                    })
                }
            })
        },

        //根据行业类型选择机构类型
        industryCodeSelect(code, institutionalCode) {
            if (code === '06') {
              this.areaCityListArr = this.areaCityListArr.filter(item => item.label === '北京市');
            } else {
              this.areaCityListArr = [...this.allArea];
            }

            this.securitySource = null;
            this.form.placeOfSuperviseCode = [];

            industryCodeSelectOrgApi(code).then(response => {
                console.info('industryCode', response);

                if (response.data) {
                    this.form.institutionalCode = ''
                    this.institutionalCodeType = response.data
                    if (this.queryNumber) {
                        console.log('55', institutionalCode)
                        this.$set(this.form, 'institutionalCode', institutionalCode) // 回显-机构类型
                    }
                }
            })
        },
        //营业执照扫描件-上传
        unifySocialCreditCodeFilefileuploadFile(e) {
            var that = this;
            var domainId = "default"//保存本地企业id          
            let now = new Date()
            let y = now.getFullYear()
            let m = now.getMonth() + 1 < 10 ? '0' + (now.getMonth() + 1) : now.getMonth() + 1
            let d = now.getDate()
            let md = m + '-' + d
            var objectKey = `uploads/${y}/${md}/${domainId}/${now.getTime()}/${e.file.name}`
            var obs = new ObsClient({
                access_key_id: obsConfig.ak,
                secret_access_key: obsConfig.sk,
                server: obsConfig.urlserver,
                timeout: 60 * 5,
            });
            obs.putObject({
                Bucket: obsConfig.BucketName,
                Key: objectKey,
                SourceFile: e.file //获取file文件
            }).then(function (result) {
                console.log(result)

                if (result.CommonMsg.Status < 300) {
                    Notify({ type: 'success', message: "上传成功" })
                    console.log('Create object:' + objectKey + ' successfully!\n');
                    var httpurl = `https://${obsConfig.BucketName}.${obsConfig.urlserver}/${objectKey}`
                    httpurl = convertCdnPath(httpurl);
                    console.log('文件上传', httpurl)
                    that.form.unifySocialCreditCodeFile = httpurl
                    console.log(that.form)

                    that.$refs.unifySocialCreditCodeFilefileListRef.clearValidate();//上传完清除校验
                    // this.$set(this.form, 'unifySocialCreditCodeFilefileList', [{ url: httpurl }])
                }
            });
        },
        //营业执照扫描件-删除图片
        unifySocialCreditCodeFilefileuploadFileDel(url, index) {
            console.log(url)
            console.log(index)
            console.log(this.form)
            this.$set(this.form, 'unifySocialCreditCodeFilefileList', [])
            this.$set(this.form, 'unifySocialCreditCodeFile', '')
        },
        //保安服务许可证扫描件-上传
        servicePermitAttachmentuploadFile(e) {
            // debugger
            var that = this;
            var domainId = "default"//保存本地企业id          
            let now = new Date()
            let y = now.getFullYear()
            let m = now.getMonth() + 1 < 10 ? '0' + (now.getMonth() + 1) : now.getMonth() + 1
            let d = now.getDate()
            let md = m + '-' + d
            var objectKey = `uploads/${y}/${md}/${domainId}/${now.getTime()}/${e.file.name}`
            var obs = new ObsClient({
                access_key_id: obsConfig.ak,
                secret_access_key: obsConfig.sk,
                server: obsConfig.urlserver,
                timeout: 60 * 5,
            });
            obs.putObject({
                Bucket: obsConfig.BucketName,
                Key: objectKey,
                SourceFile: e.file //获取file文件
            }).then(function (result) {
                console.log(result)

                if (result.CommonMsg.Status < 300) {
                    Notify({ type: 'success', message: "上传成功" })
                    console.log('Create object:' + objectKey + ' successfully!\n');
                    var httpurl = `https://${obsConfig.BucketName}.${obsConfig.urlserver}/${objectKey}`
                    httpurl = convertCdnPath(httpurl);
                    console.log('文件上传', httpurl)
                    that.form.servicePermitAttachment = httpurl
                    console.log(that.form)

                    that.$refs.servicePermitAttachmentListRef.clearValidate();//上传完清除校验
                    // this.$nextTick(() => {
                    //     this.$set(this.form, 'servicePermitAttachmentList', [{ url: httpurl }])
                    // })
                }
            });
        },
        //保安服务许可证扫描件-删除图片
        servicePermitAttachmentuploadFileDel(url, index) {
            console.log(url)
            console.log(index)
            console.log(this.form)
            this.$set(this.form, 'servicePermitAttachmentList', [])
            this.$set(this.form, 'servicePermitAttachment', '')
        },
        onOversizeservicePermitAttachmentuploadFile(file) {
            Notify({ type: 'danger', message: '图片大小不能超过 5M' })
        },
        onOversizeunifySocialCreditCodeFilefileuploadFile(file) {
            Notify({ type: 'danger', message: '图片大小不能超过 5M' })
        },
        onOversizeservicePermitAttachmentuploadFileDel(file) {
            Notify({ type: 'danger', message: '图片大小不能超过 5M' })
        },
        //经营地区
        placeOfBusinessCodeChange(value) {
            this.form.placeOfBusiness = {
                province: { code: value[0], name: CodeToText[value[0]] },
                city: { code: value[1], name: CodeToText[value[1]] },
                district: { code: value[2], name: CodeToText[value[2]] },
            }
        },
        //注册地区
        placeOfRegisterCodeChange(value) {
            this.form.placeOfRegister = {
                province: { code: value[0], name: CodeToText[value[0]] },
                city: { code: value[1], name: CodeToText[value[1]] },
                district: { code: value[2], name: CodeToText[value[2]] },
            }
        },
        // 内保行业主管单位所在地区
        placeOfCompetentUnitCodeChange(value) {
          this.form.placeOfCompetentUnit = {
                province: { code: value[0], name: CodeToText[value[0]] },
                city: { code: value[1], name: CodeToText[value[1]] },
                district: { code: value[2], name: CodeToText[value[2]] },
            }
        },
        //根据监管地区改变查询监管机构接口
        placeOfSuperviseCodeChange(value) {
            console.log(value);
            console.info('llsl');
            console.log('this.form.superviseDepartIdArr', this.form.superviseDepartIdArr)
            this.form.placeOfSupervise = {
                province: { code: value[0], name: CodeToText[value[0]] },
                city: { code: value[1], name: CodeToText[value[1]] },
                district: { code: value[2], name: CodeToText[value[2]] },
            }
            console.log(this.form.placeOfSuperviseCode)
            console.log(this.form)
            if (this.form.placeOfSuperviseCode) {//监管地区--省市区编码
                let provideCode = this.form.placeOfSuperviseCode[0]//获取省，根据省获取监管机构列表
                placeOfSuperviseCodeChangeDepartIdApi(provideCode, this.form.industryCode).then(response => {
                    console.log('监管机构', response)
                    if (response.data) {

                        this.$set(this.form, 'superviseDepartIdoptions', [response.data])//数组
                        console.log('this.form.superviseDepartIdoptions', this.form.superviseDepartIdoptions)
                        if (this.queryNumber && this.form.superviseDepartIdoptions && this.form.superviseDepartId) {
                            let arr = this.getParentsByIdsuperviseDepartIdArr(this.form.superviseDepartIdoptions, this.form.superviseDepartId)//回显监管机构，拼接superviseDepartIdArr数组
                            console.log('arr', arr)
                            this.form.superviseDepartIdArr = arr
                            // console.log('this.form.superviseDepartIdArr2', this.form.superviseDepartIdArr)
                        }
                    }else{
                        this.$set(this.form, 'superviseDepartIdoptions', [])//数组

                    }

                })
            }
        },
        //下拉选择监管机构获取名称
        superviseDepartIdChange(value) {
            console.log(value)
            let labelName = this.$refs.myCascader.getCheckedNodes()[0].pathLabels;//获取el-cascader选中的中文label
            console.log(labelName)
            this.form.superviseDepartId = value[value.length - 1]
            this.form.superviseDepartName = labelName[labelName.length - 1]
            console.log(this.form)
            console.log('this.form.superviseDepartIdArr11', this.form.superviseDepartIdArr)
        },
        getParentsByIdsuperviseDepartIdArr(list, id) {
            // debugger
            for (let i in list) {
                if (list[i] && list[i].id == id) {
                    //查询到就返回该数组对象的value
                    return [list[i].id]
                }
                if (list[i].children) {
                    let node = this.getParentsByIdsuperviseDepartIdArr(list[i].children, id)
                    // debugger
                    if (node !== undefined) {
                        //查询到把父节把父节点加到数组前面
                        node.unshift(list[i].id)
                        return node
                    }
                }
            }
        },
        serviceScopeListChange() {
            console.log('855', this.form.serviceScopeList)
            if (this.form.serviceScopeList.indexOf('08') > -1) {
                this.$set(this.form, 'isRiskAssessment', true)
            } else {
                this.$set(this.form, 'isRiskAssessment', false)
            }
        },
        formatDecimal(str, num) {//只能输入数字和一个小数点
            str = String(str)
            if (!str.trim()) {
                return str
            }
            var len1 = str.substr(0, 1)
            var len2 = str.substr(1, 1)
            console.log('len2', len2)
            // 如果第一位是0，第二位不是点，就用数字把点替换掉
            if (str.length > 1 && len1 === 0 && len2 !== '.') {
                str = str.substr(1, 1)
            }
            // 第一位不能是.
            if (len1 === '.') {
                str = ''
            }
            // 限制只能输入一个小数点
            if (str.indexOf('.') !== -1) {
                var str_ = str.substr(str.indexOf('.') + 1)
                if (str_.indexOf('.') !== -1) {
                    str = str.substr(0, str.indexOf('.') + str_.indexOf('.') + 1)
                }
            }
            // 正则替换
            str = str.replace(/[^\d^.]+/g, '') // 保留数字和小数点
            if (num || num === 0) {
                var rest = str.split('.')[1]
                if (rest && rest.length > num) {
                    rest = rest.substr(0, num)
                    str = str.split('.')[0] + '.' + rest
                }
            }
            return str
        },
        async submitForm() {
            console.log(this.form)
            if (this.form.industryCode == '02') {
                Notify({ type: 'danger', message: '暂时不支持行业类型为大活行业注册' })
                return
            }

            console.log(validation.mobile(this.form.legalPersonTelephone), this.form.legalPersonTelephone);
            if (this.form.placeOfRegisterCode) {
                this.form.placeOfRegister.province.code = this.form.placeOfRegisterCode[0]
                this.form.placeOfRegister.city.code = this.form.placeOfRegisterCode[1]
                this.form.placeOfRegister.district.code = this.form.placeOfRegisterCode[2]
            }
            if (this.form.placeOfBusinessCode) {
                this.form.placeOfBusiness.province.code = this.form.placeOfBusinessCode[0]
                this.form.placeOfBusiness.city.code = this.form.placeOfBusinessCode[1]
                this.form.placeOfBusiness.district.code = this.form.placeOfBusinessCode[2]
            }
            if (this.form.placeOfCompetentUnitCode) {
                this.form.placeOfCompetentUnit.province.code = this.form.placeOfCompetentUnitCode[0]
                this.form.placeOfCompetentUnit.city.code = this.form.placeOfCompetentUnitCode[1]
                this.form.placeOfCompetentUnit.district.code = this.form.placeOfCompetentUnitCode[2]
            }
            if (this.form.placeOfSuperviseCode) {
                this.form.placeOfSupervise.province.code = this.form.placeOfSuperviseCode[0]
                this.form.placeOfSupervise.city.code = this.form.placeOfSuperviseCode[1]
                this.form.placeOfSupervise.district.code = this.form.placeOfSuperviseCode[2]
            }
            if (this.form.superviseDepartIdArr) {
                this.form.superviseDepartId = this.form.superviseDepartIdArr[this.form.superviseDepartIdArr.length - 1]
            }

            // 群防群治行业时，系统管理员证件类型为6，警号
            if (this.form.industryCode === '06') {
              this.form.administrator.credentialType = 6;
            }

            this.$refs['ruleForm'].validate(async (valid) => {
                if (valid) {
                    if (!this.form.institutionalCode.startsWith('03') && !this.form.institutionalCode.startsWith('04') && !this.form.institutionalCode.startsWith('05') && !this.form.institutionalCode.startsWith('06') && !validation.mobile(this.form.telephone)) {
                        Notify({ type: 'danger', message: '请输入基本信息--正确的联系电话' })
                        return
                    }

                    if (this.form.institutionalCode == '0102' && (this.form.type == '2' || this.form.type == '3')) {
                        if (this.form.parentCertificateType == 0 && this.form.parentCertificateNumber && this.form.parentCertificateNumber.length != 18) {
                            console.log(this.form.parentCertificateNumber)
                            Notify({ type: 'danger', message: '请输入正确的总公司信息-总公司证件号码-只能输入18位' })
                            return
                        }
                        if (!validation.mobile(this.form.parentLegalPersonTelephone)) {
                            Notify({ type: 'danger', message: '请输入正确的总公司联系电话' })
                            return
                        }
                    }

                    if (!this.form.institutionalCode.startsWith('06') && !validation.mobile(this.form.legalPersonTelephone)) {
                        Notify({ type: 'danger', message: '请输入法人或负责人信息--正确的手机号码' })
                        return
                    }
                    if (this.form.institutionalCode == '0104' && !validation.mobile(this.form.securityPersonTelephone)) {
                        Notify({ type: 'danger', message: '请输入保安负责人--正确的手机号码' })
                        return
                    }
                    if (this.form.unifySocialCreditCode && this.form.unifySocialCreditCode.length != 18) {
                        Notify({ type: 'danger', message: '统一社会信用代码--只能输入18位' })
                        return
                    }
                    if (!validation.mobile(this.form.administrator.telephone)) {
                        Notify({ type: 'danger', message: '请输入系统管理员--正确的手机号码' })
                        return
                    }
                    if (this.form.legalPersonCredentialType == '0' && !this.form.institutionalCode.startsWith('06') && !validation.idCard(this.form.legalPersonCredentialNumber)) {
                        Notify({ type: 'danger', message: '法人或负责人信息--请输入合法的证件号码' })
                        return
                    }
                    if (this.form.institutionalCode == '0104' && this.form.securityPersonCredentialType == '0' && !validation.idCard(this.form.securityPersonCredentialNumber)) {
                        Notify({ type: 'danger', message: '保安负责人--请输入合法的证件号码' })
                        return
                    }
                    if (!this.form.institutionalCode.startsWith('06') && this.form.administrator.credentialType == '0' && !validation.idCard(this.form.administrator.credentialNumber)) {
                        Notify({ type: 'danger', message: '系统管理员--请输入合法的证件号码' })
                        return
                    }

                    if (!this.form.superviseDepartName) {
                        await this.superviseDepartCodeName()//根据监管地区，传递省编码，获取监管机构列表，在根据监管机构编码找出监管机构名称
                    }
  
                    console.log('this.form11', this.form)
                    let obj = JSON.stringify(this.form)
                    let obj2 = JSON.parse(obj)
                    delete obj2.unifySocialCreditCodeFilefileList
                    delete obj2.servicePermitAttachmentList
                    delete obj2.superviseDepartIdoptions
                    delete obj2.placeOfSuperviseCode
                    delete obj2.superviseDepartIdArr
                    await registrationSubmitApi(obj2).then(response => {
                        console.log('提交', response)
                        if (response.status == 200) {
                            this.infoFlag = true
                        }
                    });
                } else {
                    Notify({ type: 'danger', message: '请输入必填项' })
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        tips() {
            this.showtips = true
        },
        //根据监管地区，传递省编码，获取监管机构列表，在根据监管机构编码找出监管机构名称
        async superviseDepartCodeName() {
            let provideCode = this.form.placeOfSuperviseCode[0]
            await placeOfSuperviseCodeChangeDepartIdApi(provideCode, this.form.industryCode).then(response => {
                if (response.data) {
                    this.getDepartNameForDepartCode([response.data])//递归遍历获取监管名称
                    console.log('this.form12', this.form)
                }
            })
        },
        //递归遍历获取监管名称
        getDepartNameForDepartCode(list) {
            for (let i in list) {
                if (list[i] && list[i].id == this.form.superviseDepartId) {
                    return this.$set(this.form, 'superviseDepartName', list[i].name)
                }
                if (list[i].children) {
                    this.getDepartNameForDepartCode(list[i].children)
                }
            }
        },

        // 内保行业根据institutionalCode获取主管单位列表
        changeInstitutionalCode(institutionalCode) {
          if (!institutionalCode.startsWith('04')) return;
          // getSponsorListApi(institutionalCode).then(response => {
          //   let { status, data } = response;
          //   if (status !== 200) {
          //     return;
          //   }
            
          //   this.sponsorInfo = data[0];
          //   this.form.competentUnitCode = data[0].value;
          // });
        },

        // 内部行业切换保安来源
        changeSecuritySource() {
          if (this.securitySource === 1) {
            this.$confirm('您单位保安员若属于自招，请选择行业类型为【保安行业】、机构类型为【自行招用保安员单位】进行注册！', '提示', {
              type: 'warning',
              center: true,
              showCancelButton: false,
              showConfirmButton: false
            }).then(() => {}).catch(() => {});
          }
        },

        // 判断公司名称是否已经存在
        checkNameIsExist() {
          let params = {
            name: this.form.name
          };

          checkCompanyIsExistApi(params).then(res => {
            let { exist } = res.data;
            if (exist) {
              this.$confirm('当前单位已开通系统账号，可致电客服电话：400662996了解具体账号信息。', '提示', {
                type: 'warning',
                center: true,
                showCancelButton: false,
                showConfirmButton: false
              }).then(() => {}).catch(() => {});
            }
          });
        }
    }
}
</script>

<style lang="less">
.RegisterContainerBox {
    padding: 10px 10px 70px;
    font-size: 14px;

    .headerInfo {
        border: 1px solid #d9d9d9;
        border-radius: 4px;
        padding: 5px;
        text-align: left;
    }

    .contentMainBox {
        display: flex;
        flex-direction: column;
        margin-top: 20px;
        width: 100%;

        .title {
            margin-bottom: 10px;
            text-align: left;
            display: flex;

            i {
                width: 2px;
                height: 20px;
                background: #1c79ff;
                margin-right: 10px;
            }

            strong {
                color: #333333;
            }
        }
    }

    .successSection {
        font-size: 20px;
        margin-top: 20px;
    }
}
</style>
<style lang="less">
.RegisterContainerBox {
    .formItem {
        display: flex;
        flex-direction: column;

        .el-form-item__label {
            text-align: left;
        }

        .el-select {
            width: 100%;
        }
    }

    .areaItem {}

    .footerSubmit {
        position: fixed;
        bottom: 10px;
        width: 95%;
        z-index: 100;
    }

    .tipsImg {
        width: 17px;
        height: 17px;
        margin-left: 5px;
        vertical-align: -3px;
    }

    .tipsContent {
        text-align: left;
    }

}
</style>
<style>
.el-cascader-menu {
    min-width: 0;
    flex: 1;
}

.el-cascader-node {
    height: auto !important;
}

/* 手机模式 */
@media screen and (max-width:720px) {
    .myCascaderplaceClass .el-cascader-node {
        padding: 0;
        max-width: 150px;
        overflow: auto !important;
    }
}


.myCascaderplaceClass .el-cascader-node__label {
    overflow: auto;
    text-overflow: clip !important;
}

.myCascaderplaceClass .el-cascader-menu {
    min-width: 0px !important;
}

/* 手机模式 */
@media screen and (max-width:720px) {
    .myCascaderDepartClass .el-cascader-node {
        padding: 0;
        max-width: 100px;
    }
}

.myCascaderDepartClass .el-cascader-node__label {
    overflow: auto;
    text-overflow: clip !important;
}

.myCascaderDepartClass .el-cascader-menu {
    min-width: 0px !important;
}


.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.avatar-uploader .el-upload:hover {
    border-color: #409EFF;
}

.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 100px;
    height: 100px;
    line-height: 100px;
    text-align: center;
}

.avatar {
    width: 100px;
    height: 100px;
    display: block;
}

.img-tip {
  text-align: left;
  font-size: 12px;
}
</style>