<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  <div>
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
	  draggable
      width="1400px"
      height="500px"
      @close="close"
      append-to-body
      v-model="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 :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="method==='view'"
                     label-width="180px" @submit.native.prevent>
				<el-row  :gutter="0">
					<el-col :span="10">
						<el-form-item label="客户名称" prop="name" :rules="[
                   ]">
							<template #label>
								<span style="color: #ff0000;border-top: 20px">*</span> 客户名称
							</template>
							<el-input maxlength="64" v-model="inputForm.name" placeholder="请输入客户名称" clearable></el-input>
						</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="true"
								:resizable="true"
								: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>
							<template #reference>
								<el-button type="info" @click="getPopTable" style="width: 100%" plain>查询</el-button>
							</template>

						</el-popover>
					</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="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" placeholder="请填写统一社会信用代码" clearable></el-input>
                  </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" placeholder="请填写统一社会信用代码" clearable></el-input>
                  </el-form-item>
                </el-col>

                <el-col :span="12">
                  <el-form-item label="管理级次分类" prop="manageLevelTypeName"
                                :rules="[
                   ]">
                    <el-input v-model="inputForm.manageLevelTypeName" @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" @focus="openOrganizationType()" placeholder="请填写按组织类型分类" clearable></el-input>
                  </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="`/system-server/sys/office/treeData?type=2`"
                      :value="inputForm.officeId"
                      :accordion="true"
                      size="large"
                      @getValue="(value) => {inputForm.officeId=value}"/>
                  </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="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="createTime"
                                :rules="[
                   ]">
                    <el-input :disabled="true" v-model="inputForm.createTime" placeholder="请填写创建时间" clearable></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="客户分类" name="type">
            <el-form :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="method==='view'"
                     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 || method==='view'" 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 || method==='view'"
                      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 || method==='view'"
                      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 || method==='view'" 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 || method==='view'" 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 || method==='view'"
                      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 || method==='view'"
                      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 || method==='view'" 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 ref="userSelect1" :disabled="method==='view'" :readonly="true" :limit='1' :modelValue="inputForm.cwWorkClientTypeDTO.signatory1" @update:modelValue='(value) => {changeSignatory1(value)}'></UserSelect>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="首次发行签字注师2" prop="cwWorkClientTypeDTO.signatory2"
                                :rules="[
                   ]">
                    <UserSelect ref="userSelect2" :disabled="method==='view'" :readonly="true" :limit='1' :modelValue="inputForm.cwWorkClientTypeDTO.signatory2" @update:modelValue='(value) => {changeSignatory2(value)}'></UserSelect>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="首次承接业务日期" prop="inputForm.cwWorkClientTypeDTO.undertakeBusinessDate"
                                :rules="[
                   ]">
                    <el-date-picker
                      v-model="inputForm.cwWorkClientTypeDTO.undertakeBusinessDate"
                      value-format="YYYY-MM-DD"
					  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 || method==='view'" 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 || method==='view'" 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">
            <el-row :gutter="15">
              <el-button type="primary" style="margin-bottom: 15px" :disabled="method==='view'" @click="insertEvent('billing')">
                新增开票信息
              </el-button>
            </el-row>
			  <el-row  :gutter="15">
				  <el-form :disabled="method==='view'" style="width: 100%;">
					  <vxe-table
						  border
						  show-overflow
						  show-footer
						  :column-config="{resizable: true}"
						  ref="billingTable"
						  :key="tableKeyBilling"
						  class="vxe-table-element"
						  :data="inputForm.cwWorkClientBillingDTOList"
						  style=""
						  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="{}" show-overflow="title">
							  <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="是否有纳税人识别号"  show-overflow="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="{}"  show-overflow="title">
							  <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="{}"  show-overflow="title">
							  <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="{}"  show-overflow="title">
							  <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="{}"  show-overflow="title">
							  <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"  show-overflow="title">
							  <template #default="scope">
								  <el-button 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" :disabled="method==='view'" @click="insertEvent('contact')">
                新增客户联系人
              </el-button>
            </el-row>
			  <el-row  :gutter="15">
				  <el-form :disabled="method==='view'" style="width: 100%;">
					  <vxe-table
						  border
						  :column-config="{resizable: true}"
						  show-overflow
						  show-footer
						  :key="tableKeyContact"
						  ref="contactTable"
						  class="vxe-table-element"
						  :data="inputForm.cwWorkClientContactDTOList"
						  style=""
						  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="{}" show-overflow="title">
							  <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="{}" show-overflow="title">
							  <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="{}" show-overflow="title">
							  <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="{}" show-overflow="title">
							  <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="{}" show-overflow="title">
							  <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="{}" show-overflow="title">
							  <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="{}" show-overflow="title">
							  <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="{}" show-overflow="title">
							  <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 #default="scope">
								  <el-button 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-tab-pane label="关联项目" name="projects">
            <el-form :inline="true" class="query-form" style="margin-bottom: 0;padding-top: 2px;padding-left: 0" ref="projectForm" :model="projectForm" @keyup.enter.native="searchProject()" @submit.native.prevent>
              <!-- 搜索框-->
              <el-form-item label="项目名称" prop="projectName">
                <el-input v-model="projectForm.projectName" placeholder="请输入项目名称" clearable></el-input>
              </el-form-item>
              <el-form-item label="项目编号" prop="projectNumber">
                <el-input v-model="projectForm.projectNumber" placeholder="请输入项目编号" clearable></el-input>
              </el-form-item>

              <el-form-item>
                <el-button type="primary" @click="searchProject()" icon="el-icon-search">查询</el-button>
                <el-button @click="refreshProjectForm()" icon="el-icon-refresh-right">重置</el-button>
              </el-form-item>
            </el-form>
            <vxe-table
              max-height="400"
              border="inner"
              auto-resize
              resizable
              height="auto"
              :loading="loading"
              ref="projectTable"
              show-header-overflow
              show-overflow
              highlight-hover-row
              :menu-config="{}"
              :sort-config="{remote:true}"
              :data="projectList"
              :checkbox-config="{}">
              <vxe-column type="seq" width="60" title="序号"></vxe-column>
              <vxe-column min-width="230" align="center" title="项目名称" field="projectName">
                <template #default="scope">
                  <el-link  type="primary" :underline="false" v-if="hasPermission('cwProjectRecords:view')" @click="viewProject(scope.row.id)">{{scope.row.projectName}}</el-link>
                  <span v-else>{{scope.row.projectName}}</span>
                </template>
              </vxe-column>
              <vxe-column min-width="160" align="center" title="项目编号" field="projectNumber"></vxe-column>
              <vxe-column min-width="160" align="center" title="项目经理" field="projectMasterName"></vxe-column>
              <vxe-column min-width="160" align="center" title="创建人" field="createName"></vxe-column>
              <vxe-column min-width="160" align="center" title="创建时间" field="createTime"></vxe-column>
            </vxe-table>
          </el-tab-pane>
          <el-tab-pane label="关联合同" name="contract">
            <el-form :inline="true" class="query-form" style="margin-bottom: 0;padding-top: 2px;padding-left: 0" ref="contractForm" :model="contractForm" @keyup.enter.native="searchContract()" @submit.native.prevent>
              <!-- 搜索框-->
              <el-form-item label="合同名称" prop="contractName">
                <el-input v-model="contractForm.contractName" placeholder="请输入合同名称" clearable></el-input>
              </el-form-item>
              <el-form-item label="合同编号" prop="contractNo">
                <el-input v-model="contractForm.contractNo" placeholder="请输入合同编号" clearable></el-input>
              </el-form-item>

              <el-form-item>
                <el-button type="primary" @click="searchContract()"  icon="el-icon-search">查询</el-button>
                <el-button @click="refreshContractForm()" icon="el-icon-refresh-right">重置</el-button>
              </el-form-item>
            </el-form>
            <vxe-table
              max-height="500"
              border="inner"
              auto-resize
              resizable
              height="auto"
              :loading="loading"
              ref="contractTable"
              show-header-overflow
              show-overflow
              highlight-hover-row
              :menu-config="{}"
              :sort-config="{remote:true}"
              :data="contractList"
              :checkbox-config="{}">
              <vxe-column type="seq" width="60" title="序号"></vxe-column>
              <vxe-column width="200px" align="center" title="合同名称" field="contractName">
                <template #default="scope">
                  <el-link  type="primary" :underline="false" v-if="hasPermission('cw:workContract:view')" @click="viewContract(scope.row.id)">{{scope.row.contractName}}</el-link>
                  <span v-else>{{scope.row.contractName}}</span>
                </template>
              </vxe-column>
              <vxe-column min-width="160" align="center" title="合同编号" field="contractNo"></vxe-column>
              <vxe-column min-width="160" align="center" title="签约日期" field="signingDate"></vxe-column>
              <vxe-column min-width="160" align="center" title="合同金额（元）" field="contractAmount"></vxe-column>
              <vxe-column min-width="160" align="center" title="所属部门" field="departmentName"></vxe-column>
              <vxe-column min-width="160" align="center" title="创建人" field="createName"></vxe-column>
              <vxe-column min-width="160" align="center" title="创建日期" field="createTime"></vxe-column>
            </vxe-table>
          </el-tab-pane>
          <el-tab-pane label="关联报告" name="report">
            <el-form :inline="true" class="query-form" style="margin-bottom: 0;padding-top: 2px;padding-left: 0" ref="reportForm" :model="reportForm" @keyup.enter.native="searchReport()" @submit.native.prevent>
              <!-- 搜索框-->
              <el-form-item label="报告文号" prop="reportNo">
                <el-input v-model="reportForm.reportNo" placeholder="请输入报告文号" clearable></el-input>
              </el-form-item>
              <el-form-item label="项目名称" prop="projectName">
                <el-input v-model="reportForm.projectName" placeholder="请输入项目名称" clearable></el-input>
              </el-form-item>
              <el-form-item label="项目编号" prop="projectNumber">
                <el-input v-model="reportForm.projectNumber" placeholder="请输入项目编号" clearable></el-input>
              </el-form-item>

              <el-form-item>
                <el-button type="primary" @click="searchReport()" icon="el-icon-search">查询</el-button>
                <el-button @click="refreshReportForm()" icon="el-icon-refresh-right">重置</el-button>
              </el-form-item>
            </el-form>
            <vxe-table
              max-height="500"
              border="inner"
              auto-resize
              resizable
              height="auto"
              :loading="loading"
              ref="reportTable"
              show-header-overflow
              show-overflow
              highlight-hover-row
              :menu-config="{}"
              :sort-config="{remote:true}"
              :data="reportList"
              :checkbox-config="{}">
              <vxe-column type="seq" width="60" title="序号"></vxe-column>
              <vxe-column min-width="200" title="报告文号" align="center" field="reportNo">
                <template #default="scope">
                  <el-link  type="primary" :underline="false" @click="viewReport(scope.row.id)">{{scope.row.reportNo}}</el-link>
                </template>
              </vxe-column>
              <vxe-column min-width="200" title="项目名称" align="center" field="projectName">
                <template #default="scope">
                  <el-link  type="primary" :underline="false" @click="viewProject(scope.row.projectId)">{{scope.row.projectName}}</el-link>
                </template>
              </vxe-column>
              <vxe-column min-width="200" title="项目编号" align="center" field="projectNumber"></vxe-column>
              <vxe-column min-width="150" title="所属部门" align="center" field="officeName"></vxe-column>
              <vxe-column min-width="150" title="项目经理" align="center" field="projectMasterName"></vxe-column>
              <vxe-column min-width="120" title="报告创建人" align="center" field="createName"></vxe-column>
              <vxe-column min-width="180" title="报告创建时间" align="center" field="createTime"></vxe-column>
            </vxe-table>
          </el-tab-pane>
          <el-tab-pane label="关联发票" name="invoice">
            <el-form :inline="true" class="query-form" style="margin-bottom: 0;padding-top: 2px;padding-left: 0" ref="invoiceForm" :model="invoiceForm" @keyup.enter.native="searchInvoice()" @submit.native.prevent>
              <!-- 搜索框-->
              <el-form-item label="发票申请编号" prop="no">
                <el-input v-model="invoiceForm.no" placeholder="请输入发票申请编号" clearable></el-input>
              </el-form-item>

              <el-form-item>
                <el-button type="primary" @click="searchInvoice()" icon="el-icon-search">查询</el-button>
                <el-button @click="refreshInvoiceForm()" icon="el-icon-refresh-right">重置</el-button>
              </el-form-item>
            </el-form>
            <vxe-table
              max-height="500"
              border="inner"
              auto-resize
              resizable
              height="auto"
              :loading="loading"
              ref="invoiceTable"
              show-header-overflow
              show-overflow
              highlight-hover-row
              :menu-config="{}"
              :sort-config="{remote:true}"
              :data="invoiceList"
              :checkbox-config="{}">
              <vxe-column type="seq" width="60" title="序号"></vxe-column>
              <vxe-column min-width="150" title="发票申请编号" align="center" field="no">
                <template #default="scope">
                  <el-link  type="primary" :underline="false" @click="viewInvoice(false, scope.row.id)">{{scope.row.no}}</el-link>
                </template>
              </vxe-column>
              <vxe-column min-width="150" title="发票号" align="center" field="number"></vxe-column>
              <vxe-column min-width="150" title="实际开票单位" align="center" field="billingWorkplaceReal"></vxe-column>
              <vxe-column min-width="150" title="开票金额（元）" align="center" field="accountDetail"></vxe-column>
              <vxe-column min-width="150" title="开票总金额（元）" align="center" field="account"></vxe-column>
              <vxe-column min-width="120" title="开票内容" align="center" field="billingContent">
                <template #default="scope">
                  {{$dictUtils.getDictLabel('invoice_billing_content', scope.row.billingContent, '-')}}
                </template>
              </vxe-column>
              <vxe-column min-width="110" fixed="right" align="center" title="是否收款" field="receivablesStatus">
                <template #default="scope">
                  {{scope.row.receivablesStatus === '1'?'已收款':'未收款'}}
                </template>
              </vxe-column>
            </vxe-table>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>
		<template #footer>
			<span class="dialog-footer">
			  <el-button @click="close()" icon="el-icon-circle-close">关闭</el-button>
			  <el-button v-if="method === 'edit'" type="primary" icon="el-icon-circle-check" @click="doSubmit('save')">确定</el-button>
			</span>
		</template>
    </el-dialog>
    <WorkClientListForm ref="workClientListForm" @getWorkClient="getWorkClient"></WorkClientListForm>
    <ManageLevelTypeListForm ref="manageLevelTypeListForm" @getManageLevelType="getManageLevelType"></ManageLevelTypeListForm>
    <OrganizationTypeListForm ref="organizationTypeListForm" @getOrganizationType="getOrganizationType"></OrganizationTypeListForm>
    <ProjectRecordsForm ref="projectRecordsForm"></ProjectRecordsForm>
    <ContractNameForm ref="contractNameForm"></ContractNameForm>
    <ReportManagementForm ref="reportManagementForm"></ReportManagementForm>
    <InvoiceForm ref="invoiceFormDialog"></InvoiceForm>
  </div>
</template>

<script>
  import UpLoadComponent from '@/views/common/UpLoadComponent'
  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 ProjectRecordsForm from '../projectRecords/ProjectRecordsForm'
  import ManageLevelTypeListForm from './manageLevelType/ManageLevelTypeListForm'
  import OrganizationTypeListForm from './organizationType/OrganizationTypeListForm'
  import projectRecordsService from '@/api/cw/projectRecords/ProjectRecordsService'
  import contractInfoService from '@/api/cw/workContract/contractInfoService'
  // import ContractNameForm from '../workContract/ContractNameForm'
  import projectReportService from '@/api/cw/reportManagement/ProjectReportService'
  import cwFinanceInvoiceService from '@/api/cw/invoice/CwFinanceInvoiceService'
  import InvoiceForm from '../invoice/InvoiceForm'
  import ReportManagementForm from '../reportManagement/ReportManagementForm'
  export default {
    props: {
      businessId: {
        type: String,
        default: ''
      },
      formReadOnly: {
        type: Boolean,
        default: false
      },
      status: {
        type: String,
        default: ''
      }
    },
    data () {
      return {
        title: '',
        method: '',
        loading: false,
        inputForm: {
          id: '',
			createTime: '',
          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',
        visible: false,
        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不可以为空'}
          ]
        },
        projectList: [],
        contractList: [],
        projectForm: {
          projectName: '',
          projectNumber: ''
        },
        contractForm: {
          contractName: '',
          contractNo: ''
        },
        reportForm: {
          reportNo: '',
          projectName: '',
          projectNumber: ''
        },
        reportList: [],
        invoiceList: [],
        invoiceForm: {
          no: ''
        }
      }
    },
    enterpriseSearchService: null,
    created () {
      this.enterpriseSearchService = new EnterpriseSearchService()
    },
    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: {
		ProjectRecordsForm: () => import('../projectRecords/ProjectRecordsForm'),
      UpLoadComponent,
      SelectTree,
      UserSelect,
      WorkClientListForm,
      ManageLevelTypeListForm,
      OrganizationTypeListForm,
      ContractNameForm: () => import('../workContract/ContractNameForm'),
      ReportManagementForm,
      InvoiceForm
    },
    methods: {
      getKeyWatch (keyWatch) {
        this.keyWatch = keyWatch
      },
      init (method, id) {
        this.visible = true
        // this.formReadOnly = true
        this.activeName = 'base'
        if (method === 'edit') {
          this.method = method
          this.title = '客户信息修改'
        } else {
          this.method = 'view'
          this.title = '客户信息详情'
        }
        this.inputForm = {
          id: '',
			createTime: '',
          createBy: {
            id: '',
            name: this.$store.state.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
          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.workAttachmentDtoList)) {
              this.inputForm.workAttachmentDtoList = []
            }
            if (this.commonJS.isEmpty(this.inputForm.isUscCode)) {
              this.inputForm.isUscCode = '1'
            }
            if (this.commonJS.isEmpty(this.inputForm.createBy.name)) {
              this.inputForm.createBy.name = this.$store.state.user.name
            }
            if (this.commonJS.isEmpty(this.inputForm.officeId)) {
              this.inputForm.officeId = this.$store.state.user.office.id
            }
            if (this.commonJS.isEmpty(this.inputForm.companyLevel)) {
              this.inputForm.companyLevel = '1'
            }
            // if (this.formReadOnly) {
            //   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
              }
            })
            // 获取关联项目信息
            projectRecordsService.getByClientId(this.inputForm.id, this.projectForm).then((data) => {
              this.projectList = data
            })
            // 获取关联合同信息
            contractInfoService.getByClientId(this.inputForm.id, this.contractForm).then((data) => {
              this.contractList = data
            })
            // 获取关联报告信息
            projectReportService.getIdByClientId(this.inputForm.id, this.reportForm).then((data) => {
              this.reportList = data
            })
            // 查询关联发票信息
            cwFinanceInvoiceService.getIdByClientId(this.inputForm.id, this.invoiceForm).then((data) => {
              let _this = this
              let _data = data
              const wait = function () {
                return new Promise((resolve, reject) => {
                  _this.invoiceList = _data
                  resolve()
                })
              }
              wait().then(() => {
                this.invoiceList.forEach(item => {
                  item.account = parseFloat(item.account).toFixed(2)
                  if (!this.commonJS.isEmpty(item.financeInvoiceDetailDTOList)) {
                    item.accountDetail = 0
                    let num = ''
                    item.financeInvoiceDetailDTOList.forEach((detail, index) => {
                      if (!this.commonJS.isEmpty(detail.account)) {
                        item.accountDetail = parseFloat(parseFloat(item.accountDetail) + parseFloat(detail.account)).toFixed(2)
                      }
                      if ((index + 1) !== item.financeInvoiceDetailDTOList.length) {
                        num = num + detail.number + ','
                      } else {
                        num = num + detail.number
                      }
                    })
                    item.number = num
                  } else {
                    item.number = ''
                    item.accountDetail = ''
                  }
                })
              })
            })
            this.loading = false
          })
        })
      },
      saveForm (callback) {
        this.doSubmit('save', callback)
      },
      startForm (callback) {
        if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList)) {
          this.$message.error('“客户联系人”信息中至少有一条数据')
          throw new Error('“客户联系人”信息中至少有一条数据')
        } else {
          this.doSubmit('start', callback)
        }
      },
      async agreeForm (callback) {
        await workClientService.queryById(this.inputForm.id).then((data) => {
          if (data.status !== '2') { // 审核状态不是“待审核”，就弹出提示
            this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
            throw new Error()
          } else {
            this.doSubmit('agree', callback)
          }
        })
      },
      // 表单提交
      doSubmit (status, callback) {
        if (status === 'save') {
          // 暂存
          // this.inputForm.status = '1'
          this.loading = true
          if (this.commonJS.isEmpty(this.inputForm.cwWorkClientContactDTOList)) {
            this.$message.error('“客户联系人”信息中至少有一条数据')
            this.loading = false
            throw new Error('“客户联系人”信息中至少有一条数据')
          }
          this.billingSubmit()
          this.contactSubmit()
          this.baseSubmit()
          if (this.$refs.uploadComponent.checkProgress()) {
            this.loading = false
            return
          }
          this.inputForm.workAttachmentDtoList = this.$refs.uploadComponent.getDataList()
          // this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
          workClientService.saveForm(this.inputForm).then((data) => {
            // callback(data.businessTable, data.businessId, this.inputForm)
            this.loading = false
            this.close()
          }).catch(() => {
            this.loading = false
          })
          return
        } else if (status === 'start') {
          // 送审  待审核
          this.inputForm.status = '2'
        } else if (status === 'agree') {
          // 审核同意
          this.inputForm.agreeDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
          this.inputForm.agreeUserId = this.$store.state.user.id
          this.inputForm.status = '5'
        }
        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.createTime)) {
              this.inputForm.createTime = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
            }
            workClientService.saveForm(this.inputForm).then((data) => {
              callback(data.businessTable, data.businessId, this.inputForm)
              this.loading = false
            }).catch(() => {
              this.loading = false
            })
          }
        })
      },
      async updateStatusById (type) {
        if (type === 'reject' || type === 'reback') {
          if (await this.$refs.uploadComponent.checkProgress()) {
            this.loading = false
            throw new Error()
          }
          await workClientService.queryById(this.inputForm.id).then((data) => {
            if (data.status !== '2') { // status的值不等于“审核中”就弹出提示
              this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
              throw new Error()
            } else {
              if (type === 'reject') {
                // 驳回
                this.inputForm.status = '4'
                let param = {status: '4', id: this.inputForm.id}
                workClientService.updateStatusById(param)
              }
              if (type === 'reback') {
                // 撤回
                let param = {status: '3', id: this.inputForm.id}
                workClientService.updateStatusById(param)
              }
            }
          })
        }
      },
      close () {
        this.tableKeyBilling = Math.random()
        this.tableKeyContact = Math.random()
        this.inputForm = {
          id: '',
			createTime: '',
          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.$emit('refreshList')
        this.visible = false
      },
      tabHandleClick (event) {
        this.tableKeyBilling = Math.random()
        this.tableKeyContact = Math.random()
        // console.log(event)
      },
      rowStyle (event) {
        return 'cursor:pointer;'
      },
      async rowClick (event) {
        let id = this.gridData[event.rowIndex].companyid
        await this.enterpriseSearchService.enterpriseTicketInfo(id).then((data) => {
          this.inputForm.name = data.data.ENTNAME
        })
        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'
      },
      // 获取选择上一级公司后的回参
      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()
      },
      // 获取选择组织类型分类后的回参
      getOrganizationType (row) {
        this.inputForm.organizationType = row.id
        this.inputForm.organizationTypeName = row.name
      },
      // 选择组织类型分类
      openOrganizationType () {
        this.$refs.organizationTypeListForm.init()
      },
      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) {
        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 = ''
            })
          }
        }
      },
      // 打开项目详情组件
      viewProject (id) {
      	console.log('id',id)
        this.$refs.projectRecordsForm.init('view', id)
      },
      // 打开合同详情组件
      viewContract (id) {
        this.$refs.contractNameForm.init('view', id)
      },
      searchProject () {
        this.loading = true
        projectRecordsService.getByClientId(this.inputForm.id, this.projectForm).then((data) => {
          this.projectList = data
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      },
      refreshProjectForm () {
        this.$refs.projectForm.resetFields()
        this.searchProject()
      },
      searchContract () {
        this.loading = true
        contractInfoService.getByClientId(this.inputForm.id, this.contractForm).then((data) => {
          this.contractList = data
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      },
      refreshContractForm () {
        this.$refs.contractForm.resetFields()
        this.searchContract()
      },
      searchReport () {
        this.loading = true
        projectReportService.getIdByClientId(this.inputForm.id, this.reportForm).then((data) => {
          this.reportList = data
          this.loading = false
        })
      },
      refreshReportForm () {
        this.$refs.reportForm.resetFields()
        this.searchReport()
      },
      viewReport (id) {
        this.$refs.reportManagementForm.init('view', id)
      },
      searchInvoice () {
        this.loading = true
        cwFinanceInvoiceService.getIdByClientId(this.inputForm.id, this.invoiceForm).then((data) => {
          let _this = this
          let _data = data
          const wait = function () {
            return new Promise((resolve, reject) => {
              _this.invoiceList = _data
              resolve()
            })
          }
          wait().then(() => {
            this.invoiceList.forEach(item => {
              item.account = parseFloat(item.account).toFixed(2)
              if (!this.commonJS.isEmpty(item.financeInvoiceDetailDTOList)) {
                item.accountDetail = 0
                let num = ''
                item.financeInvoiceDetailDTOList.forEach((detail, index) => {
                  if (!this.commonJS.isEmpty(detail.account)) {
                    item.accountDetail = parseFloat(parseFloat(item.accountDetail) + parseFloat(detail.account)).toFixed(2)
                  }
                  if ((index + 1) !== item.financeInvoiceDetailDTOList.length) {
                    num = num + detail.number + ','
                  } else {
                    num = num + detail.number
                  }
                })
                item.number = num
              } else {
                item.number = ''
                item.accountDetail = ''
              }
            })
          })
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      },
      refreshInvoiceForm () {
        this.$refs.invoiceForm.resetFields()
        this.searchInvoice()
      },
      viewInvoice (flag, id) {
        this.$refs.invoiceFormDialog.init(flag, id)
      }
    }
  }
</script>
<style scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
<style>
  .vxe-select--panel{
    z-index: 3000 !important;
  }
</style>
