<template>
  <el-dialog
    append-to-body
    v-if="dialogVisible"
    :title="aiType == 'all' ? '整体报告' : '单科报告'"
    :visible.sync="dialogVisible"
    width="70%"
  >
    <div>
      <div v-if="Object.keys(reportInfo).length > 0">
        <p>点评：</p>
        <div class="mt10 mb10">
          <div class="fx-row" style="align-items: center">1,
            <p v-html="admissionInfo.slice(0,admissionInfo.lastIndexOf('，'))"></p>
            <span>,学校现在所开设的六种科目,</span> 现有
            <span class="f-primary">
              {{ canSign.map(item => item.groupName).join(',') }}
            </span>您可以报名
          </div>
        </div>
        <div class="mt10" v-if="aiType == 'single' && !singleRow.allowSelect">
          {{ singleRow.groupName }}不可报名
        </div>
        <div v-else>
          <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">
              <div v-if="!singleRow || singleRow.groupId == item.groupId">
                <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>
        </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 {
  name: 'subject-report',
  mixins: [MxSelectTranslateMixin],
  props: {
    admissionInfo: {
      type: String,
      default: ''
    },
    reportInfo: {
      type: Array,
      default: {}
    }
  },
  computed: {
    tipsModel() {
      const countNumber = this.canSign.reduce((prev, cur) => {
        return prev + cur.groupIndicator
      }, 0)

      return {
        countNumber
      }
    },
    // 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,
      singleRow: {}
    }
  },
  methods: {
    init(type, row) {
      this.aiType = type
      this.dialogVisible = true
      this.singleRow = row
      console.log(row)
    }
  }
}
</script>
<style scoped>
</style>
