<template>
  <div style="text-align: right">
    <el-tabs v-model="activeName">
      <!-- 报表导出 -->
      <el-tab-pane
        :label="$t('trials:readingTracking:reviewResult:reportsExport')"
        name="reportsExport"
      >
        <el-tabs type="border-card" v-model="reportCriterionId">
          <el-tab-pane
            :label="i.TrialReadingCriterionName"
            :name="i.TrialReadingCriterionId"
            v-for="i of trialCriterionList"
            :key="i.TrialReadingCriterionId"
          >
            <exportList 
              v-if="reportCriterionId === i.TrialReadingCriterionId && activeName === 'reportsExport'" 
              :trialReadingCriterionId="i.TrialReadingCriterionId" 
              :data="data"
            />
          </el-tab-pane>
        </el-tabs>
      </el-tab-pane>
      <!-- 报表导出配置 -->
      <el-tab-pane
        :label="$t('trials:readingTracking:reviewResult:reportsConfig')"
        name="reportsConfig"
      >
        <el-tabs type="border-card" v-model="reportConfigCriterionId">
          <el-tab-pane
            :label="i.TrialReadingCriterionName"
            :name="i.TrialReadingCriterionId"
            v-for="i of trialCriterionList"
            :key="i.TrialReadingCriterionId"
          >
            <configList 
              v-if="reportConfigCriterionId === i.TrialReadingCriterionId && activeName === 'reportsConfig'" 
              :trialReadingCriterionId="i.TrialReadingCriterionId"
            />
          </el-tab-pane>
        </el-tabs>
      </el-tab-pane>
    </el-tabs>
    
  </div>
</template>

<script>
import { getTrialCriterionList } from '@/api/trials/reading'
import exportList from './exportList'
import configList from './configList'
export default {
  name: 'ReviewResults',
  components: {
    exportList,
    configList
  },
  data() {
    return {
      loading: false,
      trialCriterionList: [],
      reportCriterionId: null,
      trialId: null,
      activeName: 'reportsExport',
      reportConfigCriterionId: ''
    }
  },
  props: {
    data: {
      type: Object,
      default() {
        return {}
      },
    },
  },
  mounted() {
    this.trialId = this.$route.query.trialId
    this.getTrialCriterionList()
  },
  methods: {
    async getTrialCriterionList() {
      try {
        let res = await getTrialCriterionList(this.trialId)
        if (res.IsSuccess) {
          this.trialCriterionList = res.Result
          this.reportCriterionId = this.trialCriterionList[0].TrialReadingCriterionId
          this.reportConfigCriterionId = this.trialCriterionList[0].TrialReadingCriterionId
        }
      } catch(e) {
        console.log(e)
      }
    },
  },
}
</script>

<style scoped>
</style>
