<template>
  <div class="from-table" style="height:650px;overflow:auto;">
    <a-spin :spinning="loading" style="width: 100%;height: 100%;">
      <a-row>
        <a-col :span="4" class="bg-gray">
          姓名：
        </a-col>
        <a-col :span="8">
          {{assignExpertInfo.personName}}
        </a-col>
        <a-col :span="4" class="bg-gray">
          证件号：
        </a-col>
        <a-col :span="8">
          {{assignExpertInfo.certId}}
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="4" class="bg-gray">
          性别：
        </a-col>
        <a-col :span="8">
          {{assignExpertInfo.sex}}
        </a-col>
        <a-col :span="4" class="bg-gray">
          职称：
        </a-col>
        <a-col :span="8">
          {{assignExpertInfo.titleName}}
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="4" class="bg-gray">
          联系电话：
        </a-col>
        <a-col :span="8">
          {{assignExpertInfo.mobile}}
        </a-col>
        <a-col :span="4" class="bg-gray">
          邮箱：
        </a-col>
        <a-col :span="8">
          {{assignExpertInfo.email}}
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="4" class="bg-gray">
          专业：
        </a-col>
        <a-col :span="20">
          <a-tag v-for="data in assignExpertInfo.specList" :key="data.id" :color="'green'">{{data.specName}}</a-tag>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="4" class="bg-gray">
          工作单位：
        </a-col>
        <a-col :span="20">
          {{assignExpertInfo.unitName}}
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="24" class="titalCol">
          <div>评审项目列表</div>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="24">
          <a-table style="margin: 5px;" :dataSource="assignExpertInfo.projAssignList" size="small" :scroll="{ y: 300 }" :columns="columns" rowKey="id" :pagination="false" :loading="loading">
            <template slot="evaluationInfo" slot-scope="record">
              <a-tag v-if="!!record.auditState && record.auditState == 2" :color="'green'">{{record.totalScore}}</a-tag>
              <a-tag v-else :color="'red'">未评审</a-tag>
            </template>
            <template slot="projClassInfo" slot-scope="record">
              {{ record.projClass == 1 ? "一般项目" : "重点项目" }}
            </template>
          </a-table>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="24" style="text-align:center;">
          <a-button type="danger" size="small" @click="del">删除</a-button>
        </a-col>
      </a-row>
    </a-spin>
  </div>
</template>

<script>
export default {
  name: "assignExpertView",
  props: {
    value: {
      type: String,
      default: () => {
        return null;
      },
    },
  },
  data () {
    return {
      assignExpertInfo: {

      },
      loading: true,
      tableData: [],
      columns: [
        { dataIndex: 'appNo', title: '申请编号', ellipsis: true, width: 150 },
        { dataIndex: 'projName', title: '项目名称', ellipsis: true },
        { title: "项目类别", scopedSlots: { customRender: 'projClassInfo' }, align: 'center', width: 80 },
        { title: '评分', scopedSlots: { customRender: 'evaluationInfo' }, align: 'center', width: 100 },
        { dataIndex: 'remark', title: '内容', align: 'center', ellipsis: true },
      ]
    };
  },
  created () {
    this.getAssignExpertById()
  },
  computed: {

  },
  methods: {
    getAssignExpertById () {
      let pars = { id: this.value }
      this.$api.projectAssign.getAssignGroupExpertById(pars).then(({ data = {} }) => {
        if (data) {
          this.assignExpertInfo = data
          this.loading = false
        } else {
          this.$message.error('评审专家已删除')
          this.$emit('close')
        }
      }).catch(() => { })
    },
    del () {
      let self = this
      this.$confirm({
        title: '评审专家及其评审项目明细删除',
        content: '确定要删除该评审专家及其评审项目明细？',
        okText: '确定',
        okType: 'danger',
        cancelText: '取消',
        onOk () {
          self.loading = true
          let pars = { id: self.value }
          self.$api.projectAssign.deleteAssignGroupExpert(pars).then(({ data = {} }) => {
            if (data) {
              self.$message.success('删除成功')
              self.$emit('close')
            }
            self.loading = false
          }).catch(() => {
            self.loading = false
          })
        },
        onCancel () {
        },
      })
    },
    evaluationColor (value) {
      if (value)
        return 'green'
      else
        return 'red'
    },
    evaluationText (value) {
      if (value)
        return '已评审'
      else
        return '未评审'
    },
  }
};
</script>

<style scoped>
.titalCol {
  text-align: center;
  background: #f8fafc;
  font-weight: bold;
}
</style>
