<template>
    <div>
        <!--按人 学生信息 -->
        <div class="filter-tab-wrap">
            <span :class="['filter-tab-item', tabIndex == 0 ? 'filter-tab-item-active':'']" @click="tabIndex = 0">
                {{`${$t('task.mLabel3')} ( ${unmarked} )`}}
            </span>
            <span :class="['filter-tab-item', tabIndex == 1 ? 'filter-tab-item-active':'']" @click="tabIndex = 1">
                {{`${$t('task.mLabel4')} ( ${marking.length} )`}}
            </span>
            <span :class="['filter-tab-item', tabIndex == 2 ? 'filter-tab-item-active':'']" @click="tabIndex = 2">
                {{`${$t('task.mLabel2')} ( ${marked.length} )`}}
            </span>
        </div>
        <!-- 已阅、未阅、进行中学生 -->
        <div class="setting-block stu-name-wrap">
            <div class="setting-content stu-name-content">
                <div class="stu-wrap">
                    <div class="stu-list-wrap no-stu-wrap" v-show="tabIndex == 0">
                        <p class="no-mark-text" v-if="unmarked > 0 && unmarked < total">
                            还剩
                            <span class="no-mark-count">{{unmarked}}</span>
                            人未阅,
                            <span class="continue-mark" @click="toByStuView()">继续阅卷</span>
                        </p>
                        <p class="no-mark-text" v-else-if="unmarked > 0">
                            阅卷总量
                            <span class="no-mark-count">{{unmarked}}</span>
                            人，
                            <span class="continue-mark" @click="toByStuView()">开始阅卷</span>
                        </p>
                        <EmptyData v-else textContent="暂无未阅学生"></EmptyData>
                    </div>
                    <div class="stu-list-wrap" v-show="tabIndex == 1">
                        <span class="stu-name" v-for="(item,index) in marking" :key="index" @click="toByStuView(item.stuId)">{{item.stuId}}</span>
                        <EmptyData textContent="暂无进行中学生" v-show="!marking.length"></EmptyData>
                    </div>
                    <div class="stu-list-wrap" v-show="tabIndex == 2">
                        <span class="stu-name" v-for="(item,index) in marked" :key="index" @click="toByStuView(item.stuId)">{{item.stuId}}</span>
                        <EmptyData :top="0" textContent="暂无已阅学生" v-show="!marked.length"></EmptyData>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    props: {
        stusData: {
            required: true,
            type: Array,
            default: () => {
                return []
            }
        },
        total: {
            required: true,
            type: Number,
            default: 0
        }
    },
    data() {
        return {
            tabIndex: 0
        }
    },
    methods: {
        toByStuView(stuId){
            this.$emit('getStuId',stuId)
        }
    },
    computed: {
        //当前阅卷任务未阅数量
        unmarked() {
            return this.total - this.marked.length - this.marking.length
        },
        //当前阅卷任务已阅学生信息
        marked() {
            if (this.stusData) {
                return this.stusData.filter(item => {
                    return item.info.score.indexOf(-1) == -1
                })
            } else {
                return []
            }
        },
        //当前阅卷任务进行中学生信息
        marking() {
            if (this.stusData) {
                return this.stusData.filter(item => {
                    return item.info.score.indexOf(-1) !== -1
                })
            } else {
                return []
            }
        },
    }
}
</script>
<style scoped lang="less">
.filter-tab-wrap {
    margin-top: 15px;
}
.filter-tab-item {
    display: inline-block;
    width: 80px;
    text-align: center;
    background: #1a191c;
    color: #a5a5a5;
    margin-right: 1px;
    border-top-right-radius: 15px;
    padding: 2px 0px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid rgba(98, 97, 101, 0.4);
    border-bottom: none;
}
.filter-tab-item-active {
    background: #2b2a2f;
    color: white;
}
.setting-block {
    margin-top: 30px;
}
.stu-name-wrap {
    margin-top: -1px;
}
.setting-content {
    background: #2b2a2f;
    box-shadow: 1px 1px 13px #141414;
    border: 1px solid rgba(98, 97, 101, 0.4);
    padding: 15px 10px;
    border-radius: 5px;
    margin-right: 12px;
    margin-top: 8px;
    box-shadow: 0 26px 40px -24px rgb(30, 31, 33);
    padding: 15px 10px 25px 10px;
}
.stu-name-content {
    margin-top: 0px;
    border-top-left-radius: 0px !important;
}
.stu-list-wrap {
    min-height: 151px;
}
.no-stu-wrap {
    display: flex;
    align-items: center;
}
.no-mark-text {
    user-select: none;
    .no-mark-count {
        color: white;
        font-size: 24px;
        display: inline-block;
        margin: 0px 5px;
    }
    .continue-mark {
        color: #fff;
        padding: 4px 15px;
        border-radius: 4px;
        cursor: pointer;
        background: #1cc0f3;
    }
}
.stu-name {
    font-size: 12px;
    margin: 5px 5px 5px 2px;
    background: #606060;
    padding: 2px 12px;
    border-radius: 55px;
    display: inline-block;
    cursor: pointer;
    user-select: none;
    color: #ddd;
    &:hover {
        box-shadow: 0px 0px 5px 2px #141414;
        color: white;
    }
}
</style>