<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-09-19 09:31:19
 * @LastEditTime : 2019-12-24 15:36:17
 * @LastEditors  : Please set LastEditors
 -->
<template>
  <h-view id="base-info" class="public-style" title="基本信息">
    <h-content class="content">
      <div>
        <list-item :item-height="44">
          <item v-if="!isApproved" :showArrow="true">
            <div slot="name" class="font-color required">客户类型</div>
            <input
              slot="content"
              v-model="baseInfo.bp_type_n"
              placeholder="请选择"
              type="text"
              readonly
            >
          </item>
          <item v-if="isApproved&&!isMultiRole">
            <div slot="name" class="required">客户类型</div>
            <span slot="content">{{ baseInfo.bp_type_n }}</span>
          </item>
          <item v-if="(isMultiRole&&!hasMultiRole)" :showArrow="true">
            <div slot="name" class="required">客户类型</div>
            <div slot="content" class="typeBP">
              <span>{{ baseInfo.bp_type_n }}</span>
              <span v-for="(item,index) in multiRoleList" :key="index">{{ item.bp_type_n }}</span>
              <span v-for="(item,index) in multiBpTypeSelectList" :key="item.bp_type">
                {{ item.bp_type_n }}
                <img v-if="item.bp_type_n" src="@/assets/userBind/deleteTag.png" @click.stop @click="deleteBP(item)" >
              </span>
            </div>
          </item>
          <item v-if="isApproved&&isMultiRole&&hasMultiRole" :showArrow="true">
            <div slot="name" class="required">客户类型</div>
            <div slot="content" class="typeBP">
              <span>{{ baseInfo.bp_type_n }}</span>
              <span v-for="(item,index) in multiRoleList" :key="index">{{ item.bp_type_n }}</span>
            </div>
          </item>
          <item v-if="bp_type_flag">
            <div slot="name" class="required">业务经办人</div>
            <input slot="content" v-model="baseInfo.agent_username" placeholder="请输入业务经办员工代码" >
          </item>
          </item>
          <button v-if="isAddNewType" class="type-save" @click="addNewRole">新增角色</button>
        </list-item>
        <div class="userInfo martop">企业信息</div>
        <div class="upload-id-card">
          <span class="font-color">营业执照照片上传</span>
          <div class="upload-box1">
            <div v-if="!licenseImg" @click="ocrShow('license', '')">
              <img src="@/assets/userBind/camera.png">
            </div>
            <div
              v-if="licenseImg && !isApproved" style="width: 100%;height: 100%" class="licenseBox"
              @click="ocrShow('license', '')">
              <img :src="licenseImg" style="width: 100%;height: 100%;margin: 0">
            </div>
            <div v-if="isApproved" class="licenseBox">
              <img
                v-if="licenseImg" :src="licenseImg" style="width: 100%;height: 100%;margin: 0"
                @click="showBigPicture(licenseImg)">
            </div>
          </div>
        </div>
        <!-- 营业执照识别信息 -->
        <list-item :item-height="44" class="second-part">
          <item>
            <div slot="name" class="font-color required">公司名称</div>
            <input
              slot="content"
              v-model="baseInfo.bp_name"
              placeholder=""
              readonly
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="font-color required">企业类型</div>
            <input
              slot="content"
              v-model="baseInfo.enterprise_type"
              placeholder=""
              readonly
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="font-color required">统一社会信用代码</div>
            <input
              slot="content"
              v-model="baseInfo.organization_code"
              placeholder=""
              readonly
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="font-color required">注册资本</div>
            <input
              slot="content"
              v-model="baseInfo.registered_capital"
              placeholder=""
              readonly
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="font-color required">法定代表人</div>
            <input
              slot="content"
              v-model="baseInfo.legal_person"
              placeholder=""
              readonly
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="font-color required">注册地址</div>
            <textarea
              slot="content"
              ref="myTestarea"
              v-model="baseInfo.registered_place"
              cols="30"
              rows="1"
              class="auto"
              readonly
              placeholder=""
              @input="addRows(baseInfo.registered_place)"
            />
          </item>
          <item :showArrow="true">
            <div slot="name" class="required">业务办理省</div>
            <input
              slot="content"
              v-model="baseInfo.province_name"
              placeholder=""
              type="text"
              readonly
              onfocus="this.blur()"
            >
          </item>
          <item :showArrow="true">
            <div slot="name" class="required">业务办理市</div>
            <input
              slot="content"
              v-model="baseInfo.city_name"
              placeholder=""
              type="text"
              readonly
              onfocus="this.blur()"
            >
          </item>
          <item :showArrow="true">
            <div slot="name" class="required">业务办理区/县</div>
            <input
              slot="content"
              v-model="baseInfo.district_name"
              placeholder=""
              type="text"
              readonly
              onfocus="this.blur()"
            >
          </item>
          <item :proportion="[2,2]">
            <div slot="name" class="font-color required">经营地址</div>
            <textarea
              slot="content"
              ref="myTestareaLive"
              v-model="baseInfo.business_address"
              cols="30"
              rows="1"
              readonly
              placeholder=""
              @input="addRowsLive(baseInfo.business_address)"
            />
          </item>
          <item>
            <div slot="name" class="font-color">固定电话</div>
            <input
              slot="content" v-model="baseInfo.phone" readonly placeholder="请输入固定电话"
            >
          </item>
        </list-item>
        <!-- 法定代表人信息-->
        <div class="userInfo types">法定代表人</div>
        <div class="upload-id-cards">
          <span>身份证照片上传</span>
          <div class="upload-box">
            <div v-if="!idCardFront">
              <img src="@/assets/userBind/org/front.png">
              <p>正面</p>
            </div>
            <div v-if="idCardFront && !isApproved">
              <img :src="idCardFront" style="width: 100%;height: 100%;margin: 0">
            </div>
            <div v-if="isApproved && idCardFront">
              <img
                v-if="idCardFront" :src="idCardFront" style="width: 100%;height: 100%;margin: 0"
                @click="showBigPicture(idCardFront)">
            </div>
            <div v-if="!idCardBack">
              <img src="@/assets/userBind/org/back.png">
              <p>反面</p>
            </div>
            <div v-if="idCardBack && !isApproved">
              <img :src="idCardBack" style="width: 100%;height: 100%;margin: 0">
            </div>
            <div v-if="isApproved && idCardBack">
              <img
                v-if="idCardBack" :src="idCardBack" style="width: 100%;height: 100%;margin: 0"
                @click="showBigPicture(idCardBack)">
            </div>
          </div>
        </div>
        <list-item :item-height="44" class="second-part">
          <item>
            <div slot="name" class="font-color required">姓名</div>
            <input
              slot="content"
              v-model="legal_personMsg.bp_legal_name"
              readonly
              placeholder="上传身份证自动填充"
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="font-color required">身份证号</div>
            <input
              slot="content"
              v-model="legal_personMsg.id_card_no"
              readonly
              placeholder="上传身份证自动填充"
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="required">身份证有效期从</div>
            <input
              slot="content"
              v-model="legal_personMsg.id_card_date_from"
              readonly
              placeholder="上传身份证自动填充"
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="required">身份证有效期到</div>
            <input
              slot="content"
              v-model="legal_personMsg.id_card_date_to"
              readonly
              placeholder="上传身份证自动填充"
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="font-color required">手机号</div>
            <input
              slot="content" v-model="legal_personMsg.cell_phone" readonly placeholder="请输入手机号"
              @blur="phoneCheck(legal_personMsg.cell_phone)">
          </item>
          <item>
            <div slot="name" class="font-color required">联系地址</div>
            <textarea
              ref="address"
              slot="content"
              v-model="legal_personMsg.living_address"
              cols="30"
              rows="1"
              readonly
              placeholder="请输入联系地址"
              @input="addAddressRows(legal_personMsg.living_address)"
            />
          </item>
        </list-item>
        <!-- 授权切换 -->
        <div class="authorize">
          <p class="authorize-select font-color">是否授权</p>
          <div class="authorize-checklist">
            <div v-if="flag"/>
            <img v-if="!flag" src="@/assets/userBind/org/checklist.png" alt>
          </div>
        </div>
        <div v-if="!flag" class="userInfo types">授权人信息</div>
        <div v-if="!flag" class="upload-id-cards">
          <span>身份证照片上传</span>
          <div class="upload-box">
            <div v-if="!authidCardFront">
              <img src="@/assets/userBind/org/front.png">
              <p>正面</p>
            </div>
            <div v-if="authidCardFront">
              <img :src="authidCardFront" style="width: 100%;height: 100%;margin: 0">
            </div>
            <div v-if="!authidCardBack">
              <img src="@/assets/userBind/org/back.png">
              <p>反面</p>
            </div>
            <div v-if="authidCardBack">
              <img :src="authidCardBack" style="width: 100%;height: 100%;margin: 0">
            </div>
          </div>
        </div>
        <!-- 已授权 -->
        <list-item v-if="!flag" :item-height="44" class="second-part">
          <item>
            <div slot="name" class="font-color required">姓名</div>
            <input
              slot="content"
              v-model="authMsg.auth_person_name"
              readonly
              placeholder=""
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="font-color required">身份证号</div>
            <input
              slot="content"
              v-model="authMsg.auth_person_id_card"
              readonly
              placeholder=""
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="required">身份证有效期从</div>
            <input
              slot="content"
              v-model="authMsg.auth_id_card_date_from"
              readonly
              placeholder=""
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="required">身份证有效期到</div>
            <input
              slot="content"
              v-model="authMsg.auth_id_card_date_to"
              readonly
              placeholder=""
              class="auto"
            >
          </item>
          <item>
            <div slot="name" class="font-color required">手机号</div>
            <input
              slot="content" v-model="authMsg.auth_cell_phone" readonly placeholder="请输入手机号"
              @blur="phoneCheck(authMsg.auth_cell_phone)">
          </item>
          <item>
            <div slot="name" class="font-color required">公司职务</div>
            <input slot="content" v-model="authMsg.auth_person_position" readonly placeholder="请输入公司职务">
          </item>
          <item>
            <div slot="name" class="font-color required">授权事项</div>
            <input slot="content" v-model="authMsg.auth_person_matter" readonly placeholder="请输入授权事项">
          </item>
        </list-item>

        <div v-if="!flag" class="upload-id-card" style="margin-bottom: 30px;">
          <span>授权书证件上传</span>
          <div class="upload-box1">
            <div v-if="!laImg">
              <img src="@/assets/userBind/camera.png">
            </div>
            <div v-if="laImg" class="licenseBox">
              <img :src="laImg" style="width: 100%;height: 100%;margin: 0">
            </div>
          </div>
        </div>
      </div>
    </h-content>
  </h-view>
</template>

<script>
import InputNum from './input-num'
export default {
  name: 'Enterprise',
  components: {
    InputNum,
  },
  props: {
    document_id: String,
    document_name: String,
  },
  data () {
    return {
      bp_id: '',
      flag: true, // 显示未授权框
      bpClass: '',
      laImgUpload: '',
      from: false,
      inputNum: false, // 填写业务经办
      isApproved: false, // 审批通过为true
      isAddNewType: false,
      hasPeople: false, // 是否有第二角色
      idCardFrontUpload: '',
      idCardBackUpload: '',
      authidCardFrontUpload: '',
      authidCardBackUpload: '',
      licenseImgUpload: '',
      isAGENT: this.$route.params.isAGENT, // 是否为经销商
      isMultiRole: this.$route.params.isMultiRole, // 担保人/承租人为true
      img_url: {},
      typeList: [],
      backList: [],
      saveInfo: {},
      lastInfo: {},
      multiBpTypeSelectList: [], // 添加的角色
      multiRoleList: [], // 查询出来的多角色
      msg_flag: false,
      maritalList: [],
      getBankList: [],
      cityList: [],
      provinceList: [],
      districtList: [],
      academic_bg_n: '',
      bpClass_flag: false,
      // text: '法人代表信息',
      bp_type_flag: false,
      typeName: '',
      marital_status_n: '',
      bank_card_flag: false,
      type: '请输入业务经办姓名',
      multiBpType: {
        bp_type_n: '',
        bp_type: '',
      }, // 客户选择的第二个角色
      multiRole: {
        bp_type_n: '',
        bp_type: '',
      }, // 查询出来的第二个角色
      legal_personMsg: {
        id_card_no: null,
        bp_legal_name: '',
        cell_phone: window.localStorage.getItem('user_phone'),
        living_address: '',
        id_card_date_from: '', // 法定代表人身份证有效期从
        id_card_date_to: '', // 法定代表人身份证有效期到
      },
      baseInfo: {
        agent_username: '',
        district_id: '',
        district_name: '',
        province_name: '',
        province_id: '',
        city_name: '',
        city_id: '',
        bp_type: '',
        bp_type_n: '',
        bp_name: '',
        phone: '',
        auth_flag: 'N',
        user_phone: window.localStorage.user_phone,
        legal_person: '',
        enterprise_type: '',
        business_address: '',
        registered_place: '',
        organization_code: '',
        registered_capital: '',
        // business_license_num: '',
        bp_class: this.$route.params.bpclass,
      },
      authMsg: {
        auth_person_name: '',
        auth_person_matter: '',
        auth_person_id_card: '',
        auth_cell_phone: '',
        auth_person_position: '',
        auth_id_card_date_from: '', // 授权人身份证有效期从
        auth_id_card_date_to: '', // 授权人身份证有效期到
      },
      idCardFront: '', // 身份证正面图片
      idCardBack: '', // 身份证反面图片
      authidCardFront: '', // 授权人身份证正面图片
      authidCardBack: '', // 授权人身份证反面图片
      licenseImg: '', // 营业执照照片
      laImg: '', // 授权书图片
      hasMultiRole: false, // 是否有第二个角色

      idCardFrontUrlFlag: false, // 身份证正面图片，为false则用查询出来的，为true则用拍照出来的
      idCardBackUrlFlag: false, // 身份证反面图片，为false则用查询出来的，为true则用拍照出来的
      authidCardFrontUrlFlag: false, // 授权人身份证正面图片，为false则用查询出来的，为true则用拍照出来的
      authidCardBackUrlFlag: false, // 授权人身份证反面图片，为false则用查询出来的，为true则用拍照出来的
      licenseImgUrlFlag: false, // 营业执照照片，为false则用查询出来的，为true则用拍照出来的
      laImgUrlFlag: false, // 授权书图片，为false则用查询出来的，为true则用拍照出来的
      upload_list: [], // 上传图片列表
      dowload_list: [], // 下载图片列表
      cddItemList: [], // 资料清单列表
      idCardFrontCheck_id: '', // 身份证正面check_id
      idCardBackCheck_id: '', // 身份证背面check_id
      authidCardFrontCheck_id: '', // 授权人身份证正面check_id
      authidCardBackCheck_id: '', // 授权人身份证背面check_id
      bankCardCheck_id: '', // 银行卡check_id
      licenseCheck_id: '', // 营业执照check_id
      laCheck_id: '', // 授权书check_id

      idCardFrontAttachmentId: '', // 身份证正面AttachmentId
      idCardBackAttachmentId: '', // 身份证背面AttachmentId
      authidCardFrontAttachmentId: '', // 授权人身份证正面AttachmentId
      authidCardBackAttachmentId: '', // 授权人身份证背面AttachmentId
      licenseAttachmentId: '', // 营业执照AttachmentId
      laAttachmentId: '', // 授权书AttachmentId
      bankCardImgList: [], // 存上传银行卡图片列表
      idCardFrontEditFlag: false, // 身份证正面修改标识，为true则标识已修改，后续需要重新上传此照片
      idCardBackEditFlag: false, // 身份证正面修改标识，为true则标识已修改，后续需要重新上传此照片
      authidCardFrontEditFlag: false, // 授权人身份证正面修改标识，为true则标识已修改，后续需要重新上传此照片
      authidCardBackEditFlag: false, // 授权人身份证正面修改标识，为true则标识已修改，后续需要重新上传此照片
      licenseEditFlag: false, // 营业执照照片修改标识，为true则标识已修改，后续需要重新上传此照片
      LaEditFlag: false, // 授权书图片修改标识，为true则标识已修改，后续需要重新上传此照片
      isClear: false,
    }
  },
  computed: {},
  watch: {
    'baseInfo.auth_flag' (newVal, oldVal) {
      if (newVal === '是') {
        this.flag = false
      } else if (newVal === '否') {
        this.flag = true
      }
    },
    // 监听客户类型
    'baseInfo.bp_type_n' () {
      let vm = this
      if (vm.baseInfo.bp_type === 'TENANT' || vm.baseInfo.bp_type === 'GUTA' || vm.hasPeople) {
        vm.type = '请输入业务经办员工代码'
        vm.typeName = '业务经办人'
        vm.bp_type_flag = true
      } else if (
        vm.baseInfo.bp_type === 'AGENT' ||
        vm.baseInfo.bp_type === 'OFFICE' ||
          vm.baseInfo.bp_type === 'FACTORY'
      ) {
        vm.bp_type_flag = false
        vm.typeName = ''
      }
    },
    typeName () {
      if (this.typeName === '业务经办人') {
        this.bpClass = this.baseInfo.agent_username
        this.bpClass_flag = true
      } else {
        this.bpClass = this.baseInfo.business_license_num
        this.bpClass_flag = false
      }
    },
  },
  created () {
    this.getMultipleRole()
    this.getBpType()
    this.getbaseInfo()
    this.loadItemList(true)
  },
  activated () {
    this.getMultipleRole()
    this.getBpType()
    this.getbaseInfo()
    this.loadItemList(true)
  },
  methods: {
    roleCancle () {
      this.inputNum = false
    },
    roleConfirm (e) {
      if (this.baseInfo.agent_username.indexOf(e) !== -1) {
        hlsPopup.showLongCenter('您已添加了该业务经办')
      } else {
        this.baseInfo.agent_username = this.baseInfo.agent_username + `,${e}`
      }
      this.inputNum = false
    },
    async getMultipleRole () {
      let vm = this
      let url = process.env.basePath + 'bp_role_query'
      let flag = vm.checkHasmultiple()
      let param = {
        master: {
          bp_id: window.localStorage.getItem('bp_id'),
          bp_type: window.localStorage.getItem('bp_type'),
        },
      }
      if (flag) {
        vm.hlsHttp.post(url, param).then(function (res) {
          if (res.result === 'S') {
            vm.multiRoleList = res.lists
            vm.type = '请输入业务经办员工代码'
            vm.typeName = '业务经办人'
            if (res.lists.length === 0 || res.lists.length === 1) {
              vm.hasMultiRole = false
            } else if (res.lists.length === 2) {
              vm.hasMultiRole = true
            }
            if (res.lists.length > 0) {
              vm.bp_type_flag = true
            }
          } else {
            vm.hasMultiRole = false
          }
        })
      }
    },
    async checkHasmultiple () {
      let vm = this
      let url = process.env.basePath + 'bp_role_check'
      let param = {
        bp_id: window.localStorage.getItem('bp_id'),
      }
      let res = await vm.hlsHttp.post(url, param)
      if (res.result === 'S') {
        vm.hasPeople = true
        // vm.bp_type_flag = true
        return true
      } else {
        vm.hasMultiRole = false
        vm.hasPeople = false
        vm.bp_type_flag = false
        return false
      }
    },
    timeFormat (str) {
      return `${str.substring(0, 4)}-${str.substring(4, 6)}-${str.substring(6)}`
    },
    deleteBP (e) {
      let deleteIndex
      this.multiBpTypeSelectList.forEach((i, index, arr) => {
        if (arr[index].bp_type.indexOf(e.bp_type) !== -1) {
          deleteIndex = index
        }
      })
      this.multiBpTypeSelectList.splice(deleteIndex, 1)
      this.isAddNewType = false
    },
    selectIdMultiType (e) {
      let vm = this
      let List
      if (vm.baseInfo.bp_type === 'TENANT') {
        List = vm.typeList.filter(i => {
          return i.code === 'GUTA'
        })
      } else if (vm.baseInfo.bp_type === 'GUTA') {
        List = vm.typeList.filter(i => {
          return i.code === 'TENANT'
        })
      }
      vm.hlsPopup.selectList({
        list: List,
        code: 'bp_type',
        object: {},
        returnItem: function (index, obj) {
          vm.multiBpType.bp_type = obj.bp_type
          vm.multiBpType.bp_type_n = obj.bp_type_n
          vm.isAddNewType = true
          vm.isSelected = true
        },
      })
    },
    checkUpdate () {
      let vm = this
      let url = process.env.basePath + 'prj_cdd_check_update'
      let param = {
        document_id: JSON.parse(window.localStorage.getItem('handleUser')).bp_id,
        tab_group: 'HLS_ORG_AUTH',
      }
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.loadItemList(false, 'HLS_ORG_AUTH')
        } else {
          hlsPopup.showError(res.message)
        }
      })
    },
    addRows (e) {
      if (e) {
        let addNum = Math.ceil(e.length / 16)
        // if (addNum === 0) {
        //   this.$refs.myTestarea.rows = 1
        // } else if (addNum >= addNum - 1 && addNum < addNum + 1) {
        // this.$refs.myTestarea.rows = addNum + 1
        // }
        this.$refs.myTestarea.rows = addNum
      }
    },
    addRowsLive (e) {
      if (e) {
        let addNum = Math.ceil(e.length / 16)
        // if (addNum === 0) {
        //   this.$refs.myTestareaLive.rows = 1
        // } else if (addNum >= addNum - 1 && addNum < addNum + 1) {
        // this.$refs.myTestareaLive.rows = addNum + 1
        // }
        this.$refs.myTestareaLive.rows = addNum
      }
    },
    addAddressRows (e) {
      if (e) {
        let addNum = Math.ceil(e.length / 16)
        // if (addNum === 0) {
        //   this.$refs.address.rows = 1
        // } else if (addNum >= addNum - 1 && addNum < addNum + 1) {
        // this.$refs.address.rows = addNum + 1
        // }
        this.$refs.address.rows = addNum
      }
    },
    handSubmit () {
      let bp_id = this.from ? this.document_id : this.document_id
      if (bp_id) {
        this.hlsPopup.showConfirm({
          title: '提示',
          content: '您确认提交吗？',
          onConfirm: data => {
            if (data) {
              let url = $config.basePath + 'bp_bind_submit'
              let param = {
                master: {
                  // bp_id: window.localStorage.getItem('user_id'),
                  bp_id: this.from ? this.document_id : this.bp_id,
                  company_id: '2145',
                },
              }
              let vm = this
              this.hlsHttp.post(url, param).then(function (res) {
                if (res.result === 'S') {
                  vm.hlsPopup.showSuccess('提交成功')
                  vm.$router.push({
                    name: 'HomePage',
                  })
                }
              })
            }
          },
        })
      } else {
        this.hlsPopup.showLongCenter('请先保存！')
      }
    },
    // 基本信息保存前校验
    bindCheck () {
      let vm = this
      let business_num = ''
      if (vm.baseInfo.bp_type === 'TENANT' || vm.baseInfo.bp_type === 'GUTA') {
        business_num = vm.baseInfo.agent_username
      }
      window.localStorage.setItem('business_num', business_num)
      let url = process.env.basePath + 'bp_bind_check'
      let param = {
        'master': {
          bp_class: 'ORG',
          bp_type: vm.baseInfo.bp_type,
          business_num: business_num,
        },
      }
      vm.hlsPopup.showLoading('正在校验数据有效性')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.$router.push({
            name: 'Invoice',
            params: {
              bp_id: vm.bp_id,
              organization_code: vm.baseInfo.organization_code,
              from: vm.from,
              bp_name: vm.baseInfo.bp_name,
            },
          })
        } else {
          hlsPopup.showError(res.message)
        }
      })
    },
    // 校验手机号
    phoneCheck (phone) {
      if (!hlsUtil.phoneNumber(phone) && !hlsUtil.phoneNumber86(phone)) {
        hlsPopup.showLongCenter('请输入正确的手机号')
      }
    },
    // 校验固定电话
    fixedPhoneCheck (phone) {
      let reg = /^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/
      if (!reg.test(phone)) {
        hlsPopup.showLongCenter('请输入正确的固定电话')
      }
    },

    verified (flag) {
      window.localStorage.setItem('authFlag', this.flag)
      if (!this.flag) { // 已授权
        this.baseInfo.auth_flag = 'Y'
        this.lastInfo = {...this.baseInfo, ...this.legal_personMsg, ...this.authMsg}
        this.saveInfo = {...this.lastInfo}
      } else { // 未授权
        this.baseInfo.auth_flag = 'N'
        this.lastInfo = {...this.baseInfo, ...this.legal_personMsg}
        this.saveInfo = {
          ...this.lastInfo,
          ...this.authMsg,
        }
      }
      let vm = this

      // 校验基本信息
      if (this.bpClass_flag) { // 业务经办人
        delete this.lastInfo.business_license_num
        delete this.lastInfo.id_card_name
        for (var key in vm.lastInfo) {
          if (!vm.lastInfo[key] && key !== 'phone') {
            switch (key) {
              case 'province_id':
                vm.hlsPopup.showLongCenter('请选择省份')
                break
              case 'city_id':
                vm.hlsPopup.showLongCenter('请选择城市')
                break
              case 'district_id':
                vm.hlsPopup.showLongCenter('请选择区县')
                break
              case 'bp_type':
                vm.hlsPopup.showLongCenter('客户类型未填写')
                break
              case 'agent_username':
                vm.hlsPopup.showLongCenter('业务经办员工代码未填写')
                break
              case 'bp_name':
                vm.hlsPopup.showLongCenter('公司名称未填写')
                break
              case 'enterprise_type':
                vm.hlsPopup.showLongCenter('企业类型未填写')
                break
              case 'organization_code':
                vm.hlsPopup.showLongCenter('统一社会信用代码未填写')
                break
              case 'registered_capital':
                vm.hlsPopup.showLongCenter('注册资本未填写')
                break
              case 'legal_person':
                vm.hlsPopup.showLongCenter('法定代表人未填写')
                break
              case 'registered_place':
                vm.hlsPopup.showLongCenter('注册地址未填写')
                break
              case 'business_address':
                vm.hlsPopup.showLongCenter('经营地址未填写')
                break
              case 'id_card_no':
                vm.hlsPopup.showLongCenter('身份证未填写')
                break
              case 'cell_phone':
                vm.hlsPopup.showLongCenter('手机号未填写')
                break
              case 'living_address':
                vm.hlsPopup.showLongCenter('联系地址未填写')
                break
              case 'bp_legal_name':
                vm.hlsPopup.showLongCenter('法定代表人姓名未填写')
                break
              case 'id_card_date_from':
                vm.hlsPopup.showLongCenter('身份证有效期从未填写')
                break
              case 'id_card_date_to':
                vm.hlsPopup.showLongCenter('身份证有效期到未填写')
                break
              case 'auth_person_name':
                vm.hlsPopup.showLongCenter('授权人姓名未填写')
                break
              case 'auth_person_id_card':
                vm.hlsPopup.showLongCenter('授权人身份证号未填写')
                break
              case 'auth_cell_phone':
                vm.hlsPopup.showLongCenter('授权人手机号未填写')
                break
              case 'auth_id_card_date_from':
                vm.hlsPopup.showLongCenter('授权人身份证有效期从未填写')
                break
              case 'auth_id_card_date_to':
                vm.hlsPopup.showLongCenter('授权人身份证有效期到未填写')
                break
              case 'user_phone':
                vm.hlsPopup.showLongCenter('您还未登录')
                break
              case 'auth_person_position':
                vm.hlsPopup.showLongCenter('公司职务未填写')
                break
              case 'auth_person_matter':
                vm.hlsPopup.showLongCenter('授权事项未填写')
                break
            }
            // vm.hlsPopup.showLongCenter('基本信息不完整！')
            vm.msg_flag = false
            return
          } else {
            vm.msg_flag = true
          }
        }
        this.lastInfo.business_license_num = ''
        this.lastInfo.id_card_name = ''
      } else { // 非业务经办人
        delete this.lastInfo.agent_username
        delete this.lastInfo.id_card_name
        for (var key1 in vm.lastInfo) {
          if (!vm.lastInfo[key1] && key1 !== 'phone') {
            switch (key1) {
              case 'bp_type':
                vm.hlsPopup.showLongCenter('客户类型未填写')
                break
              case 'province_id':
                vm.hlsPopup.showLongCenter('请选择省份')
                break
              case 'city_id':
                vm.hlsPopup.showLongCenter('请选择城市')
                break
              case 'district_id':
                vm.hlsPopup.showLongCenter('请选择区县')
                break
              case 'bp_name':
                vm.hlsPopup.showLongCenter('公司名称未填写')
                break
              case 'enterprise_type':
                vm.hlsPopup.showLongCenter('企业类型未填写')
                break
              case 'organization_code':
                vm.hlsPopup.showLongCenter('统一社会信用代码未填写')
                break
              case 'registered_capital':
                vm.hlsPopup.showLongCenter('注册资本未填写')
                break
              case 'legal_person':
                vm.hlsPopup.showLongCenter('法定代表人未填写')
                break
              case 'registered_place':
                vm.hlsPopup.showLongCenter('注册地址未填写')
                break
              case 'business_address':
                vm.hlsPopup.showLongCenter('经营地址未填写')
                break
              case 'id_card_no':
                vm.hlsPopup.showLongCenter('身份证未填写')
                break
              case 'cell_phone':
                vm.hlsPopup.showLongCenter('手机号未填写')
                break
              case 'living_address':
                vm.hlsPopup.showLongCenter('联系地址未填写')
                break
              case 'bp_legal_name':
                vm.hlsPopup.showLongCenter('法定代表人姓名未填写')
                break
              case 'id_card_date_from':
                vm.hlsPopup.showLongCenter('身份证有效期从未填写')
                break
              case 'id_card_date_to':
                vm.hlsPopup.showLongCenter('身份证有效期到未填写')
                break
              case 'auth_person_name':
                vm.hlsPopup.showLongCenter('授权人姓名未填写')
                break
              case 'auth_person_id_card':
                vm.hlsPopup.showLongCenter('授权人身份证号未填写')
                break
              case 'auth_cell_phone':
                vm.hlsPopup.showLongCenter('授权人手机号未填写')
                break
              case 'auth_id_card_date_from':
                vm.hlsPopup.showLongCenter('授权人身份证有效期从未填写')
                break
              case 'auth_id_card_date_to':
                vm.hlsPopup.showLongCenter('授权人身份证有效期到未填写')
                break
              case 'user_phone':
                vm.hlsPopup.showLongCenter('您还未登录')
                break
              case 'auth_person_position':
                vm.hlsPopup.showLongCenter('公司职务未填写')
                break
              case 'auth_person_matter':
                vm.hlsPopup.showLongCenter('授权事项未填写')
                break
            }
            // vm.hlsPopup.showLongCenter('基本信息不完整！')
            vm.msg_flag = false
            return
          } else {
            vm.msg_flag = true
          }
        }
        this.lastInfo.agent_username = ''
        this.lastInfo.id_card_name = ''
      }

      if (vm.hlsUtil.isCardID(vm.saveInfo.id_card_no)) {
        vm.msg_flag = false
        vm.hlsPopup.showLongCenter('身份证不正确')
      }
      if (!vm.flag) {
        if (vm.hlsUtil.isCardID(vm.saveInfo.auth_person_id_card)) {
          vm.msg_flag = false
          vm.hlsPopup.showLongCenter('授权人身份证不正确')
        }
      }

      if (vm.msg_flag) {
        vm.dowload_list = [] // 保存之前将图片下载列表清空，防止出现重复的图片
        vm.upload_list = [] // 保存之前将待上传列表清空，防止出现重复的图片
        vm.hlsPopup.showLoading('请稍候')
        let url = $config.basePath + 'bp_org_bind_save'
        let param = {
          master: vm.saveInfo,
        }
        vm.hlsPopup.showLoading('请稍候')
        vm.hlsHttp.post(url, param).then(function (res) {
          if (res.result === 'S') {
            // vm.hlsPopup.showSuccess('保存成功,请去维护附件信息')
            vm.bp_id = res.bp_id
            window.localStorage.setItem('bp_type', vm.baseInfo.bp_type)
            window.localStorage.setItem('bp_id', res.bp_id)
            vm.loadCheckIdAndSaveAtt(res.bp_id)
          } else {
            vm.hlsPopup.showLongCenter(res.message)
          }
        })
      }
    },
    loadCheckIdAndSaveAtt (bp_id) {
      let vm = this
      let type
      if (vm.baseInfo.auth_flag === 'Y') {
        type = 'HLS_ORG_AUTH'
      } else if (vm.baseInfo.auth_flag === 'N') {
        type = 'HLS_ORG_NAUTH'
      }
      let bpId = bp_id
      let url = process.env.basePath + 'prj_cdd_check_list'
      let param = {
        master: {
          'document_id': bpId,
          'document_table': 'HLS_BP_MASTER',
          'tab_group': type,
        },
      }
      vm.$post(url, param).then(function (res) {
        if (res.result === 'S') {
          var listTemp = [...res.lists]
          listTemp.forEach(item => {
            switch (item.cdd_item) {
              case 'LEGAL_ID_CARD_F': // 法定代表人身份证正面
                vm.idCardFrontCheck_id = item.check_id
                break
              case 'LEGAL_ID_CARD_B': // 法定代表人身份证背面
                vm.idCardBackCheck_id = item.check_id
                break
              case 'AUTHOR_ID_CARD_F': // 授权人身份证正面
                vm.authidCardFrontCheck_id = item.check_id
                break
              case 'AUTHOR_ID_CARD_B': //  授权人身份证背面
                vm.authidCardBackCheck_id = item.check_id
                break
              case 'ORG_CODE':
                vm.licenseCheck_id = item.check_id
                break
              case 'BANK_CARD':
                break
              case 'L/A':
                vm.laCheck_id = item.check_id
                break
              default:
              // vm.cddItemList.push(item)
            }
          })
        }
      }).then(function (res) {
        vm.saveAttatchment()// 保存附件
      }).then(function (res) {
        vm.bindCheck()// 校验+跳转
      })
    },
    saveAttatchment () {
      let vm = this
      if (vm.idCardFrontEditFlag) { // 法定代表人身份证正面图片已修改，重新上传
        vm.idCardFrontUrlFlag = true
        vm.delete_pic_to_ocr(vm.idCardFrontAttachmentId)// 先删除之前识别的图片
        let list = []
        let obj = {
          'pkvalue': vm.idCardFrontCheck_id,
          'source_type': 'PRJ_CDD_ITEM_CHECK',
          'picture': '',
          'check_id': vm.idCardFrontCheck_id,
          'filePath': vm.idCardFront,
          'attachment_id': '',
          'user_id': 1,
          'fileName': '法人身份证正面',
        }
        list.push(obj)
        vm.save_picture(list)
        vm.idCardFrontEditFlag = false // 置为false,防止再次保存重复上传，只有重新识别才会重新上传
      }
      if (vm.idCardBackEditFlag) { // 法定代表人身份证背面图片已修改，重新上传
        vm.idCardBackUrlFlag = true
        vm.delete_pic_to_ocr(vm.idCardBackAttachmentId)// 先删除之前识别的图片
        let list = []
        let obj = {
          'pkvalue': vm.idCardBackCheck_id,
          'source_type': 'PRJ_CDD_ITEM_CHECK',
          'picture': '',
          'check_id': vm.idCardBackCheck_id,
          'filePath': vm.idCardBack,
          'attachment_id': '',
          'user_id': 1,
          'fileName': '法人身份证背面',
        }
        list.push(obj)
        vm.save_picture(list)
        vm.idCardBackEditFlag = false // 置为false,防止再次保存重复上传，只有重新识别才会重新上传
      }
      if (vm.authidCardFrontEditFlag) { // 授权人身份证正面图片已修改，重新上传
        vm.authidCardFrontUrlFlag = true
        vm.delete_pic_to_ocr(vm.authidCardFrontAttachmentId)// 先删除之前识别的图片
        let list = []
        let obj = {
          'pkvalue': vm.authidCardFrontCheck_id,
          'source_type': 'PRJ_CDD_ITEM_CHECK',
          'picture': '',
          'check_id': vm.authidCardFrontCheck_id,
          'filePath': vm.authidCardFront,
          'attachment_id': '',
          'user_id': 1,
          'fileName': '授权人身份证正面',
        }
        list.push(obj)
        vm.save_picture(list)
        vm.authidCardFrontEditFlag = false // 置为false,防止再次保存重复上传，只有重新识别才会重新上传
      }
      if (vm.authidCardBackEditFlag) { // 授权人身份证背面图片已修改，重新上传
        vm.authidCardBackUrlFlag = true
        vm.delete_pic_to_ocr(vm.authidCardBackAttachmentId)// 先删除之前识别的图片
        let list = []
        let obj = {
          'pkvalue': vm.authidCardBackCheck_id,
          'source_type': 'PRJ_CDD_ITEM_CHECK',
          'picture': '',
          'check_id': vm.authidCardBackCheck_id,
          'filePath': vm.authidCardBack,
          'attachment_id': '',
          'user_id': 1,
          'fileName': '授权人身份证背面',
        }
        list.push(obj)
        vm.save_picture(list)
        vm.authidCardBackEditFlag = false // 置为false,防止再次保存重复上传，只有重新识别才会重新上传
      }
      if (vm.licenseEditFlag) { // 营业执照图片已修改，重新上传
        vm.licenseImgUrlFlag = true
        vm.delete_pic_to_ocr(vm.licenseAttachmentId)// 先删除之前识别的图片
        let list = []
        let obj = {
          'pkvalue': vm.licenseCheck_id,
          'source_type': 'PRJ_CDD_ITEM_CHECK',
          'picture': '',
          'check_id': vm.licenseCheck_id,
          'filePath': vm.licenseImg,
          'attachment_id': '',
          'user_id': 1,
          'fileName': '企业营业执照',
        }
        list.push(obj)
        vm.save_picture(list)
        vm.licenseEditFlag = false // 置为false,防止再次保存重复上传，只有重新识别才会重新上传
      }
      if (vm.LaEditFlag) { // 授权书图片已修改，重新上传
        vm.laImgUrlFlag = true
        vm.delete_pic_to_ocr(vm.laAttachmentId)// 先删除之前识别的图片
        let list = []
        let obj = {
          'pkvalue': vm.laCheck_id,
          'source_type': 'PRJ_CDD_ITEM_CHECK',
          'picture': '',
          'check_id': vm.laCheck_id,
          'filePath': vm.laImg,
          'attachment_id': '',
          'user_id': 1,
          'fileName': '授权证书',
        }
        list.push(obj)
        vm.save_picture(list)
        vm.LaEditFlag = false // 置为false,防止再次保存重复上传，只有重新识别才会重新上传
      }
    },
    // 省份查询
    getProvince () {
      let vm = this
      let url = process.env.basePath + 'fnd_province_query'
      let param = {}
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.provinceList = res.lists.map(item => {
            return {
              code: item.province_id,
              code_name: item.province_name,
            }
          })
        }
      })
    },
    // 城市查询
    getCity () {
      let vm = this
      let url = process.env.basePath + 'fnd_city_query'
      let param = {
        province_id: vm.baseInfo.province_id,
      }
      // vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        // vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.cityList = res.lists.map(item => {
            return {
              code: item.city_id,
              code_name: item.city_name,
            }
          })
        }
      })
    },
    // 区县查询
    getDistrict () {
      let vm = this
      let url = process.env.basePath + 'fnd_district_query'
      let param = {
        city_id: vm.baseInfo.city_id,
      }
      // vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        // vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.districtList = res.lists.map(item => {
            return {
              code: item.district_id,
              code_name: item.district_name,
            }
          })
        }
      })
    },
    fileSuccess (fileList, result) {
      this.fileList = fileList
      this.fileList.forEach((itemFile, index) => {
        if (
          result.response &&
            itemFile.file &&
            !itemFile.attachment_id &&
            result.response.fileName === itemFile.file.name
        ) {
          itemFile.attachment_id = result.response.attachment_id
        }
      })
    },
    //  客户类型请求
    getBpType () {
      let vm = this
      let url = process.env.basePath + 'bp_type_select'
      let param = {}
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.typeList = res.lists
            .filter(item => item.bp_type !== 'OFFICE')
            .map(item => {
              return {
                code: item.bp_type,
                code_name: item.bp_type_n,
              }
            })
        }
      })
    },
    getbaseInfo () {
      let vm = this
      let url = process.env.basePath + 'bp_org_info_query'
      let param = {
        bp_id: this.document_id,
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          delete res.info.bp_id
          vm.baseInfo = {...res.info}
          vm.authMsg.auth_person_name = res.info.auth_person_name
          vm.authMsg.auth_person_matter = res.info.auth_person_matter
          vm.authMsg.auth_person_id_card = res.info.auth_person_id_card
          vm.authMsg.auth_person_position = res.info.auth_person_position
          vm.authMsg.auth_id_card_date_from = res.info.auth_id_card_date_from
          vm.authMsg.auth_id_card_date_to = res.info.auth_id_card_date_to
          vm.authMsg.auth_cell_phone = res.info.auth_cell_phone
          // delete res.info.agent_username
          vm.legal_personMsg.id_card_no = res.info.id_card_no
          vm.legal_personMsg.bp_legal_name = res.info.bp_legal_name
          vm.legal_personMsg.cell_phone = res.info.cell_phone
          vm.legal_personMsg.living_address = res.info.living_address
          vm.legal_personMsg.id_card_date_from = res.info.id_card_date_from
          vm.legal_personMsg.id_card_date_to = res.info.id_card_date_to
          Object.assign(vm.saveInfo, res.info)
          vm.addRows(res.info.registered_place)
          vm.addRowsLive(res.info.business_address)
          vm.addAddressRows(res.info.living_address)
          if (vm.baseInfo.auth_flag === '是') {
            vm.flag = false
            vm.loadItemList(true, 'HLS_ORG_AUTH')// 附件查询
          } else if (vm.baseInfo.auth_flag === '否') {
            vm.flag = true
            vm.loadItemList(true, 'HLS_ORG_NAUTH')// 附件查询
          }
          // vm.loadItemList(true)// 附件查询
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    addNewRole () { // 增加角色
      let vm = this
      let url = process.env.basePath + 'bp_type_save'
      let param = {
        master: {
          bp_id: window.localStorage.getItem('bp_id'),
          bp_type: vm.multiBpType.bp_type,
        },
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          hlsPopup.showLongCenter('新增成功')
          vm.isAddNewType = false
          vm.type = '请输入业务经办员工代码'
          vm.typeName = '业务经办人'
          vm.bp_type_flag = true
          let item = vm.multiBpTypeSelectList.pop()
          vm.multiRoleList.push(item)
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    load_picture (check_id, index, cdd_item) {
      let vm = this
      let url = process.env.basePath + 'attachment_list_query' + '&index' + index // 附件查询
      let param = {
        check_id: check_id,
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          res.lists.forEach(item => {
            item['url'] = process.env.filePath + 'attachment_id=' + item.attachment_id + '&access_token=' + window.localStorage.access_token
          })
          switch (cdd_item) {
            case 'LEGAL_ID_CARD_F': // 法定代表人身份证正面
              if (!vm.idCardFrontUrlFlag) {
                vm.idCardFront = res.lists[0].url
              }
              vm.idCardFrontAttachmentId = res.lists[0].attachment_id
              break
            case 'LEGAL_ID_CARD_B': // 法定代表人身份证背面
              if (!vm.idCardBackUrlFlag) {
                vm.idCardBack = res.lists[0].url
              }
              vm.idCardBackAttachmentId = res.lists[0].attachment_id
              break
            case 'AUTHOR_ID_CARD_F': // 授权人身份证正面
              if (!vm.authidCardFrontUrlFlag) {
                vm.authidCardFront = res.lists[0].url
              }
              vm.authidCardFrontAttachmentId = res.lists[0].attachment_id
              break
            case 'AUTHOR_ID_CARD_B': // 授权人身份证背面
              if (!vm.authidCardBackUrlFlag) {
                vm.authidCardBack = res.lists[0].url
              }
              vm.authidCardBackAttachmentId = res.lists[0].attachment_id
              break
            case 'ORG_CODE':
              if (!vm.licenseImgUrlFlag) {
                vm.licenseImg = res.lists[0].url
              }
              vm.licenseAttachmentId = res.lists[0].attachment_id
              break
            case 'L/A':
              if (!vm.laImgUrlFlag) {
                vm.laImg = res.lists[0].url
              }
              vm.laAttachmentId = res.lists[0].attachment_id
              break
            default:
              vm.dowload_list.push(res.lists)
          }
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    // 附件查询
    loadItemList (flag, type) {
      let vm = this
      let bpId = this.document_id
      if (bpId === 'undefined') {
        bpId = null
      }
      let url = process.env.basePath + 'prj_cdd_check_list'
      let param = {
        master: {
          'document_id': bpId,
          'document_table': 'HLS_BP_MASTER',
          'tab_group': type,
        },
      }
      // vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        // vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
        //   vm.cddItemList = []
          var listTemp = [...res.lists]
          listTemp.forEach(item => {
            switch (item.cdd_item) {
              case 'LEGAL_ID_CARD_F': // 法定代表人身份证正面
                vm.idCardFrontCheck_id = item.check_id
                break
              case 'LEGAL_ID_CARD_B': // 法定代表人身份证背面
                vm.idCardBackCheck_id = item.check_id
                break
              case 'AUTHOR_ID_CARD_F': // 授权人身份证正面
                vm.authidCardFrontCheck_id = item.check_id
                break
              case 'AUTHOR_ID_CARD_B': //  授权人身份证背面
                vm.authidCardBackCheck_id = item.check_id
                break
              case 'ORG_CODE':
                vm.licenseCheck_id = item.check_id
                break
              case 'BANK_CARD':

                break
              case 'L/A':
                vm.laCheck_id = item.check_id
                break
              default:
                // vm.cddItemList.push(item)
            }
          })
          // 查询图片
          if (flag) {
            listTemp.forEach((item, index) => {
              vm.load_picture(item.check_id, index, item.cdd_item)
            })
          }
          if (vm.idCardFrontEditFlag) { // 法定代表人身份证正面图片已修改，重新上传
            vm.idCardFrontUrlFlag = true
            vm.delete_pic_to_ocr(vm.idCardFrontAttachmentId)// 先删除之前识别的图片
            let list = []
            let obj = {
              'pkvalue': vm.idCardFrontCheck_id,
              'source_type': 'PRJ_CDD_ITEM_CHECK',
              'picture': '',
              'check_id': vm.idCardFrontCheck_id,
              'filePath': vm.idCardFrontUpload,
              'attachment_id': '',
              'user_id': 1,
              'fileName': '法人身份证正面',
            }
            list.push(obj)
            vm.save_picture(list)
            vm.idCardFrontEditFlag = false // 置为false,防止再次保存重复上传，只有重新识别才会重新上传
          }
          if (vm.idCardBackEditFlag) { // 法定代表人身份证背面图片已修改，重新上传
            vm.idCardBackUrlFlag = true
            vm.delete_pic_to_ocr(vm.idCardBackAttachmentId)// 先删除之前识别的图片
            let list = []
            let obj = {
              'pkvalue': vm.idCardBackCheck_id,
              'source_type': 'PRJ_CDD_ITEM_CHECK',
              'picture': '',
              'check_id': vm.idCardBackCheck_id,
              'filePath': vm.idCardBackUpload,
              'attachment_id': '',
              'user_id': 1,
              'fileName': '法人身份证背面',
            }
            list.push(obj)
            vm.save_picture(list)
            vm.idCardBackEditFlag = false // 置为false,防止再次保存重复上传，只有重新识别才会重新上传
          }
          if (vm.authidCardFrontEditFlag) { // 授权人身份证正面图片已修改，重新上传
            vm.authidCardFrontUrlFlag = true
            vm.delete_pic_to_ocr(vm.authidCardFrontAttachmentId)// 先删除之前识别的图片
            let list = []
            let obj = {
              'pkvalue': vm.authidCardFrontCheck_id,
              'source_type': 'PRJ_CDD_ITEM_CHECK',
              'picture': '',
              'check_id': vm.authidCardFrontCheck_id,
              'filePath': vm.authidCardFrontUpload,
              'attachment_id': '',
              'user_id': 1,
              'fileName': '授权人身份证正面',
            }
            list.push(obj)
            vm.save_picture(list)
            vm.authidCardFrontEditFlag = false // 置为false,防止再次保存重复上传，只有重新识别才会重新上传
          }
          if (vm.authidCardBackEditFlag) { // 授权人身份证背面图片已修改，重新上传
            vm.authidCardBackUrlFlag = true
            vm.delete_pic_to_ocr(vm.authidCardBackAttachmentId)// 先删除之前识别的图片
            let list = []
            let obj = {
              'pkvalue': vm.authidCardBackCheck_id,
              'source_type': 'PRJ_CDD_ITEM_CHECK',
              'picture': '',
              'check_id': vm.authidCardBackCheck_id,
              'filePath': vm.authidCardBackUpload,
              'attachment_id': '',
              'user_id': 1,
              'fileName': '授权人身份证背面',
            }
            list.push(obj)
            vm.save_picture(list)
            vm.authidCardBackEditFlag = false // 置为false,防止再次保存重复上传，只有重新识别才会重新上传
          }
          if (vm.licenseEditFlag) { // 营业执照图片已修改，重新上传
            vm.licenseImgUrlFlag = true
            vm.delete_pic_to_ocr(vm.licenseAttachmentId)// 先删除之前识别的图片
            let list = []
            let obj = {
              'pkvalue': vm.licenseCheck_id,
              'source_type': 'PRJ_CDD_ITEM_CHECK',
              'picture': '',
              'check_id': vm.licenseCheck_id,
              'filePath': vm.licenseImgUpload,
              'attachment_id': '',
              'user_id': 1,
              'fileName': '企业营业执照',
            }
            list.push(obj)
            vm.save_picture(list)
            vm.licenseEditFlag = false // 置为false,防止再次保存重复上传，只有重新识别才会重新上传
          }
          if (vm.LaEditFlag) { // 授权书图片已修改，重新上传
            vm.laImgUrlFlag = true
            vm.delete_pic_to_ocr(vm.laAttachmentId)// 先删除之前识别的图片
            let list = []
            let obj = {
              'pkvalue': vm.laCheck_id,
              'source_type': 'PRJ_CDD_ITEM_CHECK',
              'picture': '',
              'check_id': vm.laCheck_id,
              'filePath': vm.laImgUpload,
              'attachment_id': '',
              'user_id': 1,
              'fileName': '授权证书',
            }
            list.push(obj)
            vm.save_picture(list)
            vm.LaEditFlag = false // 置为false,防止再次保存重复上传，只有重新识别才会重新上传
          }
        }
      })
    },
    // 身份证重新识别后，先删除之前的照片
    delete_pic_to_ocr (attachment_id) {
      let vm = this
      var delete_list = []
      let obj = {attachment_id: attachment_id}
      delete_list.push(obj)
      let url = process.env.basePath + 'app_delete_attment' // 附件删除
      let param = {
        picturelist: delete_list,
      }
      vm.hlsHttp.post(url, param).then(function (res) {
        hlsPopup.hideLoading()
        if (res.result === 'S') {

        } else if (res.result === 'E') {

        }
      })
    },
    // 图片保存
    save_picture (list) {
      let vm = this
      if (list.length) {
        // hlsPopup.showLoading('图片上传请稍候')
        var alreadyUploadNum = 0
        var attLength = 0
        var recordUploadInterval = setInterval(function () {
          if (alreadyUploadNum === attLength) {
            clearInterval(recordUploadInterval)
            /*  hlsPopup.hideLoading()
                hlsPopup.showLongCenter('图片上传成功') */
          }
        }, 500)
        for (var i = 0; i < list.length; i++) {
          let uploadSuccess = function (res) {
            if (res.result === 'S') {
              alreadyUploadNum++
              for (var j = 0; j < list.length; j++) {
                if (list[j].filePath === res.response.filePath) {
                  list[j].attachment_id = res.response.attachment_id
                  vm.upload_list.push(list[j])
                  break
                }
              }
            } else {
              hlsPopup.hideLoading()
            }
          }
          if (!list[i].attachment_id) {
            attLength++
            hlsUtil.fileUploadSvc(list[i], uploadSuccess)
          }
        }
      } else {
        hlsPopup.hideLoading()
      }
    },
    // 查看大图
    showBigPicture (pic) {
      let vm = this
      vm.hlsPopup.showBigPicture({
        imgUrl: pic,
        width: '100%',
      })
    },
  },
}
</script>
<style lang='less'>
  #base-info {
    font-family: PingFangSC-Regular;

    input::placeholder {
      color: #b4b4b5;
    }

    textarea::placeholder {
      color: #b4b4b5;
    }

    textarea {
      // height: 28px;
      text-align: right;
      color: #666;
      resize: none;
      // padding-top:16px;
    }
    .add-people{
      display: flex;
        justify-content: start;
        img{
          width:20px;
          margin-left:10px;
        }
    }
    .type-save {
      color: #fff;
      width: 80px;
      height: 25px;
      font-size: 10px;
      border-radius: 5px;
      margin: 5px 15px 5px 0px;
      float: right;
      background-color: @headerColor;
    }

    .typeBP {
      span {
        display: inline-block;
        padding: 1px 5px;
        border-radius: 5px;
        text-align: center;
        line-height: 20px;
        background-color: rgba(220, 220, 221, 0.26);
        color: #666;
        margin-right: 5px;
        margin-top: 3px;
      }

      img {
        width: 10px;
        height: 10px;
        margin-left: 1px;
      }
    }

    .tax {
      width: 351px;
      height: 78px;
      background: #fff;
      margin: 0 auto;
      margin-bottom: 15px;
      display: flex;
      align-items: center;

      .left-img {
        width: 24px;
        height: 28px;
        flex: 2.5;
        padding-left: 24px;
      }

      div {
        flex: 25;
        padding-left: 24px;

        span {
          font-family: PingFangSC-Regular;
          font-size: 14px;
          color: #383F45;
          letter-spacing: 0;
          line-height: 22px;
        }

        p {
          font-family: PingFangSC-Regular;
          font-size: 12px;
          color: rgba(56, 63, 69, 0.50);
          letter-spacing: 0;
          line-height: 22px;
        }
      }

      .right-img {
        width: 10px;
        height: 16px;
        flex: 1;
        padding-right: 21px;
      }
    }

    .content {
      margin-top: 3px;
      height: 76%;
      padding-bottom: 40px;

      .font-color {
        color: #656464;
      }

      .martop {
        margin-top: -10px;
      }

      .userInfo {
        height: 40px;
        line-height: 40px;
        background-color: #fafafa;
        color: @headerColor;
        font-size: 15px;
        margin-left: 16px;
        position: relative;
      }

      .userInfo::before {
        content: "";
        display: block;
        width: 4px;
        height: 20px;
        background-color: @headerColor;
        position: absolute;
        left: -15px;
        top: 10px;
      }

      .types {
        margin-top: 0;
      }

      .authorize {
        width: 100%;
        height: 32px;
        display: flex;
        flex-direction: row;
        align-items: center;
        background: rgba(0, 70, 156, 0.03);
        margin-bottom: 10px;

        .authorize-select {
          // width: 48px;
          height: 20px;
          font-family: PingFangSC-Regular;
          font-size: 12px;
          color: #656464;
          line-height: 20px;
          margin-left: 16px;
        }

        .authorize-checklist {
          width: 16px;
          height: 16px;
          margin-left: 8px;

          div {
            width: 100%;
            height: 100%;
            border: 1px solid @headerColor;
            border-radius: 3px;
          }
        }
      }

      .upload-id-cards {
        height: 176px;
        background-color: #fff;

        span {
          display: block;
          color: #656464;
          margin-left: 16px;
          padding-top: 16px;
          font-size: 13px;
        }

        .upload-box {
          display: flex;
          justify-content: center;
          margin-top: 15px;

          div {
            width: 172px;
            height: 120px;
            border: 1px dashed #dcdcdd;
            text-align: center;
            font-size: 14px;
            color: #b4b4b5;

            .front,
            .back {
              width: 172px;
              height: 120px;
            }
          }

          div:nth-of-type(2) {
            margin-left: 7px;
          }

          img {
            margin-top: 32px;
            width: 58px;
            height: 45px;
          }

          p {
            margin-top: 12px;
            font-size: 13px;
          }
        }
      }

      .upload-id-card {
        height: 122px;
        background-color: #fff;

        span {
          display: block;
          color: #656464;
          margin-left: 16px;
          padding-top: 16px;
          font-size: 13px;
        }

        .upload-box1 {
          width: 80px;
          height: 80px;
          border: 1px dashed #dcdcdd;
          text-align: center;
          margin-top: 8px;
          margin-left: 16px;

          .licenseBox {
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
          }

          img {
            margin-top: 30px;
            width: 25px;
            height: 25px;
          }
        }
      }

      .second-part {
        margin-top: 9px;

        .auto {
          color: #b4b4b5;
        }
      }
    }

    .put-approved {
      width: 90%;
      height: 45px;
      color: #fff;
      border-radius: 4px;
      background-color: @headerColor;
    }

    .save {
      width: 100%;
      height: 45px;
      color: #fff;
      border-radius: 4px;
      background-color: @headerColor;
    }

    .footer-button {
      //height: 88px;
      padding-top: 15px;
      padding-bottom: 15px;
    }

    .front,
    .photo,
    .backphoto,
    .back {
      display: none;
    }
  }
</style>
