<template>
  <div>
    <div class="app-container" style="padding-right:40px">
      <el-form ref="form" :model="form" :form="form" :rules="rules" label-width="240px">
        <el-divider content-position="left">基本信息</el-divider>
        <el-row v-if="isAdmin">
          <el-col :span="12">
            <el-form-item label="会员级别" prop="VIPLEVEL">
              <el-select v-model="form.VIPLEVEL" clearable placeholder="请选会员级别" style="width: 100%">
                <el-option v-for="item in agentNumList" :key="item.ROLE_ID" :label="item.ROLE_NAME" :value="item.ROLE_ID" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-else-if="msg=='add'">
          <el-col :span="12">
            <el-form-item label="会员级别" prop="AGENT_NUMBER_ID">
              <el-select v-model="form.AGENT_NUMBER_ID" clearable placeholder="请选会员级别" style="width: 100%">
                <el-option v-for="item in agentNumList" :key="item.AGENT_NUMBER_ID" :label="item.ROLE_NAME" :value="item.AGENT_NUMBER_ID" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="企业名称" prop="CORP_NAME">
              <el-input v-model="form.CORP_NAME" placeholder="请输入内容" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="邮政编码">
              <el-input v-model="form.POSTAL_CODE" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="统一社会信用代码" prop="CODE">
              <el-input v-model="form.CODE" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <!--          <el-col :span="12">-->
          <!--            <el-form-item label="属地" prop="POSSESSION">-->
          <!--              <el-cascader id="POSSESSION" ref="POSSESSION" v-model="form.POSSESSION" :options="areaList" :props="areaProps" placeholder="请选择省市县" style="width: 100%"/>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
          <el-col :span="12">
            <el-form-item label="行业监管部门" prop="INDUSTRY_DEPARTMENT">
              <el-input id="INDUSTRY_DEPARTMENT" ref="INDUSTRY_DEPARTMENT" :disabled="true" v-model="form.INDUSTRY_DEPARTMENTName" maxlength="255" placeholder="请选择市行业监管部门..." title="市行业监管部门" />
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="属地" prop="POSSESSION">
              <el-cascader id="POSSESSION" ref="POSSESSION" v-model="form.POSSESSION" :options="areaList" :props="areaProps" placeholder="请选择省市县" style="width: 100%" @change="changeArea" @visible-change="changeArea1"/>
            </el-form-item>
          </el-col>
          <!--          <el-col :span="12">-->
          <!--            <el-form-item label="监管类型" prop="REGULARTYPE">-->
          <!--              <Treeselect-->
          <!--                :options="varOList"-->
          <!--                :normalizer="normalizer"-->
          <!--                v-model="form.REGULARTYPE"-->
          <!--                placeholder="请选择监管类型"-->
          <!--                no-options-text="暂无数据"-->
          <!--                no-children-text="暂无数据"-->
          <!--                style="width: 100%;"-->
          <!--              />-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="所属行业" prop="INDUSTRYALL">
              <el-cascader
                ref="industryCascader"
                v-model="form.INDUSTRYALL"
                :options="hylxList"
                :props="industryProps"
                :show-all-levels="false"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="经济类型" prop="ECO_TYPEALL">
              <!-- <SelectTree ref="jjlxTree" :clearable="false" :options="jjlxList" :props="defaultProps" v-model="ECO_TYPE" :canparent="false" placeholder="请选择" @change="handleEco" /> -->

              <el-cascader
                ref="ecoCascader"
                v-model="form.ECO_TYPEALL"
                :options="jjlxList"
                :props="ecoProps"
                :show-all-levels="false"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="12">
            <el-form-item label="企事业单位经营地址" prop="ADDRESS_BUSINESS">
              <el-input v-model="form.ADDRESS_BUSINESS" maxlength="255" placeholder="这里输入企事业单位经营地址..." title="企事业单位经营地址"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="企业状态" prop="CORP_STATE">
              <el-select v-model="form.CORP_STATE" placeholder="请选择" style="width: 100%">
                <el-option v-for="item in corpStateList" :key="item.DICTIONARIES_ID" :label="item.NAME" :value="item.DICTIONARIES_ID" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row/>

        <el-row>
          <el-col :span="12">
            <el-form-item label="经度" prop="LONGITUDE">
              <el-input v-model="form.LONGITUDE" placeholder="请输入内容" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <div class="ud-flex">
              <div style="flex:1">
                <el-form-item label="纬度" prop="LATITUDE">
                  <el-input v-model="form.LATITUDE" placeholder="请输入内容" disabled />
                </el-form-item>
              </div>
              <div>
                <el-button style="margin-left:10px" @click="handleMap">
                  <span class="svg-container">
                    <svg-icon icon-class="international" />
                  </span>
                </el-button>
              </div>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="主要负责人" prop="CONTACTS">
              <el-input v-model="form.CONTACTS" placeholder="请输入内容" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="主要负责人电话" prop="CONTACTS_PHONE">
              <el-input v-model="form.CONTACTS_PHONE" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="12">
            <el-form-item label="法定代表人">
              <el-input v-model="form.LR_NAME" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="法人手机号">
              <el-input v-model="form.LR_PHONE" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="12">
            <el-form-item label="占地面积（㎡）">
              <el-input v-model="form.AREA_COVERED" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="职工人数(人)">
              <el-input v-model="form.EMPLOYEES" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="成立时间">
              <el-date-picker id="CREATE_DATE" ref="CREATE_DATE" v-model="form.CREATE_DATE" value-format="yyyy-MM-dd" format="yyyy-MM-dd" style="width: 100%" type="date" placeholder="请选择" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="注册资金（万元）">
              <el-input v-model="form.REGCAPITAL" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="资产总额（万元）">
              <el-input v-model="form.TOTALASSETS" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="密钥">
              <el-input v-model="form.CORPINFOKEY" placeholder="请输入内容" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="隶属关系">
              <el-select v-model="form.SUBORDINATION" clearable placeholder="请选隶属关系" style="width: 100%">
                <el-option v-for="item in subordinationList" :key="item.DICTIONARIES_ID" :label="item.NAME" :value="item.DICTIONARIES_ID" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!--        <el-row>-->
        <!--          <el-col :span="12">-->
        <!--            <el-form-item label="企业类型" prop="CORP_OF_TYPEAll">-->
        <!--              <SelectTree-->
        <!--                ref="corpOfTypeRef"-->
        <!--                :options="corpFoTypeList"-->
        <!--                :props="propsCorpFoType"-->
        <!--                :canparent="false"-->
        <!--                v-model="form.CORP_OF_TYPEAll"-->
        <!--                placeholder="请选择企业类型"-->
        <!--                style="width: 100%"-->
        <!--                node-key="id"-->
        <!--                @change="changeCorpType('form','CORP_OF_TYPE')"-->
        <!--              />-->
        <!--            </el-form-item>-->
        <!--          </el-col>-->
        <!--      -->
        <!--        </el-row>-->
        <el-row>

          <el-col :span="12">
            <el-form-item label="规模">
              <el-select v-model="form.SCALE" placeholder="请选择" style="width: 100%">
                <el-option v-for="item in scaleList" :key="item.DICTIONARIES_ID" :label="item.NAME" :value="item.DICTIONARIES_ID" />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="是否规模以上" prop="SCALE_TYPE">
              <el-radio-group id="SCALE_TYPE" ref="SCALE_TYPE" v-model="form.SCALE_TYPE">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="12">
            <el-form-item label="培训行业类型" prop="TRAINTYPE">
              <SelectTree ref="keyHyRef" :options="trainDicList" :props="defaultProps" v-model="form.TRAINTYPE" style="width: 100%" placeholder="请选择培训行业类型" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="企业可新建用户数量" prop="USERS_NUM">
              <el-input v-if="isAdmin" v-model="form.USERS_NUM" placeholder="企业新建用户数量" />
              <el-select v-else v-model="form.USERS_NUM" :disabled="form.VIPLEVEL == '' || msg == 'edit'" clearable placeholder="请选会员档位" style="width: 100%">
                <el-option v-for="item in vipGearList" :key="item.GEAR_ID" :disabled="item.remainCount === 0" :label="item.GEAR_NAME" :value="item.GEAR_NUMBER" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="form.ISDELIVER!=1 && form.ISDELIVER!=0">
          <el-col :span="12">
            <el-form-item label="是否为试用企业">
              <el-radio-group v-model="form.ISTRIAL">
                <el-radio label="1" value="1">否</el-radio>
                <el-radio label="0" value="0">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col v-show="form.ISTRIAL == 0" :span="10">
            <el-form-item label="试用时间(天)" required>
              <el-select v-model="form.TRIALTIME" placeholder="请选择">
                <el-option v-for="item in formList" :key="item.ID" :label="item.NAME" :value="item.ID" />
              </el-select>
              <!--              <el-input-->
              <!--                id="TRIALTIME"-->
              <!--                ref="TRIALTIME"-->
              <!--                v-model="form.TRIALTIME"-->
              <!--                onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"-->
              <!--                onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\sD/g,'')}"-->
              <!--                oninput="value=value.replace(/[^\d]/g,'')"-->
              <!--                placeholder="这里输入试用时间..."-->
              <!--                title="试用时间"/>-->
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="四色图类型">
              <template>
                <el-radio v-model="form.FOURTYPE" label="1">平面四色图</el-radio>
                <el-radio v-model="form.FOURTYPE" label="2">3D图</el-radio>
              </template>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="form.FOURTYPE == '1'">
          <el-col :span="24">
            <div class="lh-1">
              <el-form-item label="四色图">
                <div class="disContent">
                  <div v-for="(item, index) in four_images" :key="index" class="img-div">
                    <img :src="config.fileUrl + item.FILEPATH" alt="">
                    <div class="disContent-hide">
                      <el-tooltip class="item" effect="dark" content="预览" placement="top">
                        <span class="el-icon-zoom-in yuLan">
                          <viewer :images="four_images">
                            <img :src="config.fileUrl + item.FILEPATH" alt="" class="yuLanImg">
                          </viewer>
                        </span>
                      </el-tooltip>
                      <el-tooltip class="item" effect="dark" content="删除" placement="top">
                        <span class="Delete" @click="deleteFourImage(index)"><i class="el-icon-delete" /></span>
                      </el-tooltip>
                    </div>
                  </div>
                  <el-upload ref="fourUpload" :on-preview="handlePictureCardPreview" :on-change="fourBeforeFileUpload" :auto-upload="false" class="avatar-uploader" action="#" accept=".jpg,.jpeg,.png" list-type="picture-card">
                    <i class="el-icon-plus" />
                  </el-upload>
                </div>

                <div style="margin-top:10px;color:red">四色图：请上传1480*640格式的图片</div>
                <el-dialog :visible.sync="dialogVisible">
                  <img :src="dialogImageUrl" width="100%" alt="">
                </el-dialog>
              </el-form-item>
            </div>
          </el-col>
        </el-row>
        <el-row v-else-if="form.FOURTYPE=='2'">
          <el-col :span="12">
            <el-form-item label="四色图">
              <span v-if="form.FFILE">{{ form.FFILE.name }}</span>
              <el-upload ref="four3dUpload" :before-upload="before3DFileUpload" class="avatar-uploader" action="">
                <el-button type="primary">上传</el-button>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <div class="lh-1">
              <el-row>
                <el-col :span="24">
                  <div class="lh-1">
                    <el-form-item label="营业执照" class="is-required">
                      <div class="disContent">
                        <div v-for="(item, index) in bus_images" :key="index" class="img-div">
                          <img :src="config.fileUrl + item.FILEPATH" alt="">
                          <div class="disContent-hide">
                            <el-tooltip class="item" effect="dark" content="预览" placement="top">
                              <span class="el-icon-zoom-in yuLan">
                                <viewer :images="bus_images">
                                  <img :src="config.fileUrl + item.FILEPATH" alt="" class="yuLanImg">
                                </viewer>
                              </span>
                            </el-tooltip>
                            <el-tooltip class="item" effect="dark" content="删除" placement="top">
                              <span class="Delete" @click="deleteImage(index)"><i class="el-icon-delete" /></span>
                            </el-tooltip>
                          </div>
                        </div>
                        <el-upload ref="upload" :on-preview="handlePictureCardPreview" :on-change="beforeFileUpload" :auto-upload="false" class="avatar-uploader" action="#" accept=".jpg,.jpeg,.png" list-type="picture-card">
                          <i class="el-icon-plus" />
                        </el-upload>
                      </div>

                      <el-dialog :visible.sync="dialogVisible">
                        <img :src="dialogImageUrl" width="100%" alt="">
                      </el-dialog>
                    </el-form-item>
                  </div>

                </el-col>
              </el-row>
            </div>

          </el-col>
        </el-row>

        <template v-if="form.PERSONNEL_POSITION===0">
          <el-divider content-position="left">人员定位信息</el-divider>
          <el-row>
            <el-col :span="24">
              <el-form-item label="定位系统地址" prop="POST_URL">
                <el-input id="POST_URL" ref="POST_URL" v-model="form.POST_URL" maxlength="255" placeholder="请输入..." title="定位系统地址"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="账号" prop="ACCOUNT">
                <el-input id="ACCOUNT" ref="ACCOUNT" v-model="form.ACCOUNT" maxlength="255" placeholder="请输入..." title="账号"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="密码" prop="PASSWORD">
                <el-input id="PASSWORD" ref="PASSWORD" v-model="form.PASSWORD" maxlength="255" placeholder="请输入..." title="PASSWORD"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="地图格式" prop="USE_URL">
                <el-radio-group id="USE_URL" ref="USE_URL" v-model="form.USE_URL">
                  <el-radio label="T">瓦片地图</el-radio>
                  <el-radio label="p">倾斜摄影</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col v-if="form.USE_URL==='T'" :span="12">
              <el-form-item label="瓦片地址" prop="TILES3D_URL">
                <el-input id="TILES3D_URL" ref="TILES3D_URL" v-model="form.TILES3D_URL" maxlength="255" placeholder="请输入..." title="TILES3D_URL"/>
              </el-form-item>
            </el-col>
          </el-row>
        </template>

        <el-divider content-position="left">安全负责人信息</el-divider>
        <el-row>
          <el-col :span="12">
            <el-form-item label="姓名" prop="SAFETY_NAME">
              <el-input id="SAFETY_NAME" ref="SAFETY_NAME" v-model="form.SAFETY_NAME" maxlength="255" placeholder="这里输入安全负责人信息..." title="安全负责人信息"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="职务" prop="SAFETY_POST">
              <el-input id="SAFETY_POST" ref="SAFETY_POST" v-model="form.SAFETY_POST" maxlength="255" placeholder="这里输入安全负责人职务..." title="安全负责人职务"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="单位电话" prop="SAFETY_NUMBER">
              <el-input id="SAFETY_NUMBER" ref="SAFETY_NUMBER" v-model="form.SAFETY_NUMBER" maxlength="255" placeholder="这里输入安全负责人单位电话..." title="安全负责人单位电话"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="手机号码" prop="SAFETY_PHONE">
              <el-input id="SAFETY_PHONE" ref="SAFETY_PHONE" v-model="form.SAFETY_PHONE" maxlength="255" placeholder="这里输入安全负责人手机号码..." title="安全负责人手机号码"/>
            </el-form-item>
          </el-col>
        </el-row>
        <!--        <el-divider content-position="left">安全标准化</el-divider>-->
        <!--        <el-row>-->
        <!--          <el-col :span="12">-->
        <!--            <el-form-item label="安全标准化等级" prop="AQ_BZ_LEVEL">-->
        <!--              <el-select id="AQ_BZ_LEVEL" ref="AQ_BZ_LEVEL" v-model="form.AQ_BZ_LEVEL" clearable placeholder="请选择安全标准化等级" style="width: 100%" >-->
        <!--                <el-option v-for="item in safStaLevList" :key="item.DICTIONARIES_ID" :label="item.NAME" :value="item.DICTIONARIES_ID"/>-->
        <!--              </el-select>-->
        <!--            </el-form-item>-->
        <!--          </el-col>-->
        <!--          <el-col :span="12">-->
        <!--            <el-form-item label="安全标准化证书编号" prop="AQ_BZ_NO">-->
        <!--              <el-input id="AQ_BZ_NO" ref="AQ_BZ_NO" v-model="form.AQ_BZ_NO" maxlength="255" placeholder="这里输入安全标准化证书编号..." title="安全标准化证书编号"/>-->
        <!--            </el-form-item>-->
        <!--          </el-col>-->
        <!--        </el-row>-->
        <!--        <el-row>-->
        <!--          <el-col :span="12">-->
        <!--            <el-form-item label="安全标准化发证单位" prop="AQ_BZ_UNIT">-->
        <!--              <el-input id="AQ_BZ_UNIT" ref="AQ_BZ_UNIT" v-model="form.AQ_BZ_UNIT" maxlength="255" placeholder="这里输入安全标准化发证单位..." title="安全标准化发证单位"/>-->
        <!--            </el-form-item>-->

        <!--          </el-col>-->
        <!--          <el-col :span="12">-->
        <!--            <el-form-item label="安全标准化有效期" prop="AQ_BZ_TIME">-->
        <!--              <el-date-picker id="AQ_BZ_TIME" ref="AQ_BZ_TIME" v-model="form.AQ_BZ_TIME" value-format="yyyy-MM-dd" format="yyyy-MM-dd" style="width: 100%" type="date" placeholder="这里输入安全标准化有效期"/>-->
        <!--            </el-form-item>-->
        <!--          </el-col>-->
        <!--        </el-row>-->
        <el-divider content-position="left">企业相关属性</el-divider>
        <el-row>
          <el-col :span="12">
            <el-form-item label="有无职业卫生信息" prop="WHETHER_HYGIENE">
              <el-radio-group id="WHETHER_HYGIENE" ref="WHETHER_HYGIENE" v-model="form.WHETHER_HYGIENE">
                <el-radio :label="0">无</el-radio>
                <el-radio :label="1">有</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无重大危险源" prop="WHETHER_HAZARDS">
              <el-radio-group id="WHETHER_HAZARDS" ref="WHETHER_HAZARDS" v-model="form.WHETHER_HAZARDS">
                <el-radio :label="0">无</el-radio>
                <el-radio :label="1">有</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否有稀缺大型应急物资或设施" prop="WHETHER_SCARCE">
              <el-radio-group id="WHETHER_SCARCE" ref="WHETHER_SCARCE" v-model="form.WHETHER_SCARCE">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否涉及危化品" prop="WHETHER_CHEMICALS">
              <el-radio-group id="WHETHER_CHEMICALS" ref="WHETHER_CHEMICALS" v-model="form.WHETHER_CHEMICALS">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="有无特种设备" prop="WHETHER_SPECIALEQUIPMENT">
              <el-radio-group id="WHETHER_SPECIALEQUIPMENT" ref="WHETHER_SPECIALEQUIPMENT" v-model="form.WHETHER_SPECIALEQUIPMENT">
                <el-radio :label="0">无</el-radio>
                <el-radio :label="1">有</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有无特种作业人员" prop="WHETHER_SPECIALPEOPLE">
              <el-radio-group id="WHETHER_SPECIALPEOPLE" ref="WHETHER_SPECIALPEOPLE" v-model="form.WHETHER_SPECIALPEOPLE">
                <el-radio :label="0">无</el-radio>
                <el-radio :label="1">有</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否涉及煤气" prop="WHETHER_COALGAS">
              <el-radio-group id="WHETHER_COALGAS" ref="WHETHER_COALGAS" v-model="form.WHETHER_COALGAS">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否属于消防重点单位" prop="WHETHER_FIRE">
              <el-radio-group id="WHETHER_FIRE" ref="WHETHER_FIRE" v-model="form.WHETHER_FIRE">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否在有限空间作业" prop="WHETHER_CONFINED">
              <el-radio-group id="WHETHER_CONFINED" ref="WHETHER_CONFINED" v-model="form.WHETHER_CONFINED">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否存在涉爆粉尘作业" prop="WHETHER_POWDER">
              <el-radio-group id="WHETHER_POWDER" ref="WHETHER_POWDER" v-model="form.WHETHER_POWDER">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否涉及防雷防静电" prop="WHETHER_LIGHTNING">
              <el-radio-group id="WHETHER_LIGHTNING" ref="WHETHER_LIGHTNING" v-model="form.WHETHER_LIGHTNING">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否持有放射源" prop="WHETHER_ACTINOGEN">
              <el-radio-group id="WHETHER_ACTINOGEN" ref="WHETHER_ACTINOGEN" v-model="form.WHETHER_ACTINOGEN">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否涉及液氨制冷" prop="WHETHER_LIQUIDAMMONIA">
              <el-radio-group id="WHETHER_LIQUIDAMMONIA" ref="WHETHER_LIQUIDAMMONIA" v-model="form.WHETHER_LIQUIDAMMONIA">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否涉及危化品管道" prop="WHETHER_PIPELINE">
              <el-radio-group id="WHETHER_PIPELINE" ref="WHETHER_PIPELINE" v-model="form.WHETHER_PIPELINE">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
    </div>
    <div class="ui-height" />
    <div class="ui-foot">
      <el-button type="success" @click="confirm">保存</el-button>
      <el-button type="info" @click="goBack">返回</el-button>
    </div>

    <el-dialog :visible.sync="dialogFormMap" title="编辑坐标" width="800px" class="dy-dialog">
      <baidu-map
        v-loading="loadingMap"
        :zoom="zoom"
        :scroll-wheel-zoom="true"
        :style="{height: clientHeight+'px'}"
        @click="getClickInfo"
        @ready="handler">
        <bm-view style="width: 100%; height:100%; flex: 1" />
        <bm-control ref="control" :offset="{width: 10, height: 10}" anchor="BMAP_ANCHOR_TOP_LEFT">
          <div class="map-flex">

            <div class="map-lable">关键词：</div>
            <div style="flex:1;">
              <el-autocomplete v-model="addressKeyword" :fetch-suggestions="querySearch" :trigger-on-focus="false" placeholder="请输入详细地址" style="width:100%" @select="handleSelect" />
            </div>
            <!--            <el-input v-model="addressKeyword" style="width: 200px" placeholder="请输入内容" />-->
            <!--            <el-button slot="append" icon="el-icon-search" @click="mapNameChange"/>-->
          </div>
        </bm-control>
        <!--        <bm-local-search :keyword="addressKeyword" :auto-viewport="true"/>-->
      </baidu-map>
      <div slot="footer" class="dialog-footer">
        <span>经度：</span>
        <el-input v-model="LONGITUDE" style="width: 200px" placeholder="请输入内容" disabled />
        <span>纬度：</span>
        <el-input v-model="LATITUDE" style="width: 200px" placeholder="请输入内容" disabled />
        <el-button @click="dialogFormMap = false">取 消</el-button>
        <el-button type="primary" @click="setPosition">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { requestFN } from '@/utils/request'
import SelectTree from '@/components/SelectTree'
import { upload } from '@/utils/upload'
import { Message } from 'element-ui'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
export default {
  components: { SelectTree, Treeselect },
  data() {
    var hasCorp = (rule, value, callback) => {
      requestFN(
        '/corpinfo/hasCorp',
        {
          CORP_NAME: this.form.CORP_NAME,
          CORPINFO_ID: this.form.CORPINFO_ID
        }
      ).then((data) => {
        if (data.result == 'success' || this.msg == 'edit') {
          if (data.msg) {
            Message({
              message: data.msg,
              type: data.type,
              duration: 5 * 1000
            })
          }
          callback()
        }
      }).catch((e) => {

      })
    }
    return {
      unwatch: null,
      config: config,
      USER_ID: JSON.parse(sessionStorage.getItem('user')).USER_ID,
      ROLEID: JSON.parse(sessionStorage.getItem('user')).ROLEID,
      // AGENCY_MANAGEMENT_ID: JSON.parse(sessionStorage.getItem('user')).AGENCY_MANAGEMENT_ID,
      // 地图相关
      // clientHeight: document.documentElement.clientHeight - 250,
      clientHeight: 600,
      loadingMap: true,
      listLoading: false,
      BMap: '',
      map: '',
      normalizer(node) {
        return {
          id: node.id,
          label: node.NAME,
          children: node.children
        }
      },
      varOList: [],
      // AGENCY_MANAGEMENT_ID: this.$parent.AGENCY_MANAGEMENT_ID,
      showMap: false,
      addressKeyword: '',
      pointLngLat: '',
      zoom: 10,
      isOldData: '0',
      dialogFormMap: false,
      LATITUDE: '',
      LONGITUDE: '',
      dialogImageUrl: '',
      dialogVisible: false,
      formList: [
        { 'ID': '3', 'NAME': '3天' },
        { 'ID': '7', 'NAME': '7天' },
        { 'ID': '15', 'NAME': '15天' }
      ],
      provinceList: [],
      cityList: [],
      countyList: [],
      scaleList: [],
      hylxList: [],
      jjlxList: [],
      trainDicList: [],
      safStaLevList: [], // 安全标准化等级
      areaList: [], // 属地
      OLDFOURTYPE: '',
      defaultProps: {
        children: 'nodes',
        label: 'name',
        value: 'id'
      },
      form: {
        CORP_NAME: '', // 企业名称
        CODE: '', // 统一社会信用代码
        REGULARTYPE: '',
        COMPANY_AREA: '', // 所属区域
        ADDRESS: '', // 通讯地址
        CREATE_DATE: '', // 成立时间
        SCALE: '', // 规模
        LONGITUDE: '', // 经度
        LATITUDE: '', // 纬度
        POSTAL_CODE: '', // 邮政编码
        EMPLOYEES: '', // 职工人数(人)
        AREA_COVERED: '', // 占地面积（㎡）
        TOTALASSETS: '', // 资产总额（万元）
        CORPINFOKEY: '', // 密钥
        REGCAPITAL: '', // 注册资金（万元）
        SALESREVENUE: '', // 上年度实际营收（万元）
        ANNUALPROFIT: '', // 年利润（万元）
        ECO_TYPEAll: [], // 经济类型
        ECO_TYPE: '', // 经济类型
        ECO_TYPE2: '', // 经济类型
        INDUSTRY: '', // 所属行业
        CORP_TYPE: '', // 所属专业
        USERS_NUM: '',
        CORP_TYPE2: '',
        CORP_TYPE3: '',
        CORP_TYPE4: '',
        CORP_TYPE_SMALL: '', // 所属小专业
        CORP_TYPE_VAL: '',
        CORP_TYPEAll: '',
        LR_NAME: '', // 法定代表人
        LR_POSITION: '', // 法人职务
        LR_PHONE: '', // 法人办公电话
        LR_MOBILE: '', // 法人手机号
        CONTACTS: '', // 联系人
        CONTACTS_PHONE: '', // 联系人手机号
        CHECKPERSON: '', // 整改负责人
        CHECKPERSONPHONE: '', // 整改人电话
        ISDELETE: '', // 是否删除
        OPERATOR: '', // 修改人
        OPERATTIME: '', // 修改时间
        CREATTIME: '', // 添加时间
        CREATOR: '', // 添加人
        FOURTYPE: '1', // 四色图类型1平面,23D
        ISRECEIVE: '', // 是否接收短信
        LOGIN_USER_ID: '', // 登录账号
        ADDRESS_BUSINESS: '', // 企事业单位经营地址
        ADDRESS_OFFICE: '', // 企事业单位办公地址
        CORP_STATE: '', // 企业状态
        FIXED_ASSETS: '', // 固定资产
        YEAR_OUTPUT_VALUE: '', // 年产值
        REG_TYPE: '', // 单位注册登记类型
        SUBORDINATION: '', // 隶属关系
        // CORP_OF_TYPEAll: '', // 企业类型
        INDUSTRY_DEPARTMENT: '', // 行业监管部门
        INDUSTRY_DEPARTMENTName: '',
        SCALE_TYPE: 0, // 是否规模以上
        SAFETY_NAME: '', // 安全负责人姓名
        SAFETY_POST: '', // 安全负责人职务
        SAFETY_BACKGROUND: '', // 安全负责人学历
        SAFETY_MAJOR: '', // 安全负责人专业
        SAFETY_NUMBER: '', // 安全负责人单位电话
        SAFETY_PHONE: '', // 安全负责人手机号码
        SAFETY_TECHNICAL: '', // 安全负责人技术职称
        AQ_BZ_LEVEL: '', // 安全标准化等级
        AQ_BZ_NO: '', // 安全标准化证书编号
        AQ_BZ_UNIT: '', // 安全标准化发证单位
        AQ_BZ_TIME: '', // 安全标准化有效期
        CORP_ATTRIBUTE: '', // 企业相关属性
        POSSESSION: '',
        PROVINCE: '',
        CITY: '',
        COUNTY: '',
        VILLAGE: '',
        CORP_EXAMINE: '1',
        WHETHER_HYGIENE: 1, // 有无职业卫生信息
        WHETHER_HAZARDS: 1, // 有无重大危险源
        WHETHER_SCARCE: 1, // 是否有稀缺大型应急物资或设施
        WHETHER_CHEMICALS: 1, // 是否涉及危化品
        WHETHER_SPECIALEQUIPMENT: 1, // 有无特种设备
        WHETHER_SPECIALPEOPLE: 1, // 有无特存种作业人员
        WHETHER_COALGAS: 1, // 是否涉及煤气
        WHETHER_FIRE: 1, // 是否属于消防重点单位
        WHETHER_CONFINED: 1, // 是否在有限空间作业
        WHETHER_POWDER: 1, // 是否存在涉爆粉尘作业
        WHETHER_LIGHTNING: 1, // 是否涉及防雷防静电
        WHETHER_ACTINOGEN: 1, // 是否持有放射源
        WHETHER_LIQUIDAMMONIA: 1, // 是否涉及液氨制冷
        ISTRIAL: '0',
        WHETHER_PIPELINE: 1, // 是否涉及危化品管道
        TRIALTIME: '',
        jinweidu: '',
        AGENT_NUMBER_ID: '',
        WHETHER_PRE_SALE_SERVICE: '',
        WHETHER_AFTER_SALES_SERVICE: '',
        VIPLEVEL: '',
        PERSONNEL_POSITION: 0,
        MARKETING_PERSON: this.USER_ID,
        STATUS: '',
        VIP_GEAR: '',

        // 人员定位
        POST_URL: '',
        ACCOUNT: '',
        PASSWORD: '',
        USE_URL: 'p',
        TILES3D_URL: ''
      },
      vipGearList: [],
      MARKETING_PERSON: '',
      ECO_TYPE: '',
      ecoArr: [],
      ecoNameArr: [],
      INDUSTRY: '',
      industryArr: [],
      industryNameArr: [],
      bus_images: [],
      bus_files: [],
      four_images: [],
      four_files: [],
      corpFoTypeList: [],
      corpStateList: [],
      subordinationList: [],
      marketingpersonList: [],
      imgUrl: require('@/assets/images/map.png'),
      rules: {
        VIPLEVEL: [
          { required: true, message: '会员级别不能为空', trigger: 'blur' }
        ],
        // AGENT_NUMBER_ID: [
        //   { required: true, message: '会员级别不能为空', trigger: 'blur' }
        // ],
        CORP_NAME: [
          { required: true, message: '企业名称不能为空', trigger: 'blur' }, { validator: hasCorp, trigger: 'blur' },
          {
            pattern: /^\S*$/,
            message: '企业名称不允许输入空格'
          }
        ],
        CODE: [
          { required: true, message: '统一社会信用代码不能为空', trigger: 'blur' },
          {
            pattern: /^[^_IOZSVa-z\W]{2}\d{6}[^_IOZSVa-z\W]{10}$/,
            message: '请输入正确的统一社会信用代码'
          }
        ],
        // CORP_OF_TYPEAll: [{ required: true, message: '企业类型不能为空', trigger: 'blur' }],
        SCALE: [{ required: true, message: '规模不能为空', trigger: 'blur' }],
        SCALE_TYPE: [{ required: true, message: '是否规模以上不能为空', trigger: 'blur' }],
        POSSESSION: [
          { required: true, message: '属地不能为空', trigger: 'blur' }
        ],
        INDUSTRYALL: [
          { required: true, message: '所属行业不能为空', trigger: 'blur' }
        ],
        ECO_TYPEALL: [
          { required: true, message: '经济类型不能为空', trigger: 'blur' }
        ],
        ADDRESS_BUSINESS: [
          { required: true, message: '企事业单位经营地址不能为空', trigger: 'blur' }
        ],
        CORP_STATE: [
          { required: true, message: '企业状态不能为空', trigger: 'blur' }
        ],

        LONGITUDE: [
          { required: true, message: '经度不能为空', trigger: 'blur' }
        ],
        LATITUDE: [
          { required: true, message: '纬度不能为空', trigger: 'blur' }
        ],
        CONTACTS: [
          { required: true, message: '主要负责人不能为空', trigger: 'blur' }
        ],
        CONTACTS_PHONE: [
          { required: true, message: '主要负责人电话不能为空', trigger: 'blur' },
          { min: 11, max: 11, message: '请输入11位手机号码', trigger: 'blur' },
          {
            pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
            message: '请输入正确的手机号码'
          }
        ],
        LR_MOBILE: [
          { min: 11, max: 11, message: '请输入11位手机号码', trigger: 'blur' },
          {
            pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
            message: '请输入正确的手机号码'
          }
        ],
        TRAINTYPE: [
          { required: true, message: '培训行业类型不能为空', trigger: 'blur' }
        ],
        USERS_NUM: [
          { required: true, message: '企业可新建用户数量不能为空', trigger: 'blur' }
          // { type: 'number', message: '企业可新建用户数量必须为数字' }
        ],

        LR_PHONE: [
          { min: 11, max: 11, message: '请输入11位手机号码', trigger: 'blur' },
          {
            pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
            message: '请输入正确的手机号码'
          }
        ],
        SAFETY_PHONE: [
          { min: 11, max: 11, message: '请输入11位手机号码', trigger: 'blur' },
          {
            pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
            message: '请输入正确的手机号码'
          }
        ],
        SAFETY_NUMBER: [
          { min: 11, max: 11, message: '请输入11位手机号码', trigger: 'blur' },
          {
            pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
            message: '请输入正确的手机号码'
          }
        ],
        POST_URL: [{ required: true, message: '人员定位URL不能为空', trigger: 'blur' }],
        ACCOUNT: [{ required: true, message: '账号不能为空', trigger: 'blur' }],
        PASSWORD: [{ required: true, message: '密码不能为空', trigger: 'blur' }],
        USE_URL: [{ required: true, message: '人员定位URL不能为空', trigger: 'blur' }],
        TILES3D_URL: [{ required: true, message: '人员定位URL不能为空', trigger: 'blur' }]

        // CITY: [
        //   { required: true, message: '市不能为空', trigger: 'blur' }
        // ],
        // COUNTY: [
        //   { required: true, message: '区不能为空', trigger: 'blur' }
        // ],
        // ADDRESS: [
        //   { required: true, message: '通讯地址不能为空', trigger: 'blur' }
        // ],
        // CHECKPERSONPHONE: [
        //   { required: true, message: '主要负责人电话不能为空', trigger: 'blur' }
        // ]
      },

      propsCorpFoType: { value: 'id', id: 'id', label: 'label', children: 'children' },

      ecoProps: {
        lazy: true,
        lazyLoad: this.lazyLoad,
        value: 'id',
        id: 'id',
        label: 'label',
        children: 'children'
      },
      industryProps: {
        lazy: true,
        lazyLoad: this.lazyLoad,
        value: 'id',
        id: 'id',
        label: 'label',
        children: 'children',
        checkStrictly: false
      },
      areaProps: {
        lazy: true,
        lazyLoad: this.lazyLoadArea,
        value: 'numValue',
        id: 'id',
        label: 'label',
        children: 'children'
      },
      agentNumList: [],
      // AGENT_NUMBER_ID: '',
      msg: 'edit',
      isAdmin: false
    }
  },
  watch: {
    'form.VIPLEVEL': {
      handler() {
        var HAS_PLS = this.agentNumList.find(item => item.ROLE_ID == this.form.VIPLEVEL).HAS_PLS
        this.form.PERSONNEL_POSITION = HAS_PLS === 0 ? 1 : 0
      }
    }
  },
  async created() {
    const loading = this.$loading({
      lock: true,
      text: '读取中...',
      spinner: 'el-icon-loading',
      background: 'rgba(0, 0, 0, 0.7)'
    })
    var user = sessionStorage.getItem('user')
    var obj = JSON.parse(user)
    if (obj && obj.USER_ID == '1') {
      this.isAdmin = true
    }
    await this.getAreaDict('e725d2a91b8248f4b8f49889038df7de', '0').then(data => {
      this.areaList = data
    })
    await this.getTrainDicList()
    // this.getAgentAreaList()
    this.getAgentList()
    if (this.$parent.CORPINFO_ID) {
      this.CORPINFO_ID = this.$parent.CORPINFO_ID
      this.getData()
      this.getUserList()
    } else {
      this.msg = 'add'
      this.getDictByDicId('688d2cf1c6cd4dab999a0106e09aec83').then(data => {
        this.jjlxList = data
      })
      this.getDictByDicId('f2598ba72e864eadabf0ca4b664d26b9').then(data => {
        this.hylxList = data
      })
      this.getUserList()
    }
    // this.getHylx()
    // this.getJjlx()
    // this.getDict()
    // this.getProvinceList()
    this.getCorpFoType()
    this.getDict()
    loading.close()
  },
  methods: {
    querySearchMp(queryString, cb) {
      var marketingpersonList = this.marketingpersonList
      var results = queryString ? marketingpersonList.filter((item) => item.NAME.indexOf(queryString) !== -1) : marketingpersonList
      // 调用 callback 返回建议列表的数据
      cb(results)
    },
    handleSelectMp(item) {
      this.form.MARKETING_PERSON = item.USER_ID
      this.form.MARKETING_PERSON_NAME = item.NAME
    },
    // 加载级联的方法
    lazyLoad(nodeValue, resolve) {
      if (nodeValue.data && (!nodeValue.children || nodeValue.children.length == 0)) {
        this.getDictByDicId(nodeValue.data.id).then(data => {
          resolve(data)
        })
      } else {
        resolve(null)
      }
    },
    // 加载级联的方法
    lazyLoadArea(nodeValue, resolve) {
      if (nodeValue.data && (!nodeValue.children || nodeValue.children.length == 0)) {
        this.getAreaDict(nodeValue.data.id, nodeValue.data.level, nodeValue.data.disabled).then(data => {
          resolve(data)
        })
      } else {
        resolve(null)
      }
    },
    getUserList() {
      this.listLoading = true
      requestFN(
        '/user/getUserList',
        {
          ROLE_ID: '60f9a60488074b3e936a4097468fb66f',
          PARENT_ID: 'eee570eff038464cbdfac5f8579bbace'
        }
      ).then((data) => {
        this.listLoading = false
        this.marketingpersonList = data.varList
      }).catch((e) => {
        this.listLoading = false
      })
    },
    getAgentList() {
      requestFN(
        '/agentnumber/getAgentList',
        {
        }
      ).then((data) => {
        this.agentNumList = data.varList
      }).catch((e) => {
      })
    },
    changeArea() {
      if (!this.form.POSSESSION || !this.form.POSSESSION.length) return
      requestFN(
        '/corptype/corptypelist',
        {
          PROVINCE: this.form.POSSESSION[0],
          CITY: this.form.POSSESSION[1],
          COUNTY: this.form.POSSESSION[2]
        }
      ).then((data) => {
        this.varOList = JSON.parse(data.varOList.zTreeNodes)
      }).catch((e) => {
        this.listLoading = false
      })
    },
    changeArea1() {
      this.changeArea()
      this.form.REGULARTYPE = null
    },
    // changeArea1(event) {
    //   if (event) {
    //     this.unwatch = this.$watch(() => this.varOList, (newValue, oldValue) => {
    //       if (newValue && oldValue) {
    //         this.form.REGULARTYPE = null
    //       }
    //     }, { immediate: true })
    //   } else {
    //     if (this.unwatch) {
    //       this.unwatch()
    //       this.unwatch = null
    //     }
    //   }
    // },
    handleMap() {
      this.dialogFormMap = true
      this.LATITUDE = this.form.LATITUDE
      this.LONGITUDE = this.form.LONGITUDE
      this.$forceUpdate()
    },
    getClickInfo(e) {
      this.LONGITUDE = e.point.lng
      this.LATITUDE = e.point.lat
    },
    setPosition() {
      this.dialogFormMap = false
      this.$set(this.form, 'LATITUDE', this.LATITUDE)
      this.$set(this.form, 'LONGITUDE', this.LONGITUDE)
      // this.form.LATITUDE = this.LATITUDE
      // this.form.LONGITUDE = this.LONGITUDE
      // this.$forceUpdate()
    },

    getData() {
      requestFN(
        '/corpinfo/goEdit',
        {
          CORPINFO_ID: this.CORPINFO_ID,
          // AGENCY_MANAGEMENT_ID: this.AGENCY_MANAGEMENT_ID,
          tm: new Date().getTime()
        }
      ).then(async(data) => {
        const POSSESSION = data.pd.POSSESSION
        await this.getAreaOpts(POSSESSION, this.areaList, 0)
        this.OLDFOURTYPE = data.pd.FOURTYPE
        data.pd.MARKETING_PERSON = data.pd.MARKETING_PERSON || this.USER_ID
        if (data.pd.MARKETING_PERSON == null || data.pd.MARKETING_PERSON == '') {
          this.isOldData = '1'
        }
        this.form = data.pd
        this.changeArea()
        this.form.FOURTYPE = data.pd.FOURTYPE ? data.pd.FOURTYPE + '' : '1'
        if (data.pd.ecoOption && data.pd.ecoOption.length > 0) {
          this.jjlxList = data.pd.ecoOption
        } else {
          this.getDictByDicId('688d2cf1c6cd4dab999a0106e09aec83').then(data => {
            this.jjlxList = data
          })
        }
        if (data.pd.industryOption && data.pd.industryOption.length > 0) {
          this.hylxList = data.pd.industryOption
        } else {
          this.getDictByDicId('f2598ba72e864eadabf0ca4b664d26b9').then(data => {
            this.hylxList = data
          })
        }
        // if (data.pd.posOption && data.pd.posOption.length > 0) {
        //   this.areaList = data.pd.posOption
        // }

        // this.hylxList = data.pd.industryOption

        this.$nextTick(() => {
          this.$refs.ecoCascader.presentText = this.censusRegisterPlaceName
        })
        if (this.form.CORP_OF_TYPE2 && this.form.CORP_OF_TYPE2 != '') {
          const node = {}
          node.id = this.form.CORP_OF_TYPE2
          this.$nextTick(() => {
            this.$refs.corpOfTypeRef.handleNodeClick(node)
          })
        } else if (this.form.CORP_OF_TYPE && this.form.CORP_OF_TYPE != '') {
          const node = {}
          node.id = this.form.CORP_OF_TYPE
          this.$nextTick(() => {
            this.$refs.corpOfTypeRef.handleNodeClick(node)
          })
        }
        const nodea = {}
        nodea.id = this.form.TRAINTYPE
        this.$nextTick(() => { // 此处使用这个可以等节点渲染后再获取节点
          this.$refs.keyHyRef.handleNodeClick(nodea)
        })
        this.$forceUpdate()
        this.bus_images = data.busImgs
        if (data.pd.FOURTYPE == 1) {
          this.four_images = data.fourImgs
        }
      }).catch((e) => {
        this.$message({
          message: '操作失败',
          type: 'error'
        })
      })
    },

    async getAreaOpts(values, list, index) {
      new Promise(async(resolve, reject) => {
        let areaOpt = null
        let areaIndex = null
        list.forEach((item, k) => {
          if (item.numValue === values[index]) {
            areaOpt = item
            areaIndex = k
          }
        })
        areaOpt.children = await this.getAreaDict(areaOpt.id, areaOpt.level, areaOpt.disabled)

        if (values[index + 1]) {
          await this.getAreaOpts(values, areaOpt.children, index + 1)
        }
        this.$set(list, areaIndex, areaOpt)
        resolve()
      })
    },

    deleteImage(index) {
      this.$confirm('确定要删除吗?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        requestFN(
          '/imgfiles/delete',
          {
            IMGFILES_ID: this.bus_images[index].IMGFILES_ID
          }
        ).then(() => {
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          this.bus_images.splice(index, 1)
        }).catch((e) => {
        })
      }).catch(() => {
      })
    },
    deleteFourImage(index) {
      this.$confirm('确定要删除吗?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        requestFN(
          '/imgfiles/delete',
          {
            IMGFILES_ID: this.four_images[index].IMGFILES_ID
          }
        ).then(() => {
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          this.four_images.splice(index, 1)
        }).catch((e) => {
        })
      }).catch(() => {
      })
    },
    confirm() {
      this.$confirm('此操作重置该企业主账号密码为Aa@123456, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        if (this.bus_images.length + this.$refs.upload.uploadFiles.length < 1) {
          this.$message({
            message: '请上传营业执照',
            type: 'error'
          })
          return false
        }
        if (this.form.ISTRIAL == 0) {
          this.form.STATUS = 2
          if (!this.form.TRIALTIME) {
            this.$message({
              message: '请填写试用企业天数',
              type: 'error'
            })
            return false
          }
        } else {
          this.form.STATUS = 1
        }
        this.$refs.form.validate(valid => {
          if (valid) {
            const loading = this.$loading({
              lock: true,
              text: '提交中...',
              spinner: 'el-icon-loading',
              background: 'rgba(0, 0, 0, 0.7)'
            })

            if (this.form.POSSESSION && this.form.POSSESSION.length > 0) {
              this.form.PROVINCE = this.form.POSSESSION[0] || ''
              this.form.CITY = this.form.POSSESSION[1] || ''
              this.form.COUNTY = this.form.POSSESSION[2] || ''
              this.form.VILLAGE = this.form.POSSESSION[3] || ''
              this.form.STREET = this.form.POSSESSION[4] || ''
              this.form.COMPANY_AREA = this.$refs.POSSESSION.getCheckedNodes()[0].pathLabels ? this.$refs.POSSESSION.getCheckedNodes()[0].pathLabels.join('') : ''
            }
            this.form.SMALL = '2'
            if (this.form.ECO_TYPEALL && this.form.ECO_TYPEALL.length > 0) {
              this.form.ECO_TYPE = this.form.ECO_TYPEALL[0] || ''
              this.form.ECO_TYPE2 = this.form.ECO_TYPEALL[1] || ''
              this.form.ECO_TYPE_NAME = this.$refs.ecoCascader.getCheckedNodes()[0].pathLabels ? this.$refs.ecoCascader.getCheckedNodes()[0].pathLabels.join('/') : ''
            }

            if (this.form.INDUSTRYALL && this.form.INDUSTRYALL.length > 0) {
              this.form.CORP_TYPE = this.form.INDUSTRYALL[0] || ''
              this.form.CORP_TYPE2 = this.form.INDUSTRYALL[1] || ''
              this.form.CORP_TYPE3 = this.form.INDUSTRYALL[2] || ''
              this.form.CORP_TYPE4 = this.form.INDUSTRYALL[3] || ''
              // .pathLabels
              this.form.CORP_TYPE_NAME = this.$refs.industryCascader.getCheckedNodes()[0] ? this.$refs.industryCascader.getCheckedNodes()[0].pathLabels.join('/') : ''
            }

            const formData = new FormData()
            Object.keys(this.form).map(key => {
              formData.append(key, this.form[key])
            })

            if (this.$refs.upload.uploadFiles.length > 0) {
              for (var i = 0; i < this.$refs.upload.uploadFiles.length; i++) {
                if (this.$refs.upload.uploadFiles[i]) {
                  formData.append('imgFiles', this.$refs.upload.uploadFiles[i].raw)
                }
              }
            }
            if (this.form.FOURTYPE == '1') {
              if (this.$refs.fourUpload.uploadFiles.length > 0) {
                // eslint-disable-next-line no-redeclare
                for (var i = 0; i < this.$refs.fourUpload.uploadFiles.length; i++) {
                  if (this.$refs.fourUpload.uploadFiles[i]) {
                    formData.append('fourFiles', this.$refs.fourUpload.uploadFiles[i].raw)
                  }
                }
              }
            } else if (this.form.FOURTYPE == '2') {
              formData.append('fourFiles', this.FFILE)
            }

            formData.append('isOldData', this.isOldData)
            formData.append('EDITFOURTYPE', this.form.FOURTYPE == this.OLDFOURTYPE)

            upload(
              '/corpinfo/' + this.msg,
              formData
            ).then((data) => {
              console.log(data)
              loading.close()
              if (data.message) {
                this.$message({
                  message: data.message,
                  type: 'warning'
                })
              } else {
                this.$message({
                  message: '操作成功',
                  type: 'success'
                })
                this.$parent.activeName = 'CorpList'
              }
            }).catch((e) => {
              loading.close()
              this.$message({
                message: '操作失败',
                type: 'error'
              })
            }).finally(() => {
              loading.close()
            })
          }
        })
      })
    },
    beforeFileUpload(file, fileList) {
      const types = ['image/jpeg', 'image/jpg', 'image/png']
      const isImage = types.includes(file.raw.type)
      if (!isImage) {
        this.$message.error('上传图片只能是 JPG、JPEG、PNG 格式!')
        fileList.pop()
      }
    },
    before3DFileUpload(file) {
      this.form.FFILE = file // 列表显示使用
      this.FFILE = file // 上传使用（修改时，如果没选择文件，则不上传）
      this.$forceUpdate()
      return false
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },
    fourBeforeFileUpload(file, fileList) {
      const types = ['image/jpeg', 'image/jpg', 'image/png']
      const isImage = types.includes(file.raw.type)
      if (!isImage) {
        this.$message.error('上传图片只能是 JPG、JPEG、PNG 格式!')
        fileList.pop()
      }
      const isSize = new Promise((resolve, reject) => {
        const width = 1480
        const height = 640
        // const _URL = window.URL || window.webkitURL
        const img = new Image()
        img.onload = () => {
          const valid = img.width === width && img.height === height
          valid ? resolve() : reject()
        }
        img.src = file.url
      }).then(
        () => {
          return true
        },
        () => {
          this.$message.error('图片尺寸限制为1480 x 640')

          fileList.pop()
          return false
        }
      )
      return isImage && isSize
    },
    fourHandlePictureCardPreview(file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },
    // 企业类型的点击事件
    changeCorpType(form, val) {
      this.$nextTick(() => {
        this.$refs[form].validateField(val)
      })
      requestFN(
        '/corptypetodept/goLisByCorpTypeId',
        {
          tm: new Date().getTime(),
          CORPTYPE_ID: this.form.CORP_OF_TYPE
        }
      ).then((data) => {
        this.pd.INDUSTRY_DEPARTMENTName = data.pd.NAME
        this.pd.INDUSTRY_DEPARTMENT = data.pd.DEPARTMENT_ID
      })
        .catch((e) => {
          this.listLoading = false
        })
    },
    getTrainDicList() {
      return new Promise(resolve => {
        requestFN(
          '/dictionaries/listAllDictToParId',
          {
            parentId: '052369aa22d242118236cde52d0c67ea'
          }
        ).then((data) => {
          resolve()
          this.trainDicList = JSON.parse(data.zTreeNodes)
        }).catch((e) => {
          this.listLoading = false
        })
      })
    },
    // getHylx() {
    //   requestFN(
    //     '/dictionaries/listHylxDictToCreateCode',
    //     {}
    //   ).then((data) => {
    //     this.hylxList = JSON.parse(data.zTreeNodes)
    //   }).catch((e) => {
    //     this.listLoading = false
    //   })
    // },
    // getJjlx() {
    //   requestFN(
    //     '/dictionaries/listJjlxDictToCreateCode',
    //     {}
    //   ).then((data) => {
    //     this.jjlxList = JSON.parse(data.zTreeNodes)
    //   }).catch((e) => {
    //     this.listLoading = false
    //   })
    // },

    // 企业类型
    async getCorpFoType() {
      return new Promise((resolve) => {
        requestFN(
          '/corptype/listAllCorpTypeMent',
          {
            tm: new Date().getTime(),
            DICTIONARIES_ID: '0'
          }
        ).then((data) => {
          this.corpFoTypeList = JSON.parse(data.zTreeNodes)

          resolve()
        }).catch((e) => {
          this.listLoading = false
        })
      })
    },
    getProvinceList() {
      requestFN(
        '/dictionaries/getLevels',
        {
          DICTIONARIES_ID: 'e725d2a91b8248f4b8f49889038df7de'
        }
      ).then((data) => {
        /* this.provinceList = data.list*/
        this.provinceList = data.list
        // this.provinceList = [{ DICTIONARIES_ID: 'acd05c42faf346db9a0d067402b97c10', BIANMA: '130000', NAME: '河北省' }]
      }).catch((e) => {
      })
    },
    async getCityList() {
      if (this.form.PROVINCE) {
        var dictID = await this.getDictID(this.form.PROVINCE)
        requestFN(
          '/dictionaries/getLevels',
          {
            DICTIONARIES_ID: dictID
          }
        ).then((data) => {
          this.cityList = data.list
        }).catch((e) => {
        })
      }
    },
    async getCountyList() {
      if (this.form.CITY) {
        var dictID = await this.getDictID(this.form.CITY)
        requestFN(
          '/dictionaries/getLevels',
          {
            DICTIONARIES_ID: dictID
          }
        ).then((data) => {
          this.countyList = data.list
        }).catch((e) => {
        })
      }
    },
    getDictID(BIANMA) {
      return new Promise((resolve) => {
        requestFN(
          '/dictionaries/findByBianma',
          {
            BIANMA: BIANMA
          }
        ).then((data) => {
          resolve(data.DICTIONARIES_ID)
        }).catch((e) => {
        })
      })
    },

    getDict() {
      requestFN(
        '/dictionaries/getLevels',
        {
          DICTIONARIES_ID: '37b045e160c04ddba851073b4e510cc9'
        }
      ).then((data) => {
        this.scaleList = data.list
      }).catch((e) => {
      })
      requestFN(
        '/dictionaries/getLevels',
        {
          DICTIONARIES_ID: '4d4862f9863b4b0da67f754c49e67ea3'
        }
      ).then((data) => {
        this.corpStateList = data.list
      }).catch((e) => {
      })
      requestFN(
        '/dictionaries/getLevels',
        {
          DICTIONARIES_ID: '1a13f574d4c44cd2ac2034f8e3259f9b'
        }
      ).then((data) => {
        this.subordinationList = data.list
      }).catch((e) => {
      })
      requestFN(
        '/dictionaries/getLevels',
        {
          DICTIONARIES_ID: '4ad17876ebe24124876a2fbb1f3060e7'
        }
      ).then((data) => {
        this.safStaLevList = data.list
      }).catch((e) => {
      })
    },
    // 获取数据字典数据
    getAreaDict(dicId, level, disabled) {
      var dicListVal = []
      return new Promise((resolve) => {
        let id = ''
        if (!dicId) {
          id = '0'
        } else {
          id = dicId
        }
        requestFN(
          '/dictionaries/getAgentAreaDict',
          {
            DICTIONARIES_ID: id,
            LEVEL: level,
            DISABLED: disabled

          }
        ).then((data) => {
          if (data.list.length > 0) {
            dicListVal = data.list.map((e) => {
              if (e.zcount == '0') {
                return { value: e.DICTIONARIES_ID.toString(), numValue: e.BIANMA.toString(), label: e.NAME, id: e.DICTIONARIES_ID, leaf: true, disabled: e.DISABLED, level: e.LEVEL }
              } else {
                return { value: e.DICTIONARIES_ID.toString(), numValue: e.BIANMA.toString(), label: e.NAME, id: e.DICTIONARIES_ID, children: [], leaf: false, disabled: e.DISABLED, level: e.LEVEL }
              }
            })
          } else {
            dicListVal = undefined
          }
          return resolve(dicListVal)
        }).catch((e) => {
        })
      })
    },
    // 获取数据字典数据
    getDictByDicId(dicId) {
      var dicListVal = []
      return new Promise((resolve) => {
        let id = ''
        if (!dicId) {
          id = '0'
        } else {
          id = dicId
        }
        requestFN(
          '/dictionaries/getLevelsAndSCount',
          {
            DICTIONARIES_ID: id
          }
        ).then((data) => {
          if (data.list.length > 0) {
            dicListVal = data.list.map((e) => {
              if (e.zcount == '0') {
                return { value: e.DICTIONARIES_ID.toString(), numValue: e.BIANMA.toString(), label: e.NAME, id: e.DICTIONARIES_ID, leaf: true }
              } else {
                return { value: e.DICTIONARIES_ID.toString(), numValue: e.BIANMA.toString(), label: e.NAME, id: e.DICTIONARIES_ID, children: [], leaf: false }
              }
            })
          } else {
            dicListVal = undefined
          }
          return resolve(dicListVal)
        }).catch((e) => {
        })
      })
    },
    // 地图相关
    mapOpen() {
      this.top = this.getScrollTop()
      if (this.top) {
        this.setScrollTop(0)
      }
    },
    // 关闭地图后调用
    mapClose() {
      this.setScrollTop(this.top)
      this.top = 0
      this.showMap = false
    },
    getScrollTop() {
      let scrollTop = 0
      if (document.documentElement && document.documentElement.scrollTop) {
        scrollTop = document.documentElement.scrollTop
      } else if (document.body) {
        scrollTop = document.body.scrollTop
      }
      return scrollTop
    },
    setScrollTop(top) {
      if (!isNaN(top)) {
        if (document.documentElement && document.documentElement.scrollTop !== undefined) {
          document.documentElement.scrollTop = top
        } else if (document.body) {
          document.body.scrollTop = top
        }
      }
    },
    // 地图初始化
    handler({ BMap, map }) {
      this.mapOpen()
      this.BMap = BMap
      this.map = map
      this.loadingMap = true
      var geolocation = new BMap.Geolocation()
      const myGeo = new BMap.Geocoder()
      var $this = this
      // 调用百度地图api 中的获取当前位置接口
      geolocation.getCurrentPosition(function(r) {
        myGeo.getLocation(new BMap.Point(r.point.lng, r.point.lat), function(result) {
          if (result) {
            $this.loadingMap = false
            $this.$set($this, 'pointLngLat', { lng: result.point.lng, lat: result.point.lat })
            map.enableScrollWheelZoom(true) // 开启鼠标滚轮缩放,默认关闭
            $this.setCenter({ BMap, map }, { lng: result.point.lng, lat: result.point.lat })
          }
        })
      })
    },
    // 搜索地图
    querySearch(queryString, cb) {
      var options = {
        onSearchComplete: function(results) {
          if (local.getStatus() === 0) {
            // 判断状态是否正确
            var s = []
            for (var i = 0; i < results.getCurrentNumPois(); i++) {
              var x = results.getPoi(i)
              var item = { value: x.address + x.title, point: x.point }
              s.push(item)
              cb(s)
            }
          } else {
            cb()
          }
        }
      }
      var local = new this.BMap.LocalSearch(this.map, options)
      local.search(queryString)
    },
    handleSelect(item) {
      var { point } = item
      this.map.clearOverlays() // 清除地图上所有覆盖物
      this.map.centerAndZoom(point, this.zoom)
      const marker = new this.BMap.Marker(point) // 创建标注
      this.map.addOverlay(marker) // 将标注添加到地图中
      marker.enableDragging() // 可拖拽
      this.LONGITUDE = point.lng
      this.LATITUDE = point.lat
    },
    // 设置打开中心位置
    setCenter({ BMap, map }, location) {
      var point = new BMap.Point(location.lng, location.lat)
      const zoom = map.getZoom()
      setTimeout(() => {
        map.centerAndZoom(point, zoom)
      }, 0)
      // var marker = new BMap.Marker(point) // 创建标注
      // map.addOverlay(marker) // 将标注添加到地图中
    },
    goBack() {
      this.$parent.activeName = 'CorpList'
    }
  }
}
</script>

<style lang="sass" scoped>
.avatar-uploader
  ul
    margin: 0
    li
      padding: 0
.el-dialog__body
  padding: 0
.map-flex
  display: flex
  width: 500px
  align-items: center

.ud-flex
  display: flex
.form-group
  display: flex
  align-items: center
  .form-label
    padding: 0px 15px
    font-size: 14px
    width: 240px
    font-weight: 400
    text-align: right
    margin-bottom: 18px
    .star
      color: red
      padding-right: 4px
  .input-block
    display: flex

.disContent
  display: flex
  align-items: center
  flex-wrap: wrap
  .img-div
    position: relative
    margin: 0 10px 0px 0
    width: 108px
    height: 108px
    border-radius: 4px
    overflow: hidden
    &>img
      width: 100%
      height: 100%

.disContent-hide
  position: absolute
  width: 100%
  height: 100%
  border-radius: 4px
  background-color: rgba(48, 48, 48, 0.59)
  display: none
  top: 0
  left: 0
  line-height: 32px

  .Delete
    position: absolute
    bottom: 14px
    right: 10px
    font-size: 16px
    color: white
    cursor: pointer
  .yuLan
    position: absolute
    bottom: 23px
    right: 50px
    font-size: 16px
    color: white
    cursor: pointer
    .yuLanImg
      position: absolute
      bottom: 0
      right: 0
      width: 100%
      height: 100%
      opacity: 0

.img-div:hover .disContent-hide
  display: block

  .pitchCss
    border: 1px solid #202e78
    transition: all linear 0.1s
    width: 116px
    height: 116px

</style>

