<template>
    <view v-if="isReadonly">自行参考</view>
    <view v-else-if="rule.valid" class="fx-row gap-5 items-center text-success">
        <text v-if="isScoreTotal" :class="enrollRateColor">{{ rule.enrollRateText }}</text>
        <template v-else>
            <uv-icon name="checkmark" color="success"/>
            已达成
        </template>
    </view>
    <view v-else-if="rule.valid===null" class="fx-row gap-5 items-center" @click="$emit('tip', rule.failedMessage)">
        <uv-icon name="question-circle"/>
        无法计算
    </view>
    <view v-else class="fx-row gap-5 item-center text-error" @click="$emit('tip', rule.failedMessage)">
        <uv-icon name="close" size="14" color="error"/>
        未达成
    </view>
</template>

<script>
import MxConst from "@/common/MxConst";

export default {
    name: "enroll-status",
    props: {
        rule: {
            type: Object,
            default: () => ({})
        }
    },
    computed: {
        isReadonly() {
            return this.rule.type == MxConst.enum.ai.ruleType.readonly
        },
        isScoreTotal() {
            return this.rule.type == MxConst.enum.ai.ruleType.scoreTotal
        },
        enrollRateColor() {
            switch (this.rule.enumPickType) {
                case MxConst.enum.ai.pickType.danger.value:
                    return 'f-' + MxConst.enum.ai.pickType.danger.color
                case MxConst.enum.ai.pickType.normal.value:
                    return 'f-' + MxConst.enum.ai.pickType.normal.color
                case MxConst.enum.ai.pickType.safety.value:
                    return 'f-' + MxConst.enum.ai.pickType.safety.color
                default:
                    return 'f-333'
            }
        }
    }
}
</script>

<style scoped>

</style>