<template>
    <view v-if="list.length" class="mt-20">
        <uv-row class="text-2xs text-content">
            <uv-col :span="3">年份</uv-col>
            <uv-col :span="3">录取</uv-col>
            <uv-col :span="3">最低分</uv-col>
            <uv-col :span="3">最低位次</uv-col>
        </uv-row>
        <uv-row v-for="(history, idx) in list.filter(h => h)" class="mt-10 text-xs text-content">
            <uv-col :span="3">
                <view v-if="history">{{ history.year }}</view>
                <view v-else>{{ historyYears[idx] }}</view>
            </uv-col>
            <template v-if="history">
                <uv-col :span="3">
                    <view>
                        {{ history.numReal || '-' }}
                        <text>人</text>
                    </view>
                </uv-col>
                <uv-col :span="3">
                    <view class="fx-row">
                        <text v-if="!history.inheritScore">{{ history.score || '-' }}</text>
                        <view v-else class="fx-row" @click="$emit('notify', inheritScoreTips)">
                            {{ history.score || '-' }}
                            <uv-icon name="question-circle"/>
                        </view>
                        <uv-badge v-if="history.collect" value="征集" shape="horn" class="mr3"
                                  @click.native="$emit('notify', history.collectDesc)"/>
                    </view>
                </uv-col>
                <uv-col :span="3">
                    <view>{{ history.seat || '-' }}</view>
                </uv-col>
            </template>
            <template v-else>
                <uv-col :span="9">
                    <view class="fx-row" @click="$emit('notify', unmatchedTips)">
                        未招生
                        <uv-icon name="question-circle"/>
                    </view>
                </uv-col>
            </template>
        </uv-row>
    </view>
</template>

<script>
import {useInjectVoluntaryHeader} from "@/pagesOther/pages/voluntary/hooks/useVoluntaryHeaderInjection";

export default {
    name: "voluntary-history-list",
    emits: ['notify'],
    props: {
        container: {
            type: Object,
            default: () => ({})
        }
    },
    data() {
        return {
            unmatchedTips: '未招生，或者专业名称/备注发生变化',
            inheritScoreTips: '院校或专业组分数线，专业分数线未更新或者官网未公布'
        }
    },
    setup() {
        const {historyYears} = useInjectVoluntaryHeader()
        return {
            historyYears
        }
    },
    computed: {
        list() {
            return this.container?.histories || []
        }
    }
}
</script>

<style scoped>

</style>
