<template>
    <view class="bg-white mx-card">
        <view class="p-30 fx-row fx-bet-sta gap-20">
            <view class="fx-col gap-5">
                <text class="text-primary">[{{ paperTypeName }}]</text>
                <text class="text-main mb-8">{{ item.paperName }}</text>
                <uv-text type="tips" size="13" prefix-icon="clock" :text="item.createTime"/>
            </view>
            <view class="fx-col fx-cen-cen p-20 bg-slate-100 rounded-xl">
                <text v-if="!item.accuracy" class="text-lg text-tips">未阅卷</text>
                <text v-else class="text-lg" :class="getAccuracyClass()">{{ item.accuracy }}%</text>
                <text class="text-4xs text-tips">得分率</text>
            </view>
        </view>
        <uv-line/>
        <view class="py-20 fx-row fx-bet-cen">
            <ie-paper-collect :paper="item"/>
            <mx-tag-button text="查看详情" icon="arrow-right" reverse @click="handleDetail"/>
        </view>
    </view>
</template>

<script setup>
import {computed} from 'vue'
import {createPropDefine} from "@/utils";
import IePaperCollect from "@/pagesOther/pages/topic-center/paper-entry/components/ie-paper-collect.vue";
import {useTransfer} from "@/hooks/useTransfer";

const {transferTo} = useTransfer()
const props = defineProps({
    item: createPropDefine({}, Object)
})
const paperTypeName = computed(() => paperTypeMap[props.item.paperType] || props.item.paperType)

const paperTypeMap = {
    // TODO：ie类型暂定为知识点练习
    ie: '知识点练习',
    know_test: '知识点练习',
    auto: '基础题库',
    high_error: '高频错题',
    smart_test: '智能刷题',
    paper: '试卷'
}

const getAccuracyClass = () => {
    let {accuracy} = props.item
    if (!accuracy) return ''
    accuracy = accuracy * 1
    if (accuracy >= 80) return 'text-success'
    if (accuracy >= 60) return 'text-primary'
    return 'text-error'
}

const handleDetail = () => {
    const next = {
        readonly: true,
        examineeId: props.item.examineeId,
        title: paperTypeName.value
    }
    transferTo('/pages/topic-center/paper-exam/paper-exam', next);
}
</script>

<style scoped>

</style>