<template>
  <div class="bg-page fx-column fx-cen-cen">
    <index-card title="心理健康（MHT）" class="index-block">
      <el-button slot="more" v-has-history size="small" round @click="$router.back()">返回</el-button>
      <mx-paper :options="options" />
    </index-card>
  </div>
</template>

<script>
import IndexCard from '@/views/login/components/modules/shared/IndexCard.vue'
import MxPaper from '@/components/MxPaper/mx-paper.vue'
import transferMixin from '@/components/mx-transfer-mixin'
import paperMixin from '@/components/MxPaper/mx-paper-mixin'
import EventBus from '@/components/EventBus'
import {openExamineePaper, scoreExamineeQuestion} from "@/api/webApi/studentEvaluating";

export default {
  name: 'MentalHealthPaper',
  components: { IndexCard, MxPaper },
  mixins: [transferMixin, paperMixin],
  data() {
    return {
      overrideOpts: {
        customScoredAction: true,
        customCommittedAction: true,
        navigatorSpan: 10
      }
    }
  },
  computed: {
    queryApi() {
      // always use openExamineePaper api.
      return openExamineePaper
    },
    scoreApi() {
      // always use scoreExamineeQuestion api.
      return scoreExamineeQuestion
    }
  },
  mounted() {
    EventBus.instance.$on('customScoredAction', () => this.innerLoadPaper())
    EventBus.instance.$on('customCommittedAction', () => this.innerLoadPaper())
    this.loadPaper(this.prevData, this.overrideOpts)
  },
  beforeDestroy() {
    EventBus.instance.$off('customScoredAction')
    EventBus.instance.$off('customCommittedAction')
  },
  methods: {
    innerLoadPaper() {
      const next = {
        ...this.prevData,
        examineeId: this.paper.examineeId
      }
      const nextRoute = this.$router.resolve({name: 'MentalHealthReport'})
      this.transferTo(nextRoute.href, next, null, true)
    }
  }
}
</script>

<style scoped>

</style>
