<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  <div>
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
      v-dialogDrag
      width="1400px"
      height="500px"
      @close="close"
      append-to-body
      @keyup.enter.native=""
      :visible.sync="visible">
      <el-row>
        <el-col :span="24">
          <el-tabs v-model="activeName" type="border-card" @tab-click="tabHandleClick">
            <el-tab-pane label="基本信息" name="base">
              <el-form size="middle" :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="status === 'audit' || status === 'taskFormDetail'"
                       label-width="180px" @submit.native.prevent>
                <el-row  :gutter="0">
                  <el-col :span="10">
                    <el-form-item label="客户名称" prop="name" :rules="[
                   ]">
                      <span slot="label"><span style="color: red;border-top: 20px">*</span> 客户名称</span>
                      <el-input maxlength="64" v-model="inputForm.name" @input="blurName" @blur="blurName" placeholder="请输入客户名称" clearable></el-input>
                      <div class="usc_code_append_message">{{nameMessage}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="2">
                    <el-popover
                      v-model="visiblePop"
                      placement="left"
                      width="400"
                      height="800"
                      trigger="click"
                      :popper-options="{ boundariesElement: 'viewport', removeOnDestroy: true }"
                      ref="pops">
                      <vxe-table
                        border="inner"
                        auto-resize
                        resizable
                        :row-config="{isHover: true}"
                        :data="gridData"
                        :checkbox-config="{}"
                        :row-style="rowStyle"
                        :key="tableKey"
                        @cell-click="rowClick"
                        :show-header="false"
                      >
                        <vxe-column title="" field="entname" ></vxe-column>
                      </vxe-table>

                      <el-button type="info" slot="reference" @click="getPopTable" style="width: 100%" plain>查询</el-button>

                    </el-popover>
                    <el-form-item>

                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="客户编号" prop="no"
                                  :rules="[
                   ]">
                      <el-input :disabled="true" v-model="inputForm.no" placeholder="请填写客户编号" clearable></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row  :gutter="15">
                  <el-col :span="12">
                    <el-form-item label="客户简称" prop="abbreviation"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.abbreviation" placeholder="请填写客户简称" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="英文名称" prop="englishName"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.englishName" placeholder="请填写英文名称" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="客户类型" prop="type"
                                  :rules="[
                                  {required: true, message:'客户类型不能为空', trigger:'blur'}
                   ]">
                      <el-select v-model="inputForm.type" placeholder="请选择客户类型" clearable style="width: 100%;">
                        <el-option
                          v-for="item in $dictUtils.getDictList('cw_work_client_type')"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="特殊客户类型" prop="scType"
                                  :rules="[
                   ]">
                      <el-select v-model="inputForm.scType" placeholder="请选择特殊客户类型" clearable style="width: 100%;">
                        <el-option
                          v-for="item in $dictUtils.getDictList('cw_work_client_spe_type')"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="地址" prop="address"
                                  :rules="[
                                {required: true, message:'地址不能为空', trigger:'blur'}
                   ]">
                      <el-input v-model="inputForm.address" placeholder="地址" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="联系电话" prop="mobile"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.mobile" placeholder="联系电话" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="是否有统一社会信用代码" prop="isUscCode"
                                  :rules="[
                                  {required: true, message:'请选择是否有统一社会信用代码', trigger:'blur'}
                   ]">
                      <el-radio-group v-model="inputForm.isUscCode" @change="changeIsUscCode">
                        <el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value" >{{item.label}}</el-radio>
                      </el-radio-group>
                    </el-form-item>
                  </el-col>
                  <el-col v-if="inputForm.isUscCode === '1'" :span="12">
                    <el-form-item label="统一社会信用代码" prop="uscCode"
                                  :rules="[
                                  {required: true, message:'统一社会信用代码不能为空', trigger:'blur'}
                   ]">
                      <el-input v-model="inputForm.uscCode" @blur="blurUscCode" placeholder="请填写统一社会信用代码" clearable></el-input>
                      <div class="usc_code_append_message">{{uscCodeMessage}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col v-if="inputForm.isUscCode === '0'||commonJS.isEmpty(inputForm.isUscCode)" :span="12">
                    <el-form-item label="统一社会信用代码" prop="uscCode"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.uscCode" @blur="blurUscCode" placeholder="请填写统一社会信用代码" clearable></el-input>
                      <div class="usc_code_append_message">{{uscCodeMessage}}</div>
                    </el-form-item>
                  </el-col>

                  <el-col :span="12">
                    <el-form-item label="管理级次分类" prop="manageLevelTypeName"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.manageLevelTypeName" @clear="clearManageLevelType" @focus="openManageLevelType" placeholder="请填写管理级次分类" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="上一级公司" prop="oneUpCompanyName"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.oneUpCompanyName" @clear="clearOneUpCompanyName" @focus="openWorkClient" placeholder="请填写上一级公司" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="公司级次" prop="companyLevel"
                                  :rules="[
                   ]">
                      <el-input :disabled="true" v-model="inputForm.companyLevel" placeholder="请填写公司级次" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="主要职责" prop="keyResponsibilities"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.keyResponsibilities" placeholder="请填写主要职责" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="24">
                    <el-form-item label="经营范围" prop="businessScope"
                                  :rules="[
                   ]">
                      <el-input type="textarea" maxlength="250" v-model="inputForm.businessScope" placeholder="请填写经营范围" show-word-limit></el-input>
                    </el-form-item>
                  </el-col>

                  <el-col :span="12">
                    <el-form-item label="所属行业" prop="industry"
                                  :rules="[
                                  {required: true, message:'所属行业不能为空', trigger:'blur'}
                   ]">
                      <el-select v-model="inputForm.industry" placeholder="请选择所属行业" clearable style="width: 100%;">
                        <el-option
                          v-for="item in $dictUtils.getDictList('cw_work_client_industry')"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="企业隶属关系划分" prop="affiliation"
                                  :rules="[
                                  {required: true, message:'企业隶属关系划分不能为空', trigger:'blur'}
                   ]">
                      <el-select v-model="inputForm.affiliation" placeholder="请选择企业隶属关系划分" clearable style="width: 100%;">
                        <el-option
                          v-for="item in $dictUtils.getDictList('cw_work_client_affiliation')"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="按组织类型分类" prop="organizationTypeName"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.organizationTypeName" @clear="clearOrganizationType" @focus="openOrganizationType()" placeholder="请填写按组织类型分类" clearable></el-input>
                    </el-form-item>
                  </el-col>
<!--                  <el-col :span="12">-->
<!--                    <el-form-item label="客户报备类型" prop="reportType"-->
<!--                                  :rules="[-->
<!--                                   {required: true, message:'客户报备类型不能为空', trigger:'blur'}-->
<!--                   ]">-->
<!--                      <el-select v-model="inputForm.reportType" placeholder="请选择客户报备类型" clearable style="width: 100%;">-->
<!--                        <el-option-->
<!--                          v-for="item in $dictUtils.getDictList('cw_work_client_report_type')"-->
<!--                          :key="item.value"-->
<!--                          :label="item.label"-->
<!--                          :value="item.value">-->
<!--                        </el-option>-->
<!--                      </el-select>-->
<!--                    </el-form-item>-->
<!--                  </el-col>-->
                  <el-col :span="12">
                    <el-form-item label="上级部门" prop="oneUpOffice"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.oneUpOffice" placeholder="请填写上级部门" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="登记证书号码" prop="registrationCert"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.registrationCert" placeholder="请填写登记证书号码" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="批准机构" prop="approvingBodies"
                                  :rules="[
                   ]">
                      <el-select v-model="inputForm.approvingBodies" placeholder="请选择批准机构" clearable style="width: 100%;">
                        <el-option
                          v-for="item in $dictUtils.getDictList('cw_work_client_approve_office')"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="所属部门" prop="officeId"
                                  :rules="[
                   ]">
<!--                      <el-input v-model="inputForm.officeId" placeholder="请填写所属部门" clearable></el-input>-->
                      <SelectTree
                        ref="officeTree"
                        :props="{
                          value: 'id',             // ID字段名
                          label: 'name',         // 显示名称
                          children: 'children'    // 子级字段名
                        }"
                        :url="`/sys/office/treeData?type=2`"
                        :value="inputForm.officeId"
                        :accordion="true"
                        size="large"
                        @getValue="(value) => {commonJS.isEmpty(value)?inputForm.officeId='':inputForm.officeId=value}"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="24">
                    <el-form-item label="备注" prop="remarks"
                                  :rules="[
                   ]">
                      <el-input type="textarea" maxlength="500" v-model="inputForm.remarks" placeholder="请填写备注" show-word-limit></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row  :gutter="15">
                  <el-col :span="12">
                    <el-form-item label="创建人" prop="createBy.name"
                                  :rules="[
                   ]">
                      <el-input :disabled="true" v-model="inputForm.createBy.name" placeholder="请填写创建人" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="创建时间" prop="createDate"
                                  :rules="[
                   ]">
                      <el-input :disabled="true" v-model="inputForm.createDate" placeholder="请填写创建时间" clearable></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="客户分类" name="type">
              <el-form size="middle" :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="status === 'audit' || status === 'taskFormDetail'"
                       label-width="135px" @submit.native.prevent>
                <el-row  :gutter="15">
                  <el-col :span="12">
                    <el-form-item label="是否上市" prop="cwWorkClientTypeDTO.isListed"
                                  :rules="[
                   ]">
                      <el-radio-group v-model="inputForm.cwWorkClientTypeDTO.isListed" @change="changeUp">
                        <el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value" :key="item.id">{{item.label}}</el-radio>
                      </el-radio-group>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="上市类型" prop="cwWorkClientTypeDTO.listedType"
                                  :rules="[
                   ]">
                      <el-select :disabled="disabled_up || status === 'audit' || status === 'taskFormDetail'" v-model="inputForm.cwWorkClientTypeDTO.listedType" placeholder="请选择上市类型" clearable style="width: 100%;">
                        <el-option
                          v-for="item in $dictUtils.getDictList('cw_work_client_listed_type')"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="独资或控股公司数" prop="cwWorkClientTypeDTO.holdingCompNum"
                                  :rules="[
                   ]">
                      <el-input-number
                        :disabled="disabled_up || status === 'audit' || status === 'taskFormDetail'"
                        v-model="inputForm.cwWorkClientTypeDTO.holdingCompNum"
                        controls-position="right"
                        style="width:100%"
                        :precision="0"
                        :step="1"
                        :min="0"
                        placeholder="请输入独资或控股公司数"
                        :controls="false"
                        clearable>
                      </el-input-number>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="控股上市公司数" prop="cwWorkClientTypeDTO.holdingListedCompNum"
                                  :rules="[
                   ]">
                      <el-input-number
                        :disabled="disabled_up || status === 'audit' || status === 'taskFormDetail'"
                        v-model="inputForm.cwWorkClientTypeDTO.holdingListedCompNum"
                        controls-position="right"
                        style="width:100%"
                        :precision="0"
                        :step="1"
                        :min="0"
                        placeholder="请输入控股上市公司数"
                        :controls="false"
                        clearable>
                      </el-input-number>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="股票代码" prop="cwWorkClientTypeDTO.stockSymbol"
                                  :rules="[
                   ]">
                      <el-input :disabled="disabled_up || status === 'audit' || status === 'taskFormDetail'" v-model="inputForm.cwWorkClientTypeDTO.stockSymbol" placeholder="请填写股票代码" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="股票简称" prop="cwWorkClientTypeDTO.stockAbbreviation"
                                  :rules="[
                   ]">
                      <el-input :disabled="disabled_up || status === 'audit' || status === 'taskFormDetail'" v-model="inputForm.cwWorkClientTypeDTO.stockAbbreviation" placeholder="请填写股票简称" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="发行日期" prop="cwWorkClientTypeDTO.releaseDate"
                                  :rules="[
                   ]">
                      <el-date-picker
                        :disabled="disabled_up || status === 'audit' || status === 'taskFormDetail'"
                        v-model="inputForm.cwWorkClientTypeDTO.releaseDate"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择发行日期"
                        style="width:100%"
                        placement="bottom-start"
                        clearable>
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="上市日期" prop="cwWorkClientTypeDTO.listedDate"
                                  :rules="[
                   ]">
                      <el-date-picker
                        :disabled="disabled_up || status === 'audit' || status === 'taskFormDetail'"
                        v-model="inputForm.cwWorkClientTypeDTO.listedDate"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择上市日期"
                        style="width:100%"
                        placement="bottom-start"
                        clearable>
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="证券市场" prop="cwWorkClientTypeDTO.securitiesMarket"
                                  :rules="[
                   ]">
                      <el-select :disabled="disabled_up || status === 'audit' || status === 'taskFormDetail'" v-model="inputForm.cwWorkClientTypeDTO.securitiesMarket" placeholder="请选择证券市场" clearable style="width: 100%;">
                        <el-option
                          v-for="item in $dictUtils.getDictList('cw_work_client_securities_market')"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="控股自然人姓名" prop="cwWorkClientTypeDTO.controlNaturalPerson"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.cwWorkClientTypeDTO.controlNaturalPerson" placeholder="请填写控股自然人姓名" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="首次发行签字注师1" prop="cwWorkClientTypeDTO.signatory1"
                                  :rules="[
                   ]">
                      <UserSelect size="medium" ref="userSelect1" :disabled="status === 'audit' || status === 'taskFormDetail'" :readonly="true" :limit='1' :value="inputForm.cwWorkClientTypeDTO.signatory1" @getValue='(value) => {changeSignatory1(value)}'></UserSelect>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="首次发行签字注师2" prop="cwWorkClientTypeDTO.signatory2"
                                  :rules="[
                   ]">
                      <UserSelect size="medium" ref="userSelect2" :disabled="status === 'audit' || status === 'taskFormDetail'" :readonly="true" :limit='1' :value="inputForm.cwWorkClientTypeDTO.signatory2" @getValue='(value) => {changeSignatory2(value)}'></UserSelect>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="首次承接业务日期" prop="cwWorkClientTypeDTO.undertakeBusinessDate"
                                  :rules="[
                   ]">
                      <el-date-picker
                        v-model="inputForm.cwWorkClientTypeDTO.undertakeBusinessDate"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择首次承接业务日期"
                        style="width:100%"
                        placement="bottom-start"
                        clearable>
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="是否变更事务所" prop="cwWorkClientTypeDTO.isChangeFirm"
                                  :rules="[
                   ]">
                      <el-radio-group v-model="inputForm.cwWorkClientTypeDTO.isChangeFirm" @change="changeChange">
                        <el-radio v-for="item in $dictUtils.getDictList('yes_no')" :label="item.value" :key="item.id">{{item.label}}</el-radio>
                      </el-radio-group>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="前任事务所" prop="cwWorkClientTypeDTO.formerFirm"
                                  :rules="[
                   ]">
                      <el-input :disabled="disabled_change || status === 'audit' || status === 'taskFormDetail'" v-model="inputForm.cwWorkClientTypeDTO.formerFirm" placeholder="请填写前任事务所" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="事务所变更原因" prop="cwWorkClientTypeDTO.firmChangeCause"
                                  :rules="[
                   ]">
                      <el-input :disabled="disabled_change || status === 'audit' || status === 'taskFormDetail'" v-model="inputForm.cwWorkClientTypeDTO.firmChangeCause" placeholder="请填写事务所变更原因" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="按所有制性质分类" prop="cwWorkClientTypeDTO.ownershipType"
                                  :rules="[
                   ]">
                      <el-select v-model="inputForm.cwWorkClientTypeDTO.ownershipType" placeholder="请选择按所有制性质分类" clearable style="width: 100%;">
                        <el-option
                          v-for="item in $dictUtils.getDictList('cw_work_client_ownership_type')"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="按监管要求分类" prop="cwWorkClientTypeDTO.supervisionRequestType"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.cwWorkClientTypeDTO.supervisionRequestType" placeholder="请填写按监管要求分类" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="按最终地位分类" prop="cwWorkClientTypeDTO.finalStatusType"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.cwWorkClientTypeDTO.finalStatusType" placeholder="请填写按最终地位分类" clearable></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="主管税务机关" prop="cwWorkClientTypeDTO.taxAuthorities"
                                  :rules="[
                   ]">
                      <el-input v-model="inputForm.cwWorkClientTypeDTO.taxAuthorities" placeholder="请填写主管税务机关" clearable></el-input>
                    </el-form-item>
                  </el-col>


                </el-row>
              </el-form>
            </el-tab-pane>
            <el-tab-pane  label="开票信息" name="billing">
              <span slot="label"><span style="color: red;border-top: 20px">*</span> 开票信息</span>
              <el-row :gutter="15">
                <el-button type="primary" style="margin-bottom: 15px" size="mini" :disabled="status === 'audit' || status === 'taskFormDetail' || commonJS.isEmpty(inputForm.cwWorkClientBillingDTOList)" @click="insertEvent('billing')">
                  新增开票信息
                </el-button>
              </el-row>
              <el-row  :gutter="15">
                <el-form :disabled="status === 'audit' || status === 'taskFormDetail'">
                  <vxe-table
                    border
                    show-overflow
                    show-footer
                    :column-config="{resizable: true}"
                    ref="billingTable"
                    :key="tableKeyBilling"
                    class="vxe-table-element"
                    :data="inputForm.cwWorkClientBillingDTOList"
                    style=""
                    @cell-click=""
                    @edit-closed=""
                    highlight-current-row
                    :edit-rules="inputForm.isUscCode === '1'?validBillingRules1:validBillingRules0"
                    :edit-config="{trigger: 'click', mode: 'row', showStatus: false, autoClear: false, icon: '-'}"
                  >
                    <vxe-table-column align="center" field="companyName" title="公司名称" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input v-model="scope.row.companyName" placeholder="公司名称" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="isTaxpayerIdentificationNo" title="是否有纳税人识别号" :edit-render="{name: '$select', options: $dictUtils.getDictList('yes_no')}">
                      <template v-slot:edit="scope">
<!--                        <vxe-select :disabled="formReadOnly" @change="changeTaxpayerIdentificationNo(scope.$rowIndex)" v-model="scope.row.isTaxpayerIdentificationNo" placeholder="是否有纳税人识别号" clearable style="width: 100%;" transfer>-->
                        <vxe-select :disabled="true" v-model="scope.row.isTaxpayerIdentificationNo" placeholder="是否有纳税人识别号" clearable style="width: 100%;" transfer>
                          <vxe-option
                            v-for="item in $dictUtils.getDictList('yes_no')"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </vxe-option>
                        </vxe-select>
                      </template>
                    </vxe-table-column>

                    <vxe-table-column align="center" field="taxpayerIdentificationNo" title="纳税人识别号" :edit-render="{}">
                      <template v-slot:edit="scope">
<!--                        <el-input :disabled="scope.row.disabledTaxpayerIdentificationNo||commonJS.isEmpty(scope.row.isTaxpayerIdentificationNo)" @change="$forceUpdate()" v-model="scope.row.taxpayerIdentificationNo" placeholder="纳税人识别号" clearable></el-input>-->
                        <el-input :disabled="scope.row.isTaxpayerIdentificationNo !== '1'" v-model="scope.row.taxpayerIdentificationNo" placeholder="纳税人识别号" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="accountHolder" title="开户行" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input v-model="scope.row.accountHolder" placeholder="开户行" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="account" title="银行账号" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input v-model="scope.row.account" oninput="value=value.replace(/[^\d]/g,'')" placeholder="银行账号" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="phone" title="电话" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input v-model="scope.row.phone" oninput="value=value.replace(/[^\d]/g,'')" placeholder="电话" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="address" title="地址" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input v-model="scope.row.address" placeholder="地址" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" title="操作" width="100">
                      <template v-slot="scope">
                        <el-button size="mini" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'billing')">删除</el-button>
                      </template>
                    </vxe-table-column>
                  </vxe-table>
                </el-form>
              </el-row>
            </el-tab-pane>
            <el-tab-pane label="客户联系人" name="contact">
              <el-row :gutter="15">
                <el-button type="primary" style="margin-bottom: 15px" size="mini" :disabled="status === 'audit' || status === 'taskFormDetail'" @click="insertEvent('contact')">
                  新增客户联系人
                </el-button>
              </el-row>
              <el-row  :gutter="15">
                <el-form :disabled="status === 'audit' || status === 'taskFormDetail'">
                  <vxe-table
                    border
                    :column-config="{resizable: true}"
                    show-overflow
                    show-footer
                    :key="tableKeyContact"
                    ref="contactTable"
                    class="vxe-table-element"
                    :data="inputForm.cwWorkClientContactDTOList"
                    style=""
                    @cell-click=""
                    @edit-closed=""
                    highlight-current-row
                    :edit-rules="validContactRules"
                    :edit-config="{trigger: 'click', mode: 'row', showStatus: false, autoClear: false, icon: '-'}"
                  >
                    <vxe-table-column align="center" field="name" title="姓名" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input v-model="scope.row.name" placeholder="姓名" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="sex" title="性别" :edit-render="{name: '$select', options: $dictUtils.getDictList('sex')}">
                      <template v-slot:edit="scope">
                        <vxe-select :disabled="status === 'audit' || status === 'taskFormDetail'" v-model="scope.row.sex" placeholder="性别" clearable style="width: 100%;" transfer>
                          <vxe-option
                            v-for="item in $dictUtils.getDictList('sex')"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </vxe-option>
                        </vxe-select>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="officeId" title="部门" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input v-model="scope.row.officeId" placeholder="部门" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="position" title="职务" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input v-model="scope.row.position" placeholder="职务" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="contactFirst" title="联系方式1" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input v-model="scope.row.contactFirst" oninput="value=value.replace(/[^\d]/g,'')" placeholder="联系方式1" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="contactSecond" title="联系方式2" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input v-model="scope.row.contactSecond" oninput="value=value.replace(/[^\d]/g,'')" placeholder="联系方式2" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="fax" title="传真" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input v-model="scope.row.fax" placeholder="传真" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="email" title="邮箱" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input v-model="scope.row.email" @change="$forceUpdate()" @blur="blurEmail(scope.$rowIndex)" placeholder="邮箱" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" field="remarks" title="备注" :edit-render="{}">
                      <template v-slot:edit="scope">
                        <el-input maxlength="500" v-model="scope.row.remarks" placeholder="备注" clearable></el-input>
                      </template>
                    </vxe-table-column>
                    <vxe-table-column align="center" title="操作" width="100">
                      <template v-slot="scope">
                        <el-button size="mini" type="danger" @click="removeEvent(scope.row,scope.$rowIndex,'contact')">删除</el-button>
                      </template>
                    </vxe-table-column>
                  </vxe-table>
                </el-form>
              </el-row>
            </el-tab-pane>
            <el-tab-pane label="附件" name="files">
              <!--        附件-->
              <UpLoadComponent ref="uploadComponent"></UpLoadComponent>
            </el-tab-pane>

          </el-tabs>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
      <el-button size="small" :loading="loading" @click="close()" icon="el-icon-circle-close">关闭</el-button>
      <el-button size="small" :loading="loading" v-if="method === 'edit' || method === 'add'" type="primary" icon="el-icon-circle-check" @click="save()">确定</el-button>
    </span>
    </el-dialog>
      <WorkClientListForm ref="workClientListForm" @getWorkClient="getWorkClient"></WorkClientListForm>
      <ManageLevelTypeListForm ref="manageLevelTypeListForm" @getManageLevelType="getManageLevelType"></ManageLevelTypeListForm>
      <OrganizationTypeListForm ref="organizationTypeListForm" @getOrganizationType="getOrganizationType"></OrganizationTypeListForm>
  </div>
</template>

<script>
  import UpLoadComponent from '@/views/common/UpLoadComponent'
  import SelectUserTree from '@/views/modules/utils/treeUserSelect'
  import SelectTree from '@/components/treeSelect/treeSelect.vue'
  import UserSelect from './clientUserSelect'
  import WorkClientService from '@/api/cw/workClientInfo/WorkClientService'
  import EnterpriseSearchService from '@/api/cw/common/EnterpriseSearchService'
  import WorkClientListForm from './WorkClientListForm'
  import ManageLevelTypeListForm from './manageLevelType/ManageLevelTypeListForm'
  import OrganizationTypeListForm from './organizationType/OrganizationTypeListForm'
  export default {
    props: {
      businessId: {
        type: String,
        default: ''
      },
      formReadOnly: {
        type: Boolean,
        default: false
      },
      status: {
        type: String,
        default: ''
      }
    },
    data () {
      return {
        title: '',
        method: '',
        loading: false,
        inputForm: {
          id: '',
          createDate: '',
          createBy: {
            id: '',
            name: ''
          },
          no: '',
          name: '',
          abbreviation: '',
          englishName: '',
          type: '',
          uscCode: '',
          scType: '',
          manageLevelType: '',
          oneUpCompany: '',
          oneUpCompanyName: '',
          companyLevel: '1',
          businessScope: '',
          keyResponsibilities: '',
          industry: '',
          affiliation: '',
          organizationType: '',
          reportType: '',
          oneUpOffice: '',
          registrationCert: '',
          approvingBodies: '',
          officeId: '',
          procInsId: '',
          processDefinitionId: '',
          status: '',
          agreeDate: '',
          agreeUserId: '',
          cwWorkClientTypeDTO: {
            id: '',
            remarks: '',
            clientId: '',
            isListed: '',
            listedType: '',
            holdingCompNum: '',
            holdingListedCompNum: '',
            stockSymbol: '',
            stockAbbreviation: '',
            releaseDate: '',
            listedDate: '',
            securitiesMarket: '',
            controlNaturalPerson: '',
            signatory1: '',
            signatory2: '',
            undertakeBusinessDate: '',
            isChangeFirm: '',
            formerFirm: '',
            firmChangeCause: '',
            ownershipType: '',
            supervisionRequestType: '',
            finalStatusType: '',
            taxAuthorities: ''
          },
          cwWorkClientBillingDTOList: [],
          cwWorkClientContactDTOList: [],
          workAttachmentDtoList: [],
          address: '',
          mobile: '',
          isUscCode: '',
          manageLevelTypeName: '',
          organizationTypeName: '',
          remarks: ''
        },
        keyWatch: '',
        activeName: 'base',
        visiblePop: false,
        tableKey: '',
        gridData: [],
        disabled_up: true,
        disabled_change: true,
        tableKeyBilling: '1',
        tableKeyContact: '2',
        validBillingRules0: {
          companyName: [
            {required: true, message: '公司名称不可以为空'}
          ],
          isTaxpayerIdentificationNo: [
            {required: true, message: '是否有纳税人识别号不可以为空'}
          ],
          accountHolder: [
            {required: true, message: '开户行不可以为空'}
          ],
          account: [
            {required: true, message: '银行账号不可以为空'}
          ]
        },
        validBillingRules1: {
          companyName: [
            {required: true, message: '公司名称不可以为空'}
          ],
          isTaxpayerIdentificationNo: [
            {required: true, message: '是否有纳税人识别号不可以为空'}
          ],
          taxpayerIdentificationNo: [
            {required: true, message: '纳税人识别号不可以为空'}
          ],
          accountHolder: [
            {required: true, message: '开户行不可以为空'}
          ],
          account: [
            {required: true, message: '银行账号不可以为空'}
          ]
        },
        validContactRules: {
          name: [
            {required: true, message: '姓名不可以为空'}
          ],
          sex: [
            {required: true, message: '性别不可以为空'}
          ],
          officeId: [
            {required: true, message: '部门不可以为空'}
          ],
          position: [
            {required: true, message: '职务不可以为空'}
          ],
          contactFirst: [
            {required: true, message: '联系方式1不可以为空'}
          ]
        },
        visible: false,
        uscCodeMessage: '',
        nameMessage: ''
      }
    },
    workClientService: null,
    enterpriseSearchService: null,
    created () {
      this.enterpriseSearchService = new EnterpriseSearchService()
      this.workClientService = new WorkClientService()
    },
    computed: {
      bus: {
        get () {
          this.$refs.uploadComponent.setDividerName('附件', false)
          return this.businessId
        },
        set (val) {
          this.businessId = val
        }
      }
    },
    watch: {
      'keyWatch': {
        handler (newVal) {
          if (this.commonJS.isNotEmpty(this.bus)) {
            this.init('', this.bus)
          } else {
            this.$nextTick(() => {
              this.$refs.inputForm.resetFields()
            })
          }
        }
      }
    },
    components: {
      SelectUserTree,
      UpLoadComponent,
      SelectTree,
      UserSelect,
      WorkClientListForm,
      ManageLevelTypeListForm,
      OrganizationTypeListForm
    },
    methods: {
      getKeyWatch (keyWatch) {
        this.keyWatch = keyWatch
      },
      init (method, id) {
        if (method === 'add') {
          this.title = '新建客户信息'
        } else {
          this.title = '修改客户信息'
        }
        this.uscCodeMessage = ''
        this.nameMessage = ''
        this.visible = true
        this.activeName = 'base'
        this.workClientService = new WorkClientService()
        this.method = method
        this.inputForm = {
          id: '',
          createDate: '',
          createBy: {
            id: '',
            name: JSON.parse(localStorage.getItem('user')).name
          },
          no: '',
          name: '',
          abbreviation: '',
          englishName: '',
          type: '',
          uscCode: '',
          scType: '',
          manageLevelType: '',
          oneUpCompany: '',
          oneUpCompanyName: '',
          companyLevel: '1',
          businessScope: '',
          keyResponsibilities: '',
          industry: '',
          affiliation: '',
          organizationType: '',
          reportType: '',
          oneUpOffice: '',
          registrationCert: '',
          approvingBodies: '',
          officeId: '',
          procInsId: '',
          processDefinitionId: '',
          status: '',
          agreeDate: '',
          agreeUserId: '',
          cwWorkClientTypeDTO: {
            id: '',
            remarks: '',
            clientId: '',
            isListed: '0',
            listedType: '',
            holdingCompNum: '',
            holdingListedCompNum: '',
            stockSymbol: '',
            stockAbbreviation: '',
            releaseDate: '',
            listedDate: '',
            securitiesMarket: '',
            controlNaturalPerson: '',
            signatory1: '',
            signatory2: '',
            undertakeBusinessDate: '',
            isChangeFirm: '0',
            formerFirm: '',
            firmChangeCause: '',
            ownershipType: '',
            supervisionRequestType: '',
            finalStatusType: '',
            taxAuthorities: ''
          },
          cwWorkClientBillingDTOList: [],
          cwWorkClientContactDTOList: [],
          workAttachmentDtoList: [],
          address: '',
          mobile: '',
          isUscCode: '',
          manageLevelTypeName: '',
          organizationTypeName: '',
          remarks: ''
        }
        this.inputForm.id = id
        this.loading = false
        this.$nextTick(() => {
          this.$refs.inputForm.resetFields()
          this.loading = true
          this.workClientService.queryById(this.inputForm.id).then(({data}) => {
            this.$refs.uploadComponent.clearUpload()
            this.inputForm = this.recover(this.inputForm, data)
            this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
            if (this.inputForm.cwWorkClientTypeDTO.isListed === '1') {
              this.disabled_up = false
            } else {
              this.inputForm.cwWorkClientTypeDTO.isListed = '0'
              this.disabled_up = true
            }
            if (this.inputForm.cwWorkClientTypeDTO.isChangeFirm === '1') {
              this.disabled_change = false
            } else {
              this.inputForm.cwWorkClientTypeDTO.isChangeFirm = '0'
              this.disabled_change = true
            }
            if (this.commonJS.isEmpty(this.inputForm.isUscCode)) {
              this.inputForm.isUscCode = '1'
            }
            if (this.commonJS.isEmpty(this.inputForm.workAttachmentDtoList)) {
              this.inputForm.workAttachmentDtoList = []
            }
            if (this.commonJS.isEmpty(this.inputForm.createDate)) {
              this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
            }
            if (this.commonJS.isEmpty(this.inputForm.createBy.name)) {
              this.inputForm.createBy.name = JSON.parse(localStorage.getItem('user')).name
            }
            if (this.commonJS.isEmpty(this.inputForm.officeId)) {
              this.inputForm.officeId = JSON.parse(localStorage.getItem('user')).officeDTO.id
            }
            if (this.commonJS.isEmpty(this.inputForm.companyLevel)) {
              this.inputForm.companyLevel = '1'
            }
            // if (this.status === 'audit' || this.status === 'taskFormDetail') {
            //   this.method = 'view'
            // }
            this.$refs.uploadComponent.newUpload(this.method, this.inputForm.workAttachmentDtoList, 'cw_work_client', null, null, null, null, false)
            if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList)) {
              this.inputForm.cwWorkClientContactDTOList = []
            }
            if (this.commonJS.isEmpty(this.inputForm.cwWorkClientBillingDTOList)) {
              this.inputForm.cwWorkClientBillingDTOList = []
            }
            this.inputForm.cwWorkClientBillingDTOList.forEach(item => {
              if (this.commonJS.isEmpty(item.isTaxpayerIdentificationNo)) {
                item.taxpayerIdentificationNo = ''
                item.disabledTaxpayerIdentificationNo = true
              } else if (item.isTaxpayerIdentificationNo === '0') {
                item.taxpayerIdentificationNo = ''
                item.disabledTaxpayerIdentificationNo = true
              } else if (item.isTaxpayerIdentificationNo === '1') {
                item.disabledTaxpayerIdentificationNo = false
              }
            })
            this.loading = false
          })
        })
      },
      save () {
        // 如果uscCode是空的或者uscCode的数据不存在，再执行保存方法
        if (this.commonJS.isNotEmpty(this.inputForm.uscCode)) {
          this.workClientService.queryUscCodeIsUse(this.inputForm.uscCode).then(({data}) => {
            this.workClientService.queryUscCodeById(this.inputForm.id).then((uscCode) => {
              if (data.use === 'false' || uscCode.data.uscCode === this.inputForm.uscCode) {
                this.uscCodeMessage = ''
                this.workClientService.queryNameIsUse(this.inputForm.name).then((client) => {
                  this.workClientService.queryNameById(this.inputForm.id).then((name) => {
                    if (client.data.use === 'false' || name.data === this.inputForm.name) {
                      this.trueSave()
                      this.nameMessage = ''
                    } else {
                      this.nameMessage = '该客户已存在'
                      throw new Error()
                    }
                  })
                })
              } else {
                this.uscCodeMessage = '该客户已存在'
                throw new Error()
              }
            })
          })
        } else {
          this.workClientService.queryNameIsUse(this.inputForm.name).then((client) => {
            this.workClientService.queryNameById(this.inputForm.id).then((name) => {
              if (client.data.use === 'false' || name.data === this.inputForm.name) {
                this.trueSave()
                this.nameMessage = ''
              } else {
                this.nameMessage = '该客户已存在'
                throw new Error()
              }
            })
          })
        }
      },
      trueSave () {
        if (this.commonJS.isEmpty(this.inputForm.cwWorkClientBillingDTOList)) {
          this.$message.error('“开票信息”中至少有一条数据')
          throw new Error('“开票信息”中至少有一条数据')
        } else {
          // this.inputForm.agreeDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
          // this.inputForm.agreeUserId = this.$store.state.user.id
          this.$refs['inputForm'].validate((valid) => {
            if (valid) {
              this.loading = true
              if (this.$refs.uploadComponent.checkProgress()) {
                this.loading = false
                return
              }
              this.billingSubmit()
              this.contactSubmit()
              this.baseSubmit()
              this.inputForm.workAttachmentDtoList = this.$refs.uploadComponent.getDataList()
              if (this.commonJS.isEmpty(this.inputForm.createDate)) {
                this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
              }
              this.workClientService.saveForm(this.inputForm).then(() => {
                this.$emit('refreshList')
                this.loading = false
                this.close()
              }).catch(() => {
                this.loading = false
              })
            }
          })
        }
      },
      close () {
        this.tableKeyBilling = Math.random()
        this.tableKeyContact = Math.random()
        this.inputForm = {
          id: '',
          createDate: '',
          createBy: {
            id: '',
            name: ''
          },
          no: '',
          name: '',
          abbreviation: '',
          englishName: '',
          type: '',
          uscCode: '',
          scType: '',
          manageLevelType: '',
          oneUpCompany: '',
          oneUpCompanyName: '',
          companyLevel: '',
          businessScope: '',
          keyResponsibilities: '',
          industry: '',
          affiliation: '',
          organizationType: '',
          reportType: '',
          oneUpOffice: '',
          registrationCert: '',
          approvingBodies: '',
          officeId: '',
          procInsId: '',
          processDefinitionId: '',
          status: '',
          agreeDate: '',
          agreeUserId: '',
          cwWorkClientTypeDTO: {
            id: '',
            remarks: '',
            clientId: '',
            isListed: '',
            listedType: '',
            holdingCompNum: '',
            holdingListedCompNum: '',
            stockSymbol: '',
            stockAbbreviation: '',
            releaseDate: '',
            listedDate: '',
            securitiesMarket: '',
            controlNaturalPerson: '',
            signatory1: '',
            signatory2: '',
            undertakeBusinessDate: '',
            isChangeFirm: '',
            formerFirm: '',
            firmChangeCause: '',
            ownershipType: '',
            supervisionRequestType: '',
            finalStatusType: '',
            taxAuthorities: ''
          },
          cwWorkClientBillingDTOList: [],
          cwWorkClientContactDTOList: [],
          workAttachmentDtoList: [],
          address: '',
          mobile: '',
          isUscCode: '',
          manageLevelTypeName: '',
          organizationTypeName: '',
          remarks: ''
        }
        this.$refs.uploadComponent.clearUpload()
        this.$refs.inputForm.resetFields()
        this.visible = false
        this.uscCodeMessage = ''
        this.nameMessage = ''
      },
      tabHandleClick (event) {
        this.tableKeyBilling = Math.random()
        this.tableKeyContact = Math.random()
        // console.log(event)
      },
      rowStyle (event) {
        return 'cursor:pointer;'
      },
      startBillingDTOList () {
        if (this.commonJS.isEmpty(this.inputForm.cwWorkClientBillingDTOList)) {
          this.inputForm.cwWorkClientBillingDTOList = []
          let d = {
            companyName: this.inputForm.name,
            account: '',
            accountHolder: '',
            address: '',
            isTaxpayerIdentificationNo: this.inputForm.isUscCode,
            phone: '',
            taxpayerIdentificationNo: this.inputForm.isUscCode === '1' ? this.inputForm.uscCode : '',
            disabledTaxpayerIdentificationNo: true
          }
          this.$refs.billingTable.insertAt(d)
          this.inputForm.cwWorkClientBillingDTOList.push(d)
          this.tableKeyBilling = Math.random()
        } else {
          this.inputForm.cwWorkClientBillingDTOList[0].companyName = this.inputForm.name
          this.inputForm.cwWorkClientBillingDTOList[0].isTaxpayerIdentificationNo = this.inputForm.isUscCode
          this.inputForm.cwWorkClientBillingDTOList[0].taxpayerIdentificationNo = this.inputForm.isUscCode === '1' ? this.inputForm.uscCode : ''
        }
      },
      async rowClick (event) {
        let id = this.gridData[event.rowIndex].companyid
        await this.enterpriseSearchService.enterpriseTicketInfo(id).then((data) => {
          this.inputForm.name = data.data.ENTNAME
          this.inputForm.uscCode = data.data.UNCID
          this.inputForm.address = data.data.OPLOC
          this.startBillingDTOList()
          setTimeout(() => {
            if (this.commonJS.isNotEmpty(this.inputForm.name)) {
              this.blurName(this.inputForm.name)
            }
            if (this.commonJS.isNotEmpty(this.inputForm.uscCode)) {
              this.blurUscCode(this.inputForm.uscCode)
            }
          }, 100)
        })
        this.visiblePop = false
      },
      async getPopTable () {
        let name = this.inputForm.name
        if (this.commonJS.isNotEmpty(name)) {
          await this.enterpriseSearchService.enterpriseSearchByName(name).then(({data}) => {
            this.gridData = data.data.items
            this.$refs.pops.updatePopper()
            this.tableKey = Math.random()
          })
        }
        this.$refs.pops.updatePopper()
      },
      closePop () {
        this.visiblePop = false
      },
      clearOneUpCompanyName () {
        this.inputForm.companyLevel = '1'
        this.inputForm.oneUpCompany = ''
        this.inputForm.oneUpCompanyName = ''
      },
      // 获取选择上一级公司后的回参
      getWorkClient (list) {
        if (list[0].id === this.inputForm.id) {
          this.$message.error('”上一级公司“不可以选择自己')
        } else {
          this.inputForm.oneUpCompany = list[0].id
          this.inputForm.oneUpCompanyName = list[0].name
          this.inputForm.companyLevel = parseInt(parseInt(list[0].companyLevel) + 1)
        }
      },
      // 选择上一级公司
      openWorkClient () {
        this.$refs.workClientListForm.init()
      },
      // 获取选择管理级次分类后的回参
      getManageLevelType (row) {
        this.inputForm.manageLevelType = row.id
        this.inputForm.manageLevelTypeName = row.name
      },
      // 选择管理级次分类
      openManageLevelType () {
        this.$refs.manageLevelTypeListForm.init()
      },
      // 清除管理级次分类
      clearManageLevelType () {
        this.inputForm.manageLevelType = ''
        this.inputForm.manageLevelTypeName = ''
      },
      // 获取选择组织类型分类后的回参
      getOrganizationType (row) {
        this.inputForm.organizationType = row.id
        this.inputForm.organizationTypeName = row.name
      },
      // 选择组织类型分类
      openOrganizationType () {
        this.$refs.organizationTypeListForm.init()
      },
      // 清除组织类型分类
      clearOrganizationType () {
        this.inputForm.organizationType = ''
        this.inputForm.organizationTypeName = ''
      },
      changeUp (event) {
        if (this.inputForm.cwWorkClientTypeDTO.isListed === '1') {
          this.disabled_up = false
        } else {
          this.inputForm.cwWorkClientTypeDTO.listedType = ''
          this.inputForm.cwWorkClientTypeDTO.holdingCompNum = ''
          this.inputForm.cwWorkClientTypeDTO.holdingListedCompNum = ''
          this.inputForm.cwWorkClientTypeDTO.stockSymbol = ''
          this.inputForm.cwWorkClientTypeDTO.stockAbbreviation = ''
          this.inputForm.cwWorkClientTypeDTO.releaseDate = ''
          this.inputForm.cwWorkClientTypeDTO.listedDate = ''
          this.inputForm.cwWorkClientTypeDTO.securitiesMarket = ''
          this.disabled_up = true
        }
      },
      changeChange (event) {
        if (this.inputForm.cwWorkClientTypeDTO.isChangeFirm === '1') {
          this.disabled_change = false
        } else {
          this.inputForm.cwWorkClientTypeDTO.formerFirm = ''
          this.inputForm.cwWorkClientTypeDTO.firmChangeCause = ''
          this.disabled_change = true
        }
      },
      changeSignatory1 (value) {
        if (this.inputForm.cwWorkClientTypeDTO.signatory2 === value && this.commonJS.isNotEmpty(value)) {
          this.$message.warning('首次发行签字注师1和首次发行签字注师2不可以相同')
          this.$nextTick(() => {
            this.inputForm.cwWorkClientTypeDTO.signatory1 = ''
            this.$refs.userSelect1.changeNameValue('')
            this.$refs.userSelect1.clearSelectData()
            this.$forceUpdate()
          })
        } else {
          this.inputForm.cwWorkClientTypeDTO.signatory1 = value
        }
      },
      changeSignatory2 (value) {
        if (this.inputForm.cwWorkClientTypeDTO.signatory1 === value && this.commonJS.isNotEmpty(value)) {
          this.$message.warning('首次发行签字注师1和首次发行签字注师2不可以相同')
          this.$nextTick(() => {
            this.inputForm.cwWorkClientTypeDTO.signatory2 = ''
            this.$refs.userSelect2.changeNameValue('')
            this.$refs.userSelect2.clearSelectData()
            this.$forceUpdate()
          })
        } else {
          this.inputForm.cwWorkClientTypeDTO.signatory2 = value
        }
      },
      // 新增
      // eslint-disable-next-line no-dupe-keys
      insertEvent (type) {
        if (type === 'billing') {
          let d = {
            account: '',
            accountHolder: '',
            address: '',
            isTaxpayerIdentificationNo: this.inputForm.isUscCode,
            phone: '',
            taxpayerIdentificationNo: '',
            disabledTaxpayerIdentificationNo: true
          }
          if (this.commonJS.isEmpty(this.inputForm.cwWorkClientBillingDTOList)) {
            this.inputForm.cwWorkClientBillingDTOList = []
          }
          this.$refs.billingTable.insertAt(d)
          this.inputForm.cwWorkClientBillingDTOList.push(d)
          this.tableKeyBilling = Math.random()
        }
        if (type === 'contact') {
          let d = {
            contactFirst: '',
            contactSecond: '',
            email: '',
            fax: '',
            name: '',
            officeId: '',
            position: '',
            remarks: '',
            sex: ''
          }
          if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList)) {
            this.inputForm.cwWorkClientContactDTOList = []
          }
          this.$refs.contactTable.insertAt(d)
          this.inputForm.cwWorkClientContactDTOList.push(d)
          this.tableKeyContact = Math.random()
        }
      },
      // 删除
      removeEvent (row, rowIndex, type) {
        if (type === 'billing') {
          this.$refs.billingTable.remove(row)
          this.inputForm.cwWorkClientBillingDTOList.splice(rowIndex, 1)
        }
        if (type === 'contact') {
          this.$refs.contactTable.remove(row)
          this.inputForm.cwWorkClientContactDTOList.splice(rowIndex, 1)
        }
      },
      // 是否有纳税人识别号
      changeTaxpayerIdentificationNo (index) {
        if (this.commonJS.isEmpty(this.inputForm.cwWorkClientBillingDTOList[index].isTaxpayerIdentificationNo)) {
          this.inputForm.cwWorkClientBillingDTOList[index].taxpayerIdentificationNo = ''
          this.inputForm.cwWorkClientBillingDTOList[index].disabledTaxpayerIdentificationNo = true
        } else if (this.inputForm.cwWorkClientBillingDTOList[index].isTaxpayerIdentificationNo === '0') {
          this.inputForm.cwWorkClientBillingDTOList[index].taxpayerIdentificationNo = ''
          this.inputForm.cwWorkClientBillingDTOList[index].disabledTaxpayerIdentificationNo = true
        } else if (this.inputForm.cwWorkClientBillingDTOList[index].isTaxpayerIdentificationNo === '1') {
          this.inputForm.cwWorkClientBillingDTOList[index].disabledTaxpayerIdentificationNo = false
        }
      },
      blurEmail (index) {
        if (this.commonJS.isNotEmpty(this.inputForm.cwWorkClientContactDTOList[index].email)) {
          if (!this.validateXG.isEmail(this.inputForm.cwWorkClientContactDTOList[index].email)) {
            this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“邮箱”填写错误，请重新填写')
            this.inputForm.cwWorkClientContactDTOList[index].email = ''
            throw new Error('客户联系人中，第' + (index + 1) + '条数据的“邮箱”填写错误，请重新填写')
          }
        }
      },
      baseSubmit () {
        if (this.commonJS.isEmpty(this.inputForm.name)) {
          this.$message.error('基本信息中，”客户名称“未填写')
          this.loading = false
          throw new Error('基本信息中，”客户名称“未填写')
        }
        if (this.commonJS.isEmpty(this.inputForm.type)) {
          this.$message.error('基本信息中，”客户类型“未填写')
          this.loading = false
          throw new Error('基本信息中，”客户类型“未填写')
        }
        if (this.commonJS.isEmpty(this.inputForm.industry)) {
          this.$message.error('基本信息中，”所属行业“未填写')
          this.loading = false
          throw new Error('基本信息中，”所属行业“未填写')
        }
        if (this.commonJS.isEmpty(this.inputForm.affiliation)) {
          this.$message.error('基本信息中，”企业隶属关系划分“未填写')
          this.loading = false
          throw new Error('基本信息中，”企业隶属关系划分“未填写')
        }
        // if (this.commonJS.isEmpty(this.inputForm.reportType)) {
        //   this.$message.error('基本信息中，”客户报备类型“未填写')
        //   this.loading = false
        //   throw new Error('基本信息中，”客户报备类型“未填写')
        // }
        if (this.commonJS.isEmpty(this.inputForm.address)) {
          this.$message.error('基本信息中，”地址“未填写')
          this.loading = false
          throw new Error('基本信息中，”地址“未填写')
        }
        if (this.commonJS.isNotEmpty(this.inputForm.mobile)) {
          if (!this.validateXG.isPhoneOrMobile(this.inputForm.mobile)) {
            this.$message.error('基本信息中，”联系电话“填写不正确，请重新填写')
            this.loading = false
            throw new Error('基本信息中，”联系电话“填写不正确，请重新填写')
          }
        }
      },
      billingSubmit () {
        this.inputForm.cwWorkClientBillingDTOList.forEach((item, index) => {
          if (this.commonJS.isEmpty(item.companyName)) {
            this.$message.error('开票信息中，第' + (index + 1) + '条数据的“公司名称”未填写')
            this.loading = false
            throw new Error('开票信息中，第' + (index + 1) + '条数据的“公司名称”未填写')
          }
          if (item.isTaxpayerIdentificationNo === '1') {
            if (this.commonJS.isEmpty(item.taxpayerIdentificationNo)) {
              this.$message.error('开票信息中，第' + (index + 1) + '条数据的“纳税人识别号”未填写')
              this.loading = false
              throw new Error('开票信息中，第' + (index + 1) + '条数据的“纳税人识别号”未填写')
            }
          }
          if (this.commonJS.isEmpty(item.accountHolder)) {
            this.$message.error('开票信息中，第' + (index + 1) + '条数据的“开户行”未填写')
            this.loading = false
            throw new Error('开票信息中，第' + (index + 1) + '条数据的“开户行”未填写')
          }
          if (this.commonJS.isEmpty(item.account)) {
            this.$message.error('开票信息中，第' + (index + 1) + '条数据的“银行账号”未填写')
            this.loading = false
            throw new Error('开票信息中，第' + (index + 1) + '条数据的“银行账号”未填写')
          }
        })
      },
      contactSubmit () {
        this.inputForm.cwWorkClientContactDTOList.forEach((item, index) => {
          if (this.commonJS.isNotEmpty(item.email)) {
            if (!this.validateXG.isEmail(item.email)) {
              this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“邮箱”填写错误')
              this.loading = false
              throw new Error('客户联系人中，第' + (index + 1) + '条数据的“邮箱”填写错误')
            }
          }
          if (this.commonJS.isEmpty(item.name)) {
            this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“姓名”未填写')
            this.loading = false
            throw new Error('客户联系人中，第' + (index + 1) + '条数据的“姓名”未填写')
          }
          if (this.commonJS.isEmpty(item.sex)) {
            this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“性别”未填写')
            this.loading = false
            throw new Error('客户联系人中，第' + (index + 1) + '条数据的“性别”未填写')
          }
          if (this.commonJS.isEmpty(item.officeId)) {
            this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“部门”未填写')
            this.loading = false
            throw new Error('客户联系人中，第' + (index + 1) + '条数据的“部门”未填写')
          }
          if (this.commonJS.isEmpty(item.position)) {
            this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“职务”未填写')
            this.loading = false
            throw new Error('客户联系人中，第' + (index + 1) + '条数据的“职务”未填写')
          }
          if (this.commonJS.isEmpty(item.contactFirst)) {
            this.$message.error('客户联系人中，第' + (index + 1) + '条数据的“联系方式1”未填写')
            this.loading = false
            throw new Error('客户联系人中，第' + (index + 1) + '条数据的“联系方式1”未填写')
          }
        })
      },
      changeIsUscCode (event) {
        this.startBillingDTOList()
        if (event === '1') {
          if (this.commonJS.isNotEmpty(this.inputForm.cwWorkClientBillingDTOList)) {
            this.inputForm.cwWorkClientBillingDTOList.forEach(item => {
              item.isTaxpayerIdentificationNo = '1'
            })
          }
        }
        if (event === '0') {
          if (this.commonJS.isNotEmpty(this.inputForm.cwWorkClientBillingDTOList)) {
            this.inputForm.cwWorkClientBillingDTOList.forEach(item => {
              item.isTaxpayerIdentificationNo = '0'
              item.taxpayerIdentificationNo = ''
            })
          }
        }
      },
      // 统一社会信用代码blur事件
      blurUscCode () {
        this.startBillingDTOList()
        if (this.commonJS.isNotEmpty(this.inputForm.uscCode)) {
          this.workClientService.queryUscCodeIsUse(this.inputForm.uscCode).then(({data}) => {
            if (this.commonJS.isNotEmpty(this.inputForm.id)) {
              this.workClientService.queryUscCodeById(this.inputForm.id).then((uscCode) => {
                if (data.use !== 'false' && this.commonJS.isNotEmpty(data.use) && this.commonJS.isNotEmpty(data.id) && this.inputForm.uscCode !== uscCode.data.uscCode) {
                  this.uscCodeMessage = '该客户已存在'
                  if (data.isUpdate === 'false') {
                    this.$message.error('该客户信息已存在并且数据正在修改中')
                  } else {
                    this.$confirm(`该客户信息已存在是否进行信息修改?`, '提示', {
                      confirmButtonText: '确定',
                      cancelButtonText: '取消',
                      type: 'warning'
                    }).then(() => {
                      this.close()
                      if (data.use === '0') {
                        this.$emit('updateFlowAbleData', data.id)
                      }
                      if (data.use === '1') {
                        this.$emit('updateDialogData', data.id)
                      }
                    })
                  }
                } else {
                  this.uscCodeMessage = ''
                }
              })
            } else {
              if (data.use !== 'false' && this.commonJS.isNotEmpty(data.use) && this.commonJS.isNotEmpty(data.id)) {
                this.uscCodeMessage = '该客户已存在'
                if (data.isUpdate === 'false') {
                  this.$message.error('该客户信息已存在并且数据正在修改中')
                } else {
                  this.$confirm(`该客户信息已存在是否进行信息修改?`, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                  }).then(() => {
                    this.close()
                    if (data.use === '0') {
                      this.$emit('updateFlowAbleData', data.id)
                    }
                    if (data.use === '1') {
                      this.$emit('updateDialogData', data.id)
                    }
                  })
                }
              } else {
                this.uscCodeMessage = ''
              }
            }
          })
        } else {
          this.uscCodeMessage = ''
        }
      },
      // 客户名称blur事件
      blurName () {
        this.startBillingDTOList()
        if (this.commonJS.isNotEmpty(this.inputForm.name)) {
          this.workClientService.queryNameIsUse(this.inputForm.name).then(({data}) => {
            if (this.commonJS.isNotEmpty(this.inputForm.id)) {
              this.workClientService.queryNameById(this.inputForm.id).then((name) => {
                if (data.use !== 'false' && this.commonJS.isNotEmpty(data.use) && this.commonJS.isNotEmpty(data.id) && this.inputForm.name !== name.data) {
                  this.nameMessage = '该客户已存在'
                } else {
                  this.nameMessage = ''
                }
              })
            } else {
              if (data.use !== 'false' && this.commonJS.isNotEmpty(data.use) && this.commonJS.isNotEmpty(data.id)) {
                this.nameMessage = '该客户已存在'
              } else {
                this.nameMessage = ''
              }
            }
          })
        } else {
          this.nameMessage = ''
        }
      }
    }
  }
</script>
<style scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
<style>
  .usc_code_append_message {
    color: #F56C6C;
    font-size: 12px;
    line-height: 1;
    padding-top: 4px;
    position: absolute;
    top: 100%;
    left: 0;
  }
</style>

