<!--
  @description: 组件委员会-对接专家库（获取专家信息）
  @Modifier: haofengxian
  @routerPath:
  @date: 2020-9-3-13:38
-->
<template>
  <div class="main">
    <!-- isCanOperate: true可以操作 false不可以查看只有查看权限  00:否 01:是 -->
    <el-button v-if="tenderBase.isCanOperate" type="primary" @click="handelGetResultsOfExtractingExpert">
      获取专家
    </el-button>
    <!-- 专家列表 -->
    <section class=" mt10">
      <el-table
        ref="multipleTable"
        v-loading="loading"
        :data="tableData"
      >
        <el-table-column
          type="index"
          label="序号"
          min-width="60"
          align="center"
        />
        <el-table-column
          label="姓名"
          min-width="100"
          prop="name"
          header-align="center"
          align="left"
        />
        <el-table-column
          label="专家身份证号"
          min-width="160"
          prop="idCard"
          align="center"
        />
        <el-table-column
          label="联系方式"
          min-swidth="110"
          prop="mobilePhone"
          align="center"
        />
        <el-table-column
          label="性别"
          min-width="60"
          prop="sex"
          align="center"
        >
          <template slot-scope="scope">
            {{ filterDictText(sexList,scope.row.sex) }}
          </template>
        </el-table-column>
        <el-table-column
          label="专家类型"
          min-width="100"
          prop="type"
          align="center"
        >
          <template slot-scope="scope">
            {{ filterDictText(personTypeList,scope.row.type) }}
          </template>
        </el-table-column>
        <el-table-column
          label="专家类别"
          min-width="100"
          prop="expertType"
          align="center"
        >
          <template slot-scope="scope">
            {{ filterDictText(expertTypeList,scope.row.expertType) }}
          </template>
        </el-table-column>
        <el-table-column
          label="组长"
          min-width="60"
          prop="isLeader"
          align="center"
        >
          <template slot-scope="scope">
            {{ filterDictText(leaderStatus,scope.row.isLeader) }}
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </section>
  </div>
</template>

<script>
/* api*/
import { queryExpertListByStageId, getResultsOfExtractingExpert } from '@/api/bidding/bidCommittee'
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin' // 分页
import { bidCommitteeMixin } from './../mixins/bidCommitteeMixin'// 组建评标委员会-公共方法
import { bidCommitteeGroupMixin } from './../mixins/bidCommitteeGroupMixin'// 组建评标委员会-字典信息
/* 公用方法*/
import { filterObj, filterDictText } from '@/assets/js/utils'// 常用方法
/* 组件*/
import pagination from '@comp/common/pagination/pagination'
// 分页组件
export default {
  name: 'BidCommitteeAdd',
  components: {
    pagination // 分页组件
  },
  mixins: [ListMixin, bidCommitteeMixin, bidCommitteeGroupMixin],
  data() {
    return {
      loading: true, // loading效果
      tenderBase: this.$store.getters.tenderBase, // 项目信息
      packInfo: this.$store.getters.packInfo, // 标包信息-当前
      tableData: [] // 委员会-专家
    }
  },
  created() {
    this.loadData()// 获取数据
  },
  methods: {
    filterDictText,
    // 获取专家
    handelGetResultsOfExtractingExpert() {
      const params = {
        ...this.packInfo,
        stageType: this.tenderBase.stageType,
        tenderId: this.tenderBase.tenderId
      }
      getResultsOfExtractingExpert(params).then(response => {
        this.loadData()// 获取数据
      }).catch(() => {
      })
    },
    // 获取数据
    loadData() {
      // 查询参数值
      const params = this.getQueryParams()// 查询条件
      queryExpertListByStageId(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
        // 传递给父节点列表数据
        this.$emit('bidCommitteeTableData', this.tableData)
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = {
        stageId: this.packInfo.stageId, // 阶段id
        expertSource: '01' // 专家来源 00是外部专家库,也就是直接录入的那种,  01是抽取
      }
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    }
  }
}
</script>

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