<template>
  <div />
</template>
<script>
import store from '@/store'
import { changeURLStatic } from '@/utils/history.js'
export default {
  name: 'ReadPage',
  data() {
    return {

      readingTool: null,
      token: null
    }
  },
  mounted() {
    if (this.$router.currentRoute.query.TokenKey) {
      this.token = this.$router.currentRoute.query.TokenKey
      store.dispatch('user/setToken', this.$router.currentRoute.query.TokenKey)
      changeURLStatic('TokenKey', '')
    }
    this.readingTool = this.$router.currentRoute.query.readingTool ? JSON.parse(this.$router.currentRoute.query.readingTool) : 1
    this.readingPage()
  },
  methods: {
    readingPage() {
      var TrialReadingCriterionId = this.$router.currentRoute.query.TrialReadingCriterionId
      var trialId = this.$router.currentRoute.query.trialId
      var subjectCode = this.$router.currentRoute.query.subjectCode
      var subjectId = this.$router.currentRoute.query.subjectId
      var visitTaskId = this.$router.currentRoute.query.visitTaskId
      var isReadingTaskViewInOrder = this.$router.currentRoute.query.isReadingTaskViewInOrder
      var criterionType = this.$router.currentRoute.query.criterionType
      var path = ''
      if (this.readingTool === 0) {
        path = `/readingDicoms?TrialReadingCriterionId=${TrialReadingCriterionId}&trialId=${trialId}&subjectCode=${subjectCode}&subjectId=${subjectId}&visitTaskId=${visitTaskId}&isReadingTaskViewInOrder=${isReadingTaskViewInOrder}&criterionType=${criterionType}&readingTool=${this.readingTool}&TokenKey=${this.token}`
      } else {
        path = `/noneDicomReading?TrialReadingCriterionId=${TrialReadingCriterionId}&trialId=${trialId}&subjectCode=${subjectCode}&subjectId=${subjectId}&visitTaskId=${visitTaskId}&isReadingTaskViewInOrder=${isReadingTaskViewInOrder}&criterionType=${criterionType}&readingTool=${this.readingTool}&TokenKey=${this.token}`
      }
      this.$router.push({ path })
    }
  }
}
</script>

