<!--
  @description:专家库-查看抽取结果详情
  @Modifier:肖文龙
  @routerPath: /expert/extractProject-detail
  @date:2020-8-26
-->
<template>
  <div>
    <section class="title title_border p0-16 clearfix">
      <template>
        <div class="pointer" @click="back">
          <i class="iconfont icon-fanhui mr10" />
          抽取详情
        </div>
      </template>
    </section>
    <div class="p0-16">
      <div class="page-title">
        1.抽取项目
      </div>

      <div>
        <el-table
          ref="package"
          :data="formData.applyDetailList"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60"
            align="center"
          />
          <el-table-column
            min-width="300"
            label="项目名称"
            prop="tenderName"
            header-align="center"
          />
          <el-table-column
            min-width="120"
            label="项目编号"
            prop="tenderNo"
            header-align="center"
          />
          <el-table-column
            min-width="300"
            label="标段（包）名称"
            prop="packName"
            header-align="center"
          />
          <el-table-column
            min-width="120"
            label="标段（包）编号"
            prop="pakNo"
            header-align="center"
          />
        </el-table>
      </div>
      <div class="page-title">
        2.抽取结果
      </div>

      <table class="tableData">
        <tr>
          <td>抽取申请编号</td>
          <td>
            {{ extractResult.applyCode }}
          </td>
          <td>
            抽取结果
          </td>
          <td>
            {{ extractResult.resultStatus | extractingResults }}
          </td>
        </tr>
        <tr>
          <td>评标阶段</td>
          <td>
            {{ extractResult.stageType=='00'?"资格预审":"资格后审" }}
          </td>
          <td>专家确定方式</td>
          <td>
            {{ extractResult.rakeType=='00' ? '随机抽取':"直接指定" }}
          </td>
        </tr>
        <tr>
          <td>评标开始</td>
          <td>
            {{ extractResult.startTime }}
          </td>
          <td>评标结束</td>
          <td>
            {{ extractResult.endTime }}
          </td>
        </tr>
        <tr class="singleRow">
          <td>评标地点</td>
          <td :colspan="3">
            {{ extractResult.proviceName }}{{ extractResult.cityName }}{{ extractResult.areaName }}
          </td>
        </tr>
        <tr>
          <td>申请抽取人数</td>
          <td>
            {{ extractResult.expertNum }}
          </td>
          <td>抽取成功人数</td>
          <td>
            <span>
              {{ extractResult.ownerNum }}
            </span>
          </td>
        </tr>
      </table>
      <div class="page-title">
        3.专家列表
      </div>
      <el-button type="primary" @click="exportExperts">
        导出专家
      </el-button>
      <div class="mt10">
        <el-table
          ref="package"
          v-loading="experLoading"
          :data="expertList"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60"
            align="center"
          />
          <el-table-column
            min-width="110"
            label="专家姓名"
            prop="expertName"
            header-align="center"
          />
          <el-table-column
            width="120"
            label="联系方式"
            prop="mobile"
            align="center"
          />
          <el-table-column
            width="150"
            label="身份证"
            prop="certificateCode"
            align="center"
          />
          <el-table-column
            width="150"
            label="抽取专业"
            prop="expertMajor"
            align="center"
          />
          <el-table-column
            min-width="150"
            label="地区"
            prop="address"
            align="center"
          />
          <el-table-column
            min-width="130"
            label="抽取时间"
            prop="selectTime"
            align="center"
          >
            <template slot-scope="scope">
              {{ $Moment(scope.row.createTime).format(momentDateTime) }}
            </template>
          </el-table-column>
          <el-table-column
            width="80px"
            label="状态"
            prop="status"
            align="center"
          >
            <template slot-scope="scope">
              {{ filterDictText(expertStatusList,scope.row.status) }}
            </template>
          </el-table-column>
          <el-table-column
            width="80px"
            label="操作"
            align="center"
          >
            <template slot-scope="scope">
              <el-link
                v-if="scope.row.isAttend=='01'&& scope.row.status!='02'"
                type="primary"
                @click.stop="leave(scope.row.id)"
              >
                [请假]
              </el-link>
              <!-- 人工通知 -->
              <el-link
                v-if="scope.row.isAttend=='00'"
                type="primary"
                @click.stop="changeAttend(scope.row.id,'01')"
              >
                [同意]
              </el-link>
              <el-link
                v-if="scope.row.isAttend=='00'"
                type="primary"
                @click.stop="changeAttend(scope.row.id,'02')"
              >
                [拒绝]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="loadData" />
      </div>
    </div>
  </div>
</template>
<script>
/* api */
import { getExtractExpertDetailById, adminGetExtractApplyResultDetailInfoExpertNextPage, editAttendStatus, editLeaveStatus, adminExportExtractExpertBaseInfo } from '@/api/expert/expertscloud.js'
/* 公用方法*/
import { filterDictText, download } from '@/assets/js/utils'// 常用方法
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { extractProjectMixin } from '../mixins/extractProjectMixins'// 字典信息
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
export default {
  components: {
    pagination
  },
  filters: {
    // 00 01
    extractingResults(val) {
      switch (val) {
        case '00':
          return '待抽取'
        case '01':
          return '抽取中'
        case '02':
          return '抽取完成'
        case '03':
          return '人数不够'
        default:
          return '待抽取'
      }
    }
  },
  mixins: [extractProjectMixin, ListMixin],
  data() {
    return {
      experLoading: false,
      expertList: [], // 专家列表
      extractResult: {},
      // 项目信息
      formData: {
        isArtificial: '01', // 00 自动通知 01 人工 通知
        id: this.$route.params.id, // 项目id
        applyDetailList: [], // 项目名称/标段（包）
        tenderName: '', // 抽取结果
        tenderNo: '', // 抽取编号
        isPack: '', // 评标阶段 00 资审 01 后审
        isPac2k: '', // 专家确定方式 00 直接指定 01 随机抽取
        isPac2kw: '', // 评标开始
        isPa11c2k: '', // 评标结束
        isPaec2k: '', // 申请抽取人数
        isPaec2dk: '', // 抽取成功人数
        i2sPaec2dk: '', // 评标地点
        useStatus: '' // 状态值 00 保存 01 提交
      }
    }
  },
  created() {
    // 获取项目信息
    this.initData()
  },
  methods: {
    filterDictText,
    // 返回
    back() {
      this.$router.push('/expert/extractProject-list')
    },
    // 导出专家
    exportExperts() {
      if (this.expertList.length > 0) {
        adminExportExtractExpertBaseInfo({ id: this.$route.params.id }).then(res => {
          download(res, '【' + this.formData.applyDetailList[0].tenderName + '】抽取专家结果.xls')
        })
      }
    },
    // 获取抽取详情
    initData() {
      if (!this.formData.id) return
      getExtractExpertDetailById(this.formData.id).then(res => {
        this.formData = res.data
        this.formData.applyDetailList = this.formData.applyDetailList || []
        this.expertList = res.data.purchaserList
        // 抽取结果
        this.extractResult = res.data.apply
        this.extractResult.startTime = this.$Moment(this.extractResult.startTime).format('YYYY-MM-DD HH:mm')
        this.extractResult.endTime = this.$Moment(this.extractResult.endTime).format('YYYY-MM-DD HH:mm')
      })
      this.adminGetExtractPage()
    },
    adminGetExtractPage() {
      // 管理员获取专家列表
      const params = {}
      params.pageNo = this.paginationData.pageNo
      params.pageSize = this.paginationData.pageSize
      params.id = this.$route.params.id
      adminGetExtractApplyResultDetailInfoExpertNextPage(params).then(res => {
        this.expertList = res.data.records
        this.totalPage = res.data.rows * 1
        this.paginationData.total = res.data.total
      })
    },

    // 抽取专家结果
    loadData() {
      const params = {}
      params.pageNo = this.paginationData.pageNo
      params.pageSize = this.paginationData.pageSize
      this.experLoading = true
      // getExtractExpertDetailById(params).then(response => {
      // this.experLoading = false
      // this.expertList = response.data.records
      // this.paginationData.total = response.data.total
      // }).catch(() => {
      // this.experLoading = false
      // })
    },
    // 请假
    leave(id) {
      this.$confirm('确认专家请假?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        editLeaveStatus(id).then(res => {
          if (res.header.ret === '0') {
            this.$message({
              message: '操作成功',
              type: 'success'
            })
            // 获取抽取详情
            this.adminGetExtractPage()
          }
        }).catch(() => {

        })
      })
    },
    changeAttend(id, isAttend) {
      editAttendStatus(id, isAttend).then(res => {
        if (res.header.ret === '0') {
          this.$message({
            type: 'success',
            message: '操作成功'
          })
        }
        this.adminGetExtractPage()
      }).catch(() => {

      })
    },
    // 拒绝
    refused(row) {

    },
    // 未答应
    noPromise(row) {

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

