<template>
  <div>
    <enroll-report :generation="generation" :optional-majors="optionalMajors"
                   :dispatch-info="dispatchInfo"></enroll-report>
    <div v-if="dispatchInfo&&dispatchInfo.eSignImage" class="mt40 mb40 ml40 f24">
      <div class="fx-row bold fx-sta-cen">
        <span style="white-space: nowrap;">签名：</span>
        <el-image :src="dispatchInfo.eSignImage" fit="contain" style="height: 36px; width: 120px;"></el-image>
      </div>
      <div class="fx-row bold fx-sta-cen mt10">
        <span>报告日期：</span>
        <span>{{ dispatchInfo.activeDate }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import EnrollReport from '@/views/career/bigdataSelectCourse/enrollReport'
import { classesResult } from '@/api/webApi/elective/dispatch'

export default {
  name: 'elective-enroll-analysis',
  inject: ['getGeneration', 'getOptionalMajors'],
  components: { EnrollReport },
  data() {
    return {
      dispatchInfo: {}
    }
  },
  computed: {
    generation() {
      return this.getGeneration() || {}
    },
    optionalMajors() {
      return this.getOptionalMajors() || []
    }
  },
  watch: {
    'generation': function(newVal) {
      if (newVal?.status?.roundId) this.loadDispatchInfo()
    }
  },
  methods: {
    loadDispatchInfo() {
      const { year, roundId } = this.generation.status
      classesResult({ year, roundId }).then(res => this.dispatchInfo = res.rows.first() || {})
    }
  }
}
</script>

<style scoped>

</style>
