<template>
  <div class="supplier">
    <div class="search-supplier">
      <div class="title_wrap">
        <div class="enterprise_title">
          劳务分包队伍
        </div>
      </div>
      <div class="content-supplier">
        <el-form :model="formdata" label-width="82px" label-position="right"  :inline="true" >
          <el-row>
            <el-col :span="8">
            <el-form-item label="供应商名称">
              <el-input v-model="formdata.customerName" placeholder="请输入供应商名称"></el-input>
            </el-form-item>
            </el-col>
            <el-col :span="8">
            <el-form-item label="劳务队长">
              <el-input v-model="formdata.leaderName" placeholder="请输入劳务队长"></el-input>
            </el-form-item>
            </el-col>
            <el-col :span="8">
            <el-form-item label="注册城市">
              <el-cascader
                v-model="formdata.areas"
                :options="addressList" :collapse-tags="true" :show-all-levels="false" clearable
                :props="provienceprops"></el-cascader>
            </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
            <el-form-item label="供应商状态">
              <el-select v-model="formdata.customerState" multiple placeholder="请选择" :collapse-tags="true" clearable>
                <el-option v-for="(item,index) in customstate" :label="item.dictLabel" :value="item.dictValue" :key="index"></el-option>
              </el-select>
            </el-form-item>
            </el-col>
            <el-col :span="8">
            <el-form-item label="资质等级">
              <el-select v-model="formdata.credential" multiple placeholder="请选择" :collapse-tags="true" clearable>
                <el-option v-for="(item,index) in credential" :label="item.dictLabel" :value="item.dictValue" :key="index"></el-option>
              </el-select>
            </el-form-item>
            </el-col>
            <el-col :span="8">
            <el-form-item label="专业类别">
              <el-cascader clearable
                           v-model="formdata.groupSpecialtys"
                           :options="groupSpecialty" :collapse-tags="true"
                           :props="groupprops"></el-cascader>
            </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
            <el-form-item label="评价等级">
              <el-select v-model="formdata.creditLevel" multiple placeholder="请选择" :collapse-tags="true" clearable>
                <el-option v-for="(item,index) in creditlevel" :label="item.dictLabel" :value="item.dictValue" :key="index"></el-option>
              </el-select>
            </el-form-item>
            </el-col>
            <el-col :span="8">
            <el-form-item label="纳税人身份">
              <el-select v-model="formdata.paytaxType" multiple placeholder="请选择" :collapse-tags="true" clearable>
                <el-option v-for="(item,index) in paytaxtype" :label="item.dictLabel" :value="item.dictValue" :key="index"></el-option>
              </el-select>
            </el-form-item>
            </el-col>
            <el-col :span="8">
            <el-form-item label="纳税人税率">
              <el-select v-model="formdata.taxRate" multiple placeholder="请选择" :collapse-tags="true" clearable>
                <el-option v-for="(item,index) in taxrate" :label="item.dictLabel" :value="item.dictValue" :key="index"></el-option>
              </el-select>
            </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="准入时间">
                <el-date-picker
                  v-model="formdata.times"
                  type="daterange"
                  value-format="yyyy-MM-dd"
                  range-separator="至"
                  start-placeholder="年/月/日"
                  end-placeholder="年/月/日">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="队长身份证">
                <el-input v-model="formdata.laborCaptainIdCard" placeholder="请输入队长身份证"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="身份证查重">
                <el-select v-model="isIdCardRepeat" placeholder="请选择"  clearable>
                  <el-option label="是" value="是"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-divider></el-divider>
          <el-form-item label="  ">
            <el-button type="primary" size="small" @click="handleCurrentChange(1)">查询</el-button>
            <el-button size="small" @click="clears">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div class="table-supplier">
      <div class="total-title">
        <div class="totals">共{{total}}条</div>
        <div class="btns">
          <p class="total-dc" @click="customerExport">
            <img src="@/assets/images/EXCEL.png" alt="">
            <span class="excel">导出EXCEL</span>
          </p>
          <el-button type="primary" @click="addPro">添加劳务队队长</el-button>
        </div>
      </div>
      <div class="table-item-jf table-item-jf1 empty-table" v-if="total == 0 && !isSkeleton">
        <img class="item-jf-img" src="@/assets/images/kong.png" alt="">
        <div class="item-jf-titel">暂无相关数据</div>
        <div class="item-jf-text">抱歉，暂无数据，试试更换搜索条件吧</div>
      </div>
      <skeleton v-if="isSkeleton"></skeleton>

      <div class="table-item-jf table-item" v-if="!isSkeleton&&tableData.length>0">
        <el-table :data="tableData" :header-cell-style="{ background:'#f0f3fa',color: 'rgba(35,35,35,0.8)'}"
                  v-sticky-header.always="{offsetTop : '-16px',offsetBottom : '-15px'}" class="table-item1 fixed-table" border highlight-current-row
                  :header-row-class-name="setHeaderRow" :cell-class-name="setCellClass" :row-class-name="setRowClass" :header-cell-class-name="setCellClass"
                  ref="theOwnerListTable">

          <el-table-column type="index" label="序号" :fixed="tableColumnFixed" width="60" :resizable="false">
            <template slot-scope="scope">
              <span>{{(formdata.pageNum - 1) *formdata.pageSize + scope.$index + 1}}</span>
            </template>
          </el-table-column>
          <el-table-column label="供应商编号" prop="customerCode" :fixed="tableColumnFixed" width="120" :resizable="false">
          </el-table-column>

          <el-table-column label="供应商名称" :fixed="tableColumnFixed" width="310" :resizable="false">
            <template slot-scope="scope">
              <div class="renling">
                <div style="display:flex;align-items:center">
                  <el-tooltip placement="top" v-if="scope.row.customerText.length>20">
                    <div slot="content">{{scope.row.customerText}}</div>
                    <div class="renling">
                      <router-link v-if="scope.row.companyId" :to="`/enterprise/${encodeStr(scope.row.companyId)}?path=cooperationRecord&companyName=${scope.row.customerName}`" tag="a"
                                   class="wordprimary" v-html="scope.row.customerName"></router-link>
                      <span v-else v-html="scope.row.customerName"></span>
                    </div>
                  </el-tooltip>
                  <div class="renling" v-else>
                    <router-link v-if="scope.row.companyId" :to="`/enterprise/${encodeStr(scope.row.companyId)}?path=cooperationRecord&companyName=${scope.row.customerName}`" tag="a"
                                 class="wordprimary" v-html="scope.row.customerName"></router-link>
                    <span v-else v-html="scope.row.customerName"></span>
                  </div>
                </div>
              </div>

            </template>

          </el-table-column>
          <el-table-column label="二级市场编码" width="120" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.secondaryCode||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="营业执照号码" min-width="180">
            <template slot-scope="scope">
              {{scope.row.unifySocialCode||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="推荐单位" min-width="280">
            <template slot-scope="scope">
              {{scope.row.recommendOrg||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="公司注册区域" min-width="120" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.registerRegion||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="公司注册省" min-width="120" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.registerProvince||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="公司注册城市" min-width="120" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.registerCity||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="法人代表" min-width="85" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.representative||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="公司联系人" min-width="120" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.contactPerson||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="联系人电话" min-width="120" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.contactPhone||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="注册资本(万元)" min-width="120" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.registerCapital||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="纳税人身份" min-width="120" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.paytaxType||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="纳税人税率(%)" min-width="120" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.taxRate||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="资质等级" min-width="85" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.credential||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="主项资质" min-width="85" :resizable="false">
            <template slot-scope="scope">
              --
            </template>
          </el-table-column>
          <el-table-column label="劳务资质" min-width="85" :resizable="false">
            <template slot-scope="scope">
              --
            </template>
          </el-table-column>
          <el-table-column label="施工队长" min-width="155" :resizable="false">
            <template slot-scope="scope">
              <span v-html="scope.row.leaderName||'--'"></span>
              <span v-if="scope.$index + 1 === 1 || scope.$index + 1 === 3" style="width: 64px;height: 22px;background: #FFECE8;border-radius: 2px;line-height: 22px;display: inline-block;text-align: center;color: #FF3C3C;margin-left: 8px;">经营风险</span>
            </template>
          </el-table-column>
          <el-table-column label="联系电话" min-width="120" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.laborCaptainPhone||'--'}}
            </template>
          </el-table-column>
          <el-table-column label="身份证号" min-width="180" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.laborCaptainIdcard||'--'}}
            </template>
          </el-table-column>
          <el-table-column label="队伍规模" min-width="85" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.serviceTeamPersonnum||'--'}}
            </template>
          </el-table-column>
          <el-table-column label="专业特长" min-width="85" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.serviceTeamSpeciality||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="准入时间" min-width="180" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.approveDate2||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="公司合作数量" min-width="120" :resizable="false">
            <template slot-scope="scope">
              {{scope.row.enterpriseCooperationCount||"--"}}
            </template>
          </el-table-column>
          <el-table-column label="合作项目数量" min-width="120" :resizable="false">
            <template slot-scope="scope">
              <span>{{scope.row.projectCooperationCount||"--"}}</span>
            </template>
          </el-table-column>
          <el-table-column label="分包商等级" min-width="120" :resizable="false">
            <template slot-scope="scope">
              <span class="wordprimary" @click="getFBS(scope.row)" v-if="scope.row.creditlevel">{{scope.row.creditLevel}}</span>
              <span v-else>--</span>
            </template>
          </el-table-column>
          <el-table-column label="链接" min-width="160" :resizable="false">
            <template slot-scope="scope">
              <span class="wordprimary tabs" @click="goAccess(scope.row)">准入</span>
              <span class="wordprimary tabs" @click="goAssessment(scope.row)">考评</span>
            </template>
          </el-table-column>
          <el-table-column label="资源平台分类" min-width="120" :resizable="false">
            <template slot-scope="scope">
              --
            </template>
          </el-table-column>

        </el-table>
      </div>
      <div class="pagination clearfix" v-show="total>formdata.pageSize">
        <el-pagination background :page-size="formdata.pageSize" :current-page.sync="formdata.pageNum" @current-change="handleCurrentChange" layout="prev, pager, next"
                       :total="total">
        </el-pagination>
      </div>
    </div>
    <el-dialog title="等级及状态变更" :visible.sync="fbsvisib" custom-class='dialog-supplier' >
      <skeleton v-if="fbsisSkeleton"></skeleton>
      <div class="table-item-jf table-item" v-if="!fbsisSkeleton&&tableData.length>0">
        <el-table :data="tableData" :header-cell-style="{ background:'#f0f3fa',color: 'rgba(35,35,35,0.8)'}"
                  v-sticky-header.always="{offsetTop : '-16px',offsetBottom : '10px'}" class="table-item1 fixed-table" border highlight-current-row>

          <el-table-column type="index" label="序号" width="60" :resizable="false">
            <template slot-scope="scope">
              <span>{{scope.$index + 1}}</span>
            </template>
          </el-table-column>
          <el-table-column label="处置时间" :resizable="false">
            <template slot-scope="scope">
              <span>{{scope.row.legalPerson||'--'}}</span>
            </template>
          </el-table-column>
          <el-table-column label="处置前状态" :resizable="false">
            <template slot-scope="scope">
              <span>{{scope.row.legalPerson||'--'}}</span>
            </template>
          </el-table-column>
          <el-table-column label="处置后状态" :resizable="false">
            <template slot-scope="scope">
              <span>{{scope.row.legalPerson||'--'}}</span>
            </template>
          </el-table-column>
          <el-table-column label="处置前等级" :resizable="false">
            <template slot-scope="scope">
              <span>{{scope.row.legalPerson||'--'}}</span>
            </template>
          </el-table-column>
          <el-table-column label="处置后等级" :resizable="false">
            <template slot-scope="scope">
              <span>{{scope.row.legalPerson||'--'}}</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-dialog>


    <!--添加劳务队队长-->
    <el-dialog
      :close-on-click-modal="false"
      class="new-dialog"
      :visible.sync="dialogVisible"
      title="劳务队长信息"
      width="500px">
      <el-form class="popform" label-width="160px" :model="queryParam" :rules="rules" ref="ruleForm">
        <el-form-item label="所属供应商企业" class="row" prop="cusomerName">
          <el-input type="text" placeholder="请输入所属供应商企业" @input="inputEnterpriseName" v-model="queryParam.cusomerName"></el-input>
          <div class="enterpriseList" v-if="enterpriseList.length > 0">
            <p @click="blurEnterpriseName(item)" v-for="item in enterpriseList">
              <el-tooltip placement="top" v-if="item.name.length>26">
                <div slot="content"  v-html="item.name"></div>
                <span v-html="item.name"></span>
              </el-tooltip>
              <span v-else v-html="item.name"></span>
            </p>
          </div>
        </el-form-item>
        <el-form-item label="企业统一社会信用代码" class="row">
          <el-input type="text" placeholder="请输入企业统一社会信用代码" v-model="queryParam.unifySocialCode"></el-input>
        </el-form-item>
        <el-form-item label="劳务队长姓名" class="row" prop="leaderName">
          <el-input type="text" placeholder="请输入劳务队长姓名" v-model="queryParam.leaderName"></el-input>
        </el-form-item>
        <el-form-item label="劳务队长身份证号码" class="row" prop="laborCaptainIdcard" :style="tip ?'margin-bottom:0px;':'margin-bottom:16px;'">
          <el-input type="text" placeholder="请输入劳务队长身份证号码" @input="inputLaborLeaderId" v-model="queryParam.laborCaptainIdcard"></el-input>
          <p class="tip" v-if="tip" style="color:#ff4949;">该身份证号已归属其他供应商企业。<span style="color:#0081FF;cursor: pointer;" @click="handleClick">查看异常</span></p>
        </el-form-item>
        <el-form-item label="联系电话" class="row" prop="laborCaptainPhone">
          <el-input type="text" placeholder="请输入联系电话" v-model="queryParam.laborCaptainPhone"></el-input>
        </el-form-item>
        <el-form-item label="队伍规模" class="row">
          <el-input type="text" placeholder="请输入队伍规模" v-model="queryParam.serviceTeamPersonnum"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleCancel">关闭</el-button>
        <el-button type="primary" @click="handleAdd">添加</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import { encodeStr } from '@/assets/js/common.js'
  import '@/assets/styles/public.scss'
  import '@/assets/styles/supplierlist.scss'
  import skeleton from '@/views/project/projectList/component/skeleton'
  import { areaAll, bizDictData, custmerInfolist,companyList,getLborLeaderId,addLaborLeader,exportCustomerList } from '@/api/supplier/supplier'
  import { getDicts } from '@/api/system/dict/data'
  import {queryConditionFiltering} from '@/utils/index'
  export default {
    name: 'laborSubcontractingTeam',
    components:{skeleton},
    data(){
      return{
        encodeStr,
        addressList:[],
        arealist:[],
        creditlevel:[],
        customstate:[],
        credential:[],
        paytaxtype:[],
        taxrate:[],
        groupSpecialty:[],
        provienceprops:{
          checkStrictly:false,
          multiple:true,
          label:'value',
        },
        groupprops:{
          checkStrictly:false,
          multiple:true,
          value:'id',
        },
        formdata:{
          customerClass:'劳务分包队伍',
          pageNum:1,
          pageSize:50,
          times:[],
          customerName:"",
          leaderName:"",
          areas:[],
          customerState:[],
          credential:[],
          groupSpecialtys:[],
          groupSpecialtyId:[],
          creditLevel:[],
          paytaxType:[],
          taxRate:[],
          registerProvince:[],
          registerCity:[],
          approveDate2Start:null,
          approveDate2End:null,
          laborCaptainIdCard:null,
        },
        tableData:[],
        isSkeleton:false,
        total:0,
        // table列是否悬浮
        tableColumnFixed: true,
        fbsvisib:false,
        fbsisSkeleton:false,
        dialogVisible:false,
        queryParam:{
          cusomerName:''
        },
        rules:{
          cusomerName:[{ required: true, message: '请输入所属供应商企业！', trigger: 'blur' },],
          laborCaptainIdcard:[{ required: true, message: '请输入劳务队长身份证号码', trigger: 'blur' },],
          leaderName:[{ required: true, message: '请输入劳务队长姓名', trigger: 'blur' },],
          laborCaptainPhone:[{ required: true, message: '请输入联系电话', trigger: 'blur' },],
        },
        enterpriseList:[],
        tip:false,
        isIdCardRepeat:'',
      }
    },
    watch: {
      dialogVisible: {
        handler(newValue) {
          if(!newValue){
            this.enterpriseList=[]
          }
        }
      },
    },
    created() {
      this.init()
      this.cusoomerInfolist()
    },
    methods:{
      init(){
        //评价等级
        getDicts('credit_level').then(res=>{
          this.creditlevel = res.data
        })
        //供应商状态
        getDicts('custom_state').then(res=>{
          this.customstate = res.data
        })
        //纳税人身份
        getDicts('paytaxtype').then(res=>{
          this.paytaxtype = res.data
        })
        //纳税人税率
        getDicts('taxrate').then(res=>{
          this.taxrate = res.data
        })
        //资质等级
        getDicts('credential').then(res=>{
          this.credential = res.data
        })
        // this.dataRegion()
        //专业类别
        bizDictData().then(res=>{
          this.groupSpecialty = res.data
        })
        // 地区树
        areaAll().then(res=>{
          this.addressList = res.data
        })
      },
      clears(){
        this.formdata = {
          customerClass: '劳务分包队伍',
          pageNum: 1,
          pageSize: 50,
          times: [],
          customerName: '',
          leaderName: '',
          areas: [],
          customerState: [],
          credential: [],
          groupSpecialtys: [],
          groupSpecialtyId: [],
          creditLevel: [],
          paytaxType: [],
          taxRate: [],
          registerProvince: [],
          registerCity: [],
          approveDate2Start: null,
          approveDate2End: null
        }
        this.cusoomerInfolist()
      },
      cusoomerInfolist(){
        this.isSkeleton = true
        let param = this.formdata
        if(param.times){
          param.approveDate2Start = param.times[0]
          param.approveDate2End = param.times[1]
        }else{
          param.approveDate2Start = ''
          param.approveDate2End = ''
        }
        param.groupSpecialtyId = []
        if(param.groupSpecialtys){
          param.groupSpecialtys.forEach(item=>{
            param.groupSpecialtyId.push(item[item.length-1])
          })
        }
        if(param.areas){
          let province = []
          let city = []
          param.areas.forEach(item=>{
            if(item.length == 3){//到市
              if(item[1].indexOf('重庆')>-1||item[1].indexOf('北京')>-1||item[1].indexOf('天津')>-1||item[1].indexOf('上海')>-1){
                province.push(item[1])
              }else{
                city.push(item[2])
              }
            }
          })
          param.registerProvince = province
          param.registerCity = city
        }else{
          param.registerProvince = []
          param.registerCity = []
        }
        if(this.isIdCardRepeat === '是'){
          param.isIdCardRepeat=true
        }else {
          delete param.isIdCardRepeat
        }
        custmerInfolist(queryConditionFiltering(this.formdata)).then(res=>{
          this.isSkeleton = false
          this.tableData = res.rows
          this.total = res.total
          this.tableData.forEach(item=>{
            item.customerText = item.customerName.replace(/<\/?[^>]+(style=('|")[^'"]*)?>/gi, '')
          })
        })
      },
      handleCurrentChange(val){
        this.formdata.pageNum = val
        this.cusoomerInfolist()
      },
      setHeaderRow() {
        return "owner-table-list-header";
      },
      setCellClass({ row, column, rowIndex, columnIndex }) {
        if (columnIndex == 1) {
          return "enterprise-name-column";
        }
      },
      setRowClass({ row, rowIndex }) {
        return "enterprise-name-row";
      },
      //点击分包商等级
      getFBS(row){
        this.fbsvisib = true
        this.fbsisSkeleton = true
      },
      //点击准入
      goAccess(row){
        this.$tab.openPage(row.customerName+'-准入情况', '/supplier/supplierlist/access',{customerKey:row.customerKey})
      },
      //点击考评
      goAssessment(row){
        this.$tab.openPage(row.customerName+'-供应商考评', '/supplier/supplierlist/assessment')
      },
      addPro(){
        this.dialogVisible=true;
      },
      customerExport(){
        let param = this.formdata;
        param.customerClass='劳务分包队伍'
        if(param.times){
          param.approveDate2Start = param.times[0]
          param.approveDate2End = param.times[1]
        }else{
          param.approveDate2Start = ''
          param.approveDate2End = ''
        }
        param.groupSpecialtyId = []
        if(param.groupSpecialtys){
          param.groupSpecialtys.forEach(item=>{
            param.groupSpecialtyId.push(item[item.length-1])
          })
        }
        if(param.areas){
          let province = []
          let city = []
          param.areas.forEach(item=>{
            if(item.length == 3){//到市
              if(item[1].indexOf('重庆')>-1||item[1].indexOf('北京')>-1||item[1].indexOf('天津')>-1||item[1].indexOf('上海')>-1){
                province.push(item[1])
              }else{
                city.push(item[2])
              }
            }
          })
          param.registerProvince = province
          param.registerCity = city
        }else{
          param.registerProvince = []
          param.registerCity = []
        }
        if(this.isIdCardRepeat === '是'){
          param.isIdCardRepeat=true
        }else {
          delete param.isIdCardRepeat
        }
        delete param.pageNum
        delete param.pageSize


        exportCustomerList(param).then(blob => {
          this.$download.saveAs(blob, `劳务分包队伍.xlsx`)
        })
      },
      //模糊查询
      inputEnterpriseName(){
        if(this.queryParam.cusomerName.length === 0){
          this.enterpriseList=[]
          return
        }
        let pram = {
          keyword:this.queryParam.cusomerName,
          page:{page: 1, limit: 20}
        }
        companyList(pram).then(res=>{
          if(res.code == 200){
            this.enterpriseList=res.data.list;
          }else{

          }
        })
      },
      inputLaborLeaderId(){
        getLborLeaderId(this.queryParam.laborCaptainIdcard).then(res=>{
          if(res.code == 200){
            if(res.data){
              this.tip=true;
              this.tableDataList=res.data;
            }else {
              this.tip=false;
              this.tableDataList=[];
            }
          }
        })
      },
      handleClick(){
        this.dialogVisible=false;
        this.tip=false;
        this.tableDataList=[];
        this.tableData = this.tableDataList;
        this.tableData.forEach(item=>{
          item.customerText = item.customerName.replace(/<\/?[^>]+(style=('|")[^'"]*)?>/gi, '')
        })
        this.queryParam={
          cusomerName:'',
          unifySocialCode:'',
          leaderName:'',
          laborCaptainIdcard:'',
          laborCaptainPhone:'',
          serviceTeamPersonnum:'',
        }
      },
      blurEnterpriseName(item){
        this.queryParam.unifySocialCode=item.creditCode
        this.queryParam.cusomerName=item.name.replace(/<[^>]+>/g,'');
        this.enterpriseList=[]
      },
      handleAdd(){
        let pram = {
          ...this.queryParam
        }
        pram.serviceTeamPersonnum=Number(pram.serviceTeamPersonnum);
        if(this.tip){
          pram.badReason='挂靠风险';
          pram.badBehaviorSituation=this.queryParam.leaderName+'已存在'+this.queryParam.cusomerName+'，存在挂靠风险';
          pram.dataSource=1
        }else {
          delete pram.badReason
          delete pram.badBehaviorSituation
        }
        addLaborLeader(pram).then(res=>{
          if(res.code == 200){
            this.dialogVisible=false;
            this.tip=false;
            this.cusoomerInfolist();
            this.$message({
              message: '新增成功',
              type: 'success'
            });
            this.queryParam={
              cusomerName:'',
              unifySocialCode:'',
              leaderName:'',
              laborCaptainIdcard:'',
              laborCaptainPhone:'',
              serviceTeamPersonnum:'',
            }
          }
        })
      },
      handleCancel(){
        this.dialogVisible=false;
        this.tip=false;
        this.queryParam={
          cusomerName:'',
          unifySocialCode:'',
          leaderName:'',
          laborCaptainIdcard:'',
          laborCaptainPhone:'',
          serviceTeamPersonnum:'',
        }
      },
    }
  }
</script>

<style scoped lang="scss">
  .supplier{
    .total-title{
      height: 36px;
      line-height: 36px;
      .btns{
        float: right;
        display: inline-block;
        text-align: right;
        ::v-depp .el-button--medium{
          padding: 10px;
        }

        .total-dc {
          cursor: pointer;
          margin-right: 16px;
          float: left;
          img {
            width: 18px;
            margin-right: 6px;
            margin-top: -4px;
          }
          color: rgba(35, 35, 35, 0.8);
        }
      }
    }
    ::v-deep .new-dialog {
      .el-dialog__header{
        border-bottom: 1px solid #eee;
      }
      .el-dialog__footer{
        border-top: 1px solid #eee;
        padding-top:20px;
      }
      .el-dialog__body {
        padding: 20px 20px 0 20px;
      }
      .el-form-item {
        margin-bottom: 16px;
      }
      .enterpriseList{
        width: 300px;
        height: 176px;
        border-radius: 4px;
        background: #ffffff;
        position: absolute;
        box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.12);
        border: 1px solid #E4E7ED;
        z-index: 9;
        top:40px;
        padding-top: 8px;
        overflow: auto;
        cursor: pointer;
        p{
          height: 32px;
          line-height: 32px;
          color:#232323;
          font-size: 14px;
          padding-left: 20px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        p:hover{
          background: #F5F7FA;
        }
      }
    }
  }


</style>

