<template>
  <el-table
    ref="taskTbl"
    :data="taskList"
    :row-class-name="rowClass"
    class="historicAssess_wrapper"
  >
    <!-- 访视/阅片期名称 -->
    <el-table-column
      prop="VisitTaskNum"
      :label="$t('trials:medicalFeedback:table:taskName')"
      width="200"
      sortable="custom"
      show-overflow-tooltip
    >
      <template slot-scope="scope">
        {{ scope.row.TaskName }}
      </template>
    </el-table-column>
    <!-- 盲态任务标识 -->
    <el-table-column
      prop="TaskBlindName"
      :label="$t('trials:medicalFeedback:table:taskBlindName')"
      width="200"
      sortable="custom"
      show-overflow-tooltip
    />

    <template v-if="judgeQuestion && judgeQuestion.length > 0">
      <el-table-column
        v-for="(qs,index) in judgeQuestion"
        :key="qs"
        prop=""
        :label="qs"
        show-overflow-tooltip
        width="150"
      >
        <template slot-scope="scope">
          <span v-if="scope.row.JudgeQuestionAnswerInfoList[index] && scope.row.JudgeQuestionAnswerInfoList[index].QuestionGenre === 3 && scope.row.JudgeQuestionAnswerInfoList[index].DictionaryCode">
            {{ scope.row.JudgeQuestionAnswerInfoList[index].Answer?$fd(scope.row.JudgeQuestionAnswerInfoList[index].DictionaryCode,parseInt(scope.row.JudgeQuestionAnswerInfoList[index].Answer)):'' }}
          </span>
          <span v-else>
            {{ scope.row.JudgeQuestionAnswerInfoList.length>index?scope.row.JudgeQuestionAnswerInfoList[index].Answer:'' }}
          </span>

        </template>
      </el-table-column>
    </template>

    <!-- 有无更新 -->
    <!-- <el-table-column
      prop="IsGlobalChange"
      :label="$t('trials:medicalFeedback:title:isGlobalChange')"
      width="100"
      show-overflow-tooltip
    >
      <template slot-scope="scope">
        {{ $fd('YesOrNo', scope.row.IsGlobalChange) }}
      </template>
    </el-table-column> -->
    <!-- 当前阅片人 -->
    <el-table-column
      prop="ArmEnum"
      :label="$t('trials:medicalFeedback:title:currentReader')"
      show-overflow-tooltip
      width="120"
    >
      <template slot-scope="scope">
        <el-button
          v-if="scope.row.TaskId"
          type="text"
          @click="handleView(scope.row,scope.row.TaskId)"
        >
          {{ $fd('ArmEnum', scope.row.ArmEnum) }}
        </el-button>
      </template>
    </el-table-column>
    <!-- 关联阅片人 -->
<!--    <el-table-column-->
<!--      prop="OtherArmEnum"-->
<!--      :label="$t('trials:medicalFeedback:title:otherReader')"-->
<!--      show-overflow-tooltip-->
<!--      width="100"-->
<!--    >-->
<!--      <template slot-scope="scope">-->
<!--        <el-button-->
<!--          v-if="scope.row.OtherTaskId"-->
<!--          type="text"-->
<!--          @click="handleView(scope.row,scope.row.OtherTaskId)"-->
<!--        >-->
<!--          {{ $fd('ArmEnum', scope.row.OtherArmEnum) }}-->
<!--        </el-button>-->
<!--      </template>-->
<!--    </el-table-column>-->
<!--    &lt;!&ndash; 关联全局任务 &ndash;&gt;-->
<!--    <el-table-column-->
<!--      prop="GlobalTaskName"-->
<!--      :label="$t('trials:medicalFeedback:title:relatedGlobalTask')"-->
<!--      show-overflow-tooltip-->
<!--      width="120"-->
<!--    >-->
<!--      <template slot-scope="scope">-->
<!--        <el-button-->
<!--          v-if="scope.row.GlobalTaskId"-->
<!--          type="text"-->
<!--          @click="handleView(scope.row,scope.row.GlobalTaskId)"-->
<!--        >-->
<!--          {{ scope.row.GlobalTaskName }}-->
<!--        </el-button>-->
<!--      </template>-->
<!--    </el-table-column>-->
<!--    &lt;!&ndash; 关联裁判任务 &ndash;&gt;-->
<!--    <el-table-column-->
<!--      prop="JudgeTaskName"-->
<!--      :label="$t('trials:medicalFeedback:title:relatedadjudicationTask')"-->
<!--      show-overflow-tooltip-->
<!--      width="120"-->
<!--    >-->
<!--      <template slot-scope="scope">-->
<!--        <el-button-->
<!--          v-if="scope.row.JudgeTaskId"-->
<!--          type="text"-->
<!--          @click="handleView(scope.row,scope.row.JudgeTaskId)"-->
<!--        >-->
<!--          {{ scope.row.JudgeTaskName }}-->
<!--        </el-button>-->
<!--      </template>-->
<!--    </el-table-column>-->
  </el-table>
</template>
<script>
import { getToken } from '@/utils/auth'
export default {
  name: 'VReview',
  props: {
    auditInfo: {
      type: Object,
      default() {
        return {}
      }
    },
    rowData: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      taskList: [],
      judgeQuestion: []
    }
  },
  mounted() {
    this.initPage()
  },
  methods: {
    initPage() {
      var judgeQS = []
      if (this.auditInfo.TaskList.length > 0 && this.auditInfo.TaskList[0].JudgeQuestionAnswerInfoList) {
        this.auditInfo.TaskList[0].JudgeQuestionAnswerInfoList.map(v => {
          judgeQS.push(v.QuestionName)
        })
      }
      this.judgeQuestion = judgeQS
      this.taskList = this.auditInfo.TaskList
    },
    handleView(row, visitTaskId) {
      var trialId = this.$route.query.trialId
      // var visitTaskId = type === 1 ? row.TaskId : row.OtherTaskId

      var token = getToken()
      var criterionType = this.rowData.CriterionType
      var readingTool = this.rowData.ReadingTool
      readingTool = isNaN(parseInt(readingTool)) ? null : parseInt(readingTool)
      var isReadingTaskViewInOrder = this.rowData.IsReadingTaskViewInOrder
      var trialReadingCriterionId = this.rowData.TrialReadingCriterionId
      var path = ''

      if (readingTool === 0) {
        path = `/readingDicoms?TrialReadingCriterionId=${trialReadingCriterionId}&trialId=${trialId}&subjectCode=${this.rowData.SubjectCode}&subjectId=${this.rowData.SubjectId}&visitTaskId=${visitTaskId}&isReadingTaskViewInOrder=${isReadingTaskViewInOrder}&criterionType=${criterionType}&readingTool=${readingTool}&TokenKey=${token}&key=${new Date().getTime()}`
      } else {
        path = `/noneDicomReading?TrialReadingCriterionId=${trialReadingCriterionId}&trialId=${trialId}&subjectCode=${this.rowData.SubjectCode}&subjectId=${this.rowData.SubjectId}&visitTaskId=${visitTaskId}&isReadingTaskViewInOrder=${isReadingTaskViewInOrder}&criterionType=${criterionType}&readingTool=${readingTool}&TokenKey=${token}&key=${new Date().getTime()}`
      }
      const routeData = this.$router.resolve({ path })
      window.open(routeData.href, '_blank')
    },
    rowClass({ row, rowIndex }) {
      if (row.IsCurrentTask) {
        return 'highlight_row'
      }
    }
  }
}
</script>
<style lang="scss">
.historicAssess_wrapper{
  .highlight_row{
    color: #000;
    background-color: #ffde7b;
  }
  .highlight_row:hover>td {
    background-color: #ffde7b !important;
  }
}
</style>
