<!--
  @description: 组件委员会-添加专家
  @Modifier: yf
  @routerPath:
  @date: 2020/7/7-17:16
-->
<template>
  <el-dialog
    v-dialogDrag
    v-loading="loading"
    :visible.sync="selectExpertDialog.dialog"
    :close-on-click-modal="false"
    title="选择专家"
    width="850px"
    custom-class="el-dialog__body-p0"
  >
    <div class="main mb10 form_table_main">
      <el-table
        v-loading="loading"
        :data="tableData"
        highlight-current-row
        border
        @current-change="currentChange"
      >
        <el-table-column type="index" label="序号" width="50" align="center" />
        <el-table-column label="姓名" width="80" prop="expertName" align="center" />
        <el-table-column label="专家身份证号" min-width="150" prop="idcardNo" align="center" />
        <el-table-column label="手机号" width="100" prop="expertTelephone" align="center" />
        <el-table-column label="工作单位" min-width="150" prop="company" align="center" />
      </el-table>
      <!--分页组件-->
      <page-nation :pagination-data="paginationData" @change="initData" />
    </div>
    <div slot="footer" class="dialog-footer" style="text-align: center">
      <el-button type="primary" @click="selectExperts">
        确 定
      </el-button>
      <el-button @click="selectExpertDialog.dialog=false">
        取 消
      </el-button>
    </div>
  </el-dialog>
</template>
<script>
/* 分页组件*/
import pagination from '@comp/common/pagination/pagination'
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin' // 分页
/* api */
import {
  listProcurementExpertdrawOffByExpertName
} from '@/api/procurement/procurementEvaluation'
export default {
  components: {
    'page-nation': pagination // 分页组件
  },
  mixins: [ListMixin],
  props: {
    selectExpertDialog: {
      type: Object,
      default: function() {
        return {
          dialog: false,
          expertName: '' // 专家姓名
        }
      }
    }
  },
  data() {
    return {
      loading: true,
      tableData: [], // 表格数据
      currentData: {} // 勾选数据
    }
  },
  watch: {
    // 弹框打开状态
    'selectExpertDialog.dialog'(val) {
      if (val) {
        this.initData()
      }
    }
  },
  methods: {
    // 初始化数据
    initData() {
      const data = {
        expertName: this.selectExpertDialog.expertName, // 专家姓名
        packId: this.selectExpertDialog.packId, // 标段id
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize
      }
      listProcurementExpertdrawOffByExpertName(data).then(res => {
        this.loading = false
        // 设置列表总条数
        this.paginationData.total = res.data.total
        // 列表数据
        this.tableData = res.data.records
      })
    },
    // 勾选数据
    currentChange(val) {
      this.currentData = val
    },
    // 确定
    selectExperts() {
      // 关闭弹框
      this.selectExpertDialog.dialog = false
      this.$emit('selectExpert', this.currentData)
    }
  }
}
</script>
<style lang="less" scoped>
  .tableLimit {
    cursor: pointer;
    /deep/.el-table__body tr.current-row>td {
      background-color: #dbe5ec;
    }
  }
  .form_table_main{
    padding: 0 10px 10px;
  }
</style>
