<template>
  <el-dialog
    append-to-body
    v-if="dialogVisible"
    title="单科报告"
    :visible.sync="dialogVisible"
    width="70%"
  >
    <div v-if="Object.keys(reportInfo).length > 0">
      <p>点评：</p>
      <div class="mt10 mb10">
        <p>1,学校现在所开设的六种科目,
          <span  class="f-red">
            {{tipsModel.admissionInfo}}
          </span>,
          现有
          <span class="f-primary">
            {{ canSign.map(item => item.groupName).join(',') }}
          </span>您可以报名
        </p>
      </div>
      <div class="mb10">
        <p>2,专业符合情况：</p>
        <div class="mb5" v-for="item in canSign">
          <span class="f-primary mr5"> {{item.groupName}}:</span>
          <div style="display: inline" v-if="item.colleges.length > 0">
            <span class="mr5" v-for="college in item.colleges">{{`${college.major}(${college.college})`}},</span>
             符合您的专业要求;
          </div>
          <p style="display: inline" class="f-red" v-else>您的自选专业没有符合该组合的</p>
        </div>
      </div>
      <div class="mb10">
        <p>3,三科成绩情况：</p>
        <div v-for="(item,index) in canSign">
          <span>{{item.groupName}} : </span>成绩{{item.scoreSumGroup}} <span class="f-primary" v-if="index == 0"> *成绩最优</span>
        </div>
      </div>
      <div class="mb10">
        <p class="mb10">4,三科录取分析：</p>
        <div v-for="(item,index) in canSign" class="mb10">
          <p>{{item.groupName}} : 成绩{{item.scoreSumGroup}}<span class="f-primary" v-if="index == 0"> (补录成绩最优组合)</span> </p>
          <p>在补录学生{{tipsModel.countNumber}}人中该组合成绩最优学生有{{item.bestInIndicator}}人,该组合计划人数为{{item.groupIndicator}}
            您在该<span v-if="index == 0">最优</span>组合中排名{{ item.rankInBest }},您可以被该组合录取。您的成绩符合该组合。<span v-if="item.colleges.length == 0">（自选专业不符合）</span>
            <span v-if="index == 0">按照成绩优先原则,系统推荐您报该组合。</span>
            <span v-else>您如果不填写系统推荐您的最优组合,您也可以报该组合。</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'

export default {
  mixins:[MxSelectTranslateMixin],
  props: {
    prevPreferences: {
      type:Array,
      default: []
    },
    reportInfo: {
      type: Array,
      default: {}
    },
    currentGroup: {
      type: String,
      default: ''
    }
  },
  computed: {
    tipsModel(){
      if(!this.prevPreferences.length) return {}
      const countNumber = this.canSign.reduce((prev,cur)=>{
         return prev + cur.groupIndicator
      },0)
      const str = this.prevPreferences.map(item=>{
        return this.translateGroup(item)
      }).join('、')
      const admissionInfo = `${str}您不符合条件`
      return {
        countNumber,
        admissionInfo
      }
    },
    isCanSignFlag() {
      // 传入的组合是否能报名
      if (!this.reportInfo.length) return {}
      if (!this.currentGroup) return {}

      return this.reportInfo.filter(item => {
        return item.groupName == this.currentGroup
      })[0]
    },
    canSign() {
      if (!this.reportInfo.length) return []
      return this.reportInfo.filter(item => {
        return item.allowSelect
      }).sort((prev,next )=> prev.scoreSumGroup <  next.scoreSumGroup ?  1 : -1 )
    }
  },
  data() {
    return {
      dialogVisible: false
    }
  },
  methods: {}
}
</script>
<style scoped>
</style>
