<!--
  @description: 驱动内-抽取专家-抽取申请
  @Modifier: haofx
  @routerPath:/bidding/projectDrive/extractApply
  @date: 2020/8/26-13:27
-->
<template>
  <div class="main">
    <!-- 1 抽取申请 -->
    <section>
      <div class="page-title">
        <span>1 抽取申请</span>
      </div>
      <el-form :model="allData" inline>
        <table class="from_table">
          <!--抽取申请编号--->
          <tr>
            <td>
              <el-form-item label="抽取申请编号" prop="applyCode" />
            </td>
            <td colspan="3">
              <el-input v-model="allData.applyCode" style="width:90%" disabled />
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item label="评标阶段" prop="stageType" />
            </td>
            <td>
              <el-radio-group v-model="allData.stageType">
                <el-radio label="00">
                  资格预审
                </el-radio>
                <el-radio label="01">
                  资格后审
                </el-radio>
              </el-radio-group>
            </td>
            <td>
              <el-form-item label="专家确定方式" prop="rakeType" />
            </td>
            <td>
              <el-radio-group v-model="allData.rakeType" :disabled="!!typeIs">
                <el-radio label="00">
                  随机抽取
                </el-radio>
                <el-radio label="01">
                  直接指定
                </el-radio>
              </el-radio-group>
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item label="评标开始时间" prop="startTime" />
            </td>
            <td>
              <el-date-picker
                v-model="allData.startTime"
                :format="elValueFormat"
                :value-format="elValueFormat"
                type="date"
                placeholder="选择日期"
              />
            </td>
            <td>
              <el-form-item label="评标结束时间" prop="endTime" />
            </td>
            <td>
              <el-date-picker
                v-model="allData.endTime"
                :format="elValueFormat"
                :value-format="elValueFormat"
                type="date"
                placeholder="评标结束时间"
                style="width: 90%"
              />
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item label="专家人数" prop="expertNum" />
            </td>
            <td>
              <el-input
                v-model="allData.expertNum"
                placeholder="请输入专家人数"
                type="number"
                min="0"
              />
            </td>
            <td>
              <el-form-item label="业主代表人数" prop="ownerNum" />
            </td>
            <td>
              <el-input
                v-model="allData.ownerNum"
                placeholder="请输入业主代表人数"
                type="number"
                min="0"
              />
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item ref="area" label="评标地点" prop="area" />
            </td>
            <td colspan="3">
              <el-cascader
                v-model="allData.area"
                :options="regionData"
                style="width:31%"
                @change="addressChangeF"
              />
              <el-input v-model="allData.adress" style="width:60%" />
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item label="抽取回避" />
            </td>
            <td colspan="3">
              <el-input v-model="allData.attendDay" class="only_input" style="width:10%" />天内参加过评标的专家不再抽取 一个月参加过
              <el-input v-model="allData.attendCount" class="only_input" style="width:10%" />次评标的专家不再抽取
            </td>
          </tr>
        </table>
      </el-form>
    </section>
    <!-- 2 设置抽取条件 -->
    <section v-if="extractMethod">
      <div class="page-title">
        <span>2 设置抽取条件</span>
        <el-button style="margin-left: 16px" type="primary" plain @click="addExtractCondition">
          添加
        </el-button>
      </div>
      <expertSepcialDialog
        ref="expertSelectworkunitDialog"
        :title="types"
        @dialogExpertSepcialList="dialogExpertSepcialList"
      />
      <!--抽取条件点击弹框-->
      <el-dialog
        :title="textMap[dialogStatus]+`抽取条件`"
        :visible.sync="extractingConditions"
        width="560px"
        @close="closeDialog('extractForm')"
      >
        <div>
          <el-form
            ref="extractForm"
            :model="extractForm"
            :rules="rules"
            label-position="right"
            label-width="120px"
          >
            <el-form-item label="抽取专业" class="publicTitle_f" prop="specialName">
              <el-input
                v-model="extractForm.specialName"
                placeholder="抽取专业"
                style="width: calc(100% - 130px)"
                disabled
              />
              <el-button type="primary" @click="changeSelect('1')">
                选择
              </el-button>
              <el-button @click="clearSelect('1')">
                清空
              </el-button>
            </el-form-item>
            <el-form-item ref="areaD" label="抽取专家地区" prop="areaD">
              <el-cascader
                v-model="extractForm.areaD"
                :options="regionData"
                style="width:100%;"
                change-on-select
                @change="addressChange"
              />
            </el-form-item>
            <el-form-item label="抽取人数" class="publicTitle_f" prop="expertNum">
              <el-input
                v-model="extractForm.expertNum"
                placeholder="抽取人数"
              />
            </el-form-item>
            <el-form-item label="备选专业" class="publicTitle_f" prop="spareMajorName">
              <el-input
                v-model="extractForm.spareMajorName"
                placeholder="备选专业"
                style="width: calc(100% - 130px)"
                disabled
              />
              <el-button type="primary" @click="changeSelect('0')">
                选择
              </el-button>
              <el-button @click="clearSelect('0')">
                清空
              </el-button>
            </el-form-item>
          </el-form>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitExtractForm">
            确 定
          </el-button>
          <el-button @click="extractingConditions = false">
            取 消
          </el-button>
        </div>
      </el-dialog>
      <div>
        <el-table :data="tableData">
          <el-table-column type="index" label="序号" width="60" align="center" />
          <el-table-column label="评标专业" align="center" prop="specialName" />
          <el-table-column label="抽取人数" align="center" prop="expertNum" />
          <el-table-column label="抽取专家地区" align="center" prop="cityName" />
          <el-table-column label="备选专业" align="center" prop="spareMajorName" />
          <el-table-column label="操作" align="center" width="120">
            <template slot-scope="scope">
              <el-link type="primary" @click="handleDelete(scope.row,scope.$index)">
                [删除]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </section>
    <!-- 3 回避专家 -->
    <el-form v-if="!extractMethod" ref="form" label-width="160px">
      <div class="page-title">
        <span>3 录入专家</span>
        <el-button style="margin-left: 16px" type="primary" plain @click="addExpert">
          添加
        </el-button>
      </div>
      <div>
        <el-table :data="entryExpertList">
          <el-table-column label="序号" align="center" type="index" />
          <el-table-column label="专家姓名" align="center" prop="expertName" />
          <el-table-column label="专家身份证号" align="center" prop="certificateCode" />
          <el-table-column label="专业" align="center" prop="specialName" />
          <el-table-column label="区域" align="center" prop="area" />
          <el-table-column label="联系方式" align="center" prop="mobile" />
          <el-table-column label="操作" align="center" width="120">
            <template slot-scope="scope">
              <el-link type="primary" @click="handleDeleteExpertDirect(scope.row,scope.$index)">
                [删除]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-dialog :visible.sync="addExpertVisible" title="录入专家">
        <el-form ref="expertSearch" :model="expertSearch" inline>
          <el-form-item label="专家姓名">
            <el-input v-model="expertSearch.expertName" />
          </el-form-item>
          <el-form-item label="专家身份证号">
            <el-input v-model="expertSearch.certificateCode" />
          </el-form-item>
          <div class="fr">
            <el-button @click="expertSearchFn">
              查询
            </el-button>
            <el-button @click="resetFn">
              重置
            </el-button>
          </div>
        </el-form>
        <el-table :data="expertData" @selection-change="handleSelectionChangeExpert">
          <el-table-column type="selection" />
          <el-table-column label="序号" type="index" />
          <el-table-column label="专家姓名" prop="realName" />
          <el-table-column label="专家身份证号" prop="certificateCode" />
          <el-table-column label="专业" prop="specialName">
            <template slot-scope="{row}">
              {{ row.specialName ? row.specialName :"暂无数据" }}
            </template>
          </el-table-column>
          <el-table-column label="区域" prop="area">
            <template slot-scope="{row}">
              {{ row.area ? row.area :"暂无数据" }}
            </template>
          </el-table-column>
          <el-table-column label="联系方式" prop="mobile" />
        </el-table>
        <el-row class="pagination p16">
          <div class="page-number fl">
            共{{ Math.ceil(expertTotal/expertSearch.pageSize) }}页 {{ expertTotal }}条
          </div>
          <el-pagination
            :current-page="expertSearch.page"
            :page-size="expertSearch.pageSize"
            :total="expertTotal"
            layout="prev, pager, next, sizes"
            class="fr"
            background
            @current-change="pickHandleEx"
            @size-change="handleSizeProjectChangeEx"
          />
        </el-row>
        <div slot="footer" class="dialog-footer" style="text-align: center">
          <el-button type="primary" @click="addDirect">
            确 定
          </el-button>
          <el-button @click="addExpertVisible = false">
            取 消
          </el-button>
        </div>
      </el-dialog>
    </el-form>
    <!-- 3 录入采购方代表 -->
    <el-form ref="form" label-width="160px">
      <div class="page-title">
        <span>3 录入采购方代表</span>
        <el-button style="margin-left: 16px" type="primary" plain @click="addExtractConditions">
          添加
        </el-button>
      </div>

      <div>
        <el-table :data="purchaserList">
          <el-table-column type="index" label="序号" width="60" align="center" />
          <el-table-column label="专家姓名" align="center" prop="name" />
          <el-table-column label="身份证号" align="center" prop="idCard" />
          <el-table-column label="手机号" align="center" prop="mobilePhone" />
          <el-table-column label="性别" align="center" prop="sex">
            <template slot-scope="scope">
              <span v-if="scope.row.sex==='00'">男</span>
              <span v-if="scope.row.sex==='01'">女</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" width="120">
            <template slot-scope="scope">
              <el-link type="primary" @click="removeConditList(scope.$index,'purchaserList')">
                [删除]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
      </div>

      <el-dialog
        :visible.sync="conditions"
        title="添加采购方代表"
      >
        <el-form ref="purchaseSearchs" :model="purchaseSearchs" inline>
          <el-form-item label="姓名">
            <el-input v-model="purchaseSearchs.name" />
          </el-form-item>
          <el-form-item label="身份证号">
            <el-input v-model="purchaseSearchs.idCard" />
          </el-form-item>
          <div class="fr">
            <el-button @click="purchaseSearchFn">
              查询
            </el-button>
            <el-button @click="resetFn">
              重置
            </el-button>
          </div>
        </el-form>
        <!--录入采购方代表弹框表格-->
        <el-table :data="purchaserListData" @selection-change="handleSelectionChangePurchaser">
          <el-table-column type="selection" />
          <el-table-column label="序号" type="index" />
          <el-table-column label="姓名" prop="name" />
          <el-table-column label="身份证号" prop="idCard" />
          <el-table-column label="手机号" prop="mobilePhone" />
          <el-table-column label="性别" prop="sex">
            <template slot-scope="scope">
              <span v-if="scope.row.sex==='00'" type="primary">男</span>
              <span v-if="scope.row.sex==='01'" type="primary">女</span>
            </template>
          </el-table-column>
        </el-table>

        <el-row class="pagination p16">
          <div class="page-number fl">
            共{{ Math.ceil(expertTotal/purchaseSearchs.pageSize) }}页 {{ expertTotal }}条
          </div>
          <el-pagination
            :current-page="purchaseSearchs.page"
            :page-size="purchaseSearchs.pageSize"
            :total="expertTotal"
            layout="prev, pager, next, sizes"
            class="fr"
            background
            @current-change="pickHandleEx"
          />
          <!-- @size-change="handleSizePurchaserChangeEx" -->
        </el-row>
        <div slot="footer" class="dialog-footer" style="text-align: center">
          <el-button type="primary" @click="ensure">
            确 定
          </el-button>
          <el-button @click="conditions = false">
            取 消
          </el-button>
        </div>
      </el-dialog>

      <!--添加专家弹框-->
      <!-- <el-dialog
        :visible.sync="conditions"
        title="添加专家"
        width="560px"
        @close="closeDialog('extractForm')"
      >
        <div>
          <el-row>
            <el-col>
              <el-form ref="expertFrom" :model="expertFrom" :rules="rules" :inline-message="true">
                <table class="from_table" style="margin-top:10px"> -->
      <!--毕业院校--->
      <!-- <tr>
                    <td>
                      <el-form-item label="姓名" prop="realName" />
                    </td>
                    <td>
                      <el-input
                        v-model="expertFrom.realName"
                        placeholder="姓名"
                        style="width:calc(100% - 140px)"
                      />
                      <el-button
                        @click="addConditionData"
                      >添加</el-button>
                    </td>
                  </tr> -->
      <!--身份证号--->
      <!-- <tr>
                    <td>
                      <el-form-item label="身份证号" prop="certificateCode" />
                    </td>
                    <td>
                      <el-input
                        v-model.trim="expertFrom.certificateCode"
                        placeholder="身份证号"
                        class="show-word-limit-padding"
                      />
                    </td>
                  </tr> -->
      <!--手机号-->
      <!-- <tr>
                    <td>
                      <el-form-item label="手机号 " prop="mobile" />
                    </td>
                    <td>
                      <el-input
                        v-model.trim="expertFrom.mobile"
                        placeholder="手机号"
                        class="show-word-limit-padding"
                      />
                    </td>
                  </tr> -->
      <!--性别-->
      <!-- <tr>
                    <td>
                      <el-form-item label="性别" prop="sex" />
                    </td>
                    <td>
                      <el-radio-group v-model="expertFrom.sex">
                        <el-radio
                          v-for="item in sex"
                          :key="item.typecode"
                          :label="item.typename"
                          :value="item.typecode"
                        />
                      </el-radio-group>
                    </td>
                  </tr>
                </table> -->
      <!-- </el-form>
            </el-col>
          </el-row>
          <div slot="footer" class="dialog-footer" style="text-align: center">
            <el-button type="primary" @click="submitExtractConditions">确 定</el-button>
            <el-button @click="conditions = false">取 消</el-button>
          </div>
        </div>
      </el-dialog> -->
    </el-form>
    <!-- 4 设置回避单位 -->
    <el-form v-if="extractMethod" ref="form" label-width="160px">
      <div class="page-title">
        <span>4 设置回避单位</span>
        <el-button style="margin-left: 16px" type="primary" plain @click="avoidUnitFn">
          添加
        </el-button>
      </div>
      <!--回避单位弹框-->
      <el-dialog
        :title="textMap[dialogStatus]+`回避单位`"
        :visible.sync="avoidUnit"
        width="560px"
      >
        <div>
          <el-form
            ref="avoidUnitForm"
            :model="avoidUnitForm"
            :rules="avoidUnitFormrules"
            label-position="right"
            label-width="100px"
          >
            <el-form-item label="机构代码" prop="avoidOrgcode">
              <el-input v-model="avoidUnitForm.avoidOrgcode" placeholder="机构代码" style="width: calc(100% - 130px)" />
              <el-button type="primary" @click="changeAvoidUnit">
                选择
              </el-button>
              <el-button @click="clearUnit">
                清空
              </el-button>
            </el-form-item>
            <el-form-item label="机构名称" prop="avoidCompany">
              <el-input v-model="avoidUnitForm.avoidCompany" placeholder="机构名称" />
            </el-form-item>
            <el-form-item label="回避原因" prop="reason">
              <el-radio-group v-model="avoidUnitForm.reason">
                <el-radio
                  v-for="item in reason"
                  :key="item.typecode"
                  :label="item.typecode"
                >
                  {{ item.typename }}
                </el-radio>
              </el-radio-group>
            </el-form-item>
          </el-form>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="saveAvoidUnit">
            确 定
          </el-button>
          <el-button @click="avoidUnit = false">
            取 消
          </el-button>
        </div>
      </el-dialog>
      <!-- 回避单位选择 -->
      <el-dialog :visible.sync="agencyDialogVisible" :close-on-click-modal="false" title="回避单位选择">
        <el-form :model="companySearch" inline>
          <el-form-item label="单位名称">
            <el-input v-model="companySearch.comName" style="width:120px" />
          </el-form-item>
          <el-form-item label="组织机构代码">
            <el-input v-model="companySearch.comCode" style="width:120px" />
          </el-form-item>
          <div class="fr">
            <el-button type="primary" @click="searchCompany">
              查询
            </el-button>
            <el-button @click="resetCompany">
              重置
            </el-button>
          </div>
        </el-form>
        <div>
          <el-table :data="companyList" highlight-current-row @current-change="handleCurrentChange">
            <el-table-column type="index" label="序号" />
            <el-table-column label="单位名称" prop="comName" />
            <el-table-column label="组织机构代码" prop="comCode" />
          </el-table>
        </div>

        <el-row class="pagination p16">
          <div class="page-number fl">
            共{{ Math.ceil(total/companySearch.pageSize) }}页 {{ total }}条
          </div>
          <el-pagination
            :current-page="companySearch.page"
            :page-size="companySearch.pageSize"
            :total="total"
            layout="prev, pager, next, sizes"
            class="fr"
            background
            @current-change="pickHandleCom"
            @size-change="handleSizeChangeCom"
          />
        </el-row>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="addComNameCode">
            确 定
          </el-button>
          <el-button @click="agencyDialogVisible = false">
            取 消
          </el-button>
        </div>
      </el-dialog>
      <!-- 回避单位 -->
      <div>
        <el-table :data="avoidData">
          <el-table-column type="index" label="序号" width="60" align="center" />
          <el-table-column label="机构代码" align="center" prop="avoidOrgcode" />
          <el-table-column label="机构名称" align="center" prop="avoidCompany" />
          <el-table-column label="回避原因" align="center" prop="reason">
            <template slot-scope="scope">
              {{ reason.find(item=>item.typecode==scope.row.reason).typename }}
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" width="120">
            <template slot-scope="scope">
              <el-link type="primary" @click="handleDeleteAvoid(scope.row,scope.$index)">
                [删除]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-form>
    <!-- 5 回避专家 -->
    <el-form v-if="extractMethod" ref="form" label-width="160px">
      <div class="page-title">
        <span>5 回避专家</span>
        <el-button style="margin-left: 16px" type="primary" plain @click="avoidExpertFn">
          添加
        </el-button>
      </div>
      <!--回避专家弹框-->
      <el-dialog
        :title="textMap[dialogStatus]+`回避专家`"
        :visible.sync="avoidExpert"
      >
        <el-form ref="expertSearch" :model="expertSearch" inline>
          <el-form-item label="专家姓名">
            <el-input v-model="expertSearch.expertName" style="width:140px" />
          </el-form-item>
          <el-form-item label="专家身份证号">
            <el-input v-model="expertSearch.certificateCode" style="width:140px" />
          </el-form-item>
          <div class="fr" style="float:right">
            <el-button type="primary" @click="expertSearchFn">
              查询
            </el-button>
            <el-button @click="resetFn">
              重置
            </el-button>
          </div>
        </el-form>
        <el-table :data="expertData" @selection-change="handleSelectionChangeExpert">
          <el-table-column type="selection" />
          <el-table-column label="序号" type="index" />
          <el-table-column label="专家姓名" prop="realName" />
          <el-table-column label="专家身份证号" prop="certificateCode" />
          <el-table-column label="专业" prop="specialName">
            <template slot-scope="{row}">
              {{ row.specialName ? row.specialName :"暂无数据" }}
            </template>
          </el-table-column>
          <el-table-column label="区域" prop="area">
            <template slot-scope="{row}">
              {{ row.area ? row.area :"暂无数据" }}
            </template>
          </el-table-column>
          <el-table-column label="联系方式" prop="mobile" />
        </el-table>
        <el-row class="pagination p16">
          <div class="page-number fl">
            共{{ Math.ceil(expertTotal/expertSearch.pageSize) }}页 {{ expertTotal }}条
          </div>
          <el-pagination
            :current-page="expertSearch.page"
            :page-size="expertSearch.pageSize"
            :total="expertTotal"
            layout="prev, pager, next, sizes"
            class="fr"
            background
            @current-change="pickHandleEx"
            @size-change="handleSizeProjectChangeEx"
          />
        </el-row>
        <div slot="footer" class="dialog-footer" style="text-align: center">
          <el-button type="primary" @click="addAvoidExpert">
            确 定
          </el-button>
          <el-button @click="avoidExpert = false">
            取 消
          </el-button>
        </div>
      </el-dialog>
      <!-- 回避专家 -->
      <div>
        <el-table :data="avoidExpertData">
          <el-table-column type="index" label="序号" width="60" align="center" />
          <el-table-column label="专家姓名" align="center" prop="expertName" />
          <el-table-column label="身份证号" align="center" prop="certificateCode" />
          <el-table-column label="手机号" align="center" prop="mobile" />
          <el-table-column label="操作" align="center" width="120">
            <template slot-scope="scope">
              <el-link type="primary" @click="handleDeleteExpert(scope.row,scope.$index)">
                [删除]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-form>
    <!--保存按钮-->
    <div class="but_footer">
      <div class="but_footer-h">
        <div class="but_footer-but">
          <el-button @click="saveaddItem('00')">
            保存
          </el-button>
          <el-button type="primary" @click="saveItem('01')">
            提交
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* 接口*/
import { getTenderAndPackageList, submitOrsaveExtractApplyByTenderManager, getExtractExpertDetailById } from '@/api/expert/extractExpert/extractExpert'
import { getAlreadyExistExpertComName } from '@/api/expert/expertscloud'
import { getExpertList, getExpertCompanyList, getExpertDepartList } from '@/api/expert/extractExpert/extractExpert'
import { getDetailExpertCompanyList, getDetailExpertAvoidDepartList } from '@/api/expert/extractExpert/extractExpert'
import { getExtractApplyCode, queryAllRepresentList } from '@/api/expert/expertscloud'
/* 公用方法*/
import { linkerName, checkRate } from '@/assets/js/validate'

import { filterObj } from '@/assets/js/utils' // 过滤空的key
import { regionData, CodeToText } from 'element-china-area-data'
import { commonMxin } from '@/mixins/commonMxin'
import { extractExpetMixins } from '@/views/expert/extractExpert/mixins/extractExpetMixins'// 字典信息
import { filterDictText } from '@/assets/js/utils'// 常用方法
import { mapGetters } from 'vuex'
// 混入
import { ListMixin } from '@/mixins/ListMixin'
/* 组件*/
import expertSepcialDialog from '@views/expert/expertInfo/expertEvaluationInfo/expertSepcial-dialog' // 选择评标专业树弹窗
export default {
  components: {
    expertSepcialDialog
  },
  mixins: [commonMxin, extractExpetMixins, ListMixin],
  data() {
    return {
      types: '', // 是否抽取专业还是备选专业
      addExpertList: [], // 添加专家变量
      addConditList: [], // 添加专家变量
      projectArr: [], // 添加招标项目变量
      expertData: [],
      expertSearch: {
        expertName: '',
        certificateCode: '',
        expertIds: [],
        page: 1,
        pageSize: 10
      },
      purchaseSearchs: {
        name: '',
        idCard: '',
        page: 1,
        pageSize: 10
      },
      // 获取采购方信息需要传递的参数
      conditionsList: {
        isOperation: '',
        name: '',
        orderBy: '',
        pageNo: 0,
        pageSize: 10,
        representIdList: [
        ],
        technicalTitle: '',
        workCompany: ''
      },
      // 4 录入采购方代表 录入专家字段
      expertFrom: {
        realName: '', // 姓名
        certificateCode: '', // 身份证号
        sex: '', // 男女
        mobile: '' // 手机号码
      },
      entryExpertList: [], // 直接指定录入专家列表
      companyList: [],
      total: 0,
      expertTotal: 0,
      companySearch: {
        pageSize: 10,
        page: 1,
        comName: '',
        comCode: ''
      },
      allData: {
        area: [],
        adress: '', // 详细地址
        applyCode: '', // 申请编号
        areaCode: '', // 评标地点（区编号）
        areaName: '', // 评标地点（区名称）
        attendCount: '', // 一个月内参加过几次的专家不在被抽
        attendDay: '', // 几天内参加过评标的专家不再被抽取
        auditStatus: '', // 00审核中,02驳回,01通过
        cityCode: '', // 评标地点（市编号）
        cityName: '', // 评标地点（市名称）
        endTime: '', // 评标结束时间
        expertNum: '', // 专家人数
        id: '', // 申请id
        operationType: '', // 操作类型：00是保存 01是提交
        ownerNum: '', // 业主代表人数
        proviceCode: '', // 评标地点（省编号）
        proviceName: '', // 评标地点（省名称）
        rakeType: '00', // 指定抽取方式 00随机抽取 01直接指定
        reason: '', // 审核意见
        resultStatus: '',
        stageType: '01', // 评标阶段 00 资审 01 后审
        startTime: '', // 评标开始时间
        useStatus: '',
        extractApplyDetailList: [], // 招标项目详情
        extractConditionList: [], // 抽取条件详情
        extractAvoidCompanyList: [], // 回避单位详情
        extractAvoidExpertList: [], // 回避专家详情
        extractResultList: [], // 指定专家详情
        companyList: [], // 专家库列表
        companyStr: '',
        avoidDepartList: []// 回避部门列表
      },
      addExpertVisible: false, // 录入专家弹框
      firstTotal: 0,
      secondTotal: 0,
      totalPage: 0,
      dialogStatus: '', // 弹框状态
      textMap: {
        update: '编辑',
        create: '添加'
      },
      activeNames: ['1'],
      daichouqu: '待抽取',
      chouquzhong: '01',
      chehui: '01',
      major: '',
      extractDetails: false, // 抽取详情
      agencyDialogVisible: false, // 添加回避单位
      avoidExperts: false, // 添加回避专家
      avoidReason: '', // 回避原因
      avoidUnit: false, // 回避单位弹框
      avoidExpert: false, // 回避专家弹框
      location: [], //  项目所在区域
      extractingConditions: false, // 抽取条件弹框
      conditions: false, // 4 录入采购方代表选择弹框
      // 回避单位数据
      agencyDialogForm: {
        comCode: '',
        orgName: '',
        page: 1,
        pageSize: 10
      },
      //  专家列表
      specialistData: [

      ],
      tableData: [
        // 抽取条件列表
      ],
      avoidData: [
        // 回避单位
      ],
      purchaserListData: [], //  采购方代表
      avoidExpertData: [], // 回避专家
      extractForm: {
        type: '', // 类别
        specialName: '', // 抽取专业
        specialCode: '', // 抽取专业code
        cityName: '', // 抽取专家地区
        expertNum: '', // 抽取人数
        spareMajorName: '', // 备选专业
        spareMajorCode: '',
        expertExtractConditionAssistSpeciallist: [],
        areaD: [] // 抽取条件弹框选择地区
      },
      avoidUnitForm: {
        avoidOrgcode: '', // 机构代码
        avoidCompany: '', // 机构名称
        reason: '01', // 回避原因
        typename: ''
      },
      regionDataProps: {
        value: 'territoryName',
        label: 'territoryName'
      },
      regionData: regionData,
      isif: true,
      isifH: false,
      isShow: '01', //  01 展示 2和3   02  展示4
      fillorLook: '01', //  01 填写   02 查看
      mode: 'transfer', // transfer addressList
      toData: [],
      rules: {
        realName: [{ required: true, validator: linkerName, trigger: 'blur' }], // 联系人姓名
        rakeType: [{ required: true }],
        departName: [{ required: true, message: '回避部门不能为空' }],
        stageType: [{ required: true }],
        applyCode: [
          { required: true, message: '抽取申请编号不能为空' }
        ],
        tenderProject: [{ required: true, message: '项目不能为空' }],
        startTime: [
          { required: true, message: '请选择日期', trigger: 'blur' }
        ],
        endTime: [
          { required: true, message: '请选择日期', trigger: 'blur' }
        ],
        expertNum: [
          { required: true, validator: checkRate, trigger: 'blur' } // 格式校验
        ],
        ownerNum: [
          { required: true, validator: checkRate, message: '业主代表人数不能为空', trigger: 'blur' }
        ],
        area: [{ required: true, message: '评标地点不能为空' }],
        specialName: [{ required: true, message: '抽取专业不能为空' }],
        areaD: [{ required: true, message: '抽取专家地区不能为空' }],
        companyStr: [{ required: true, message: '请选择专家库' }]
      },
      avoidUnitFormrules: {
        avoidOrgcode: [{ required: true, message: '机构代码不能为空' }],
        avoidCompany: [{ required: true, message: '机构名称不能为空' }],
        reason: [{ required: true }]
      },
      extractMethod: true,
      searchForm: {
        page: 1,
        pageSize: 10,
        tenderName: '',
        tenderNo: '',
        packIds: []
      },
      arrName: [],
      arrId: [],
      projectData: [],
      multipleSelection: [],
      checkedExpert: [],
      specialtyNameArr: [],
      type: '',
      isChecked: false,
      checkedObj: '',
      selectProjectList: [],
      chooseVisible: false,
      searchCom: {
        comIds: [],
        comName: '',
        page: 1,
        pageSize: 10
      },
      totalE: 0,
      comLists: [],
      checkedListS: [],
      arrNames: [],
      arrIds: [],
      avoidDepartData: [], // 回避部门列表
      avoidDepartForm: {
        departName: '',
        reason: '',
        id: ''
      },
      checkedExpert1: [],
      purchaserList: [],
      avoidDepart: false,
      initData: {
        page: 1,
        pageSize: 10
      },
      departTotal: 0,
      departVisible: false,
      allDepartList: [],
      checkedDepartList: [],
      typeIs: ''
    }
  },
  computed: {
    ...mapGetters(['device', 'pager', 'layout'])
  },
  watch: {
    'conditions'(n, o) {
      if (n) {
        this.checkedExpert1 = []
      }
    },
    'allData.rakeType'(newval, oldval) {
      if (newval === '00') {
        this.extractMethod = true
        this.entryExpertList = []
        this.addExpertList = []
        this.avoidExpertData = []
        this.purchaserList = []
      } else {
        this.extractMethod = false
        this.avoidExpertData = []
        this.addExpertList = []
        this.purchaserList = []
      }
    }
  },
  created() {
    // 获取列表信息
    this.getExtractApplyCode()
  },
  mounted() {
    const id = this.$route.query.id ? this.$route.query.id : ''
    this.typeIs = id
    if (id) {
      getExtractExpertDetailById(id).then(res => {
        this.allData = Object.assign(this.allData, res.data.apply)
        this.allData.area = [this.allData.proviceCode, this.allData.cityCode, this.allData.areaCode]
        this.projectList = res.data.applyDetailList
        this.avoidExpertData = res.data.avoidExpertList
        this.avoidData = res.data.companyList
        this.entryExpertList = res.data.expertList
        if (this.entryExpertList instanceof Array && this.entryExpertList.length) {
          this.entryExpertList.forEach(val => {
            val.expertId = val.id
          })
        }
        if (res.data.condionList instanceof Array && res.data.condionList.length) {
          res.data.condionList.forEach(val => {
            const everyData = {}
            everyData.type = val.con.type // 类别
            everyData.specialName = val.con.specialName // 抽取专业
            everyData.specialCode = val.con.specialCode // 抽取专业code
            everyData.cityName = val.con.cityName // 抽取专家地区
            everyData.cityCode = val.con.cityCode // 抽取专家地区
            everyData.expertNum = val.con.expertNum // 抽取人数
            everyData.spareMajorName = val.specialNameList.join(',')// 备选专业
            everyData.spareMajorCode = val.specialCodeList.join(',')
            val.specialCodeList.forEach((value, index) => {
              const obj = {}
              obj.name = val.specialNameList[index]
              obj.id = value
              this.specialtyNameArr.push(obj)
            })
            everyData.expertExtractConditionAssistSpeciallist = []
            for (let i = 0; i < this.specialtyNameArr.length; i++) {
              const obj = {}
              obj.specialName = this.specialtyNameArr[i].name
              obj.specialId = this.specialtyNameArr[i].id
              everyData.expertExtractConditionAssistSpeciallist.push(obj)
            }
            this.tableData.push(everyData)
          })
        }
      })
      this.getDetailExpertCompanyList(id)
      this.getDetailExpertAvoidDepartList(id)
    }
  },
  methods: {
    // 当前选择的信息
    handleSelectionChangePurchaser(val) {
      val.forEach(val => {
        val.expertName = val.realName
        val.expertId = val.id
      })
      this.checkedExpert1 = val
    },
    // 获取抽取项目列表信息
    getExtractApplyCode() {
      getExtractApplyCode().then(res => {
        this.allData.applyCode = res.data
      })
    },
    filterDictText, // 字典值替换文本通用方法
    getDetailExpertCompanyList(id) {
      getDetailExpertCompanyList(id).then(res => {
        if (res.data.length) {
          this.allData.companyList = [...res.data]
          const arr = []
          res.data.forEach(val => {
            arr.push(val.comName)
          })
          this.allData.companyStr = arr.join(',')
        }
      })
    },
    getDetailExpertAvoidDepartList(id) {
      getDetailExpertAvoidDepartList(id).then(res => {
        this.avoidDepartData = [...res.data]
      })
    },
    // 回避专家分页
    pickHandleDe(val) {
      this.initData.page = val
      this.initData.pageSize = 10
      this.getExpertDepartList()
    },
    // 回避专家分页
    handleSizeProjectChangeDe(val) {
      this.initData.page = 1
      this.initData.pageSize = val
      this.getExpertDepartList()
    },
    // 选择部门列表
    getExpertDepartList() {
      getExpertDepartList(this.initData).then(res => {
        if (res.data.returnData.length) {
          const arr = []
          res.data.returnData.forEach(val => {
            const obj = {}
            obj.departName = val
            arr.push(obj)
          })
          this.allDepartList = [...arr]
          this.departTotal = res.data.total * 1
        }
      }).catch(() => {

      })
    },
    avoidDepartFn() {
      this.dialogStatus = 'create'
      this.avoidDepart = true
    },
    // 保存回避部门
    addAvoidDepart(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          const obj = JSON.parse(JSON.stringify(this.avoidDepartForm))
          this.avoidDepartData.push(obj)
          this.avoidDepart = false
        }
      })
    },
    searchE() {
      this.searchCom.pageNo = 1
      this.searchCom.pageSize = 10
      this.getExpertCompanyList()
    },
    resetEs() {
      Object.keys(this.searchCom).forEach(val => {
        this.searchCom[val] = ''
      })
      this.searchCom.pageNo = 1
      this.searchCom.pageSize = 10
      this.getExpertCompanyList()
    },
    addComLists() {
      if (!this.checkedListS.length) {
        this.$message({
          type: 'warning',
          message: '至少添加一个专家库'
        })
      } else {
        this.checkedListS.forEach(val => {
          this.arrNames.push(val.comName)
          this.arrIds.push(val.comId)
        })
        for (let i = 0; i < this.checkedListS.length; i++) {
          const obj = {}
          obj.comName = this.checkedListS[i].comName
          obj.comId = this.checkedListS[i].comId
          obj.id = this.checkedListS[i].id
          this.allData.companyList.push(obj)
        }
        const arr = Array.from(new Set(this.arrNames))
        this.allData.companyStr = arr.join(',')
        this.chooseVisible = false
      }
    },
    getExpertCompanyList() {
      getExpertCompanyList(this.searchCom).then(res => {
        this.comLists = res.data.returnData
        this.totalE = res.data.total * 1
      })
    },
    handleCurrentChangeE(val) {
      this.checkedListS = [...val]
    },
    chooseE() {
      this.chooseVisible = true
      this.searchCom.comIds = Array.from(new Set(this.arrIds))
      this.getExpertCompanyList()
    },
    resetE() {
      this.allData.companyStr = ''
      this.arrNames = []
      this.arrIds = []
      this.allData.companyList = []
    },
    pickHandleE(val) {
      this.searchCom.pageNo = val
      this.searchCom.pageSize = 10
      this.getExpertCompanyList()
    },
    handleSizeChangeE(val) {
      this.searchCom.pageNo = 1
      this.searchCom.pageSize = val
      this.getExpertCompanyList()
    },
    selectProject(val) {
      this.selectProjectList = val
    },
    removeConditList(index, type) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.purchaserList.splice(index, 1)
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    handleCurrentChange(val) {
      this.isChecked = true
      this.checkedObj = { ...val }
    },
    addComNameCode() {
      if (this.isChecked) {
        this.avoidUnitForm.avoidCompany = this.checkedObj.comName
        this.avoidUnitForm.avoidOrgcode = this.checkedObj.comCode
        this.isChecked = false
        this.agencyDialogVisible = false
      } else {
        this.$message({
          type: 'warning',
          message: '至少添加一条数据'
        })
      }
    },
    searchCompany() {
      this.companySearch.pageNo = 1
      this.getAlreadyExistExpertComName()
    },
    resetCompany() {
      this.getAlreadyExistExpertComName()
      Object.keys(this.companySearch).forEach(val => {
        this.companySearch[val] = ''
      })
      this.companySearch.pageNo = 1
      this.companySearch.pageSize = 10
    },
    getAlreadyExistExpertComName() {
      getAlreadyExistExpertComName(this.companySearch).then(res => {
        this.companyList = res.data.records
      }).catch(() => {

      })
    },
    closeDialog(formRule) {
      this.$refs[formRule].resetFields()
      if (formRule === 'avoidDepartForm') {
        this.avoidDepartForm.reason = ''
      }
      if (formRule === 'extractForm') {
        this.arrName = []
        this.arrId = []
        this.extractForm.spareMajorName = ''
        this.extractForm.spareMajorCode = ''
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
      this.projectArr = this.projectArr.concat(this.multipleSelection)
    },
    handleSelectionChangeExpert(val) {
      val.forEach(val => {
        val.expertName = val.realName
        val.expertId = val.id
      })
      this.checkedExpert = val
      this.addExpertList = this.addExpertList.concat(this.checkedExpert)
    },
    addAvoidExpert() {
      const arr = []
      this.checkedExpert.forEach(val => {
        arr.push(val.expertId)
      })
      this.avoidExpert = false
      this.addExpertVisible = false
      const obj = {}
      this.addExpertList = this.addExpertList.reduce(function(item, next) {
        obj[next.expertId] ? '' : obj[next.expertId] = true && item.push(next)
        return item
      }, [])
      this.avoidExpertData = JSON.parse(JSON.stringify(this.addExpertList))
    },

    addDirect() {
      const arr = []
      this.checkedExpert.forEach(val => {
        arr.push(val.expertId)
      })
      this.addExpertVisible = false
      this.avoidExpert = false
      const obj = {}
      this.addExpertList = this.addExpertList.reduce(function(item, next) {
        obj[next.expertId] ? '' : obj[next.expertId] = true && item.push(next)
        return item
      }, [])
      this.entryExpertList = JSON.parse(JSON.stringify(this.addExpertList))
    },
    ensure() {
      if (this.checkedExpert1.length) {
        this.purchaserList = [...this.purchaserList, ...this.checkedExpert1]
        this.conditions = false
      } else {
        this.$message({
          type: 'warning',
          message: '至少添加一条数据'
        })
      }
    },

    addPick() {
      if (this.multipleSelection.length) {
        const arr = []
        this.multipleSelection.forEach(val => {
          val.pakNo = val.packNo
          arr.push(val.packId)
        })
        this.searchForm.packIds = [...arr]
        const obj = {}
        this.projectArr = this.projectArr.reduce(function(item, next) {
          obj[next.packNo] ? '' : obj[next.packNo] = true && item.push(next)
          return item
        }, [])
        this.projectList = JSON.parse(JSON.stringify(this.projectArr))
        this.projectIsVisible = false
      } else {
        this.$message({
          type: 'warning',
          message: '至少添加一条数据'
        })
      }
    },
    getTenderAndPackageList() {
      getTenderAndPackageList(this.searchForm).then(res => {
        this.projectData = res.data.records
        this.totalPage = res.data.total * 1
      })
    },
    searchProject() {
      this.getTenderAndPackageList()
    },
    resetProject() {
      Object.keys(this.searchForm).forEach(val => {
        this.searchForm[val] = ''
      })
      this.searchForm.pageNo = 1
      this.searchForm.pageSize = 10
      this.getTenderAndPackageList()
    },
    pickHandle(value) {
      this.searchForm.pageNo = value
      this.searchForm.pageSize = 10
      this.getTenderAndPackageList()
    },
    handleSizeProjectChange(value) {
      this.searchForm.pageNo = 1
      this.searchForm.pageSize = value
      this.getTenderAndPackageList()
    },
    // 回避单位分页
    pickHandleCom(val) {
      this.companySearch.pageNo = val
      this.companySearch.pageSize = 10
      this.getAlreadyExistExpertComName()
    },
    // 回避单位分页
    handleSizeChangeCom(val) {
      this.companySearch.pageSize = val
      this.companySearch.pageNo = 1
      this.getAlreadyExistExpertComName()
    },
    // 添加抽取条件
    addExtractCondition() {
      this.extractingConditions = true
      this.dialogStatus = 'create'
      // this.extractForm.areaD = []
    },
    // 查询条件
    expertSearchFn() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param) // 过滤空的key
    },
    purchaseSearchFn() {
      const param = Object.assign({}, this.purchaseSearchs)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param) // 过滤空的key
    },

    // 4 录入采购方代表
    addExtractConditions() {
      this.conditions = true
      const data = {
        ...this.conditionsList
      }
      data.representIdList = this.purchaserList.map(item => item.id)
      queryAllRepresentList(data).then(response => {
        this.purchaserListData = response.data.records
        this.paginationData.total = response.data.total
      })
    },

    // 添加回避单位弹框
    avoidUnitFn() {
      this.avoidUnit = true
      this.dialogStatus = 'create'
      this.avoidUnitForm = {
        avoidOrgcode: '', // 机构代码
        avoidCompany: '', // 机构名称
        reason: '1' // 回避原因
      }
    },
    //  录入专家添加
    addExpert() {
      if (this.entryExpertList.length) {
        const arr = []
        this.entryExpertList.forEach(val => {
          arr.push(val.expertId)
        })
        this.expertSearch.expertIds = [...arr]
        if (this.typeIs) {
          this.addExpertList = this.addExpertList.concat(this.entryExpertList)
        }
      } else {
        this.expertSearch.expertIds = []
      }
      this.addExpertVisible = true
      this.avoidExpert = false
      this.expertSearch.expertName = ''
      this.expertSearch.certificateCode = ''
      this.expertSearch.pageNo = 1
      this.expertSearch.pageSize = 10
      this.getExpertList()
    },
    // 添加回避专家弹框
    avoidExpertFn() {
      if (this.avoidExpertData.length) {
        const arr = []
        this.avoidExpertData.forEach(val => {
          arr.push(val.expertId)
        })
        this.expertSearch.expertIds = [...arr]
      } else {
        this.expertSearch.expertIds = []
      }
      this.avoidExpert = true
      this.addExpertVisible = false
      this.dialogStatus = 'create'
      this.expertSearch.expertName = ''
      this.expertSearch.certificateCode = ''
      this.expertSearch.pageNo = 1
      this.expertSearch.pageSize = 10
      this.getExpertList()
    },
    // 录入专家重置
    resetFn() {
      this.expertSearch.expertName = ''
      this.expertSearch.certificateCode = ''
      this.expertSearch.pageNo = 1
      this.expertSearch.pageSize = 10
      this.getExpertList()
    },
    // 分页
    pickHandleEx(val) {
      this.expertSearch.pageNo = val
      this.expertSearch.pageSize = 10
      this.getExpertList()
    },
    // 分页
    handleSizeProjectChangeEx(val) {
      this.expertSearch.pageNo = 1
      this.expertSearch.pageSize = val
      this.getExpertList()
    },
    // 回避专家接口获取及push到表格里面
    getExpertList() {
      getExpertList(this.expertSearch).then(res => {
        this.expertData = res.data.records
        this.expertTotal = res.data.total * 1
      }).catch(() => {

      })
    },
    // 提交抽取详情
    submitExtract() {
      if (this.avoidData.length) {
        this.$message({
          type: 'warning',
          message: '请设置回避单位'
        })
        return false
      }
      this.$refs['allData'].validate(valid => {
        if (valid) {
          if (this.tableData.length) {
            this.$message({
              type: 'warning',
              message: '请设置抽取条件'
            })
          }
        } else {
          return false
        }
      })
    },
    // 删除回避原因
    handleDeleteAvoid(row, index) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.avoidData.splice(index, 1)
        this.$message({
          type: 'info',
          message: '删除成功'
        })
      })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 回避部门删除某一条
    handleDeleteDepart(row, index) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.avoidDepartData.splice(index, 1)
        this.$message({
          type: 'success',
          message: '删除成功!'
        })
      })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 直接指定专家 删除某一条
    handleDeleteExpertDirect(row, index) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.entryExpertList.splice(index, 1)
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 回避专家 删除某一条
    handleDeleteExpert(row, index) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.avoidExpertData.splice(index, 1)
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 抽取条件列表，根据d删除某一条
    handleDelete(row, index) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.tableData.splice(index, 1)
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 抽取条件列表，根据d编辑某一条
    handleUpdate(row) {
      this.extractingConditions = true
      this.dialogStatus = 'update'
    },
    // 保存回避单位
    saveAvoidUnit() {
      this.$refs['avoidUnitForm'].validate(valid => {
        if (valid) {
          const obj = JSON.parse(JSON.stringify(this.avoidUnitForm))
          this.avoidData.push(obj)
          this.avoidUnit = false
        }
      })
    },
    // 保存抽取条件
    submitExtractForm() {
      this.$refs['extractForm'].validate(valid => {
        if (valid) {
          // 保存抽取条件
          const obj = JSON.parse(JSON.stringify(this.extractForm))
          this.tableData.push(obj)
          this.extractingConditions = false
        }
      })
    },
    // 4 录入采购方代表
    submitExtractConditions() {
      this.$refs['expertFrom'].validate(valid => {
        if (valid) {
          const obj = JSON.parse(JSON.stringify(this.expertFrom))
          this.purchaserList.push(obj)
          this.conditions = false
        } else {
          this.conditions = true
        }
      })
    },
    // 保存按钮
    saveaddItem(status) {
      this.useStatus = status
      this.$refs['allData'].validate(valid => {
        if (valid) {
          this.allData.operationType = status
          if (!this.projectList.length) {
            this.$message({
              type: 'warning',
              message: '请添加项目'
            })
            return false
          }
          if (this.allData.rakeType === '00') {
            if (!this.tableData.length) {
              this.$message({
                type: 'warning',
                message: '请添加抽取条件'
              })
              return false
            }
            this.allData.extractConditionList = JSON.parse(JSON.stringify(this.tableData))
            this.allData.extractAvoidCompanyList = JSON.parse(JSON.stringify(this.avoidData))
            this.allData.extractAvoidExpertList = JSON.parse(JSON.stringify(this.avoidExpertData))
            this.allData.extractApplyDetailList = JSON.parse(JSON.stringify(this.projectList))
            this.allData.avoidDepartList = JSON.parse(JSON.stringify(this.avoidDepartData))
            this.allData.extractResultList = JSON.parse(JSON.stringify(this.entryExpertList))
            // extractResultList1 明天换掉
            this.allData.purchaserDeputationList = JSON.parse(JSON.stringify(this.purchaserList))
            submitOrsaveExtractApplyByTenderManager(this.allData).then(res => {
              this.tableData = ''
            }).catch(() => {
            })
          }
          if (this.allData.rakeType === '01') {
            if (!this.entryExpertList.length) {
              this.$message({
                type: 'warning',
                message: '请添加指定专家'
              })
              return false
            }
            this.allData.extractConditionList = JSON.parse(JSON.stringify(this.tableData))
            this.allData.extractAvoidCompanyList = JSON.parse(JSON.stringify(this.avoidData))
            this.allData.extractAvoidExpertList = JSON.parse(JSON.stringify(this.avoidExpertData))
            this.allData.extractApplyDetailList = JSON.parse(JSON.stringify(this.projectList))
            this.allData.avoidDepartList = JSON.parse(JSON.stringify(this.avoidDepartData))
            this.allData.extractResultList = JSON.parse(JSON.stringify(this.entryExpertList))
            // extractResultList1 明天换掉
            this.allData.purchaserDeputationList = JSON.parse(JSON.stringify(this.purchaserList))
            submitOrsaveExtractApplyByTenderManager(this.allData).then(res => {
            }).catch(() => {

            })
          }
        } else {
          return false
        }
      })
    },
    // 提交
    saveItem(status) {
      this.useStatus = status
      this.$refs['allData'].validate(valid => {
        if (valid) {
          this.allData.operationType = status
          if (!this.projectList.length) {
            this.$message({
              type: 'warning',
              message: '请添加项目'
            })
            return false
          }
          if (this.allData.rakeType === '00') {
            if (!this.tableData.length) {
              this.$message({
                type: 'warning',
                message: '请添加抽取条件'
              })
              return false
            }

            this.purchaserList.map(item => {
              item.purchaserId = item.id
              item.purchaserName = item.name
              /*             item.mobilePhone = item.mobilePhone
              item.idCard = item.idCard
              item.departName = item.departName
              item.departId = item.departId
              item.sex = item.sex*/
            })
            this.allData.extractConditionList = JSON.parse(JSON.stringify(this.tableData))
            this.allData.extractAvoidCompanyList = JSON.parse(JSON.stringify(this.avoidData))
            this.allData.extractAvoidExpertList = JSON.parse(JSON.stringify(this.avoidExpertData))
            this.allData.extractApplyDetailList = JSON.parse(JSON.stringify(this.projectList))
            this.allData.avoidDepartList = JSON.parse(JSON.stringify(this.avoidDepartData))
            this.allData.extractResultList = JSON.parse(JSON.stringify(this.entryExpertList))
            this.allData.purchaserDeputationList = JSON.parse(JSON.stringify(this.purchaserList))
            submitOrsaveExtractApplyByTenderManager(this.allData).then(res => {
              this.$router.replace('extractApplyList')
            }).catch(() => {
            })
          }
          if (this.allData.rakeType === '01') {
            if (!this.entryExpertList.length) {
              this.$message({
                type: 'warning',
                message: '请添加指定专家'
              })
              return false
            }
            this.allData.extractConditionList = JSON.parse(JSON.stringify(this.tableData))
            this.allData.extractAvoidCompanyList = JSON.parse(JSON.stringify(this.avoidData))
            this.allData.extractAvoidExpertList = JSON.parse(JSON.stringify(this.avoidExpertData))
            this.allData.extractApplyDetailList = JSON.parse(JSON.stringify(this.projectList))
            this.allData.avoidDepartList = JSON.parse(JSON.stringify(this.avoidDepartData))
            this.allData.extractResultList = JSON.parse(JSON.stringify(this.entryExpertList))
            // extractResultList1新增的采购方代表 明天换掉
            this.allData.purchaserDeputationList = JSON.parse(JSON.stringify(this.purchaserList))
            submitOrsaveExtractApplyByTenderManager(this.allData).then(res => {
              this.$router.replace('/expertExtract/extractApplyList')
            }).catch(() => {

            })
          }
        } else {
          return false
        }
      })
    },
    // 抽取详情
    extractList() {
      this.extractDetails = true
    },
    // 回避单位分页
    handleSizeChange() { },
    // 选择回避单位
    changeAvoidUnit() {
      this.agencyDialogVisible = true
      this.getAlreadyExistExpertComName()
    },
    clearUnit() { // 清空回避单位偶搜索
      this.avoidUnitForm.avoidCompany = ''
      this.avoidUnitForm.avoidOrgcode = ''
    },
    extractExpertWay(val) {
      //  01 随机抽取  02 指定抽取
      if (val === '01') {
        this.isShow = '01'
      } else if (val === '02') {
        this.isShow = '02'
      }
    },
    addressChangeF(arr) { // 评标地点
      this.allData.proviceCode = arr[0]
      this.allData.areaCode = arr[2]
      this.allData.cityCode = arr[1]
      this.allData.proviceName = CodeToText[arr[0]]
      this.allData.areaName = CodeToText[arr[2]]
      this.allData.cityName = CodeToText[arr[1]]
    },
    //  三级联动
    addressChange(arr) {
      this.extractForm.areaD = [...arr]
      this.extractForm.cityName = CodeToText[arr[arr.length - 1]]
      this.extractForm.cityCode = arr[arr.length - 1]
    },
    changeSelect(type) { // 打开评标专业选择弹窗
      this.types = type
      this.$refs.expertSelectworkunitDialog.dialogData.dialog = true
    },
    dialogExpertSepcialList(data, title) { // 添加评标专业到弹窗
      if (this.types === '1') {
        this.extractForm.specialName = data.labels
      } else {
        this.extractForm.spareMajorName = data.labels
        this.extractForm.spareMajorCode = data.keys
        this.extractForm.expertExtractConditionAssistSpeciallist = data.keys.split(',').map((item, index) =>
          ({ specialId: item, specialName: data.labels.split(',')[index] }))
      }
    },
    clearSelect(type) { // 清空抽取专业
      if (type === '1') {
        this.extractForm.specialName = ''
        this.extractForm.specialCode = ''
      } else {
        this.arrName = []
        this.arrId = []
      }
    }
  }
}
</script>

<style lang="less" scoped>
</style>
