<style>
  .page_MyCustomer ._mc_addbox {
    height: 52px;
    width: 100%;
    margin-top: 20px;
  }

  .page_MyCustomer ._mc_addbox>li {
    float: left;
    width: 116px;
    font-size: 14px;
    height: 52px;
    color: #666;
    text-align: center;
    line-height: 52px;
    background: #E9E9E9;
    cursor: pointer;
  }

  .page_MyCustomer ._mc_addbox>li.active {
    background: #fff;
    color: #333;
  }

  .page_MyCustomer ._mc_addbox .divActive {
    margin: -3px auto;
    width: 26px;
    height: 3px;
    background: #E95252;
  }

  .page_MyCustomer ._mc_edit {
    overflow: auto;
    display: none;
    position: absolute;
    z-index: 50;
    bottom: 0;
    left: 0;
    border-top: 3px solid #38425d;
    background-color: #f9f9f9;
    padding: 10px;
    width: 100%;
    min-width: 1146px;
  }

  .page_MyCustomer .edHeightOne {
    display: block !important;
    height: 450px;
  }

  .MyCustomerDiv ._mc_list {
    background: #fff;
    padding-top: 20px;
    box-sizing: border-box;
    overflow: hidden !important;

  }

  .page_MyCustomer ._mc_list>ul>li {
    padding: 20px 20px 0 20px;
    width: 260px;
    box-sizing: border-box;
    height: 410px;
    float: left;
    border: 1px solid #F1F2F5;
    background: #fff;
    margin-right: 10px;
    margin-bottom: 20px;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
  }

  .page_MyCustomer ._mc_list>ul>li:hover {
    box-shadow: 0px 0px 10px rgba(191, 191, 191, 1);
    transition: all linear 0.3s;
  }

  .page_MyCustomer ._mc_list>ul>li .iconDelete {
    cursor: pointer;
    display: none;
    position: absolute;
    top: -4px;
    right: 0;
    color: #E95252;
    z-index: 5;
  }

  .page_MyCustomer ._mc_list>ul>li:hover .iconDelete {
    display: block;
  }

  .page_MyCustomer ._mc_list>ul>li .iconDelete1 {
    cursor: pointer;
    display: none;
    position: absolute;
    top: -4px;
    right: 16px;
    color: #2CA4F0;
    z-index: 5;
  }

  .page_MyCustomer ._mc_list>ul>li:hover .iconDelete1 {
    display: block;
  }

  .page_MyCustomer ._mc_list>ul>li .iconDelete2 {
    cursor: pointer;
    display: none;
    position: absolute;
    top: -4px;
    right: 32px;
    color: #34BFA3;
    z-index: 5;
  }

  .page_MyCustomer ._mc_list>ul>li:hover .iconDelete2 {
    display: block;
  }

  .page_MyCustomer ._mc_list>ul>li>img {
    position: absolute;
    z-index: 5;
  }

  .page_MyCustomer ._head_info_box {
    text-align: center;
    font-size: 14px;
    color: #333333
  }

  .page_MyCustomer ._head_info_box img {
    height: 48px;
    width: 48px;
    border-radius: 50%;
    margin-bottom: 5px
  }

  .page_MyCustomer ._head_info_box p {
    margin-bottom: 8px;
  }

  .page_MyCustomer ._head_info_box .icon-img_dianhua {
    color: #09D49D
  }

  .page_MyCustomer ._addr {
    color: #666666
  }

  .page_MyCustomer ._record {
    padding: 5px 10px 15px;
    border-bottom: 1px solid #F5F5F5;
    min-height: 120px
  }

  .page_MyCustomer ._record p {
    margin-bottom: 10px;
    text-align: center;
    font-size: 14px;
    border-radius: 4px;
    padding: 2px;
    color: white;
    background-color: #257BF1;
  }

  .page_MyCustomer ._record p._other_n {
    color: #666666;
    background-color: #F5F5F5;
  }

  .page_MyCustomer ._record p._fist_n {
    color: #09D49D;
    background-color: #E9F7F1;
  }

  .page_MyCustomer ._record p._other {
    color: #257BF1;
    background-color: #E4EFFF;
  }

  .page_MyCustomer ._bt {
    font-size: 14px;
    margin-top: 15px;
    text-align: center;
    color: #666;
  }

  .page_MyCustomer ._bt span {
    color: #FF9000
  }

  .page_MyCustomer ._edHeight {
    height: 340px;
  }

  .page_MyCustomer ._scrollbar::-webkit-scrollbar {
    width: 4px;
    height: 8px;
  }

  .page_MyCustomer ._scrollbar::-webkit-scrollbar-thumb {
    border-radius: 4px;
    -webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
    background: #c9c9c9;
  }

  .page_MyCustomer ._scrollbar::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    background: #EDEDED;
  }

  .page_MyCustomer ._mc_edit ._tit {
    padding-left: 10px;
    border-left: 3px solid #E95252;
    font-size: 16px;
    font-family: 'PingFangSc-Fine';
    color: #000000
  }

  .page_MyCustomer ._mc_edit ._info_box ul._form li {
    float: left;
  }

  .page_MyCustomer ._check_list {
    padding-left: 120px;
    margin-bottom: 20px;
  }

  .page_MyCustomer ._check_box .el-form-item {
    margin-bottom: 0
  }

  .page_MyCustomer ._info_box .el-form-item__label {
    font-size: 12px;
    color: #666;
  }

  ._remark textarea {
    resize: none;
    width: 646px;
    height: 100px
  }

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

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

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

  .page_MyCustomer .avatar {
    width: 148px;
    height: 148px;
    display: block;
  }

  .page_MyCustomerSearch {
    width: 100%;
    min-height: auto;
    overflow: hidden;
    padding: 0 0 20px 0;
  }

  .page_MyCustomerSearch li {
    float: left;
    font-size: 12px;
    color: #666;
    margin: 20px 0 0px 0;
  }

  .page_MyCustomerSearch li>span {
    display: inline-block;
  }

  .page_MyCustomerSearch li span>em {
    display: inline-block;
    min-width: 60px;
    text-align: right;
    font-style: normal;
    margin: 0 12px 0 0;
  }

  .page_MyCustomerSearch li:last-child {
    float: right;
  }

  .page_MyCustomerSearch ._class_b {
    color: #257BF1 !important
  }

  .xqBtn {
    background: #09D49D;
    color: #fff !important;
    width: 100%;
    display: inline-block;
    border-radius: 4px;
    font-size: 14px;
    height: 38px;
    line-height: 38px;
    text-align: center;
  }

  .page_MyCustomer .upload-demo {
    text-align: center;
  }

  .MycustomerTable th,
  .MycustomerTable td {
    text-align: left;
    padding-left: 25px
  }

  .MyCustomerDetailbottomLayer {
    overflow: auto;
    position: absolute;
    height: 200px;
    z-index: 50;
    bottom: 0;
    left: 0;
    border-top: 1px solid #d1d1d1;
    background-color: #FFFFFF;
    padding: 20px 20px 0;
    width: 100%;
  }

  .MyCustomerDetailbottomLayer>p {
    border-left: 3px solid #E95252;
    text-indent: 15px;
    height: 14px;
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 14px;
    color: #000;
  }

  .MyCustomerDetailbottomLayer .el-form-item__label {
    font-size: 12px !important;
  }

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

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

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

  .MyCustomerDetailbottomLayer .avatar {
    width: 148px;
    height: 148px;
    display: block;
  }

  .yichangde {
    display: inline-block;
    border-radius: 50%;
    color: red;
    border: 1px solid red;
    font-size: 12px;
    width: 18px;
    height: 18px;
    text-align: center;
    cursor: pointer;
  }

</style>
<template>
  <div class="page_MyCustomer MyCustomerDiv">
    <div class="page_MyCustomerSearch">
      <li>
        <span>
          <em>{{$t('salesModule.keyWords')}}:</em>
          <el-input class='w220' v-model='msg.CustomerName' @keyup.enter.native="getList()"
            :placeholder="$t('salesModule.enterPhone')"></el-input>
        </span>
      </li>
      <li>
        <button class="hollowFixedBtn" @click="getList()">{{$t('pub.searchBtn')}}</button>
        <button class="normalBtn"
          @click="addShow=true;isOldPerson=false,addLayer1=false">{{$t('salesModule.addCustomer')}}</button>
        <button class="normalBtn" @click="outerVisible=true">导入</button>
        <button class="normalBtn" @click="getDownList">模板下载</button>
      </li>
    </div>
    <div class="_mc_addbox">
      <li :class="{active:type==2}" @click="type=2;clickGetList(2)">
        {{$t('salesModule.InformalClient')}}
        <div class="divActive" v-show="type==2"></div>
      </li>
      <li :class="{active:type==1}" @click="type=1;clickGetList(1)">
        {{$t('salesModule.notInformalClient')}}
        <div class="divActive" v-show="type==1"></div>
      </li>
      <li :class="{active:type==3}" @click="type=3;clickGetList(3)">
        {{$t('salesModule.UnapprovedClient')}}
        <div class="divActive" v-show="type==3"></div>
      </li>
      <li :class="{active:type==4}" @click="type=4;clickGetList(4)">
        {{$t('salesModule.BlackListCustomers')}}
        <div class="divActive" v-show="type==4"></div>
      </li>
    </div>
    <div class="_mc_list _scrollbar" :class="addShow==true?'_edHeight':''">
      <table class="MycustomerTable singeRowTable" border="0" cellspacing="0" cellpadding="0" v-loading="loading">
        <tr>
          <th>姓名</th>
          <th>联系电话</th>
          <th>门店名称</th>
          <th>近期约访</th>
          <th>最近拜访</th>
          <th>累计拜访</th>
          <th>幸福存折</th>
          <th>累计交易额</th>
          <th>询价与需求</th>
          <th>所属联盟</th>
          <th>优惠券</th>
          <th>操作</th>
        </tr>
        <tr v-for="(item,i) in dataList" :key="i">
          <td>
            <span>{{item.contact}}</span>
            <el-popover width="280" popper-class="pd20" trigger="click">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr class="_color_666">
                  <th>异常名称</th>
                  <th>创建人</th>
                  <th>创建时间</th>
                </tr>
                <tr v-for="(unionItem,x) in CustomerException">
                  <td>{{unionItem.ExceptionName}}</td>
                  <td>{{unionItem.CreateByName}}</td>
                  <td>{{unionItem.CreateTimestr}}</td>
                </tr>
              </table>
              <span v-show="item.exceptionCount > 0" slot="reference" class="yichangde"
                @click="yichangde(item)">异</span>
            </el-popover>
          </td>
          <td>{{item.contactNumber}}</td>
          <td>{{item.customerName}}</td>
          <td>
            <p v-if="item.customerVisitList.length>0">
              {{item.customerVisitList[0].visitDateTime}}
            </p>
            <p v-else>{{$t('salesModule.noYuefang')}}</p>
          </td>
          <td>
            <div @click="goUrl(type,item.customerId,1)">
              <p v-if="item.customerVisitList[1]">
                <span
                  style="cursor: pointer;text-decoration: underline;">{{item.customerVisitList[1].visitDateTime}}</span>
              </p>
              <p v-else>
                <span style="cursor: pointer;text-decoration: underline;">{{$t('pub.noMsg')}}</span></p>
            </div>

          </td>
          <td><span @click="goUrl(type,item.customerId,2)"
              style="cursor: pointer;text-decoration: underline;">{{item.visiteCount}}</span></td>
          <td>{{item.cL_Balance}}</td>
          <td><span @click="goUrl(type,item.customerId,3)"
              style="cursor: pointer;text-decoration: underline;">{{item.tradeTotal}}</span></td>
          <td>{{item.inquireCount}}</td>
          <td>{{item.allianceName}}</td>
          <td><span style="cursor: pointer;text-decoration: underline;"
              @click.stop="goUrC('CouponsList',item.customerAccountId)">{{item.couponNum}}</span></td>
          <td>
            <el-tooltip class="item" effect="dark" content="编辑" placement="top-start">
              <el-button @click.stop="EditMsg(item)" style="padding:4px" type="primary" icon="iconfont icon-bianji"
                circle></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="账户管理" placement="top-start">
              <el-button style="padding:4px" @click.stop="goUrlT('empBankAccount',item.customerId)" type="danger"
                icon="iconfont icon-guanliyuan" circle></el-button>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="交易详情" placement="top-start">
              <el-button style="padding:4px" @click.stop="goUrC('CustomerAnalysis',item.customerId)" type="success"
                icon="iconfont icon-icon-test6" circle></el-button>
            </el-tooltip>
          </td>
        </tr>
        <tr v-if="dataList.length==0">
          <td colspan="12" style="text-align:center">暂无数据</td>
        </tr>
      </table>
      <el-pagination background @current-change="handleCurrentChange" :current-page.sync="currentPage"
        layout="total,prev, pager, next, jumper" :page-size="this.msg.pageSize" :total="total">
      </el-pagination>
    </div>
    <div class="_mc_edit _scrollbar" :class="addShow==true?'edHeightOne':''">
      <p class="_tit">{{$t('salesModule.addCustomer')}}
        <span class="fr">
          <button class="hollowFixedBtn" type="button" @click="cancelEdit()">{{$t('pub.cancelBtn')}}</button>
          <button type="button" class="normalBtn" v-if='allowAdd' @click="saveVisa()">{{$t('pub.saveBtn')}}</button>
        </span>
      </p>
      <el-form class="_info_box clearfix" :model="addMsg" :rules="rules" ref="addMsg" label-width="120px">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item :label="$t('restaurant.res_ContactNumber')" prop="contactNumber">
              <el-input :disabled="isOldPerson" v-model="addMsg.contactNumber"
                @input='searchHistory(addMsg.contactNumber)' :placeholder="$t('pub.pleaseImport')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('salesModule.storeName')" prop="customerName">
              <el-input :disabled="isOldPerson" v-model="addMsg.customerName" :placeholder="$t('pub.pleaseImport')"
                maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('hotel.suplier_contact')" prop="contact">
              <el-input :disabled="isOldPerson" v-model="addMsg.contact" :placeholder="$t('pub.pleaseImport')"
                maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item :label="$t('pub.area')">
              <el-select filterable v-model='addMsg.Province' @change='getCity'>
                <el-option v-for='item in provinceList' :label='item.Name' :value='item.ID' :key='item.ID'>
                </el-option>
              </el-select>
              <el-select filterable v-model='addMsg.City' @change='getRegion'>
                <el-option v-for='item in cityList' :label='item.Name' :value='item.ID' :key='item.ID'>
                </el-option>
              </el-select>
              <el-select filterable v-model='addMsg.District'>
                <el-option v-for='item in regionList' :label='item.Name' :value='item.ID' :key='item.ID'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('hotel.hotel_detailinfo')" prop="address">
              <el-input v-model="addMsg.address" :placeholder="$t('salesModule.HouseNumber')" maxlength="50"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item :label="$t('salesModule.Belongbrand')" prop="brandIds">
              <el-select filterable class='multiple_input' multiple v-model='addMsg.brandIds'
                :placeholder="$t('pub.pleaseSel')">
                <el-option v-for='item in CustomerBrandList' :label='item.name' :value='item.id' :key='item.id'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('visaT.post')" prop="Duty">
              <el-select filterable v-model='addMsg.Duty' :placeholder="$t('pub.pleaseSel')">
                <el-option v-for='item in zw' :label='item.Name' :value='item.ID' :key='item.ID'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('salesModule.premises')" prop="Premises">
              <el-select filterable v-model='addMsg.Premises' :placeholder="$t('pub.pleaseSel')">
                <el-option v-for='item in jycs' :label='item.Name' :value='item.ID' :key='item.ID'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('salesModule.CustomerSource')" prop="CustomerSourceType">
              <el-select filterable v-model='addMsg.CustomerSourceType' :placeholder="$t('pub.pleaseSel')">
                <el-option v-for='item in khly' :label='item.Name' :value='item.ID' :key='item.ID'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="18">
            <el-form-item :label="$t('hotel.hotel_remark')" prop="remark">
              <el-input v-model="addMsg.remark" type="textarea" maxlength="500"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('salesModule.CustomerInfo')" prop="remark" v-show='addMsg.CustomerSourceType==6'>
              <el-input v-model="addMsg.CustomerSource" maxlength="20"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item :label="$t('salesModule.BusinessPhoto')">
              <el-upload class="avatar-uploader" action="" :http-request="uploadImg"
                accept="image/jpeg,image/gif,image/png,image/bmp" :show-file-list="false">
                <img v-if="BusinessCardPhotos" :src="BusinessCardPhotos" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('salesModule.doorPhoto')">
              <el-upload class="avatar-uploader" action="" :http-request="uploadImg1"
                accept="image/jpeg,image/gif,image/png,image/bmp" :show-file-list="false">
                <img v-if="HousePhotos" :src="HousePhotos" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('salesModule.businessPhoto')">
              <el-upload class="avatar-uploader" action="" :http-request="uploadImg2"
                accept="image/jpeg,image/gif,image/png,image/bmp" :show-file-list="false">
                <img v-if="Images" :src="Images" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="6">
          </el-col>
        </el-row>
      </el-form>
    </div>

    <el-dialog custom-class="w700" title="模板导入" :visible.sync="outerVisible" center>
      <el-upload ref="ticketUpload" drag class="upload-demo" :action="getImportFileUrl()"
        :on-success="handleAvatarSuccess">
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处,或
          <em>点击上传</em>
        </div>
        <div slot="tip" class="el-upload__tip">只能上传Excel文件</div>
      </el-upload>
    </el-dialog>
    <div class="MyCustomerDetailbottomLayer ownScrollbarStyle" style="height:500px;" v-show="addLayer1">
      <p>修改客户信息</p>
      <p class="fz12 color333 fbold" style="border: none; padding-left: 3px;">可直接保存</p>
      <el-form label-width="80px">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="门店名称:">
              <el-input class='w200' v-model='updateMsg.CustomerName'></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="联系人姓名">
              <el-input class='w200' v-model='updateMsg.Contact'></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="updateMsg.customerExceptionList.length > 0">
            <el-form-item label="解决异常">
              <el-select class='w200' filterable multiple clearable collapse-tags
                v-model='updateMsg.CustomerExceptionIds'>
                <el-option v-for='item in updateMsg.customerExceptionList' :label='item.exceptionName'
                  :value='item.exceptionId' :key='item.exceptionId'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
          </el-col>
        </el-row>
        <el-row :gutter="20" style='margin-top:13px;'>
          <el-col :span="24">
            <p class="fz12 color333 fbold" style="border: none; margin-bottom: 15px; padding-left: 20px;">需审核信息<span
                class="colorE95252 fz12 fwnormal">
                (编辑门店地址后,客户将重新进入审核流程)
              </span>
            </p>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="区域:">
              <el-select class='w200' filterable v-model='updateMsg.Province' @change='getCityNew'>
                <el-option v-for='item in provinceList' :label='item.Name' :value='item.ID' :key='item.ID'>
                </el-option>
              </el-select>
              <el-select class='w200' filterable v-model='updateMsg.City' @change='getRegionNew'>
                <el-option v-for='item in cityList' :label='item.Name' :value='item.ID' :key='item.ID'>
                </el-option>
              </el-select>
              <el-select class='w200' filterable v-model='updateMsg.District'>
                <el-option v-for='item in regionList' :label='item.Name' :value='item.ID' :key='item.ID'>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="详细地址:">
              <el-input v-model='updateMsg.Address'></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="名片照片:">
              <el-upload class="avatar-uploader" action="" :http-request="uploadImgNew"
                accept="image/jpeg,image/gif,image/png,image/bmp" :show-file-list="false">
                <img v-if="BusinessCardPhotosNew" :src="BusinessCardPhotosNew" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="门牌照片:">
              <el-upload class="avatar-uploader" action="" :http-request="uploadImg1New"
                accept="image/jpeg,image/gif,image/png,image/bmp" :show-file-list="false">
                <img v-if="HousePhotosNew" :src="HousePhotosNew" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="营业执照:">
              <el-upload class="avatar-uploader" action="" :http-request="uploadImg2New"
                accept="image/jpeg,image/gif,image/png,image/bmp" :show-file-list="false">
                <img v-if="ImagesNew" :src="ImagesNew" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <input type="button" class="normalBtn" value="保存" @click="saveUpdate()" />
            <input type="button" class="hollowFixedBtn" value="取消" @click="addLayer1=false" />
          </el-col>
        </el-row>
      </el-form>
    </div>

  </div>
</template>
<script>
  export default {
    data() {
      return {
        addLayer1: false,
        allowAdd: true,
        defaultImg: 'this.src="' + require("../../assets/img/litheader.png") + '"',
        BusinessCardPhotos: '',
        HousePhotos: '',
        Images: '',
        isOldPerson: false,
        type: 2,
        msg: {
          pageIndex: 1,
          pageSize: 12,
          CustomerStatus: 2,
          CustomerName: '',
          Address: '',
          Country: '-1',
          Province: '-1',
          City: '-1',
          District: '-1',
        },
        addMsg: {
          CustomerId: 0,
          customerName: '',
          contact: '',
          contactNumber: '',
          address: '',
          brandIds: [],
          remark: '',
          Duty: '',
          Premises: '',
          CustomerId: '0',
          BusinessCardPhotos: [],
          HousePhotos: [],
          Images: [],
          CustomerSourceType: '',
          CustomerSource: '',
          Country: '2',
          Province: '',
          City: '',
          District: '',
        },
        addMsgS: {
          isPreFilled: true,
          customerInfo: {},
          customerVisit: {
            remark: '',
            expectVisitDateTime: '',
            expectHour: 0
          }
        },
        rules: {
          contact: [{
            required: true,
            message: this.$t('rule.EnterContratPerson'),
            trigger: "blur"
          }],
          customerName: [{
            required: true,
            message: this.$t('rule.EnterCustomer'),
            trigger: "blur"
          }],
          contactNumber: [{
            required: true,
            message: this.$t('rule.EnterPNum'),
            trigger: "blur"
          }],
          brandIds: [{
            required: true,
            message: this.$t('rule.ChoiceBrand'),
            trigger: "change"
          }],
          Duty: [{
            required: true,
            message: this.$t('rule.ChoiceJob'),
            trigger: "change"
          }],
          remark: [{
            required: false,
            message: this.$t('rule.ChoiceJob'),
            trigger: "change"
          }],
          Premises: [{
            required: true,
            message: this.$t('rule.ChoiceJYCS'),
            trigger: "change"
          }],
          CustomerSourceType: [{
            required: true,
            message: this.$t('rule.ChoiceCusFrom'),
            trigger: "change"
          }],
          customerName: [{
            required: true,
            message: this.$t('rule.EnterCusName'),
            trigger: "blur"
          }],
          address: [{
            required: true,
            message: this.$t('visaT.qsradder'),
            trigger: "blur"
          }],
        },
        dataList: [],
        CustomerBrandList: [],
        checkedCities: [],
        checkAll: false,
        addShow: false,
        noData: false,
        loading: true,
        isIndeterminate: true,
        total: 0,
        currentPage: 1,
        provinceList: [],
        cityList: [],
        regionList: [],
        jycs: [], //经营场所
        zw: [], //职务
        khly: [], //客户来源
        outerVisible: false,
        updateMsg: {
          CustomerName: '',
          CustomerId: 0,
          Address: '',
          Country: 2,
          Province: 0,
          Contact: '',
          City: 0,
          District: 0,
          HousePhotos: [],
          BusinessCardPhotos: [],
          Images: [],
          customerExceptionList: [],
          CustomerExceptionIds: [],
        },
        cityList: [],
        regionList: [],
        id: '',
        ImagesNew: '',
        BusinessCardPhotosNew: '',
        HousePhotosNew: '',
        CustomerException: [],
        JYExceptionList: [],
      }
    },
    methods: {
      yichangde(obj) {
        this.apipost("app_get_GetCustomerException", {
          customerId: obj.customerId
        }, res => {
          if (res.data.resultCode == 1) {
            this.CustomerException = res.data.data
          }
        })
      },
      EditMsg(item) {
        this.addLayer1 = true;
        this.id = item.customerId;
        this.getMyCustomerInfo();
      },
      saveUpdate() {
        if (this.updateMsg.District == '') {
          this.updateMsg.District = 0
        }
        if (this.BusinessCardPhotos) {
          this.updateMsg.BusinessCardPhotos = []
          this.updateMsg.BusinessCardPhotos.push(this.BusinessCardPhotos)
        }
        if (this.HousePhotos) {
          this.updateMsg.HousePhotos = []
          this.updateMsg.HousePhotos.push(this.HousePhotos)
        }
        if (this.Images) {
          this.updateMsg.Images = []
          this.updateMsg.Images.push(this.Images)
        }
        let sheng = ''
        let shi = ''
        let qu = ''
        if (this.updateMsg.District == '') {
          this.updateMsg.District = 0
        }
        if (this.updateMsg.City == '') {
          this.updateMsg.City = 0
        }
        this.provinceList.forEach(item => {
          if (this.updateMsg.Province == item.ID) {
            sheng = item.Name
          }
        })
        this.cityList.forEach(item => {
          if (this.updateMsg.City == item.ID) {
            shi = item.Name
          }
        })
        this.regionList.forEach(item => {
          if (this.updateMsg.District == item.ID) {
            qu = item.Name
          }
        })
        let AreaName = sheng + shi + qu
        this.updateMsg.Address = AreaName + ',' + this.updateMsg.Address
        this.apipost('app_customer_UpdateCustomerAddress', this.updateMsg, res => {
          if (res.data.resultCode == 1) {
            this.addLayer1 = false;
            this.$message.success(res.data.message)
            this.getList()
            this.addLayer1 = false
          } else {
            this.$message.error(res.data.message)
          }
        }, err => {})
      },
      uploadImgNew(file) {
        //上传
        let newArr = [];
        newArr.push(file.file);
        let path = "/Upload/Temporary/";
        this.UploadSelfFileT(path, newArr, x => {
          this.BusinessCardPhotosNew = this.domainManager().ViittoFileUrl + x.data.FilePath
        });
      },
      uploadImg1New(file) {
        //上传
        let newArr = [];
        newArr.push(file.file);
        let path = "/Upload/Temporary/";
        this.UploadSelfFileT(path, newArr, x => {
          this.HousePhotosNew = this.domainManager().ViittoFileUrl + x.data.FilePath
        });
      },
      uploadImg2New(file) {
        //上传
        let newArr = [];
        newArr.push(file.file);
        let path = "/Upload/Temporary/";
        this.UploadSelfFileT(path, newArr, x => {
          this.ImagesNew = this.domainManager().ViittoFileUrl + x.data.FilePath
        });
      },
      getMyCustomerInfo() {
        this.apipost('app_GetMyCustomerInfo', {
          customerId: this.id
        }, res => {
          if (res.data.resultCode == 1) {
            let x = res.data.data;
            // this.customerInfo=res.data.data
            // if(this.customerInfo.address.indexOf(',')!=-1){
            // 	this.customerInfo.address=this.customerInfo.address.split(',')[1]
            // }else{
            // 	this.customerInfo.address=this.customerInfo.address
            // }
            // this.contact=res.data.data.contact
            this.updateMsg.CustomerName = x.customerName
            this.updateMsg.Contact = x.contactName
            this.updateMsg.CustomerId = x.customerId
            this.updateMsg.Address = x.address.split(',')[1]
            this.updateMsg.Province = x.province
            this.getCityNew()
            this.updateMsg.City = x.city
            this.getRegionNew()
            this.updateMsg.customerExceptionList = x.customerExceptionList
            this.updateMsg.CustomerExceptionIds = []
            this.updateMsg.District = x.district
            if (x.businessCardPhotos && x.businessCardPhotos.length > 0) {
              this.BusinessCardPhotos = x.businessCardPhotos[0]
            }
            if (x.images && x.images.length > 0) {
              this.Images = x.images[0]
            }
            if (x.housePhotos && x.housePhotos.length > 0) {
              this.HousePhotos = x.housePhotos[0]
            }
          } else {}
        }, err => {})
      },
      getCityNew() {
        this.apipost('app_customer_GetChildList', {
          Id: this.updateMsg.Province,
          "level": 2
        }, res => {
          if (res.data.resultCode == 1) {
            this.cityList = res.data.data;
            // this.regionList=[]
            // this.updateMsg.City=''
            // this.updateMsg.District=''
          }
        }, err => {})
      },
      getRegionNew() {
        this.apipost('app_customer_GetChildList', {
          Id: this.updateMsg.City,
          "level": 3
        }, res => {
          if (res.data.resultCode == 1) {
            this.regionList = res.data.data
            // this.updateMsg.District=''
          }
        }, err => {})
      },
      //导入
      getImportFileUrl() {
        let url =
          this.domainManager().UploadFileUrl +
          "?cmd=dmc_post_LocalFileUpload&fileType=1&fileLimit=1&Type=9&EmployeeId=" +
          this.getLocalStorage().EmployeeId +
          "&importType=" +
          this.importType;
        return url;
      },
      //上传文件后清空文件队列
      handleAvatarSuccess(res, file) {
        this.$refs.ticketUpload.clearFiles();
        if (res.resultCode == 1) {
          this.Success(res.message);
          this.outerVisible = false;
        }
      },
      //下载模板文件
      getDownList() {
        this.apipost(
          "app_customer_GetCustomerTemplate", {},
          res => {
            if (res.data.resultCode == 1) {
              this.downList =
                this.domainManager().LocalTemplateFileDownLoadUrl +
                res.data.data.FileUrl;
              window.open(this.downList);
            } else {
              this.Error(res.data.message);
            }
          },
          err => {}
        );
      },
      deleteCustomer(obj) {
        this.$confirm(this.$t('tips.shifoushanchu'), this.$t('tips.tips'), {
          confirmButtonText: this.$t('pub.sureBtn'),
          cancelButtonText: this.$t('pub.cancelBtn'),
          type: 'warning'
        }).then(() => {
          this.apipost('app_customer_Remove', {
            ID: obj.customerId
          }, res => {
            if (res.data.resultCode == 1) {
              this.Success(res.data.message);
              this.getList()
            }
          }, err => {})
        }).catch(() => {
          this.Error('已取消删除!');
        });
      },
      uploadImg(file) {
        //上传
        let newArr = [];
        newArr.push(file.file);
        let path = "/Upload/Temporary/";
        this.UploadSelfFileT(path, newArr, x => {
          this.BusinessCardPhotos = this.domainManager().ViittoFileUrl + x.data.FilePath
        });
      },
      uploadImg1(file) {
        //上传
        let newArr = [];
        newArr.push(file.file);
        let path = "/Upload/Temporary/";
        this.UploadSelfFileT(path, newArr, x => {
          this.HousePhotos = this.domainManager().ViittoFileUrl + x.data.FilePath
        });
      },
      uploadImg2(file) {
        //上传
        let newArr = [];
        newArr.push(file.file);
        let path = "/Upload/Temporary/";
        this.UploadSelfFileT(path, newArr, x => {
          this.Images = this.domainManager().ViittoFileUrl + x.data.FilePath
        });
      },
      searchHistory(val) {
        if (val.length == 11) {
          this.apipost('app_customer_GetCustomerByContactNumber', {
            ContactNumber: val
          }, res => {
            if (res.data.resultCode == 1) {
              if (res.data.data.customerInfo.customerId > 0) {

                this.isOldPerson = true
                let x = res.data.data.customerInfo
                this.addMsg = x
                this.addMsg.Province = x.province
                this.addMsg.customerId = x.customerId
                this.getCity1()
                this.addMsg.City = x.city
                this.getRegion1()
                this.addMsg.District = x.district
                this.addMsg.Duty = x.duty
                this.addMsg.Premises = x.premises
                this.addMsg.CustomerSourceType = x.customerSourceType
                let dictid = []
                res.data.data.brandList.forEach(x => {
                  dictid.push(x.dictId)
                })
                this.addMsg.brandIds = dictid

                if (x.businessCardPhotos && x.businessCardPhotos.length > 0) {
                  this.BusinessCardPhotos = x.businessCardPhotos[0]
                }
                if (x.images && x.images.length > 0) {
                  this.Images = x.images[0]
                }
                if (x.housePhotos && x.housePhotos.length > 0) {
                  this.HousePhotos = x.housePhotos[0]
                }
              }
              this.allowAdd = true
            } else {
              if (res.data.message.indexOf('已注册客户信息') != -1) {
                this.allowAdd = false
              }
              this.$message.error(res.data.message)

            }
          }, err => {})
        } else {}
      },
      getJycs() {
        this.apipost('app_today_visit_GetCustomerPremisesEnum', {}, res => {
          if (res.data.resultCode == 1) {
            this.jycs = res.data.data
          }
        }, err => {})
      },
      getZw() {
        this.apipost('app_today_visit_GetCustomerDutyEnum', {}, res => {
          if (res.data.resultCode == 1) {
            this.zw = res.data.data
          }
        }, err => {})
      },
      getKhly() {
        this.apipost('app_customer_GetCustomerSourceEnum', {}, res => {
          if (res.data.resultCode == 1) {
            this.khly = res.data.data
          }
        }, err => {})
      },
      getProvince() {
        this.apipost('app_customer_GetChildList', {
          Id: 2,
          "level": 1
        }, res => {
          if (res.data.resultCode == 1) {
            this.provinceList = res.data.data
          }
        }, err => {})
      },
      getCity() {
        this.apipost('app_customer_GetChildList', {
          Id: this.addMsg.Province,
          "level": 2
        }, res => {
          if (res.data.resultCode == 1) {
            this.cityList = res.data.data
            this.regionList = []
            this.addMsg.City = ''
            this.addMsg.District = ''
          }
        }, err => {})
      },
      getRegion() {
        this.apipost('app_customer_GetChildList', {
          Id: this.addMsg.City,
          "level": 3
        }, res => {
          if (res.data.resultCode == 1) {
            this.regionList = res.data.data
            this.addMsg.District = ''
          }
        }, err => {})
      },
      getCity1() {
        this.apipost('app_customer_GetChildList', {
          Id: this.addMsg.Province,
          "level": 2
        }, res => {
          if (res.data.resultCode == 1) {
            this.cityList = res.data.data
          }
        }, err => {})
      },
      getRegion1() {
        this.apipost('app_customer_GetChildList', {
          Id: this.addMsg.City,
          "level": 3
        }, res => {
          if (res.data.resultCode == 1) {
            this.regionList = res.data.data
          }
        }, err => {})
      },
      goUrl(type, id, num) {
        this.$router.push({
          name: 'MyCustomerDetail',
          query: {
            "id": id,
            "num": num
          }
        })
      },
      goUrC(path, customerId) {
        this.$router.push({
          name: path,
          query: {
            "customerId": customerId,
            blank: 'y'
          }
        })

      },
      goUrlT(path, id) {
        this.$router.push({
          name: path,
          query: {
            "id": id,
            "type": 8,
            blank: 'y'
          }
        })
      },
      clickGetList(type) {
        this.msg.pageIndex = 1
        this.currentPage = 1
        this.msg.CustomerStatus = type
        this.getList()
      },
      getList() { // 获取列表数据
        this.apipost('app_get_my_customer_list', this.msg, res => {
          if (res.data.resultCode == 0) {
            this.loading = false;
            this.dataList = []
          } else {
            this.dataList = res.data.data.pageData;
            this.total = res.data.data.count;
            this.loading = false;
          }
        }, err => {})
      },
      getCustomerBrandList() { // 获取品牌
        this.apipost('app_get_customer_brand', {}, res => {
          if (res.data.resultCode == 1) {
            this.CustomerBrandList = res.data.data;
          } else {
            this.$message.error(res.data.message)
          }
        }, err => {})
      },
      saveVisa() { // 保存
        if (this.addMsg.District == '') {
          this.addMsg.District = 0
        }
        this.addMsgS.customerInfo = this.addMsg
        if (this.BusinessCardPhotos) {
          this.addMsg.BusinessCardPhotos = []
          this.addMsg.BusinessCardPhotos.push(this.BusinessCardPhotos)
        }
        if (this.HousePhotos) {
          this.addMsg.HousePhotos = []
          this.addMsg.HousePhotos.push(this.HousePhotos)
        }
        if (this.Images) {
          this.addMsg.Images = []
          this.addMsg.Images.push(this.Images)
        }
        let sheng = ''
        let shi = ''
        let qu = ''
        if (this.addMsg.District == '') {
          this.addMsg.District = 0
        }
        if (this.addMsg.City == '') {
          this.addMsg.City = 0
        }
        this.provinceList.forEach(item => {
          if (this.addMsg.Province == item.ID) {
            sheng = item.Name
          }
        })
        this.cityList.forEach(item => {
          if (this.addMsg.City == item.ID) {
            shi = item.Name
          }
        })
        this.regionList.forEach(item => {
          if (this.addMsg.District == item.ID) {
            qu = item.Name
          }
        })
        let AreaName = sheng + shi + qu
        this.addMsg.address = AreaName + ',' + this.addMsg.address
        this.apipost('app_add_new_visit_customer', this.addMsgS, res => {
          if (res.data.resultCode == 1) {
            this.addMsg = {
              customerName: '',
              contact: '',
              contactNumber: '',
              address: '',
              brandIds: [],
              remark: '',
              Duty: '',
              Premises: '',
              CustomerId: '0',
              BusinessCardPhotos: [],
              HousePhotos: [],
              Images: [],
              CustomerSourceType: '',
              CustomerSource: '',
              Country: '2',
              Province: '',
              City: '',
              District: '',
            }
            this.addMsgS.customerVisit.expectVisitDateTime = ''
            this.$message.success(res.data.message)
            this.addShow = false
            this.getList()
          } else {
            this.$message.error(res.data.message)
          }
        }, err => {})
      },
      cancelEdit() { // 取消新增
        this.addShow = false
        this.addMsg = {
          customerName: '',
          contact: '',
          contactNumber: '',
          address: '',
          remark: '',
          brandIds: [],
        }
        this.BusinessCardPhotos = '',
          this.HousePhotos = '',
          this.Images = '',
          this.addMsgS.customerVisit.expectVisitDateTime = ''
        this.resetForm('addMsg')
      },
      resetForm(formName) { // 重置表单
        this.$refs[formName].resetFields();
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
    },
    mounted() {
      this.getList()
      this.getCustomerBrandList()
      this.getProvince()
      this.getJycs()
      this.getZw()
      this.getKhly()
    }
  }

</script>