<template>
  <div class="from-table" style="height:300px;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="4" class="bg-gray">
          <div>评审结果：</div>
        </a-col>
        <a-col :span="20">
          <a-tag v-if="!assignExpertInfo.gradeScore" :color="evaluationColor(assignExpertInfo.gradeScore)">{{evaluationText(assignExpertInfo.gradeScore)}}</a-tag>
          <a-tag v-if="assignExpertInfo.gradeScore" :color="'green'">{{assignExpertInfo.gradeScore}}</a-tag>
        </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,
    };
  },
  created () {
    this.getAssignExpertById()
  },
  computed: {

  },
  methods: {
    getAssignExpertById () {
      let pars = { id: this.value }
      this.$api.projectAssign.getAssignExpertById(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.deleteAssignExpert(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>
