<template>
  <div style="text-align: left">
    <el-tabs
      type="border-card"
      v-model="TrialReadingCriterionId"
      style="height: 300px"
    >
      <el-tab-pane
        :label="i.TrialReadingCriterionName"
        :name="i.TrialReadingCriterionId"
        v-for="i of trialCriterionList"
        :key="i.TrialReadingCriterionId"
      >
        <div class="message">
          <span>{{ $t('trials:consistencyAnalysis:button:exportSelf') }}</span>
          <el-button
            type="primary"
            icon="el-icon-download"
            @click="handleExport(5)"
            size="mini"
          >
            {{ $t('common:button:export') }}
          </el-button>
        </div>
        <div class="message">
          <span>{{ $t('trials:consistencyAnalysis:button:exportGroup') }}</span>
          <el-button
            type="primary"
            icon="el-icon-download"
            @click="handleExport(6)"
            size="mini"
          >
            {{ $t('common:button:export') }}
          </el-button>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { getTrialCriterionList } from '@/api/trials/reading'

export default {
  name: 'exportList',
  data() {
    return {
      TrialReadingCriterionId: null,
      trialId: null,
    }
  },
  mounted() {
    this.trialId = this.$route.query.trialId
    this.getTrialCriterionList()
  },
  methods: {
    handleExport(type) {
      this.$emit('handleExport', type, this.TrialReadingCriterionId)
    },
    getTrialCriterionList() {
      getTrialCriterionList(this.trialId)
        .then((res) => {
          this.trialCriterionList = res.Result
          this.TrialReadingCriterionId =
            this.trialCriterionList[0].TrialReadingCriterionId
        })
        .catch(() => {})
    },
  },
}
</script>

<style scoped>
.message {
  display: flex;
  align-items: center;
  line-height: 60px;
}
.message span {
  margin-right: 20px;
}
</style>
