<template>
    <div class="">
        <!-- <el-tabs tab-position="left" style="height: 200px;"> -->
        <el-tabs tab-position="left" v-model="activeTab" :before-leave="back">
            <el-tab-pane label="考试信息" :disabled="disable" name="0">
                <examInfo ref="examInfo" :examId="id" @sendStatus="sendStatus"></examInfo>
            </el-tab-pane>
            <el-tab-pane label="报名阶段（信息审核）" :disabled="disable1" name="1">
                <InfoReview ref="InfoReview" :examId="id" @sendStatus="sendStatus"></InfoReview>
            </el-tab-pane>
            <el-tab-pane label="考场分配" :disabled="disable2" name="2">
                <examRoomAllocate ref="examRoomAllocate" :examId="id" @sendStatus="sendStatus" />
            </el-tab-pane>
            <el-tab-pane label="成绩管理" :disabled="disable3" name="3">
                <scoreManage ref="scoreManage" :examId="id" @sendStatus="sendStatus" />
            </el-tab-pane>
            <el-tab-pane label="返回列表" name="4">
            </el-tab-pane>
        </el-tabs>
    </div>
</template>

<script>
import examInfo from "../components/examInfo.vue";
import InfoReview from "../components/InfoReview.vue";
import examRoomAllocate from "../components/examRoomAllocate.vue";
import scoreManage from "../components/scoreManage.vue";
import { getExam, listProject } from "@/api/smartSchool/examinationManage";
export default {
    name: '',
    components: {
        examInfo,
        InfoReview,
        examRoomAllocate,
        scoreManage
    },
    created() {
        this.id = this.$route.query.id
        this.handleTab(this.$route.query.index)
        this.sendStatus()

    },
    data() {
        return {
            id: null,
            status: null,
            activeTab: '0',
            disable: true,
            disable1: true,
            disable2: true,
            disable3: true,
            statu: null,
            // 测试项目
            projectList: [],

        }
    },

    methods: {
        /** 设置activeTab */
        handleTab(status) {
            this.activeTab = status
            if (status == '4') {
                this.activeTab = '3'
            }
            switch (status) {
                case '0':
                    this.disable = false;
                    break;
                case '1':
                    this.disable = this.disable1 = false
                    break;
                case '2':
                    this.disable = this.disable1 = this.disable2 = false
                    break;
                case '3':
                    this.disable = this.disable1 = this.disable2 = this.disable3 = false
                    break;
                case '4':
                    this.disable = this.disable1 = this.disable2 = this.disable3 = false
                    break;
            }

        },
        // 发送状态
        sendStatus() {
            getExam(this.id).then(res => {
                this.statu = res.data.status
                this.isSearch(this.statu)
                this.handleTab(this.statu)
            });
            // console.log(this.$refs.examInfo, 95);
            // this.$refs.scoreManage.getStatus(statu)
        },
        // 判断状态
        isSearch(index) {
            switch (index) {
                case '0':
                    this.$refs.examInfo.getStatus(this.statu)
                    break;
                case '1':
                    this.$refs.InfoReview.getStatus(this.statu)
                    break;
                case '2':
                    this.$refs.examRoomAllocate.getStatus(this.statu)
                    break;
                case '3':
                    this.$refs.scoreManage.getStatus(this.statu)
                    break;
                case '4':
                    this.$refs.scoreManage.getStatus(this.statu)
                    break;
                default: return;
            }
        },
        // 跳转
        back(activeName) {
            this.isSearch(activeName)
            if (activeName == '4') {
                // this.$router.go(-1)
                this.$store.dispatch("tagsView/delView", this.$route);
                this.$router.replace({
                    path: '/teachAffairAdministration/exam/examManage',
                })

            }
        },
    },

}
</script>

<style scoped></style>
