<style>
  .addMsgSW{
    width: 105px;
  }
  .updateMsgSw{
    width: 169px;
  }
  ._info_img ul {
    /* padding: 10px 0 */
  }

  ._info_img ul li {
    height: 52px;
    float: left;
    position: relative;
    cursor: pointer
  }

  ._info_img ul li:hover ._see_img {
    opacity: 1;
  }

  ._info_img ul li img {
    width: 50px;
    height: 50px;
  }

  ._see_img {
    position: absolute;
    top: 0;
    width: 100%;
    height: 50px;
    line-height: 34px;
    text-align: center;
    background-color: rgba(2, 2, 2, 0.3);
    display: inherit;
    opacity: 0;
    transition: all linear .5s
  }

  ._see_img i.iconfont {
    display: inline-block;
    width: 32px;
    height: 32px;
    margin-top: 8px;
    border-radius: 50%;
    color: #FFFFFF !important;
    background-color: rgba(255, 255, 255, 0.5);
  }

  ._show_img_box {
    position: fixed;
    background: rgba(0, 0, 0, .6);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    text-align: center;
    overflow: auto;
  }
  .page_MyCustomer .icon-guanbi1{
    width: 18px;height: 18px;
    line-height: 20px;
    text-align: center;
    color: #fff;position: absolute;
    right: -5px;top: -10px;
    background: #dedede;border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    z-index: 3;
  }
  .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="reSearchPage"
            :placeholder="$t('salesModule.enterPhone')"></el-input>
        </span>
      </li>
      <li>
        <button class="hollowFixedBtn" @click="reSearchPage">{{$t('pub.searchBtn')}}</button>
        <button class="normalBtn"
          @click="clickAdd">{{$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:msg.CustomerStatus==2}" @click="clickGetList(2)">
        {{$t('salesModule.InformalClient')}}
        <div class="divActive" v-show="msg.CustomerStatus==2"></div>
      </li>
      <li :class="{active:msg.CustomerStatus==1}" @click="clickGetList(1)">
        {{$t('salesModule.notInformalClient')}}
        <div class="divActive" v-show="msg.CustomerStatus==1"></div>
      </li>
      <li :class="{active:msg.CustomerStatus==3}" @click="clickGetList(3)">
        {{$t('salesModule.UnapprovedClient')}}
        <div class="divActive" v-show="msg.CustomerStatus==3"></div>
      </li>
      <li :class="{active:msg.CustomerStatus==4}" @click="clickGetList(4)">
        {{$t('salesModule.BlackListCustomers')}}
        <div class="divActive" v-show="msg.CustomerStatus==4"></div>
      </li>
      <li :class="{active:msg.CustomerStatus==0}" @click="clickGetList(0)">
        签约结算客户
        <div class="divActive" v-show="msg.CustomerStatus==0"></div>
      </li>
    </div>
    <div class="_mc_list _scrollbar" :class="addShow==true?'_edHeight':''">
      <table v-if="msg.CustomerStatus!=0" 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>
          <th width="200px">操作</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}}
            <span v-if="item.departmentManagerStr&&msg.CustomerStatus==1" style="color: red;margin-left: 10px;">
              待{{item.departmentManagerStr}}审核
            </span>
          </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>
            <span style="cursor: pointer;color: #2CA4F0" @click="seeDeta(item)">{{ item.depositMoney?item.depositMoney:0 }}</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>
            <el-tooltip class="item" effect="dark" content="团队成员" placement="top-start">
              <el-button style="padding:4px" @click.stop="goTeamMember(item)" type="primary"
                icon="el-icon-user-solid" circle></el-button>
            </el-tooltip>
          </td>
        </tr>
        <tr v-if="dataList.length==0">
          <td colspan="13" style="text-align:center">暂无数据</td>
        </tr>
      </table>
      <!-- 产品列表 -->
    <signedClientList v-else :loading="loading" :list="dataList" :isVisa="isVisa" @success="reSearchPage" :pagesTitle="pagesTitle"></signedClientList>
      <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':''">
      <div style="height: 30px;">
        <p class="_tit">{{$t('salesModule.addCustomer')}}
          <span class="fr">
            <button class="hollowFixedBtn" type="button" @click="cancelEdit()">{{$t('pub.cancelBtn')}}</button>
            <el-button type="button" class="normalBtn" v-if='allowAdd' @click="saveVisa()"
            :loading="loadingSave">{{$t('pub.saveBtn')}}</el-button>
          </span>
        </p>
      </div>
      <el-form class="_info_box clearfix" :model="addMsg" :rules="rules" ref="addMsg" label-width="120px">
        <el-row :gutter="20">
          <el-col :span="4">
            <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="4">
            <!-- :label="$t('salesModule.storeName')" -->
            <el-form-item label="客户名称" 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="4">
            <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-form-item :label="$t('pub.area')">
              <el-select class="addMsgSW" 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 class="addMsgSW" 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 class="addMsgSW" 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-col :span="6">
            <el-form-item label="統一编号" prop="UniqueCode">
              <el-input v-model="addMsg.UniqueCode" placeholder="请输入統一编号" maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="LINE ID" prop="LINEID">
              <el-input v-model="addMsg.LINEID" placeholder="请输入LINE ID" maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="Email" prop="Email">
              <el-input v-model="addMsg.Email" placeholder="请输入Email" style="width: 240px;"></el-input>

            </el-form-item>
          </el-col> -->
          <el-col :span="8">
            <el-form-item label="合同资料">
              <div style="display: flex;flex-wrap: wrap;">
              <div class="_info_img" v-if="addMsg.BusinessCardPhotos&&addMsg.BusinessCardPhotos.length>0">
                <ul class="clearfix">
                <li v-for="(img,imgI) in addMsg.BusinessCardPhotos" style="margin-right: 5px;position: relative;border:1px dashed #d1d1d1;border-radius: 6px;">
                  <img v-if="!img" src="../../assets/img/Travelslider.png" alt="">
                  <el-image
                    v-if="img&&verificationFile(img,3)"
                    :src="img"
                    :preview-src-list="[img]">
                  </el-image>
                  <div v-if="img&&verificationFile(img,1)"
                    style="width: 50px; line-height: 50px;text-align: center;">
                    <span class="_wenjian_P iconfont"
                      :class="img.substring(img.lastIndexOf('.')+1,img.length).toUpperCase()=='PDF'? 'icon-pdf' : 'icon-excel'"></span>
                  </div>
                  <span class="iconfont icon-guanbi1"
                    @click="deleteUploadFile(imgI)"></span>
                  <div v-if="img&&verificationFile(img,1)" class="_see_img" @click="verificationFile(img,3)?'':showUpLoadFile2(img)">
                    <i class="iconfont icon-sousuo"></i>
                  </div>
                </li>
                </ul>
              </div>
              <div style="display: flex; justify-content: end;">
                <el-upload class="upload-demo"
                ref="my-upload"
                  style="display:inline-block;position:relative;top:-1px;left:3px;"
                  :http-request="uploadImg"
                  :show-file-list="false" action="">
                  <el-button size="small" type="primary">上传合同</el-button>
              </el-upload>
              </div>
            </div>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="平台用户名">
              <div style="display: flex;flex-wrap: nowrap;justify-content: space-between;">
                <div style="display: flex; flex-wrap: wrap;align-items: center;">
                  <el-tag
              :key="tag"
              v-for="tag in addMsg.PlatformUserNameList"
              closable
              :disable-transitions="false"
              @close="handleClose(tag,1)"
              size="medium"
              style="margin-right: 5px;margin-bottom: 3px;">
              {{tag}}
            </el-tag>
            <div>
              <el-input
              class="input-new-tag"
              v-if="inputVisible"
              v-model="inputValue"
              ref="saveTagInputTwo"
              size="small"
              @keyup.enter.native="handleInputConfirm(1)"
              @blur="handleInputConfirm(1)"
            >
            </el-input>
                  <el-button v-else class="button-new-tag" size="small" @click="showInput(1)">+ 添加</el-button>
            </div>
                </div>
              </div>

            </el-form-item>

          </el-col>
          <el-col :span="4">
            <el-form-item label="签约结算客户" prop="SigningType">
              <div style="display: flex;flex-wrap: nowrap;">
                <div>
                  <el-checkbox v-model='addMsg.SigningType'>
                  </el-checkbox>
                </div>
                <div v-if="addMsg.SigningType">
                  <el-upload v-if="!saveMsg || !saveMsg.length" class="upload-demo" :disabled="!addMsg.SigningType"
                    style="display:inline-block;position:relative;top:-1px;left:3px;" :http-request="uploadFileBtn"
                    :show-file-list="false" action="">
                    <el-button size="small" type="primary">上传签约资料</el-button>
                  </el-upload>
                  <div v-if="addMsg.SigningType && saveMsg&& saveMsg.length>0">
                    <template v-for="(subItem,subIndex) in saveMsg">
                      <a style="margin-left:20px;color:blue;cursor:pointer;" target="_blank" :key="subIndex"
                        @click="downloadFile(subItem.URL,subItem.FileName)">{{subItem.FileName}}</a>

                      <a :key="subIndex+1000" style="margin-left:20px;color:blue;cursor:pointer;"
                        @click="DeleteFile(subIndex)">删除</a>
                    </template>
                  </div>
                  <span style="color: red;margin-left: 5px;">(此处为客户与我司月度结款)</span>
                </div>
              </div>

            </el-form-item>
          </el-col>
          <template v-if="isShow">
            <el-col :span="6">
              <el-form-item :label="$t('salesModule.CustomerSource')" prop="CustomerSourceType">
                <el-select filterable v-model='addMsg.CustomerSourceType' style="width: 100%;" :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-col :span="4">
              <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="4">
              <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="4">
              <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('hotel.hotel_remark')" prop="remark">
                <el-input v-model="addMsg.remark" autosize 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-col :span="4">
              <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="4">
              <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>
        </template>
        </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-if="addLayer1">
      <p>修改客户信息</p>
      <el-row :gutter="20">
        <el-col :span="18">
          <p class="fz12 color333 fbold" style="border: none; padding-left: 3px;">可直接保存</p>
        </el-col>
        <el-col :span="6" style="text-align: right;">
          <input type="button" class="hollowFixedBtn" value="取消" @click="addLayer1=false" />
          <input type="button" class="normalBtn" value="保存" @click="saveUpdate()" />
        </el-col>
      </el-row>
      <el-form label-width="80px" >

        <el-row :gutter="20">
          <el-col :span="4">
            <el-form-item label="联系电话">
              <el-input v-model="updateMsg.contactNumber" @input='searchHistory(updateMsg.contactNumber)'
                placeholder="请输入联系电话"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="门店名称">
              <el-input v-model='updateMsg.CustomerName'></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="联系人姓名">
              <el-input v-model='updateMsg.Contact'></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" v-if="updateMsg.customerExceptionList.length > 0">
            <el-form-item label="解决异常">
              <el-select 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="4">
            <el-form-item label="统一编码">
              <el-input class='w200' v-model='updateMsg.uniqueCode'></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="LINE ID">
              <el-input class='w200' v-model='updateMsg.lineid'></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="Email">
              <el-input class='w200' v-model='updateMsg.email'></el-input>
            </el-form-item>
          </el-col> -->

          <el-col :span="12">
            <el-form-item label="签约" prop="SigningType">
              <div style="display: flex;flex-wrap: nowrap;">
                <div>
                  <el-checkbox v-model='updateMsg.SigningType'>签约结算客户
                  </el-checkbox>
                </div>
                <div v-show="updateMsg.SigningType">
                  <el-upload v-if="!saveMsg || !saveMsg.length" class="upload-demo" :disabled="!updateMsg.SigningType"
                style="display:inline-block;position:relative;top:-1px;left:3px;" :http-request="uploadFileBtn"
                :show-file-list="false" action="">
                <el-button size="small" type="primary">上传签约资料</el-button>
              </el-upload>
              <template v-if="updateMsg.SigningType && saveMsg&& saveMsg.length>0">
                <div v-for="(subItem,subIndex) in saveMsg" style="display: flex;flex-wrap: nowrap;">
                  <a style="margin-left:20px;color:blue;cursor:pointer;" target="_blank" :key="subIndex"
                    @click="downloadFile(subItem.URL,subItem.FileName)">{{subItem.FileName}}</a>

                  <a :key="subIndex+1000" style="margin-left:20px;color:blue;cursor:pointer;"
                    @click="DeleteFile(subIndex)">删除</a>
                </div>
              </template>
              <span style="color: red;margin-left: 5px;">(此处为客户与我司月度结款)</span>
                </div>
              </div>

            </el-form-item>
          </el-col>
          <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-col :span="8">
            <el-form-item label="区域">
              <el-select class="updateMsgSw" 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="updateMsgSw" 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="updateMsgSw" 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="8">
            <el-form-item label="详细地址">
              <el-input v-model='updateMsg.Address'  maxlength="50"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="合同资料">
              <div style="display: flex;flex-wrap: wrap;">
                <div class="_info_img" v-if="updateMsg.BusinessCardPhotos&&updateMsg.BusinessCardPhotos.length>0">
                  <ul class="clearfix">
                  <li v-for="(img,imgI) in updateMsg.BusinessCardPhotos"
                  style="margin-right: 5px;position: relative;border:1px dashed #d1d1d1;border-radius: 6px;">
                    <img v-if="!img" src="../../assets/img/Travelslider.png" alt="">
                    <el-image
                    v-if="img&&verificationFile(img,3)"
                    :src="img"
                    :preview-src-list="[img]">
                  </el-image>
                    <div v-if="img&&verificationFile(img,1)"
                      style="width: 50px; line-height: 50px;text-align: center;">
                      <span class="_wenjian_P iconfont"
                        :class="img.substring(img.lastIndexOf('.')+1,img.length).toUpperCase()=='PDF'? 'icon-pdf' : 'icon-excel'"></span>
                    </div>
                    <span class="iconfont icon-guanbi1"
                    @click="deleteUploadFile(imgI)"></span>
                    <div v-if="img&&verificationFile(img,1)" class="_see_img" @click="verificationFile(img,3)?'':showUpLoadFile2(img)">
                      <i class="iconfont icon-sousuo"></i>
                    </div>
                  </li>
                  </ul>
                </div>
                <div style="display: flex; justify-content: end;">
                  <el-upload class="upload-demo"
                  ref="my-upload"
                    style="display:inline-block;position:relative;top:-1px;left:3px;"
                    :http-request="uploadImg"
                    :show-file-list="false" action="">
                    <el-button size="small" type="primary">上传合同</el-button>
                </el-upload>
                </div>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="平台用户名">
              <el-tag
              :key="tag"
              v-for="tag in updateMsg.PlatformUserNameList"
              closable
              :disable-transitions="false"
              @close="handleClose(tag)"
              size="small"
              style="margin-right: 5px;margin-bottom: 3px;">
              {{tag}}
            </el-tag>
            <el-input
              class="input-new-tag"
              v-if="inputVisible"
              v-model="inputValue"
              ref="saveTagInput"
              size="small"
              @keyup.enter.native="handleInputConfirm"
              @blur="handleInputConfirm"
            >
            </el-input>
            <el-button v-else class="button-new-tag" size="small" @click="showInput">+ 添加</el-button>
            </el-form-item>

          </el-col>
          <el-col :span="4">
            <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="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="4">
            <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="Images" :src="Images" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <detailList v-if="showdetail" :ClientId="detailObj&&detailObj.customerId" @cancel="showdetail=false"></detailList>
    <!-- 团队成员 -->
    <TeamMemberList v-if="ShowTeamMember" :customerId="customerId"
    @close="ShowTeamMember=false,customerId=null"
    @success="getList"></TeamMemberList>
  </div>
</template>
<script>
  import detailList from "../FinancialModule/PrestorageManagement/components/detailList.vue";
  import signedClientList from './Common/signedClientList'
  import TeamMemberList from './Common/TeamMemberList'
  export default {
    components:{
      signedClientList,
      detailList,
      TeamMemberList
    },
    data() {
      return {
        loadingSave: false,
        customerId: null,
        ShowTeamMember: false,
        detailObj: null,
        showdetail: false,
        isVisa: false, // 是否是签证下面的菜单
        pagesTitle: '跟团游产品',
        saveMsg: [],
        headers: {
          'Content-Type': 'application/octet-stream'
        },
        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',
          SigningType: 0
        },
        addMsg: {
          CustomerId: 0,
          customerName: '',
          contact: '',
          contactNumber: '',
          address: '',
          brandIds: [],
          remark: '',
          Duty: '',
          Premises: '',
          CustomerId: '0',
          BusinessCardPhotos: [],
          HousePhotos: [],
          Images: [],
          CustomerSourceType: '',
          CustomerSource: '',
          Country: '2',
          Province: '',
          City: '',
          District: '',
          UniqueCode: '',
          LINEID: '',
          Email: '',
          PlatformUserNameList: []
        },
        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"
          }],
          UniqueCode: [{
            required: true,
            message: '请输入统一编码',
            trigger: "blur"
          }],
          LINEID: [{
            required: true,
            message: '请输入LINE ID',
            trigger: "blur"
          }],
          Email: [{
            required: true,
            message: '请输入Email',
            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: {
          SigningType: false,
          contactNumber: '',
          CustomerName: '',
          CustomerId: 0,
          Address: '',
          Country: 2,
          Province: 0,
          Contact: '',
          City: 0,
          District: 0,
          HousePhotos: [],
          BusinessCardPhotos: [],
          Images: [],
          customerExceptionList: [],
          CustomerExceptionIds: [],
          uniqueCode: '',
          lineid: '',
          email: '',
          PlatformUserNameList: []
        },
        cityList: [],
        regionList: [],
        id: '',
        ImagesNew: '',
        BusinessCardPhotosNew: '',
        HousePhotosNew: '',
        CustomerException: [],
        JYExceptionList: [],
        isShow: true,
        inputVisible: false,
        inputValue: '',
      }
    },
    methods: {
      showUpLoadFile2(i) { // 预览上传文件
        if (i.substring(i.lastIndexOf('.') + 1, i.length).toUpperCase() == 'PDF') {
          this.previewPDF(i)
        } else {
          window.open("https://view.officeapps.live.com/op/view.aspx?src=" + i)
        }
      },
      handleClose(tag,type) {
        if(type==1){
          this.addMsg.PlatformUserNameList.splice(this.addMsg.PlatformUserNameList.indexOf(tag), 1);
        }else{
          this.updateMsg.PlatformUserNameList.splice(this.updateMsg.PlatformUserNameList.indexOf(tag), 1);
        }
      },
      showInput(type) {
        this.inputVisible = true;
        this.$nextTick(_ => {
          if(type==1){
            this.$refs.saveTagInputTwo.$refs.input.focus();
          }else{
            this.$refs.saveTagInput.$refs.input.focus();
          }
        });
      },
      handleInputConfirm(type) {
        let inputValue = this.inputValue;
        if (inputValue) {
          if(type==1){
            this.addMsg.PlatformUserNameList.push(inputValue);
          }else{
            this.updateMsg.PlatformUserNameList.push(inputValue);
          }
        }
        this.inputVisible = false;
        this.inputValue = '';
      },
      goTeamMember(row){
        this.customerId = row.customerId
        this.ShowTeamMember = true
      },
      seeDeta(row){
        this.detailObj = row
        this.showdetail = true
      },
      reSearchPage(){
        this.msg.pageIndex = 1
        this.currentPage = 1
        this.getList()
      },
      clickAdd(){
        this.cancelData()
        this.inputValue = ''
        this.inputVisible = false
        this.addShow=true;
        this.isOldPerson=false,
        this.addLayer1=false
      },
      uploadFileBtn(file) { //上传
        if (file.file.size > 1024 * 1024 * 100) {
          this.$message.warning('文件大小不能超过100M！')
          return
        }
        let that = this
        let newArr = [];
        newArr.push(file.file)
        let path = "/Upload/Temporary/"
        this.$message.info('上传中...')
        this.UploadSelfFileT(path, newArr, x => {
          var newUrl = this.domainManager().ViittoFileUrl + x.data.FilePath
          let fileSize = file.file.size < 1024 ? file.file.size : (file.file.size / 1024).toFixed(0);
          this.saveMsg = []
          this.saveMsg.push({
            Path: x.data.FilePath,
            URL: newUrl,
            FileName: file.file.name,
            MD5Sign: file.file.uid,
            FileSize: fileSize,
            FolderId: this.msg.ParentId
          })
        });
      },
      //删除文件
      DeleteFile(subIndex) {
        this.saveMsg.splice(subIndex, 1);
      },
      //下载文件
      downloadFile(fileUrl, fileName) {
        const link = document.createElement('a');
        link.href = fileUrl;
        link.target = "_blank";
        link.download = fileName;
        document.body.appendChild(link);
        link.click();
      },
      yichangde(obj) {
        this.apipost("app_get_GetCustomerException", {
          customerId: obj.customerId
        }, res => {
          if (res.data.resultCode == 1) {
            this.CustomerException = res.data.data
          }
        })
      },
      EditMsg(item) {
        this.inputValue = ''
        this.inputVisible = false
        this.addLayer1 = true;
        this.id = item.customerId;
        this.getMyCustomerInfo();
      },
      saveUpdate() {
        // if(!this.updateMsg.contactNumber){
        //   this.$message.error('请输入联系电话')
        //   return
        // }
        if (!this.updateMsg.CustomerName) {
          this.$message.error('请输入客户名称')
          return
        }
        if (!this.updateMsg.Contact) {
          this.$message.error('请输入联系人')
          return
        }
        // if(!this.updateMsg.uniqueCode){
        //   this.$message.error('请输入统一编码')
        //   return
        // }
        // if(!this.updateMsg.lineid){
        //   this.$message.error('请输入LINE ID')
        //   return
        // }

        // if(this.updateMsg.email){
        //   var reg=/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
        //   if(!reg.test(this.updateMsg.email)){
        //     this.$message.error('请输入有效的邮箱')
        //     return
        //   }
        // }
        if (this.updateMsg.SigningType && !this.saveMsg.length) {
          this.$message.error('请上传签约材料')
          return
        } else {
          if (this.saveMsg && this.saveMsg.length > 0) {
            this.updateMsg.SigningFile = this.saveMsg[0].Path
          }
        }
        this.updateMsg.SigningType = this.updateMsg.SigningType ? 1 : 0
        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
        if(this.updateMsg.Address==''||!this.updateMsg.Address){
          this.updateMsg.Address = AreaName
          // this.updateMsg.Address = AreaName + ',' + this.updateMsg.Address
        }
        if(this.updateMsg.Address&&this.updateMsg.Address.indexOf(AreaName)==-1){
          this.updateMsg.Address = AreaName + ',' + this.updateMsg.Address
        }

        if (!this.updateMsg.Address) {
          this.$message.error('请输入详情地址')
          return
        }
        this.apipost('app_customer_UpdateCustomerAddress', this.updateMsg, res => {
          if (res.data.resultCode == 1) {
            this.addLayer1 = false;
            this.$message.success(res.data.message)
            this.getList()
          } else {
            this.$message.error(res.data.message)
          }
        }, err => {
        })
      },
      deleteUploadFile(fIndex,type){
        if(type){
          this.addMsg.BusinessCardPhotos.splice(fIndex,1)
        }else{
          this.updateMsg.BusinessCardPhotos.splice(fIndex,1)
        }
      },
      uploadImgNew(file) {
        let that = this;
        that.$message.info('上传中...')
        //上传
        let newArr = [];
        newArr.push(file.file);
        let path = "/Upload/Temporary/";
        this.UploadSelfFileT(path, newArr, x => {
          this.BusinessCardPhotos = this.domainManager().ViittoFileUrl + x.data.FilePath
          this.updateMsg.BusinessCardPhotos.push(this.BusinessCardPhotos)
          that.$message.success('上传成功');
        });
      },
      uploadImg1New(file) {
        let that = this;
        that.$message.info('上传中...')
        //上传
        let newArr = [];
        newArr.push(file.file);
        let path = "/Upload/Temporary/";
        this.UploadSelfFileT(path, newArr, x => {
          this.HousePhotos = this.domainManager().ViittoFileUrl + x.data.FilePath
          that.$message.success('上传成功');
        });
      },
      uploadImg2New(file) {
        let that = this;
        that.$message.info('上传中...')
        //上传
        let newArr = [];
        newArr.push(file.file);
        let path = "/Upload/Temporary/";
        this.UploadSelfFileT(path, newArr, x => {
          this.Images = this.domainManager().ViittoFileUrl + x.data.FilePath
          that.$message.success('上传成功');
        });
      },
      getMyCustomerInfo() {
        this.apipost('app_GetMyCustomerInfo', {
          customerId: this.id
        }, res => {
          if (res.data.resultCode == 1) {
            let x = res.data.data;
            this.updateMsg.contactNumber = x.contactNumber
            this.updateMsg.CustomerName = x.customerName
            this.updateMsg.Contact = x.contactName
            this.updateMsg.CustomerId = x.customerId
            this.updateMsg.Address = x.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

            this.BusinessCardPhotos = x.businessCardPhotos && x.businessCardPhotos.length > 0?x.businessCardPhotos[0]:''
            this.updateMsg.BusinessCardPhotos = x.businessCardPhotos?x.businessCardPhotos:[]
            this.updateMsg.PlatformUserNameList = x.platformUserNameList?x.platformUserNameList:[]
            this.Images = x.images && x.images.length > 0?x.images[0]:''
            this.HousePhotos = x.housePhotos && x.housePhotos.length > 0?x.housePhotos[0]:''

            this.updateMsg.uniqueCode = x.uniqueCode
            this.updateMsg.lineid = x.lineid
            this.updateMsg.email = x.email
            this.updateMsg.email = x.email
            this.updateMsg.email = x.email
            var newUrl = this.domainManager().ViittoFileUrl + x.signingFile
            this.saveMsg = x.signingFile ? [{
              Path: x.signingFile,
              URL: newUrl,
              FileName: '签约附件'
            }] : []
            this.updateMsg.SigningType = x.signingType ? true : false
          } 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;
          }
        }, err => {})
      },
      getRegionNew() {
        this.apipost('app_customer_GetChildList', {
          Id: this.updateMsg.City,
          "level": 3
        }, res => {
          if (res.data.resultCode == 1) {
            this.regionList = res.data.data;
          }
        }, 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 that = this;
        that.$message.info('上传中...')
        //上传
        let newArr = [];
        newArr.push(file.file);
        let path = "/Upload/Temporary/";
        this.UploadSelfFileT(path, newArr, x => {
          that.BusinessCardPhotos = this.domainManager().ViittoFileUrl + x.data.FilePath
          if(that.addShow==true){
            that.addMsg.BusinessCardPhotos.push(that.BusinessCardPhotos)
          }
          if(that.addLayer1==true){
            that.updateMsg.BusinessCardPhotos.push(that.BusinessCardPhotos)
          }
          that.$message.success('上传成功');
        });
      },
      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
            this.addMsg.Premises = res.data.data[0].ID
          }
        }, err => {})
      },
      getZw() {
        this.apipost('app_today_visit_GetCustomerDutyEnum', {}, res => {
          if (res.data.resultCode == 1) {
            this.zw = res.data.data
            this.addMsg.Duty = res.data.data[1].ID
          }
        }, err => {})
      },
      getKhly() {
        this.apipost('app_customer_GetCustomerSourceEnum', {}, res => {
          if (res.data.resultCode == 1) {
            this.khly = res.data.data
            this.addMsg.CustomerSourceType = res.data.data[0].ID
          }
        }, 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.CustomerStatus = type
        if(type==0){
          this.msg.SigningType=1
        }else{
          this.msg.SigningType=0
        }
        this.reSearchPage()
      },
      // 获取列表数据
      getList() {
        this.dataList = []
        this.loading = true;
        this.apipost('app_get_my_customer_list', this.msg, res => {
          this.loading = false;
          if (res.data.resultCode == 1) {
            this.dataList = res.data.data.pageData;
            this.total = res.data.data.count;
          }
        }, err => {
          this.loading = false;
        })
      },
      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.contactNumber) {
          this.$message.error('请输入联系电话')
          return
        }
        if (!this.addMsg.customerName) {
          this.$message.error('请输入客户名称')
          return
        }
        if (!this.addMsg.contact) {
          this.$message.error('请输入联系人')
          return
        }
        if (this.addMsg.SigningType && !this.saveMsg.length) {
          this.$message.error('请上传签约材料')
          return
        } else {
          if (this.saveMsg && this.saveMsg.length > 0) {
            this.addMsg.SigningFile = this.saveMsg[0].Path
          }
        }

        if (this.updateMsg.Email) {
          var reg = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
          if (!reg.test(this.updateMsg.Email)) {
            this.$message.error('请输入有效的邮箱')
            return
          }
        }
        if (this.addMsg.District == '') {
          this.addMsg.District = 0
        }

        // 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
        if(this.addMsg.address==''||!this.addMsg.address){
          this.addMsg.address = AreaName
          // this.addMsg.address = AreaName + ',' + this.addMsg.address
        }
        if(this.addMsg.address&&this.addMsg.address.indexOf(AreaName)==-1){
          this.addMsg.address = AreaName + ',' + this.addMsg.address
        }
        if (!this.addMsg.address) {
          this.$message.error('请输入详情地址')
          return
        }
        this.addMsgS.customerInfo = {
          ...this.addMsg,
          SigningType: this.addMsg.SigningType ? 1 : 0
        }
        this.loadingSave = true
        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: '',
              PlatformUserNameList: []
            }
            this.addMsgS.customerVisit.expectVisitDateTime = ''
            this.$message.success(res.data.message)
            this.addShow = false
            this.getList()
          } else {
            this.$message.error(res.data.message)
          }
          this.loadingSave = false
        }, err => {this.loadingSave = false})
      },
      cancelEdit() { // 取消新增
        this.addShow = false
        this.cancelData()
        this.resetForm('addMsg')
      },
      cancelData(){
        this.addMsg = {
          CustomerId: 0,
          customerName: '',
          contact: '',
          contactNumber: '',
          address: '',
          brandIds: [],
          remark: '',
          Duty: '',
          Premises: '',
          CustomerId: '0',
          BusinessCardPhotos: [],
          HousePhotos: [],
          Images: [],
          CustomerSourceType: '',
          CustomerSource: '',
          Country: '2',
          Province: '',
          City: '',
          District: '',
          UniqueCode: '',
          LINEID: '',
          Email: '',
          PlatformUserNameList: []
        }
        this.BusinessCardPhotos = '',
        this.HousePhotos = '',
        this.Images = '',
        this.addMsgS.customerVisit.expectVisitDateTime = ''
      },
      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>
