<!--
  @description: 抽取专家-抽取申请审核
  @Modifier: 徐媛媛
  @routerPath:/extractExpert/extractApply
  @date: 2020/8/26-13:27
-->
<template>
  <div class="leave_container">
    <h1>
      <i class="iconfont icon-fanhui" style="padding-right:10px" @click="back" />抽取申请审核
    </h1>
    <div style="padding-right: 100px">
      <!--抽取项目信息-->
      <div class="page-title">
        <h3 class="title_d">
          01 抽取申请
        </h3>
        <el-form ref="allData" :model="allData" label-width="160px">
          <el-row>
            <el-col :span="20">
              <el-form-item label="抽取申请编号" prop="applyCode">
                <el-input v-model="allData.applyCode" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="20">
              <el-form-item label="选择招标项目">
                <el-table :data="resultData">
                  <el-table-column label="序号" type="index" />
                  <el-table-column label="招标项目名称" prop="tenderName" />
                  <el-table-column label="招标项目编号" prop="tenderNo" />
                  <el-table-column label="标段名称" prop="packName" />
                  <el-table-column label="标段编号" prop="pakNo" />
                </el-table>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="10">
              <el-form-item
                label="评标阶段"
                prop="stageType"
              >
                {{ allData.stageType=='01' ? '资格后审':'资格预审' }}
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item
                label="专家确定方式"
                prop="applicationNumber"
              >
                {{ allData.rakeType=='00' ? '随机抽取':"直接指定" }}
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="10">
              <el-form-item label="评标开始" prop="startTime">
                <el-date-picker
                  v-model="allData.startTime"
                  type="datetime"
                  placeholder="选择日期时间"
                  style="width: 100%"
                  disabled
                />
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item label="评标结束时间" prop="endTime">
                <el-date-picker
                  v-model="allData.endTime"
                  type="datetime"
                  placeholder="选择日期时间"
                  style="width: 100%"
                  disabled
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="10">
              <el-form-item label="专家人数" prop="expertNumber">
                {{ allData.expertNum }}
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item label="业主代表人数" prop="ownerNumber">
                {{ allData.ownerNum }}
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="20">
              <el-form-item
                label="评标地点"
                prop="area"
              >
                {{ allData.proviceName+allData.cityName+allData.areaName +(allData.adress?allData.adress:'') }}
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="20">
              <el-form-item label="抽取回避">
                <span class="only_input">{{ allData.attendDay }}</span> 天内参加过评标的专家不再抽取 一个月参加过
                <span class="only_input">{{ allData.attendCount }}</span> 次评标的专家不再抽取
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <!--设置抽取条件-->
      <div v-if="allData.rakeType=='00'" class="page-title">
        <h3 class="title_d">
          02 设置抽取条件
        </h3>
        <el-table :data="tableData" border>
          <el-table-column type="index" label="序号" align="center" />
          <!-- <el-table-column prop="type" label="类别" align="center">
            <template slot-scope="{row}">{{ row.type | formatType }}</template>
          </el-table-column>-->
          <el-table-column prop="specialName" label="评标专业" align="center" />
          <el-table-column prop="expertNum" label="抽取人数" align="center" />
          <el-table-column prop="cityName" label="抽取专家地区" align="center" />
          <el-table-column prop="spareMajorName" label="备选专业" align="center" />
        </el-table>
      </div>
      <!--录入专家-->
      <div v-if="allData.rakeType=='01'" class="page-title">
        <div style="position:relative">
          <h3 class="title_d">
            02 录入专家
          </h3>
        </div>
        <el-table :data="expertList " style="margin-top:10px">
          <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>
      </div>
      <!--设置回避单位-->
      <div v-if="allData.rakeType=='00'" class="page-title">
        <h3 class="title_d">
          03 设置回避单位
        </h3>
        <el-table :data="avoidData" border>
          <el-table-column type="index" label="序号" align="center" />
          <el-table-column prop="avoidOrgcode" label="机构代码" align="center" />
          <el-table-column prop="avoidCompany" label="机构名称" align="center" />
          <el-table-column prop="reason" label="回避原因" align="center">
            <template slot-scope="scope">
              {{ scope.row.reason | formatReason }}
            </template>
          </el-table-column>
        </el-table>
        <h3 class="title_d">
          回避专家
        </h3>
        <el-table :data="avoidExpertData" border>
          <el-table-column type="index" label="序号" align="center" />
          <el-table-column prop="expertName" label="专家姓名" align="center" />
          <el-table-column prop="certificateCode" label="身份证号" align="center" />
          <el-table-column prop="mobile" label="手机号" align="center" />
        </el-table>
      </div>
      <div v-if="!status" class="page-title">
        <h3 class="title_d">
          {{ allData.rakeType=='00'? "04":"03" }} 审核意见
        </h3>
        <table class="has_info">
          <tr>
            <td class="bg" style="text-align:center">
              审核意见
            </td>
            <td>
              <el-input
                v-model="auditExpertApplyForm.reason"
                placeholder="请输入审核意见"
                type="textarea"
                autosize
              />
            </td>
          </tr>
        </table>
        <div style="text-align:center;margin:8px auto">
          <el-button type="primary" @click="auditExpertApply('01')">
            审核通过
          </el-button>
          <el-button @click="auditExpertApply('02')">
            审核不通过
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getExtractExpertDetailById, adminAuditExtractApply } from '@/api/expert/expertscloud'
export default {
  filters: {
    formatReason(val) {
      let text = ''
      switch (val) {
        case '1':
          text = '项目业主'
          break
        case '2':
          text = '行政监督单位'
          break
        case '3':
          text = '投标单位'
          break
        case '4':
          text = '代理机构'
          break
        case '5':
          text = '行政主管单位'
          break
        case '6':
          text = '其他原因'
          break
      }
      return text
    }
  },
  data() {
    return {
      auditExpertApplyForm: {
        reason: ''
      },
      tableData: [],
      resultData: [],
      avoidExpertData: [],
      avoidData: [],
      expertList: [

      ],
      allData: {
        adress: '', // 详细地址
        applyCode: '', // 申请编号
        areaCode: '', // 评标地点（区编号）
        areaName: '', // 评标地点（区名称）
        attendCount: '', // 一个月内参加过几次的专家不在被抽
        attendDay: '', // 几天内参加过评标的专家不再被抽取
        auditStatus: '', // 00审核中,02驳回,01通过
        cityCode: '', // 评标地点（市编号）
        cityName: '', // 评标地点（市名称）
        endTime: '', // 评标结束时间
        expertNum: '', // 专家人数
        id: '', // 申请id
        operationType: '', // 操作类型：00是保存 01是提交
        ownerNum: '', // 业主代表人数
        proviceCode: '', // 评标地点（省编号）
        proviceName: '', // 评标地点（省名称）
        rakeType: '01', // 指定抽取方式 00随机抽取 01直接指定
        reason: '', // 审核意见
        resultStatus: '',
        stageType: '01', // 评标阶段 00 资审 01 后审
        startTime: '', // 评标开始时间
        useStatus: '',
        extractApplyDetailList: [], // 招标项目详情
        extractConditionList: [], // 抽取条件详情
        extractAvoidCompanyList: [], // 回避单位详情
        extractAvoidExpertList: [], // 回避专家详情
        extractResultList: []// 指定专家详情
      },
      status: ''
    }
  },
  mounted() {
    const id = this.$route.query.id
    this.status = !!this.$route.query.status
    // 根据id回显数据
    this.getExtractExpertDetailById(id)
  },
  methods: {
    getExtractExpertDetailById(id) { // 根据id回显数据
      getExtractExpertDetailById(id).then(res => {
        this.allData = Object.assign(this.allData, res.data.apply)
        this.resultData = res.data.applyDetailList
        this.avoidExpertData = res.data.avoidExpertList
        this.avoidData = res.data.companyList
        this.expertList = res.data.expertList
        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(',')
          this.tableData.push(everyData)
        })
      }).catch(() => {

      })
    },
    back() {
      this.$router.go(-1)
    },
    auditExpertApply(type) { // 审核通过/审核不通过
      this.auditExpertApplyForm.auditStatus = type
      this.auditExpertApplyForm.id = this.$route.query.id
      if (type === '02' && !this.auditExpertApplyForm.reason) {
        this.$message({
          type: 'warning',
          message: '审核意见不能为空'
        })
        return false
      }
      const text = type === '01' ? '确认审核通过？' : '确认审核不通过？'
      this.$confirm(text, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        adminAuditExtractApply(this.auditExpertApplyForm).then(res => {
          this.$router.replace('/extractAdmin/extractAdminList')
        }).catch(() => {

        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        })
      })
    }
  }
}
</script>
<style lang="less" scoped>
</style>

