<!-- 联系人信息维护 -->
<!--suppress ALL -->
<template>
  <div>
    <dialog-edit :visible.sync="dialogVisible" :form="contactForm" :editModel="editModel" :api="api" :formRules="formRules"
                 :title="$t('enterpriseInfoManage.supplierInfoManage.contactInfoMaintain')" labelWidth="150px"
                 :autoSave="autoSave" @onSaved="onSaved"
                 :menuCode="menuId" savePerms="contactSave" :loading="form.loading">
      <span class="account-title">{{$t('enterpriseInfoManage.supplierInfoManage.accountInfos')}}</span>
      <div class="account-info">
        <el-divider></el-divider>
      </div>
      <dym-form :componentList="accountList" :formValue="contactForm" @selectChanged="templateAllEvent"></dym-form>
<!--      <transition name="el-fade-in">-->
      <div v-if="loadingDiv" style="height: 100px" v-loading="loadingDiv"></div>
<!--      </transition>-->
      <div v-for="(item, index) in contactForm.contactList" :key="index">
        <el-row>
          <el-col :span="24" align="right" :class="index === 0 ? 'btn-bottom' : 'btn-del'">
            <auth-button v-if="index === 0" type="primary" size="medium" icon="iconfont iconxinzeng"  @click="showCreate"
                         :label="$t('enterpriseInfoManage.supplierInfoManage.createContact')"
                         :menuCode="menuId" perms="contactCreate" :openPerms="true"></auth-button>
            <auth-button v-if="!item.forbiddenStatus" type="danger" icon="iconfont iconshanchu" size="medium" @click="showDelEdit(index)"
                         :label="$t('enterpriseInfoManage.supplierInfoManage.delContact')"
                         :menuCode="menuId" perms="contactDelete" :openPerms="true"></auth-button>
          </el-col>
        </el-row>
        <div>
          <div class="header-title">
            <el-collapse v-model="activeNames">
              <el-row>
                <el-collapse-item :name="index * 2 + 1">
                  <template slot="title">
                    <i v-if="item.forbiddenStatus" class="iconfont iconshanchu"></i>
                    <span>{{contactTitle(index, item)}}</span>
                    <span v-if="item.forbiddenStatus && editModel !== 'V'" class="redColor">{{'(删除原因：' + item.deleteReason + ')'}}</span>
                  </template>
                  <el-row :gutter="10">
                    <!-- 联系人角色(下拉组件)(第一联系人无表单验证) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.contactRole')" :prop="'contactList.' + index + '.contactLevel'"
                                    :rules="item.forbiddenStatus ? { required: false } : { required: true, message: $t('regMsg.enterpriseInfoManage.contactRole'), trigger: 'blur' }">
                        <!--<select-contact-level v-model="item.contactLevel" :disabled="item.forbiddenStatus" :reload="reload" :placeholder="$t('common.pleaseInput')" :queryParas="contactInfo"-->
                                              <!--class="item-width" :parasObj="{'index': index}" @selectChanged="contactLevelEvent"></select-contact-level>-->
                        <select-dictionary v-model="item.contactLevel" :disabled="item.forbiddenStatus"  :dictTypeCode="'ZD00690'" :store="$store"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width">
                        </select-dictionary>
                      </el-form-item>
                    </el-col>
                    <!-- 联系人(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.contact')" :prop="'contactList.' + index + '.employeeName'"
                                    :rules="item.forbiddenStatus ? { required: false } : formRules.contact">
                        <el-input v-model="item.employeeName" :disabled="item.forbiddenStatus"  :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width dymForm"></el-input>
                      </el-form-item>
                    </el-col>
                    <!-- 性别(字典)(表单验证) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.sex')" :prop="'contactList.' + index + '.gender'"
                                    :rules="item.forbiddenStatus ? { required: false }: formRules.sex">
                        <select-dictionary v-model="item.gender" :disabled="item.forbiddenStatus"  :dictTypeCode="'ZD0031'" :store="$store"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width">
                        </select-dictionary>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <!-- 手机号码(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.mobilePhone')" :prop="'contactList.' + index + '.telephone'"
                                    :rules="item.forbiddenStatus ? { required: false } : [{ required: true, message: $t('regMsg.enterpriseInfoManage.mobilePhone'), trigger: 'blur' },
                                  { validator: mobilePhoneCheck, trigger: 'blur' }]">
                        <el-input :disabled="item.forbiddenStatus"  v-model="item.telephone" maxlength="11" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width dymForm"></el-input>
                      </el-form-item>
                    </el-col>
                    <!-- 微信号(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.weChat')" :prop="'contactList.' + index + '.weixin'"
                                    :rules="item.forbiddenStatus ? { required: false } : [{ required: item.qq === undefined || item.qq === '', message: $t('regMsg.enterpriseInfoManage.weChat'), trigger: 'blur' },
                                  {validator: weChatCheck, trigger: 'blur', obj: item}]">
                        <el-input :disabled="item.forbiddenStatus" v-model="item.weixin" maxlength="50" :placeholder="$t('common.pleaseInput')" class="item-width dymForm"></el-input>
                      </el-form-item>
                    </el-col>
                    <!-- QQ号(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.QQ')" :prop="'contactList.' + index + '.qq'"
                                    :rules="item.forbiddenStatus ? { required: false } : [{ required: item.weixin === undefined || item.weixin === '', message: $t('regMsg.enterpriseInfoManage.QQ'), trigger: 'blur' },
                                  {validator: QQCheck, trigger: 'blur', obj: item}]">
                        <el-input :disabled="item.forbiddenStatus"  v-model="item.qq" maxlength="20" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width dymForm"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <!-- 座机 -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.telephone')" :prop="'contactList.' + index + '.telephone2'"
                                    :rules="item.forbiddenStatus ? { required: false } : formRules.telephone2">
                        <el-input :disabled="item.forbiddenStatus"  v-model="item.telephone2" maxlength="12" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width dymForm"></el-input>
                      </el-form-item>
                    </el-col>
                    <!-- 邮箱地址 -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.email')" :prop="'contactList.' + index + '.email'"
                                    :rules="item.forbiddenStatus ? { required: false } : formRules.email">
                        <el-input :disabled="item.forbiddenStatus" v-model="item.email" maxlength="100" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width dymForm"></el-input>
                      </el-form-item>
                    </el-col>
                    <!-- 做事风格(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.workStyle')" :prop="'contactList.' + index + '.characterStyle'"
                                    :rules="item.forbiddenStatus ? { required: false } : { required: index === 0, message: $t('regMsg.enterpriseInfoManage.workStyle'), trigger: 'blur' }">
                        <el-input :disabled="item.forbiddenStatus" v-model="item.characterStyle" maxlength="100" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width dymForm"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <!-- 部门(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.department')" :prop="'contactList.' + index + '.enterpriseDepartment'"
                                    :rules="item.forbiddenStatus ? { required: false } : { required: index === 0, message: $t('regMsg.enterpriseInfoManage.department'), trigger: 'blur' }">
                        <select-department :disabled="item.forbiddenStatus" v-model="item.enterpriseDepartment" :queryParas="{ keyId: contactForm.enterpriseId}"
                                           :allowCreate="true" :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" name="deptInfo" :parasObj="{ index: index }"
                                           @selectChanged="contactListSelectChanged"></select-department>
                      </el-form-item>
                    </el-col>
                    <!-- 职务(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.duty')" :prop="'contactList.' + index + '.position'"
                                    :rules="item.forbiddenStatus ? { required: false } : { required: index === 0, message: $t('regMsg.enterpriseInfoManage.duty'), trigger: 'blur' }">
                        <el-input :disabled="item.forbiddenStatus" v-model="item.position" maxlength="100" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width dymForm"></el-input>
                      </el-form-item>
                    </el-col>
                    <!-- 性格(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.character')" :prop="'contactList.' + index + '.character'"
                                    :rules="item.forbiddenStatus ? { required: false } : [{ required: index === 0, message: $t('regMsg.enterpriseInfoManage.character'), trigger: 'blur' },
                                    {validator: forbiddenStatusCheck, trigger: 'blur'}]">
                        <el-input :disabled="item.forbiddenStatus" v-model="item.character" maxlength="50" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width dymForm"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <!-- 生日 -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.birth')">
                        <div class="birth-class">
                          <div style="flex: 0">
                            <el-radio-group :disabled="item.forbiddenStatus"  v-model="item.calendarType" @change="calendarTypeEvent(item.calendarType, index)">
                              <el-radio :label="0" class="elRadioDiv">{{$t('enterpriseInfoManage.supplierInfoManage.solarCalendar')}}</el-radio>
                              <el-radio :label="1" class="elRadioDiv">{{$t('enterpriseInfoManage.supplierInfoManage.lunarCalendar')}}</el-radio>
                            </el-radio-group>
                          </div>
                          <div style="flex: 1">
                            <j-date-picker v-model="item.birthday" ref="calendar"
                                           :width="width1"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')"
                                           :picker-options="pickerOptions"
                                           :rangeSeparator="rangeSeparator"
                                           :disabled="item.forbiddenStatus"
                                           :showLunarClass="showLunarClass"
                                           :showLunarControl="showLunarControl"
                                           :type="type"
                                           :isLunar1="item.calendarType === 1 ? true : false"
                                           @dateEvent="dateEvent"
                                           :class="{'day-number': true, 'margin-left': true, 'wedgetWidth': true}"
                                           :showBackYears="showBackYears"
                                           :index="index"
                                           :showLunarIcon="showLunarIcon"
                                           :format="format"></j-date-picker>
                            <!--<el-date-picker type="date" v-model="form.birthday" :placeholder="$t('common.pleaseSelect')" class="date-class"></el-date-picker>-->
                          </div>
                        </div>
                      </el-form-item>
                    </el-col>
                    <!-- 年龄 -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.age')">
                        <el-input v-model="item.age" maxlength="11" :disabled="true" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width dymForm"></el-input>
                      </el-form-item>
                    </el-col>
                    <!-- 星座 -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.constellation')">
                        <select-dictionary :disabled="item.forbiddenStatus"  v-model="item.constellation" :dictTypeCode="'ZDC0108'" :store="$store"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width"></select-dictionary>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <!-- 籍贯 -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.native')">
                        <el-input :disabled="item.forbiddenStatus" v-model="item.nativePlace" maxlength="20" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width dymForm"></el-input>
                      </el-form-item>
                    </el-col>
                    <!-- 婚否(字典) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.marital')">
                        <select-dictionary :disabled="item.forbiddenStatus" v-model="item.maritalStatus" :dictTypeCode="'ZD0003'" :store="$store"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width dymForm">
                        </select-dictionary>
                      </el-form-item>
                    </el-col>
                    <!-- 爱好 -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.hobby')" :prop="'contactList.' + index + '.hobby'"
                                    :rules="item.forbiddenStatus ? { required: false } : formRules.hobby">
                        <el-input :disabled="item.forbiddenStatus" v-model="item.hobby" maxlength="100" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width dymForm"></el-input>
                      </el-form-item>
                    </el-col>
                    <!-- 关联已有账号 -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.associateExistingAccount')">
                        <!--<el-input v-model="item.hobby" :placeholder="$t('common.pleaseInput')" class="item-width"></el-input>-->
                        <select-existing-accounts :disabled="item.forbiddenStatus" v-model="item.associateExistingAccount" :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')"
                                                  class="item-width" :queryParas="existingAccount"></select-existing-accounts>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-collapse-item>
                <el-collapse-item :name="index * 2 + 2">
                  <template slot="title">
                    <i v-if="item.forbiddenStatus" class="iconfont iconshanchu"></i>
                    <span >{{businessTitle(index, item)}}</span>
                    <span v-if="item.forbiddenStatus && editModel !== 'V'" class="redColor">{{'(删除原因：' + item.deleteReason + ')'}}</span>
                  </template>
                  <el-row :gutter="10">
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <!-- 是否合作方 (表单验证prop) -->
                      <el-form-item v-if="enterpriseType === 'projectCompany'" :label="$t('enterpriseInfoManage.projCompanyInfoManage.partnerOrNot')" :prop="'contactList.' + index + '.partnerFlag'"
                                    :rules="item.forbiddenStatus ? { required: false } : formRules.partnerFlag">
                        <select-dictionary :disabled="item.forbiddenStatus" v-model="item.partnerFlag" :dictTypeCode="'ZD0003'" :store="$store"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width">
                        </select-dictionary>
                      </el-form-item>
                      <!-- 是否挂靠(表单验证prop) -->
                      <el-form-item v-else :label="$t('enterpriseInfoManage.supplierInfoManage.isAttached')" :prop="'contactList.' + index + '.anchoredFlag'"
                                    :rules="item.forbiddenStatus ? { required: false } : formRules.isAttached">
                        <select-dictionary :disabled="item.forbiddenStatus" v-model="item.anchoredFlag" :dictTypeCode="'ZD0003'" :store="$store"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width">
                        </select-dictionary>
                      </el-form-item>
                    </el-col>
                    <!-- 上班时间(字典)(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.officeHours')" :prop="'contactList.' + index + '.workTimeId'"
                                    :rules="item.forbiddenStatus ? { required: false } : formRules.officeHours">
                        <select-work-shift :disabled="item.forbiddenStatus" v-model="item.workTimeId"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width">
                        </select-work-shift>
                      </el-form-item>
                    </el-col>
                    <!-- 周末是否操作(字典)(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.operateWeek')" :prop="'contactList.' + index + '.weekendOperation'"
                                    :rules="item.forbiddenStatus ? { required: false } : formRules.operateWeek">
                        <select-dictionary :disabled="item.forbiddenStatus" v-model="item.weekendOperation" :dictTypeCode="'ZD0003'" :store="$store"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width">
                        </select-dictionary>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <!-- 保理负责事项(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.responsibleMatter')" :prop="'contactList.' + index + '.factoringResponsibility'"
                                    :rules="item.forbiddenStatus ? { required: false } : formRules.responsibleMatter">
                        <select-dictionary :disabled="item.forbiddenStatus" v-model="item.factoringResponsibility" :dictTypeCode="'factor_responsibility'" :store="$store"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width">
                        </select-dictionary>
                      </el-form-item>
                    </el-col>
                    <!-- 对保理熟悉程度(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.familiarity')" :prop="'contactList.' + index + '.factoringDegree'"
                                    :rules="item.forbiddenStatus ? { required: false } : formRules.familiarity">
                        <select-dictionary :disabled="item.forbiddenStatus" v-model="item.factoringDegree" :dictTypeCode="'factor_degree'" :store="$store"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width">
                        </select-dictionary>
                      </el-form-item>
                    </el-col>
                    <!-- 保理操作配合程度(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.coordination')" :prop="'contactList.' + index + '.coordinationDegree'"
                                    :rules="item.forbiddenStatus ? { required: false } : formRules.coordination">
                        <select-dictionary :disabled="item.forbiddenStatus" v-model="item.coordinationDegree" :dictTypeCode="'coordination_degree'" :store="$store"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width">
                        </select-dictionary>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <!-- 盖章方式(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.sealWay')" :prop="'contactList.' + index + '.stampWay'"
                                    :rules="item.forbiddenStatus ? { required: false } : formRules.sealWay">
                        <select-dictionary :disabled="item.forbiddenStatus" v-model="item.stampWay" :multiple="true" :dictTypeCode="'sealing_method'" :bufferParams="{ 'index': index }" :store="$store"
                                           @selectChanged="selectChanged"
                                           name="stampWayInfo"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width">
                        </select-dictionary>
                      </el-form-item>
                    </el-col>
                    <!-- 电子章盖章流程(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.sealFlow')" :prop="'contactList.' + index + '.stampingProcess'"
                                    :rules="item.stampingFlag && !item.forbiddenStatus ? formRules.sealFlow : { required: false }">
                        <select-dictionary v-model="item.stampingProcess" :disabled="!item.stampingFlag || item.forbiddenStatus" :dictTypeCode="'stamp_process'" :store="$store"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width">
                        </select-dictionary>
                      </el-form-item>
                    </el-col>
                    <!-- 电子章盖章天数(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.sealDay')" :prop="'contactList.' + index + '.stampedDays'"
                                    :rules="item.stampingFlag && !item.forbiddenStatus ? formRules.sealDay : { required: false }">
                        <el-input v-model="item.stampedDays" :disabled="!item.stampingFlag || item.forbiddenStatus" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <!-- 鲜章盖章流程(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.chapterStampingProcess')" :prop="'contactList.' + index + '.chapterStampingProcess'"
                                    :rules="item.stampingFlag1 && !item.forbiddenStatus ? formRules.chapterStampingProcess : { required: false }">
                        <select-dictionary v-model="item.chapterStampingProcess" :disabled="!item.stampingFlag1 || item.forbiddenStatus" :dictTypeCode="'chapter_stamping_process'" :store="$store"
                                           :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width">
                        </select-dictionary>
                      </el-form-item>
                    </el-col>
                    <!-- 鲜章盖章天数(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.chapterStampedDays')" :prop="'contactList.' + index + '.chapterStampedDays'"
                                    :rules="item.stampingFlag1 && !item.forbiddenStatus ? formRules.chapterStampedDays : { required: false }">
                        <el-input v-model="item.chapterStampedDays" :disabled="!item.stampingFlag1 || item.forbiddenStatus" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width"></el-input>
                      </el-form-item>
                    </el-col>
                    <!-- 保理资料模板(表单验证prop) -->
                    <!--<el-col :xs="24" :sm="24" :md="24" :lg="8">-->
                    <!--<el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.absDataTemplate')" :prop="'contactList.' + index + '.factoringTemplate'"-->
                    <!--:rules="formRules.absDataTemplate">-->
                    <!--<el-input v-model="item.factoringTemplate" :placeholder="$t('common.pleaseInput')" class="item-width"></el-input>-->
                    <!--</el-form-item>-->
                    <!--</el-col>-->
                    <!-- 工作负责板块(表单验证prop) -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="8">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.workResTemplate')" :prop="'contactList.' + index + '.workResTemplate'"
                                    :rules="!item.forbiddenStatus ? [{ required: true, message: $t('regMsg.enterpriseInfoManage.workResTemplate'), trigger: 'blur' }] : { required: false }">
                        <select-work-template v-model="item.workResTemplate" :optionList="optionList" :disabled="item.forbiddenStatus"
                                              :reload="reloadWork" :index="index" @selectChanged="templateEvent" :placeholder="editModel === 'V' ? '' : $t('common.pleaseSelect')" class="item-width"></select-work-template>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <!-- 特殊事项 -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="24">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.specialIssue')">
                        <el-input :disabled="item.forbiddenStatus" v-model="item.specialMatter" maxlength="500" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="10">
                    <!-- 备注 -->
                    <el-col :xs="24" :sm="24" :md="24" :lg="24">
                      <el-form-item :label="$t('enterpriseInfoManage.supplierInfoManage.remark')">
                        <el-input :disabled="item.forbiddenStatus" type="textarea" v-model="item.memo" maxlength="500" :placeholder="editModel === 'V' ? '' : $t('common.pleaseInput')" class="item-width"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-collapse-item>
              </el-row>
            </el-collapse>
          </div>
        </div>
      </div>
      <span v-if="historyFlag" class="account-title1">{{$t('enterpriseInfoManage.supplierInfoManage.historyInfos')}}</span>
      <dym-form v-if="historyFlag" :componentList="billList" :formValue="historyForm" class="bill-form"></dym-form>
      <data-table v-if="historyFlag" :operateBtnLayout="operateBtnLayout" :queryParas="queryParas" :sourceData="sourceHistoryData"
                  :toolMenuFlag="toolMenuFlag" :columns="billColumns" :showPage="showPage"></data-table>
    </dialog-edit>
    <create-contact-edit :visible.sync="showDetail" :menuId="menuId" :enterpriseType="enterpriseType" :form="item" :editModel="showModel" :regMsg="regMsg" @createSuccess="createSuccess"></create-contact-edit>
    <del-hint-edit :visible.sync="showDelFlag" :menuId="menuId" :delStatus="true" :form="item" :editModel="delModel" @delSuccess="delSuccess"></del-hint-edit>
  </div>
</template>

<script>
import { DialogEdit, dymForm, DataTable, authButton, SelectDictionary, validate, regExp, JDatePicker } from 'newepoch-components'
import BaseEdit from '@/pages/baseEditPage'
import * as format from '@/filters/index.js'
// import { regExp } from '@/validator/index'
import SelectDepartment from '@/components/element/enterpriseInfoManage/SelectDepartment.vue'
import SelectWorkTemplate from '@/components/element/enterpriseInfoManage/SelectWorkTemplate.vue'
import CreateContactEdit from '@/pages/enterpriseInfoManage/supplierInfoManage/createContactEdit.vue'
import DelHintEdit from '@/pages/enterpriseInfoManage/supplierInfoManage/delEnterpriseEdit.vue'
import SelectExistingAccounts from '@/components/element/enterpriseInfoManage/SelectExistingAccounts.vue'
import supplierInfoManageApi from '@/api/enterpriseInfoManage/supplierInfoManageApi.js'
// import lunarCalendar from 'lunar-calendar-datepicker'
import SelectWorkShift from '@/components/element/enterpriseInfoManage/SelectWorkShift.vue'
import SelectContactLevel from '@/components/element/enterpriseInfoManage/SelectContactLevel.vue'
export default {
  extends: new BaseEdit(),
  name: 'contactInfoEdit',
  components: {
    DialogEdit,
    dymForm,
    DataTable,
    authButton,
    SelectDepartment,
    SelectDictionary,
    SelectWorkTemplate,
    CreateContactEdit,
    DelHintEdit,
    SelectExistingAccounts,
    JDatePicker,
    SelectWorkShift,
    SelectContactLevel
  },
  props: {
    enterpriseType: {
      type: String,
      default: function () {
        return null
      }
    }
  },
  data () {
    return {
      // 农历组件
      type: 'DATE',
      isLunar1: false,
      showLunarClass: 'MIX',
      showBackYears: 2,
      showLunarIcon: false,
      showLunarControl: false,
      width1: '98%',
      format: 'YYYY-MM-DD',
      rangeSeparator: '-',
      disabled: false,
      editable: true,
      clearable: true,
      pickerOptions: {
        disabledDate (time) {
          // return time.getTime() < Date.now() - 8.64e7;
        }
      },
      // 中文数字 数组
      chnNumChar: ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'],
      chnUnitSection: ['', '万', '亿', '万亿', '亿亿'],
      chnUnitChar: ['', '十', '百', '千'],
      toolMenuFlag: false,
      showPage: false,
      showDetail: false,
      showDelFlag: false,
      autoSave: false,
      operateBtnLayout: '',
      showModel: '',
      delModel: '',
      item: {},
      // 重新加载
      reload: false,
      // 部门重新加载
      reloadFlag: false,
      reloadWork: false,
      // 保存按钮加载标识
      loading: false,
      // 保存按钮加载标识
      loadingDiv: false,
      // 联系人角色查询条件
      level: [],
      contactInfo: {
        accountId: this.form.accountId,
        flag: '0'
      },
      // 负责模块
      templateInfo: [],
      // 工作负责模块入参
      optionList: [],
      existingAccount: {},
      // 历史提单
      sourceHistoryData: [],
      // 历史
      historyFlag: false,
      // 提单次数信息
      historyForm: {},
      queryParas: {
        keyId: this.form.accountId
      },
      contactForm: {
        contactList: []
      },
      sourceData: [],
      // 账号信息
      accountList: [
        // 企业名称
        {
          value: 'enterpriseName',
          disabled: false,
          componentName: 'el-input',
          label: this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage.enterpriseName,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseInput,
          cols: [24, 24, 24, 8],
          prop: 'enterpriseName'
        },
        // 账号类型(字典处理)
        {
          value: 'employeeAccountType',
          disabled: false,
          componentName: 'SelectDictionary',
          dictTypeCode: 'create_account_type',
          store: this.$store,
          label: this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage.accountType,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseInput,
          cols: [24, 24, 24, 8],
          prop: 'employeeAccountType'
        },
        // 登录账号
        {
          value: 'account',
          disabled: false,
          componentName: 'el-input',
          label: this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage.loginAccount,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseInput,
          cols: [24, 24, 24, 8],
          prop: 'account'
        },
        // 是否做业务(表单验证)
        {
          value: 'businessStatus',
          disabled: false,
          componentName: 'SelectDictionary',
          dictTypeCode: 'ZD0003',
          store: this.$store,
          label: this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage.doBusiness,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect,
          cols: [24, 24, 24, 8],
          prop: 'businessStatus'
        },
        // 负责板块 (级联多选组件)(表单验证)
        {
          value: 'resTemplate',
          disabled: false,
          name: 'resTemplate',
          componentName: SelectWorkTemplate,
          label: this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage.resTemplate,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseSelect,
          cols: [24, 24, 24, 8],
          prop: 'resTemplate',
          reload: false
        }
      ],
      // 历史提单信息 表单
      billList: [
        // 提单数量
        {
          value: 'billAmount',
          disabled: true,
          componentName: 'el-input',
          label: this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage.billAmount,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseInput,
          cols: [24, 24, 24, 8],
          prop: 'billAmount'
        },
        // 提单频率(数据处理)
        {
          value: 'billTimes',
          disabled: true,
          componentName: 'el-input',
          label: this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage.billTimes,
          placeholder: this.$i18n.messages[this.$i18n.locale].common.pleaseInput,
          cols: [24, 24, 24, 8],
          prop: 'billTimes'
        }
      ],
      // 历史提单信息 表格
      billColumns: [
        // 合同名称
        {
          prop: 'contractName',
          align: 'center',
          disabled: false,
          label: this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage.contractName,
          width: ''
        },
        // 合同金额(元)
        {
          prop: 'contractAmount',
          align: 'center',
          disabled: false,
          label: this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage.contractMoney,
          width: '',
          format: (row) => { return format.thousandFilter(row.contractAmount) }
        },
        // 已提单金额(元)
        {
          prop: 'factoringMoney',
          align: 'center',
          disabled: false,
          label: this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage.billedAmount,
          width: '',
          format: (row) => { return format.thousandFilter(row.factoringMoney) }
        },
        // 款项性质
        {
          prop: 'paymentInfo',
          align: 'center',
          disabled: false,
          label: this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage.sumProperties,
          width: ''
          // format: (row) => { return format.formatDict(row.paymentInfo, '') }
        }
      ],
      // 表单验证
      formRules: {
        // 是否做业务
        businessStatus: [{ required: true, message: this.regMsg.enterpriseInfoManage.doBusiness, trigger: 'blur' }],
        // 负责板块
        resTemplate: [{ required: true, message: this.regMsg.enterpriseInfoManage.resTemplate, trigger: 'blur' }],
        // 联系人
        contact: [{ required: true, message: this.regMsg.enterpriseInfoManage.contact }, { validator: validate.nameValidate, trigger: 'blur' }],
        // 性别
        sex: [{ required: true, message: this.regMsg.enterpriseInfoManage.sex, trigger: 'change' }],
        // 手机号码
        mobilePhone: [{ required: true, message: this.regMsg.enterpriseInfoManage.mobilePhone, trigger: 'blur' }, { validator: validate.mobilePhoneValidate, trigger: 'blur' }],
        // 是否挂靠
        isAttached: [{ required: true, message: this.regMsg.enterpriseInfoManage.isAttached, trigger: 'blur' }],
        // 是否合作方
        partnerFlag: [{ required: true, message: this.regMsg.enterpriseInfoManage.partnerFlag, trigger: 'blur' }],
        // 上班时间
        officeHours: [{ required: true, message: this.regMsg.enterpriseInfoManage.officeHours, trigger: 'blur' }],
        // 周末是否操作
        operateWeek: [{ required: true, message: this.regMsg.enterpriseInfoManage.operateWeek, trigger: 'blur' }],
        // 保理负责事项
        responsibleMatter: [{ required: true, message: this.regMsg.enterpriseInfoManage.responsibleMatter, trigger: 'change' }],
        // 对保理熟悉程度
        familiarity: [{ required: true, message: this.regMsg.enterpriseInfoManage.familiarity, trigger: 'change' }],
        // 保理操作配合程度
        coordination: [{ required: true, message: this.regMsg.enterpriseInfoManage.coordination, trigger: 'change' }],
        // 盖章方式
        sealWay: [{ required: true, message: this.regMsg.enterpriseInfoManage.sealWay, trigger: 'change' }],
        // 电子章盖章流程
        sealFlow: [{ required: true, message: this.regMsg.enterpriseInfoManage.sealFlow, trigger: 'change' }],
        // 电子章盖章天数
        sealDay: [{ required: true, message: this.regMsg.enterpriseInfoManage.sealDay, trigger: 'change' },
          { validator: this.chapterStampedDaysCheck, trigger: 'change' }],
        // 鲜章盖章流程
        chapterStampingProcess: [{ required: true, message: this.regMsg.enterpriseInfoManage.sealFlow, trigger: 'change' }],
        // 鲜章盖章天数
        chapterStampedDays: [{ required: true, message: this.regMsg.enterpriseInfoManage.sealDay, trigger: 'change' },
          { validator: this.chapterStampedDaysCheck, trigger: 'change' }],
        // 保理资料模板
        absDataTemplate: [{ required: true, message: this.regMsg.enterpriseInfoManage.absDataTemplate, trigger: 'blur' }],
        // 座机
        telephone2: [{ validator: validate.telephoneValidate, trigger: 'blur' }],
        email: [{ validator: validate.emailValidate, trigger: 'blur' }],
        // 爱好
        hobby: [{ validator: validate.legalPersonValidate, trigger: 'blur' }]
        // 工作负责板块
        // workResTemplate: [{ required: true, message: this.regMsg.enterpriseInfoManage.workResTemplate, trigger: 'change' }]
      }
    }
  },
  computed: {
    activeNames: {
      get () {
        if (this.contactForm.contactList.length > 0) {
          let arr = []
          for (let i = 0; i < this.contactForm.contactList.length; i++) {
            if (!this.contactForm.contactList[i].forbiddenStatus) {
              arr.push(i * 2 + 1)
              arr.push(i * 2 + 2)
            }
          }
          return arr
        } else {
          return []
        }
      },
      set (val) {
        this.$emit('update:activeNames', val)
      }
    },
    api () {
      return supplierInfoManageApi.employee
    }
  },
  // activated () {
  //   // 初始调用
  //   this.queryParas.keyId = this.form.accountId
  //   this.handleFilter()
  // },
  // mounted () {
  //   // 初始调用
  //   this.queryParas.keyId = this.form.accountId
  //   this.handleFilter()
  // },
  methods: {
    // 查询
    handleFilter () {
      let $this = this
      $this.queryParas.keyId = $this.form.keyId
      $this.level = []
      this.loadingDiv = true
      supplierInfoManageApi.employeeContact.getList(this.queryParas).then(res => {
        this.loadingDiv = false
        if (res && res.data) {
          // 企业名称
          // $this.contactForm.enterpriseName = res.data.enterpriseName
          $this.$set($this.contactForm, 'enterpriseName', res.data.enterpriseName)
          // 账号类型
          $this.contactForm.employeeAccountType = format.formatFindDefoult(res.data.employeeAccountType)
          // 登录账号
          // $this.contactForm.account = res.data.account
          $this.$set($this.contactForm, 'account', res.data.account)
          // 是否做业务
          // $this.contactForm.businessStatus = res.data.businessStatus
          $this.$set($this.contactForm, 'businessStatus', res.data.businessStatus)
          // 负责板块
          // let ids = $this.templateToId(res.data.accountTerritoryDtoList)
          if (res.data.accountTerritoryDtoList.length > 0) {
            $this.contactForm.resTemplate = $this.templateToId(res.data.accountTerritoryDtoList)
          }
          this.accountList[4].reload = !this.accountList[4].reload
          // $this.contactForm.resTemplate = $this.test
          // 账号keyId
          $this.contactForm.keyId = res.data.keyId
          // 账号ID
          $this.contactForm.accountId = res.data.accountId
          // 企业ID
          $this.contactForm.enterpriseId = res.data.enterpriseId
          let data = []
          // 联系人排序
          let newDataList = $this.sortByKey(res.data.fincrmEmployeeAccountRelDTOList, 'contactLevel')
          newDataList.forEach((it, index) => {
            let info = {}
            // 联系人等级keyId
            info.employeeLeavelId = it.keyId
            // 联系人信息keyId
            info.employeeKeyId = it.fincrmEmployeeDTO.keyId
            // 联系人详细信息keyId
            info.employeeInfoKeyId = it.fincrmEmployeeInfoDTO.keyId
            if (it.fincrmEmployeeBusinessDTO) {
              // 联系人业务相关信息keyId
              info.employeeBusinessKeyId = it.fincrmEmployeeBusinessDTO.keyId
              // 是否合作方
              info.partnerFlag = format.formatFindDefoult(it.fincrmEmployeeBusinessDTO.partnerFlag)
              // 上班时间
              if (it.fincrmEmployeeBusinessDTO.workTimeId === '0' || it.fincrmEmployeeBusinessDTO.workTimeId === 0) {
                info.workTimeId = ''
              } else {
                info.workTimeId = it.fincrmEmployeeBusinessDTO.workTimeId
              }
              // 周末是否操作
              info.weekendOperation = it.fincrmEmployeeBusinessDTO.weekendOperation.toString()
              // 保理负责事项
              info.factoringResponsibility = format.formatFindDefoult(it.fincrmEmployeeBusinessDTO.factoringResponsibility.toString())
              // 对保理熟悉程度
              info.factoringDegree = format.formatFindDefoult(it.fincrmEmployeeBusinessDTO.factoringDegree.toString())
              // 保理操作配合程度
              info.coordinationDegree = format.formatFindDefoult(it.fincrmEmployeeBusinessDTO.coordinationDegree.toString())
              // 特殊事项
              info.specialMatter = it.fincrmEmployeeBusinessDTO.specialMatter
              // 备注
              info.memo = it.fincrmEmployeeBusinessDTO.memo
            }
            // 联系人角色
            info.contactLevel1 = '第' + format.numberToChinese(parseInt(it.contactLevel)) + '联系人'
            info.contactLevel = it.contactLevel
            $this.level.push(info.contactLevel1)
            // info.contactLevel = '第一联系人'
            // 联系人
            info.reload = true
            info.employeeName = it.fincrmEmployeeDTO.employeeName
            // 性别
            info.gender = format.formatFindDefoult(it.fincrmEmployeeDTO.gender)
            // 手机号
            info.telephone = it.fincrmEmployeeDTO.telephone
            // 微信号
            info.weixin = it.fincrmEmployeeDTO.weixin
            // qq
            info.qq = it.fincrmEmployeeDTO.qq
            // 座机
            info.telephone2 = it.fincrmEmployeeInfoDTO.officePhone
            // 邮箱地址
            info.email = it.fincrmEmployeeDTO.email
            // 做事风格
            info.characterStyle = it.fincrmEmployeeDTO.characterStyle
            // 部门
            info.enterpriseDepartment = format.formatDictDefoult(it.fincrmEmployeeInfoDTO.enterpriseDeptId)
            // 职务
            info.position = it.fincrmEmployeeInfoDTO.position
            // 性格
            info.character = it.fincrmEmployeeDTO.character
            // 生日
            if (it.fincrmEmployeeDTO.birthday === '1900-01-01' || it.fincrmEmployeeDTO.birthday === -2209017600000) {
              info.birthday = ''
            } else {
              if (it.fincrmEmployeeDTO.calendarType === '0') {
                info.birthday = format.formatCheckDatetime(it.fincrmEmployeeDTO.birthday)
                // info.birthday = '1970-01-01'
              } else if (it.fincrmEmployeeDTO.calendarType === '1') {
                info.birthday = 'L' + format.formatCheckDatetime(it.fincrmEmployeeDTO.birthday)
              }
            }
            // 日期类型
            if (it.fincrmEmployeeDTO.calendarType) {
              info.calendarType = parseInt(it.fincrmEmployeeDTO.calendarType)
            } else {
              info.calendarType = 1
              // this.$set($this.contactForm.contactList[index], 'calendarType', 1)
            }
            // 年龄
            info.age = format.formatFindDefoult(it.fincrmEmployeeDTO.age)
            // 星座
            info.constellation = format.formatFindDefoult(it.fincrmEmployeeDTO.constellation)
            // 籍贯
            info.nativePlace = it.fincrmEmployeeDTO.nativePlace
            // 婚否
            info.maritalStatus = format.formatFindDefoult(it.fincrmEmployeeDTO.maritalStatus)
            // 爱好
            info.hobby = it.fincrmEmployeeDTO.hobby
            // 关联已有账号
            info.associateExistingAccount = it.accountId
            /* 业务相关操作信息 */
            // 是否挂靠
            info.anchoredFlag = format.formatFindDefoult(it.fincrmEmployeeInfoDTO.anchoredFlag)
            // 盖章方式 attributeDTOList
            let stampWay = []
            it.attributeDTOList.forEach(s => {
              stampWay.push(s.attributeValue)
              // 2电子章
              if (s.attributeValue === '2') {
                // $this.$set($this.contactForm.contactList[index], 'stampingFlag', true)
                info.stampingFlag = true
              }
              // 1鲜章
              if (s.attributeValue === '1') {
                // $this.$set($this.contactForm.contactList[index], 'stampingFlag1', true)
                info.stampingFlag1 = true
              }
            })
            if (stampWay.length > 0) {
              info.stampWay = stampWay
            } else {
              info.stampWay = ''
            }
            // this.$set($this.contactForm.contactList[index], 'stampWay', stampWay)
            // 电子章盖章流程
            info.stampingProcess = it.stampProcessZero
            // 电子章盖章天数
            info.stampedDays = it.stampedAayZero
            // 鲜章盖章流程
            info.chapterStampingProcess = it.stampProcessOne
            // 鲜章盖章天数
            info.chapterStampedDays = it.stampedAayOne
            // 保理资料模板
            // info.factoringTemplate = it
            // 工作负责板块 fincrmPlateAreaRelDTOList
            if (it.fincrmPlateAreaRelDTOList.length > 0) {
              info.workResTemplate = $this.templateToId(it.fincrmPlateAreaRelDTOList)
            }
            // 是否禁用
            // info.forbiddenStatus = true
            if (it.fincrmEmployeeDTO.forbiddenStatus && it.fincrmEmployeeDTO.forbiddenStatus === '1') {
              info.forbiddenStatus = true
            } else {
              info.forbiddenStatus = false
            }
            // 删除原因
            info.deleteReason = it.fincrmEmployeeDTO.deleteReason
            data.push(info)
          })

          $this.contactForm.contactList = data
          if (this.editModel === 'V') {
            $this.contactForm.contactList.forEach(item => {
              $this.$set(item, 'forbiddenStatus', true)
              $this.$set(item, '')
            })
          }
          // $this.$set($this.contactForm, 'contactList', data)
        }
      })
    },
    // 保存
    onSaved () {
      let $this = this
      // $this.loading = true
      this.$set($this.form, 'loading', true)
      // let fincrmEmployeeBusinessDTO = {}
      // let fincrmEmployeeDTO = {}
      // let fincrmEmployeeInfoDTO = {}
      let infoList = []
      // let fincrmPlateContractRelDTOList = {}
      $this.contactForm.contactList.forEach(it => {
        let data = {
          fincrmEmployeeBusinessDTO: {
            fincrmPlateContractRelDTOList: []
          },
          fincrmEmployeeDTO: {},
          fincrmEmployeeInfoDTO: {}
        }
        // let stamp = {}
        data.keyId = it.employeeLeavelId
        // 联系人信息keyId
        data.fincrmEmployeeDTO.keyId = it.employeeKeyId
        // 联系人详细信息keyId
        data.fincrmEmployeeInfoDTO.keyId = it.employeeInfoKeyId
        // 联系人业务相关信息keyId
        data.fincrmEmployeeBusinessDTO.keyId = it.employeeBusinessKeyId
        // 联系人角色 组件处理
        data.contactLevel = it.contactLevel
        // 联系人
        data.fincrmEmployeeDTO.employeeName = it.employeeName
        // 性别
        data.fincrmEmployeeDTO.gender = it.gender
        // 手机号
        data.fincrmEmployeeDTO.telephone = it.telephone
        // 微信号
        data.fincrmEmployeeDTO.weixin = it.weixin
        // qq
        data.fincrmEmployeeDTO.qq = it.qq
        // 座机
        data.fincrmEmployeeDTO.telephone2 = it.telephone2
        // 邮箱地址
        data.fincrmEmployeeDTO.email = it.email
        // 做事风格
        data.fincrmEmployeeDTO.characterStyle = it.characterStyle
        // 部门
        data.fincrmEmployeeInfoDTO.enterpriseDeptId = it.deptId
        // 部门名称
        data.fincrmEmployeeInfoDTO.enterpriseDepartment = it.deptName
        // 职务
        data.fincrmEmployeeInfoDTO.position = it.position
        // 性格
        data.fincrmEmployeeDTO.character = it.character
        // 生日
        data.fincrmEmployeeDTO.birthday = it.newDate
        // data.fincrmEmployeeDTO.birthday = '2009-01-01'
        // 日期类型
        data.fincrmEmployeeDTO.calendarType = it.calendarType
        // 年龄
        data.fincrmEmployeeDTO.age = it.age
        // 星座
        if (it.constellation === '' || it.constellation === undefined) {
          data.fincrmEmployeeDTO.constellation = -1
        } else {
          data.fincrmEmployeeDTO.constellation = it.constellation
        }
        // 籍贯
        data.fincrmEmployeeDTO.nativePlace = it.nativePlace
        // 婚否
        data.fincrmEmployeeDTO.maritalStatus = it.maritalStatus
        // 爱好
        data.fincrmEmployeeDTO.hobby = it.hobby
        // 关联已有账号
        // data.associateExistingAccount = it.accountId
        data.accountId = it.associateExistingAccount
        /* 业务相关操作信息 */
        // 是否挂靠
        data.fincrmEmployeeInfoDTO.anchoredFlag = it.anchoredFlag
        // 是否合作方
        // data.fincrmEmployeeInfoDTO.partnerFlag = it.partnerFlag
        // 上班时间
        data.fincrmEmployeeBusinessDTO.workTimeId = it.workTimeId
        // 周末是否操作
        data.fincrmEmployeeBusinessDTO.weekendOperation = it.weekendOperation
        // 保理负责事项
        data.fincrmEmployeeBusinessDTO.factoringResponsibility = it.factoringResponsibility
        // 是否合作方
        data.fincrmEmployeeBusinessDTO.partnerFlag = it.partnerFlag
        // 对保理熟悉程度
        data.fincrmEmployeeBusinessDTO.factoringDegree = it.factoringDegree
        // 保理操作配合程度
        data.fincrmEmployeeBusinessDTO.coordinationDegree = it.coordinationDegree
        // 盖章方式 attributeDTOList
        // data.stampWay = ''
        data.attributeDTOList = []
        if (it.stampWay.length > 0) {
          it.stampWay.forEach(s => {
            let attribute = {}
            attribute.attributeType = 1
            attribute.attributeValue = s
            data.attributeDTOList.push(attribute)
          })
        } else {
          data.attributeDTOList = []
        }
        // 盖章流程
        data.stampProcessZero = it.stampingProcess
        // 电子章盖章天数
        data.stampedAayZero = it.stampedDays
        // 鲜章盖章流程
        data.stampProcessOne = it.chapterStampingProcess
        // 鲜章盖章天数
        data.stampedAayOne = it.chapterStampedDays
        // 保理资料模板
        // info.factoringTemplate = it
        // 工作负责板块 fincrmPlateAreaRelDTOList
        data.fincrmPlateAreaRelDTOList = it.fincrmPlateAreaRelDTOList
        // 特殊事项
        data.fincrmEmployeeBusinessDTO.specialMatter = it.specialMatter
        // 备注
        data.fincrmEmployeeBusinessDTO.memo = it.memo
        infoList.push(data)
      })
      let dataList = {}
      // 企业名称
      // dataList.enterpriseName = $this.contactForm.enterpriseName
      // 账号类型
      // dataList.employeeAccountType = $this.contactForm.employeeAccountType
      // 登录账号
      // dataList.account = $this.contactForm.account
      // 账号Id
      dataList.accountId = $this.contactForm.accountId
      // 企业keyId
      dataList.enterpriseId = $this.contactForm.enterpriseId
      // 是否做业务
      dataList.businessStatus = $this.contactForm.businessStatus
      // 账号keyId
      dataList.keyId = $this.contactForm.keyId
      // 企业负责板块
      dataList.accountTerritoryDtoList = $this.templateInfo
      dataList.fincrmEmployeeAccountRelDTOList = infoList
      // 企业标签
      dataList.enterpriseType = $this.form.tagCode
      // 登录用户名
      dataList.userName = this.$store.getters.nikeName
      // $this.contactForm.resTemplate = ''
      supplierInfoManageApi.employeeUpdate.update(dataList).then(res => {
        if (res && res.data) {
          $this.success(this.$i18n.messages[this.$i18n.locale].common.updateSuccess)
          $this.dialogVisible = false
          this.$set($this.form, 'loading', false)
          $this.$emit('createSuccess')
        } else {
          $this.error(this.$i18n.messages[this.$i18n.locale].common.updateError)
        }
      }).catch(() => {
        this.$set($this.form, 'loading', false)
      })
    },
    historyFilter () {
      let $this = this
      let data = {}
      // 企业Id
      data.enterpriseId = $this.form.enterpriseId
      // 企业类型
      data.enterpriseType = $this.form.tagCode
      supplierInfoManageApi.historyInfo.getHistoryList(data).then(res => {
        if (res && res.data) {
          if (res.data.length > 0) {
            $this.historyFlag = true
            // 提单次数
            $this.$set($this.historyForm, 'billAmount', res.data[0].ladingSum)
            // 提单频率
            $this.$set($this.historyForm, 'billTimes', res.data[0].ladingFrequency)
            $this.sourceHistoryData = res.data
          } else {
            $this.historyFlag = false
          }
        } else {
          $this.historyFlag = false
        }
      })
    },
    // 阳历星座返回
    dateEvent (date, constellation, index) {
      let $this = this
      // this.contactForm.contactList[index].constellation = constellation
      let borthday = date.substring(0, 4)
      let nowDate = new Date()
      let newYear = nowDate.getFullYear()
      let age = newYear - parseInt(borthday)
      // let barthday1 = format.getTimestamp(date)
      // $this.contactForm.contactList[index].newDate = format.getTimestamp(date)
      let num = format.constellationToNumber(constellation)
      if (num) {
        $this.$set($this.contactForm.contactList[index], 'constellation', num.toString())
      } else {
        $this.$set($this.contactForm.contactList[index], 'constellation', '12')
      }
      $this.$set($this.contactForm.contactList[index], 'age', age)
      $this.$set($this.contactForm.contactList[index], 'newDate', date)
      // console.log(borthday, age, constellation, index)
    },
    // 盖章方式返回 盖章流程禁用
    selectChanged (key, name, data, bufferParams) {
      // dictId
      if (name === 'stampWayInfo') {
        if (data.length > 0) {
          if (data.length === 1) {
            data.forEach(it => {
              // 1电子章 2鲜章
              if (it.dictId === '1') {
                this.$set(this.contactForm.contactList[bufferParams.index], 'chapterStampingProcess', '')
                this.$set(this.contactForm.contactList[bufferParams.index], 'chapterStampedDays', '')
                this.$set(this.contactForm.contactList[bufferParams.index], 'stampingFlag', true)
              } else {
                this.$set(this.contactForm.contactList[bufferParams.index], 'stampingFlag', false)
              }
              if (it.dictId === '2') {
                this.$set(this.contactForm.contactList[bufferParams.index], 'stampingProcess', '')
                this.$set(this.contactForm.contactList[bufferParams.index], 'stampedDays', '')
                this.$set(this.contactForm.contactList[bufferParams.index], 'stampingFlag1', true)
              } else {
                this.$set(this.contactForm.contactList[bufferParams.index], 'stampingFlag1', false)
              }
            })
          }
          if (data.length === 2) {
            // data.forEach(it => {
            //   if (it.dictId === '2') {
            //     this.$set(this.contactForm.contactList[bufferParams.index], 'stampingFlag', true)
            //   }
            //   if (it.dictId === '1') {
            //     this.$set(this.contactForm.contactList[bufferParams.index], 'stampingFlag1', true)
            //   }
            // })
            this.$set(this.contactForm.contactList[bufferParams.index], 'stampingFlag', true)
            this.$set(this.contactForm.contactList[bufferParams.index], 'stampingFlag1', true)
          }
        } else {
          this.$set(this.contactForm.contactList[bufferParams.index], 'stampingFlag', false)
          this.$set(this.contactForm.contactList[bufferParams.index], 'stampingFlag1', false)
          this.$set(this.contactForm.contactList[bufferParams.index], 'stampingProcess', '')
          this.$set(this.contactForm.contactList[bufferParams.index], 'stampedDays', '')
          this.$set(this.contactForm.contactList[bufferParams.index], 'chapterStampingProcess', '')
          this.$set(this.contactForm.contactList[bufferParams.index], 'chapterStampedDays', '')
        }
      }
    },
    // 联系人角色处理
    contactLevelEvent (val, name, data, parasObj) {
      if (val) {
        // this.contactForm.contactList[parasObj.index].contactLevel1 = data.contactLevel
        this.$set(this.contactForm.contactList[parasObj.index], 'contactLevel1', data.contactLevel)
      }
    },
    // 工作模块数据处理
    templateEvent (index, name, dataLists, val) {
      let $this = this
      $this.contactForm.contactList[index].fincrmPlateAreaRelDTOList = []
      if (dataLists.length > 0) {
        let list = []
        dataLists.forEach(item => {
          let data = {
            children: []
          }
          if (item.children.length > 0) {
            item.children.forEach(it => {
              let child = {
                children: []
              }
              if (it.children.length > 0) {
                it.children.forEach(it2 => {
                  let child2 = {}
                  child2.contractId = it2.value
                  child2.contractName = it2.label
                  child.children.push(child2)
                })
              }
              child.areaId = it.value
              child.areaName = it.label
              data.children.push(child)
            })
          }
          data.coreEnterpriseId = item.value
          data.coreEnterpriseName = item.label
          list.push(data)
          $this.contactForm.contactList[index].fincrmPlateAreaRelDTOList = list
        })
      }
      // if (index > 0 && dataLists.length > 0) {
      //   // obj.item.workResTemplate
      //   // let allDataList = $this.contactForm.resTemplate
      //   let dataList = []
      //   let newList = []
      //   if ($this.contactForm.contactList[0].workResTemplate > $this.contactForm.contactList[index].workResTemplate.length) {
      //     dataList = $this.contactForm.contactList[0].workResTemplate
      //     newList = $this.contactForm.contactList[index].workResTemplate
      //   } else {
      //     dataList = $this.contactForm.contactList[index].workResTemplate
      //     newList = $this.contactForm.contactList[0].workResTemplate
      //   }
      //   // let newList = $this.contactForm.contactList[index].workResTemplate
      //   // let dataList = $this.contactForm.contactList[0].workResTemplate
      //   if (index !== 0) {
      //     let length2 = newList.filter(info => {
      //       if (info.length === 2) {
      //         return info
      //       }
      //     })
      //     let length3 = newList.filter(info => {
      //       if (info.length === 3) {
      //         return info
      //       }
      //     })
      //     var flag = false
      //     dataList.forEach(item => {
      //       // 判断三维数组
      //       if (item.length === 3) {
      //         let newLength3 = length3.filter(it3 => {
      //           if (it3[2] === item[2]) {
      //             return it3
      //           }
      //         })
      //         // 判断是否存在数据
      //         if (newLength3.length === 0) {
      //           flag = true
      //         }
      //       } else if (item.length === 2) {
      //         let newLength2 = length2.filter(it2 => {
      //           if (it2[1] === item[1]) {
      //             return it2
      //           }
      //         })
      //         // 不存在删除该条数据
      //         if (newLength2.length === 0) {
      //           flag = true
      //         }
      //       }
      //     })
      //     if (flag) {
      //       $this.$set($this.contactForm.contactList[index], 'showFlag', flag)
      //     } else {
      //       $this.$set($this.contactForm.contactList[index], 'showFlag', flag)
      //     }
      //   }
      // }
      // if (index === 0 && dataLists.length > 0) {
      //   // this.$nextTick(function () {
      //   // })
      // }
      // if (index === 0 && dataLists.length > 0) {
      //   let dataList = []
      //   let newDataList = []
      //   if ($this.contactForm.contactList) {
      //     if ($this.contactForm.contactList.length > 1) {
      //       $this.contactForm.contactList.forEach((newIt, inx) => {
      //         let newList = []
      //         if (inx === 0) {
      //           newDataList = newIt.workResTemplate
      //         }
      //         if (inx !== 0) {
      //           if (newDataList.length > newIt.workResTemplate.length) {
      //             dataList = newDataList
      //             newList = newIt.workResTemplate
      //           } else {
      //             dataList = newIt.workResTemplate
      //             newList = newDataList
      //           }
      //           // let newList = newIt.workResTemplate
      //           let length2 = newList.filter(info => {
      //             if (info.length === 2) {
      //               return info
      //             }
      //           })
      //           let length3 = newList.filter(info => {
      //             if (info.length === 3) {
      //               return info
      //             }
      //           })
      //           let flag1 = false
      //           dataList.forEach(item => {
      //             // 判断三维数组
      //             if (item.length === 3) {
      //               let newLength3 = length3.filter(it3 => {
      //                 if (it3[2] === item[2]) {
      //                   return it3
      //                 }
      //               })
      //               // 不存在删除该条数据
      //               if (newLength3.length === 0) {
      //                 flag1 = true
      //               }
      //             } else if (item.length === 2) {
      //               let newLength2 = length2.filter(it2 => {
      //                 if (it2[1] === item[1]) {
      //                   return it2
      //                 }
      //               })
      //               // 不存在删除该条数据
      //               if (newLength2.length === 0) {
      //                 flag1 = true
      //               }
      //             }
      //           })
      //           if (flag1) {
      //             $this.$set($this.contactForm.contactList[inx], 'showFlag', flag1)
      //           } else {
      //             $this.$set($this.contactForm.contactList[inx], 'showFlag', flag1)
      //           }
      //         }
      //       })
      //     }
      //   }
      // }
    },
    // 负责模块数据处理
    templateAllEvent (data, index) {
      if (data.Info) {
        let list = []
        this.reloadWork = !this.reloadWork
        this.optionList = data.Info
        data.Info.forEach(item => {
          let data = {
            children: []
          }
          if (item.children.length > 0) {
            item.children.forEach(it => {
              let child = {
                children: []
              }
              if (it.children.length > 0) {
                it.children.forEach(it2 => {
                  let child2 = {}
                  child2.contractId = it2.value
                  child2.contractName = it2.label
                  child.children.push(child2)
                })
              }
              child.areaId = it.value
              child.areaName = it.label
              data.children.push(child)
            })
          }
          data.coreEnterpriseId = item.value
          data.coreEnterpriseName = item.label
          list.push(data)
          this.templateInfo = list
        })
      }
    },
    // 负责模块数据转换去id
    templateToId (data) {
      let ids = []
      if (data.length > 0) {
        data.forEach(item => {
          if (item.children.length > 0) {
            item.children.forEach(it => {
              if (it.children.length > 0) {
                it.children.forEach(it2 => {
                  let list = []
                  list.push(item.coreEnterpriseId)
                  list.push(it.areaId)
                  list.push(it2.contractId)
                  ids.push(list)
                })
              } else {
                let list1 = []
                list1.push(item.coreEnterpriseId)
                list1.push(it.areaId)
                ids.push(list1)
              }
            })
          }
        })
      }
      return ids
    },
    // 性格验证
    forbiddenStatusCheck: function (rule, value, callback) {
      if (!this.UtilJs.isEmpty(value)) {
        if (regExp.legalPerson.test(value)) {
          callback()
        } else {
          callback(new Error('请输入中英文'))
        }
      } else {
        callback()
      }
    },
    // 手机号码校验
    mobilePhoneCheck: function (rule, value, callback) {
      if (!this.UtilJs.isEmpty(value)) {
        if (regExp.mobilePhone.test(value)) {
          callback()
        } else {
          callback(new Error(this.regMsg.enterpriseInfoManage.phone))
        }
      } else {
        callback()
      }
    },
    // 邮箱校验
    emailCheck: function (rule, value, callback) {
      if (!this.UtilJs.isEmpty(value)) {
        if (regExp.email.test(value)) {
          callback()
        } else {
          callback(new Error(this.regMsg.enterpriseInfoManage.email))
        }
      } else {
        callback()
      }
    },
    // 微信校验
    weChatCheck: function (rule, value, callback) {
      // let obj = rule.obj
      if (!this.UtilJs.isEmpty(value)) {
        if (regExp.weChat.test(value)) {
          callback()
        } else {
          callback(new Error(this.regMsg.enterpriseInfoManage.weixin))
        }
      } else {
        callback()
      }
    },
    // QQ校验
    QQCheck: function (rule, value, callback) {
      // let obj = rule.obj
      if (!this.UtilJs.isEmpty(value)) {
        if (regExp.QQ.test(value)) {
          callback()
        } else {
          callback(new Error(this.regMsg.enterpriseInfoManage.qq))
        }
      } else {
        callback()
      }
    },
    // 工作负责板块校验
    workResTemplateCheck: function (rule, value, callback) {
      // { validator: workResTemplateCheck, trigger: 'change', obj: {item: item, index: index}}
      let obj = rule.obj
      let $this = this
      // obj.item.workResTemplate
      let allDataList = $this.contactForm.resTemplate
      let newList = obj.item.workResTemplate
      let dataList = $this.contactForm.contactList[0].workResTemplate
      if (obj.index !== 0) {
        let length2 = newList.filter(info => {
          if (info.length === 2) {
            return info
          }
        })
        let length3 = newList.filter(info => {
          if (info.length === 3) {
            return info
          }
        })
        var flag = false
        dataList.forEach(item => {
          // 判断三维数组
          if (item.length === 3) {
            let newLength3 = length3.filter(it3 => {
              if (it3[2] === item[2]) {
                return it3
              }
            })
            // 不存在删除该条数据
            if (newLength3.length === 0) {
              // flag = true
              allDataList.forEach(item1 => {
                // 判断三维数组
                if (item1.length === 3) {
                  let new1Length3 = length3.filter(list3 => {
                    if (list3[2] === item[2]) {
                      return list3
                    }
                  })
                  // 不存在删除该条数据
                  if (new1Length3.length === 0) {
                    flag = true
                  }
                }
                // 判断二维数组
                if (item1.length === 2) {
                  let new1Length2 = length2.filter(list2 => {
                    if (list2[1] === item[1]) {
                      return list2
                    }
                  })
                  // 不存在删除该条数据
                  if (new1Length2.length === 0) {
                    flag = true
                  }
                }
              })
            }
          } else if (item.length === 2) {
            let newLength2 = length2.filter(it2 => {
              if (it2[1] === item[1]) {
                return it2
              }
            })
            // 不存在删除该条数据
            if (newLength2.length === 0) {
              // flag = true
              allDataList.forEach(item1 => {
                // 判断三维数组
                if (item1.length === 3) {
                  let new1Length3 = length3.filter(list3 => {
                    if (list3[2] === item[2]) {
                      return list3
                    }
                  })
                  // 不存在赋值给判断属性
                  if (new1Length3.length === 0) {
                    flag = true
                  }
                }
                // 判断二维数组
                if (item1.length === 2) {
                  let new1Length2 = length2.filter(list2 => {
                    if (list2[1] === item[1]) {
                      return list2
                    }
                  })
                  // 不存在赋值给判断属性
                  if (new1Length2.length === 0) {
                    flag = true
                  }
                }
              })
            }
          }
        })
        if (flag) {
          callback(new Error(this.regMsg.enterpriseInfoManage.workResTemplateInfo))
        } else {
          callback()
        }
      } else {
        callback()
      }
    },
    // 盖章天数校验
    chapterStampedDaysCheck: function (rule, value, callback) {
      if (!this.UtilJs.isEmpty(value)) {
        if (regExp.dayNum.test(value)) {
          if (value > 30) {
            callback(new Error(this.regMsg.enterpriseInfoManage.sealDayInfoCheck))
          } else {
            callback()
          }
        } else {
          callback(new Error(this.regMsg.enterpriseInfoManage.sealDayInfo))
        }
      } else {
        callback()
      }
    },
    // 新建联系人
    showCreate () {
      let data = {}
      data.account = this.contactForm.account
      data.enterpriseName = this.contactForm.enterpriseName
      data.employeeAccountType = this.contactForm.employeeAccountType
      data.enterpriseId = this.form.enterpriseId
      // 企业标签
      data.tagCode = this.form.tagCode
      data.accountKeyId = this.form.keyId
      // 账号ID
      data.accountId = this.form.accountId
      data.resTemplate = this.contactForm.resTemplate
      data.flag = 1
      data.businessStatus = this.contactForm.businessStatus
      data.calendarType = 0
      data.reload = this.reload
      data.optionList = this.optionList
      // this.reload = !this.reload
      this.showModel = 'C'
      this.item = Object.assign({ loading: false }, data)
      this.showDetail = true
    },
    // 删除联系人
    showDelEdit (index) {
      if (this.contactForm.contactList.length === 1) {
        this.warning(this.$i18n.messages[this.$i18n.locale].common.deleteInfo)
      } else {
        this.delModel = 'C'
        this.item = Object.assign({}, { keyId: this.form.keyId, employeeId: this.contactForm.contactList[index].employeeKeyId, enterpriseId: this.contactForm.enterpriseId })
        this.showDelFlag = true
      }
    },
    // 新建联系人成功
    createSuccess (contactItem) {
      // this.contactForm.contactList.push(contactItem)
      this.reload = !this.reload
      this.contactForm.contactList = []
      this.handleFilter()
      this.historyFilter()
    },
    // 删除联系人成功
    delSuccess () {
      this.reload = !this.reload
      this.contactForm.contactList = []
      this.handleFilter()
      this.historyFilter()
    },
    // 动态表单--联系人基本信息表头
    contactTitle (index, item) {
      let common = this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage
      // let num = this.numberToChinese(index)
      // let level = item.contactLevel
      return this.level[index] + common.contactBasicInfo
    },
    // 动态表单--联系人业务信息表头
    businessTitle (index, item) {
      let common = this.$i18n.messages[this.$i18n.locale].enterpriseInfoManage.supplierInfoManage
      // let num = this.numberToChinese(index)
      // let level = item.contactLevel
      return this.level[index] + common.contactBusInfo
    },
    // 切换为中文数字
    sectionToChinese (section) {
      let $this = this
      let strIns = ''
      let chnStr = ''
      let unitPos = 0
      let zero = true
      while (section > 0) {
        let v = section % 10
        if (v === 0) {
          if (!zero) {
            zero = true
            chnStr = $this.chnNumChar[v] + chnStr
          }
        } else {
          zero = false
          strIns = $this.chnNumChar[v]
          strIns += $this.chnUnitChar[unitPos]
          chnStr = strIns + chnStr
        }
        unitPos++
        section = Math.floor(section / 10)
      }
      return chnStr
    },
    // 阿拉伯数字转化为中文数字
    numberToChinese (index) {
      let $this = this
      let num = index + 1
      let unitPos = 0
      let strIns = ''
      let chnStr = ''
      let needZero = false
      while (num > 0) {
        let section = num % 10000
        if (needZero) {
          chnStr = $this.chnNumChar[0] + chnStr
        }
        strIns = $this.sectionToChinese(section)
        strIns += (section !== 0) ? $this.chnUnitSection[unitPos] : $this.chnUnitSection[0]
        chnStr = strIns + chnStr
        needZero = (section < 1000) && (section > 0)
        num = Math.floor(num / 10000)
        unitPos++
      }
      return chnStr
    },
    // 单选框事件
    calendarTypeEvent (calendarType, index) {
      this.$set(this.contactForm.contactList[index], 'birthday', '')
      this.$set(this.contactForm.contactList[index], 'age', '')
      this.$set(this.contactForm.contactList[index], 'constellation', '')
    },
    // 数组对象排序
    sortByKey (array, key) {
      return array.sort(function (a, b) {
        let x = a[key]
        let y = b[key]
        return ((x < y) ? -1 : ((x > y) ? 1 : 0))
      })
    },
    // 比较数组是否相等
    arrEuqalse (arr1, arr2) {
      if (!arr1 || !arr2) {
        return false
      }
      if (arr1.length !== arr2.length) {
        return false
      }
      for (let i = 0; i < arr2.length; i++) {
        if (arr1.indexOf(arr2[i]) === -1) {
          return false
        }
      }
      for (let i = 0; i < arr1.length; i++) {
        if (arr2.indexOf(arr1[i]) === -1) {
          return false
        }
      }
      return true
    },
    // 部门数据处理
    contactListSelectChanged (val, name, data, obj) {
      if (name === 'deptInfo') {
        if (data) {
          // this.$set(this.formValue.contactArray[obj.index], 'deptName', data.deptName)
          this.$set(this.contactForm.contactList[obj.index], 'deptId', data.keyId)
        } else if (val && !data) {
          this.$set(this.contactForm.contactList[obj.index], 'deptId', '')
          this.$set(this.contactForm.contactList[obj.index], 'deptName', val)
        }
      }
    }
  },
  watch: {
    visible (val) {
      let $this = this
      if (val) {
        $this.reload = !this.reload
        $this.reloadFlag = !$this.reloadFlag
        this.$nextTick(() => {
          if (this.editModel === 'V') {
            $this.accountList.forEach((item, index) => {
              $this.$set(item, 'disabled', true)
              $this.$set(item, 'pleaceholder', '')
            })
            $this.billList.forEach((item, index) => {
              $this.$set(item, 'disabled', true)
              $this.$set(item, 'pleaceholder', '')
            })
          } else {
            $this.$set($this.accountList[0], 'disabled', true)
            $this.$set($this.accountList[1], 'disabled', true)
            $this.$set($this.accountList[2], 'disabled', true)
          }
        })
        $this.handleFilter()
        $this.historyFilter()
        // 获取企业ID
        $this.contactInfo.accountId = this.form.accountId
        $this.existingAccount.enterpriseId = this.form.enterpriseId
      } else {
        for (let key in this.contactForm) {
          if (key === 'contactList') {
            $this.contactForm[key] = []
          } else {
            $this.contactForm[key] = ''
          }
        }
        $this.$emit('createSuccess')
      }
    },
    'contactForm.resTemplate' (val) {
      if (val) {
        let $this = this
        let length2 = val.filter(info => {
          if (info.length === 2) {
            return info
          }
        })
        let length3 = val.filter(info => {
          if (info.length === 3) {
            return info
          }
        })
        $this.contactForm.contactList.forEach(it => {
          if (it.workResTemplate) {
            let workResTemplatelist = []
            it.workResTemplate.forEach((item, index) => {
              // 判断三维数组
              if (item.length === 3) {
                let newLength3 = length3.filter(it3 => {
                  if (it3[2] === item[2]) {
                    return it3
                  }
                })
                // 不存在删除该条数据
                if (newLength3.length > 0) {
                  workResTemplatelist.push(newLength3[0])
                  // it.workResTemplate.splice(index, 1)
                }
              }
              // 判断二维数组
              if (item.length === 2) {
                let newLength2 = length2.filter(it2 => {
                  if (it2[1] === item[1]) {
                    return it2
                  }
                })
                // 不存在删除该条数据
                if (newLength2.length > 0) {
                  workResTemplatelist.push(newLength2[0])
                  // it.workResTemplate.splice(index, 1)
                }
              }
            })
            it.reload = !it.reload
            it.workResTemplate = workResTemplatelist
          }
        })
      }
    }
  }
}
</script>

<style scoped lang="scss">
  @import '~@/styles/enterpriseInfoManage/supplierInfoManage/contactInfoEdit.scss';
</style>
