<template>
  <div class="fx-column">
    <el-tabs v-model="activeTab" type="card">
      <el-tab-pane v-for="(tab,idx) in tabs" :key="idx" :label="tab.title" :name="tab.value"></el-tab-pane>
    </el-tabs>
    <round-score-import v-if="activeTab==0" :default-show-search="false" :enable-selection="true"
                        @selectionChanged="handleScoreSelection"></round-score-import>
    <div v-if="activeTab==1">阅卷系统导入即将开通，敬请期待</div>
    <div v-if="activeTab==2">测评系统导入即将开通，敬请期待</div>
  </div>
</template>

<script>
import RoundScoreImport from '@/views/permission/round-score-import'

export default {
  name: 'round-setting-score',
  components: { RoundScoreImport },
  props: {
    settingModel: {
      type: Object,
      default: _ => ({})
    }
  },
  data() {
    return {
      activeTab: '0',
      tabs: [{ title: '手工导入', value: '0' },
        { title: '阅卷系统导入', value: '1' },
        { title: '测评系统导入', value: '2' }]
    }
  },
  methods: {
    handleScoreSelection(selections) {
      let exists = this.settingModel.importWeight
      const newSelections = selections.filter(i => !exists.some(s => s.importId == i.importId))
      exists.push(...newSelections)
      this.$set(this.settingModel, 'importWeight', exists)
      this.msgSuccess('导入成功')
    },
    shouldGoNext() {
      if (!this.settingModel.importWeight?.length) {
        const error = '请先导入选科成绩，否则系统将无法进行AI选科决策'
        this.$alert(error, '错误提示', { type: 'error' })
        return Promise.reject(error)
      }
      return Promise.resolve(this.settingModel)
    }
  }
}
</script>

<style scoped>

</style>
