<template>
  <el-dialog
    append-to-body
    v-if="dialogVisible"
    title="选科过程报告"
    :visible.sync="dialogVisible"
    width="70%"
  >
    <div>
      <div class="mb10" >
        <p class="mb5">1，报名情况：</p>
          <span v-if="approved">恭喜</span>
          <span  v-if="!appliedModel.selectedList.length">
            <span>您在{{subTitle(appliedModel.option.title)}}阶段未填报，</span>
          </span>
          <span  v-else-if="appliedModel.selectedList.some(m=>m.rejected)">
            <span>您在{{subTitle(appliedModel.option.title)}}阶段拒绝填报了</span>
            <span class="f-red"> {{apply.toString(',')}} </span>组合，
          </span>
          <span v-else>
            <span>您在{{subTitle(appliedModel.option.title)}}阶段填报的</span>
            <span :class="approved ? 'f-primary': 'f-red'"> {{apply.toString(',')}}组合 </span>
            <span  v-if="approved">已被录取</span>
            <span v-else>未被录取</span>,
          </span>
          <span>学校现在所开设的{{activeModel.models.length}}种科目,现有 <span class="f-primary">{{ canSign.map(item => item.groupName).join(',') }} </span> {{canSign.length}}个科目缺额, </span>
          <span>系统推荐您 <span class="f-primary">{{activeModel.models.find(item => item.isRecommend).groupName}}</span> 科目组合</span>
      </div>
      <div>
        <div class="mb10">
          <p class="mb5">2，专业符合情况：</p>
          <div class="mb5" v-for="item in canSign">
            <div class="f-primary mr5 mb5"> {{item.groupName}}{{item.groupName == recommend ? '(系统推荐科目组合)' : ''}}</div>
            <div style="display: inline" v-if="item.colleges.length > 0">
              <span class="mr5" v-for="college in item.colleges">{{ college.college }}：{{college.major}}。</span>
              符合您的专业要求;
            </div>
            <p style="display: inline" class="f-red" v-else>该组合没有您自选的专业</p>
          </div>
        </div>
        <div class="mb10">
          <p class="mb5">3，成绩情况：</p>
          <div v-for="(item,index) in canSign" class="mb10">
            <div class="mb5">{{ item.groupName }}:{{index == 0 ? '(成绩最优)': ''}}</div>
            <div>成绩{{ item.scoreSumGroup }}</div>
          </div>
        </div>
        <div class="mb10">
          <p class="mb5">4，录取分析：</p>
          <p  class="f-primary">系统推荐:{{recommend}}{{canSign[0].groupName == recommend ? '成绩最优组合' : ''}}</p>
          <p>您所在学校参与{{activeModel.option.title}}的学生共计有{{activeModel.disenrollCount}}人</p>
          <p>您在未录满的{{canSign.length}}个组合中，全校{{ activeModel.option.title }}人数排名如下:</p>
          <p v-for="item in canSign">
            {{item.groupName}} <span class="f-red">{{item.rankInDisenroll}}</span> 名 <span>{{`(${item.rankInDisenroll}/${activeModel.disenrollCount})`}}</span>
          </p>
          <p>计划数如下:</p>
          <p v-for="item in canSign">{{item.groupName}} <span class="f-red">{{item.groupIndicator}}</span> 人</p>
          <p>成绩最优人数如下:</p>
          <p v-for="item in canSign">{{item.groupName}} <span class="f-red">{{item.bestInIndicator}}</span> 人</p>
          <p class="f-red">
            您在{{canSign.length}}个缺额组合中{{bestAchieve.groupName}}成绩最优组合{{ bestAchieve.scoreSumGroup }}分，
            在该组合最优人数{{ bestAchieve.bestInIndicator }}人中，排名第{{bestAchieve.rankInBest}}名，
            全校排名第{{bestAchieve.rankInDisenroll}}名，计划数为{{bestAchieve.groupIndicator}}人
            <span v-if="section.must">
              ，您可以被该组合录取。
            </span>
            <span v-else-if="section.maybe">
              ，如果没有其他学生在该组合全校排名比您高且填报该组合，您可以被该组合录取。
            </span>
            <span v-else>
              ，所以您不能被成绩最优组合{{bestAchieve.groupName}}录取，系统推荐您报名{{recommend}}组合
            </span>
          </p>
        </div>
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible =false">确 定</el-button>
      </span>
  </el-dialog>
</template>
<script>
import MxSelectTranslateMixin from '@/components/Cache/modules/mx-select-translate-mixin.js'
import ElectiveEnrollInfo from '@/views/elective/select/components/elective-enroll-info'
import ElectiveToolsMixin from '@/views/elective/select/components/elective-tools-mixins'
// import ElectiveTableMixin from '@/views/elective/select/components/elective-table-mixins'

export default {
  name: 'elective-ai-report-dialog',
  mixins: [MxSelectTranslateMixin, ElectiveToolsMixin,ElectiveEnrollInfo],
  props: {
    generation: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      dialogVisible: false,
      singleRow: {}
    }
  },
  computed: {
    // 1报名情况 填报组合
    apply(){
      return this.appliedModel.selectedList.map(item => item.groupName)
    },
    // 1报名情况 推荐组合
    recommend() {
      return this.activeModel.models.find(item => item.isRecommend)?.groupName
    },
    activeModel() {
      if (!this.generation) return {}
      return this.generation.activeModel
    },
    // 成绩最优
    bestAchieve(){
      return this.canSign[0]
    },
    section() {
      return {
        must: this.bestAchieve.rankInDisenroll <= this.bestAchieve.groupIndicator, // 可以录
        maybe: this.bestAchieve.rankInBest <= this.bestAchieve.groupIndicator  && this.bestAchieve.rankInDisenroll > this.bestAchieve.groupIndicator, // 可能录上
        other: '', // 录不上,可以报推荐
      }
    },
    canSign() {
      // if (!this.reportInfo.length) return []
      return this.activeModel.models.filter(item => {
        return item.allowSelect
      }).sort((prev, next) => prev.scoreSumGroup < next.scoreSumGroup ? 1 : -1)
    }
  },
  methods: {
    init(type, row) {
      this.aiType = type
      this.dialogVisible = true
      this.singleRow = row
    }
  }
}
</script>
<style scoped>
</style>
