<template>
    <div class="knowledgePaps">
        <div class="chart_title">
            <div class="title_left">
                <span class="secondary_title" style="font-weight: bold;">3、</span>
                <span class="secondary_title" v-if="titleParts.knowledgeName">{{ titleParts.knowledgeName }} / </span>
                <span class="main_title">薄弱知识点精准提升</span>
            </div>
            <button class="export_btn" @click="$emit('export-knowledge-paps')">
                <i class="iconfont icon_export"></i>
                导出精准提升试题
            </button>
        </div>

        <div class="data_container" v-if="knowledgData.length > 0">
            <div class="question_item" v-for="(item, index) in knowledgData" :key="index">
                <!-- 推题头部 -->
                <div class="question_header">
                    <div class="question_meta">
                        <span class="question_num">{{ index + 1 }}</span>
                        <span class="question_type">题型类型：
                            <i class="typeColor" style="color:#333333;font-weight: bold;">{{ item.questionType }}</i>
                        </span>
                        <span class="question_difficulty">难度：
                            <i class="typeColor" style="color:#fac858;font-weight: bold;">{{ item.questionLevel }}</i>
                        </span>
                    </div>
                    <div class="question_source">来源：
                        <i class="typeColor" style="color:#999999;">{{ item.fromPaper }}</i>
                    </div>
                </div>
                <!-- 推题内容 -->
                <div class="question_content">
                    <p v-html ='item.title || "" '></p>
                </div>
                <!-- 推题底部 -->
                <div class="question_tags">
                    <span class="tags_label">知识点：</span>
                    <span class="tag" v-for="(knowledge, index) in (item.knowledge || '').split('、')" :key="index" v-if="knowledge">
                        {{ knowledge }}
                    </span>
                </div>
            </div>
        </div>

        <div 
           class="module_chart no_content_data no_data"  
           element-loading-background="#ffffff" v-else>
          <span>暂无数据</span> 
        </div>
    </div>
</template>
<script>
export default {
    name: "knowledgePaps",
    props: {
        // 知识点名称
        knowledgeName: {
            type: String,
            default: ''
        },
        // 薄弱知识点精准提升数据
        knowledgData: {
            type: Array,
            default: () => []
        }
    },
    computed: {
        // 标题部分
        titleParts() {
            return {
                knowledgeName: this.knowledgeName
            }
        }
    },
    data() {
        return {
        }
    },
    mounted() {
    },
    watch: {
        // knowledgData: {
        //     handler(newVal, oldVal) {
        //         console.log(newVal);
        //     },
        //     deep: true
        // }
    },
    methods: {
        
    },
}
</script>
<style scoped lang="scss">
.knowledgePaps {
    background: #FFFFFF;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 10px;
    position: relative;

    // 标题部分
    .chart_title {
        font-size: 16px;
        margin-bottom: 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 10px;

        .title_left {
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .main_title {
            font-weight: 600;
            color: #333;
        }

        .secondary_title {
            font-weight: normal;
            color: #999;
        }

        .export_btn {
            display: flex;
            align-items: center;
            gap: 5px;
            width: 152px;
            height: 36px;
            line-height: 36px;
            background: #2E64FA;
            color: white;
            border: none;
            border-radius: 4px;
            font-size: 14px;
            cursor: pointer;
            padding:0;
            transition: all 0.3s ease;

            &:hover {
                background: #5883fb;
            }

            &:active {
                background: #2E64FA;
            }

            .iconfont {
                width: 14px;
                margin-left: 10px;
            }
        }
    }

    // 内容部分
    .question_item {
        background: #FFFFFF;
        border-radius: 10px 10px 10px 10px;
        border: 1px solid #DCDFE6;
        padding: 20px;
        margin-bottom: 10px;
        transition: all 0.3s ease;
        &:hover {
            box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
        }
        // 试题标题
        .question_header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-bottom: 20px;
            flex-wrap: wrap;
            gap: 10px;
            border-bottom: 1px solid #EBEEF5;
            .question_meta {
                display: flex;
                align-items: center;
                gap: 10px;
                flex-wrap: wrap;

                .question_num {
                    display: inline-block;
                    width: 24px;
                    height: 24px;
                    line-height: 24px;
                    background: #2E64FA;
                    color: white;
                    border-radius: 4px;
                    text-align: center;
                    font-size: 14px;
                }

                .question_type,
                .question_difficulty {
                    font-size: 14px;
                    color: #999999;
                }
            }

            .question_source {
                font-size: 14px;
                color: #999;
            }
        }
        // 试题内容
        .question_content {
            padding: 20px 0;
            border-bottom: 1px solid #EBEEF5;
            p {
                font-size: 16px;
                color: #333333;
                margin-bottom: 10px;
                line-height: 2; 
            }
        }
        // 试题底部
        .question_tags {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
            margin-top: 20px;
            .tags_label {
                font-size: 14px;
                color: #666;
            }
            .tag {
                display: inline-block;
                padding: 4px 10px;
                background: rgba(59,162,114,0.1);
                border-radius: 4px 4px 4px 4px;
                border: 1px solid #3BA272;
                color: #3BA272;
            }
        }
    }
    .question_item:last-child {
        margin-bottom: 0;
    }

    // 暂无数据
    .no_data{
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        height: 220px;
        font-size: 14px;
        span{
            margin-top: 11%;
        }
    }
}

</style>
