<template>
    <div class="create-priv-container">
        <div class="create-header">
            <p class="create-header-title" @click="consData">{{$t('learnActivity.createEv.createLabel')}}</p>
            <Button class="btn-save" type="text" :loading="isLoading" ghost icon="ios-albums-outline" @click="saveEvaluation" style="margin-right:30px;">
                {{$t('learnActivity.createEv.publishEv')}}
            </Button>
            <Button class="btn-save" type="text" ghost icon="md-arrow-back" @click="confirmToManage">
                {{$t('learnActivity.createEv.return')}}
            </Button>
        </div>
        <div class="create-body">
            <div class="evaluation-attr-wrap">
                <p class="wrap-label">{{$t('learnActivity.createEv.baseInfo')}}</p>
                <div style="width:100%; height:calc(100% - 45px);padding-top:30px;" class="ivu-select-nochoose light-iview-form light-el-input">
                    <vuescroll>
                        <Form ref="evaForm" :model="evaluationInfo" label-position="top" class="evaluation-attr-form " label-colon :rules="ruleValidate">
                            <FormItem :label="$t('learnActivity.createEv.evName')" prop="name">
                                <Input v-model="evaluationInfo.name" :placeholder="$t('learnActivity.createEv.evName')"></Input>
                            </FormItem>
                            <FormItem prop="source">
                                <label slot="label" style="width：200px">
                                    <span>{{$t('learnActivity.createEv.evMode')}}</span>
                                    <Tooltip :content="$t('tip.examMode')" transfer theme="light" max-width="300">
                                        <Icon type="ios-information-circle-outline" color="#1cc0f3" style="margin-left:5px" />
                                    </Tooltip>
                                </label>
                                <Select v-model="evaluationInfo.source">
                                    <Option v-for="(item,index) in $GLOBAL.EV_MODE()" :value="item.value" :key="index">{{ item.label }}</Option>
                                </Select>
                            </FormItem>
                            <FormItem :label="$t('learnActivity.createEv.evType')" prop="type">
                                <Select v-model="evaluationInfo.type">
                                    <Option v-for="(item,index) in $GLOBAL.EV_TYPE()" :value="item.value" :key="index">{{ item.label }}</Option>
                                </Select>
                            </FormItem>
                            <FormItem :label="$t('learnActivity.createEv.courseType')" prop="course">
                                <Select v-model="evaluationInfo.scope" @on-change="resetCourse">
                                    <Option value="school" v-show="$store.state.userInfo.hasSchool">{{$t('learnActivity.createEv.cusLabel1')}}</Option>
                                    <Option value="private">{{$t('learnActivity.createEv.cusLabel2')}}</Option>
                                </Select>
                            </FormItem>
                            <!-- 使用级联选择 课程--》班级 -->
                            <FormItem :label="$t('learnActivity.createEv.evTarget')" prop="targets">
                                <label slot="label">
                                    <span>{{$t('learnActivity.createEv.evTarget')}}</span>
                                    <Tooltip :content="$t('tip.targetTips')" transfer theme="light" max-width="300">
                                        <Icon type="ios-information-circle-outline" color="#1cc0f3" style="margin-left:5px" />
                                    </Tooltip>
                                </label>
                                <el-cascader size="small" :options="targetData" :show-all-levels="false" clearable filterable v-model="evaluationInfo.targets" @visible-change="visibleChange" :props="props" @change="treeChange" style="width:100%;" :popper-class="cascaderClass">
                                </el-cascader>
                            </FormItem>
                            <FormItem :label="$t('learnActivity.createEv.publishType')" prop="publish">
                                <Checkbox v-model="evaluationInfo.publish" :true-value="$GLOBAL.PUBLISH_TYPE()[0].value" :false-value="$GLOBAL.PUBLISH_TYPE()[1].value" @on-change="publishChange">
                                    <span style="margin-left:5px;user-select: none;">{{$GLOBAL.PUBLISH_TYPE()[0].label}}</span>
                                </Checkbox>
                            </FormItem>
                            <FormItem :label="$t('learnActivity.createEv.startTime')" v-if="evaluationInfo.publish == 1" prop="startTime">
                                <DatePicker :options="dateOpt" type="datetime" format="yyyy/MM/dd HH:mm" v-model="startTime" split-panels :placeholder="$t('learnActivity.createEv.sTimeHolder')" style="width:100%" @on-change="getDate($event,0)"></DatePicker>
                            </FormItem>
                            <FormItem :label="$t('learnActivity.createEv.endTime')" prop="endTime">
                                <DatePicker :options="dateOpt1" type="datetime" format="yyyy/MM/dd HH:mm" v-model="endTime" split-panels :placeholder="$t('learnActivity.createEv.eTimeHolder')" style="width:100%" @on-change="getDate($event,1)"></DatePicker>
                            </FormItem>
                        </Form>
                    </vuescroll>
                </div>
            </div>
            <div class="evaluation-question-wrap">
                <div class="evaluation-question-main">
                    <Tabs v-model="activeTab" type="card" class="question-main-tabs" name="createTest">
                        <TabPane :label="$t('learnActivity.createEv.papersLabel')" name="manualPaper" v-if="createType == 'manualPaper'" :index="1" tab="createTest">
                            <ManualPaper @selectPaper="selectPaper" :selectedId="evaluationInfo.paperInfo[0] ? evaluationInfo.paperInfo[0].id : ''"></ManualPaper>
                        </TabPane>
                        <TabPane :label="$t('learnActivity.createEv.perviewLabel')" name="preview" :index="2" tab="createTest">
                            <div class="teacher-preview-container">
                                <!--返回顶部-->
                                <div class="back-to-top" :title="$t('learnActivity.mgtScEv.returnTop')" v-show="showBack" @click="handleBackToTop">
                                    <Icon type="ios-arrow-up" />
                                </div>
                                <vuescroll ref="paper-preview" @handle-scroll="checkBackTop">
                                    <TestPaper v-if="activeTab == 'preview'" :paper="evaluationInfo.paperInfo.length ? evaluationInfo.paperInfo[0] : {item:[]}" isExamPaper></TestPaper>
                                </vuescroll>
                            </div>
                        </TabPane>
                    </Tabs>
                </div>
            </div>
        </div>

    </div>
</template>
<script>
import BlobTool from '@/utils/blobTool.js'
import TestPaper from '@/view/evaluation/index/TestPaper.vue'
import ManualPaper from './ManualPaper.vue'
export default {
    components: {
        TestPaper,
        ManualPaper
    },
    data() {
        const _this = this
        return {
            isEdit: false,
            props: {
                multiple: true,
                value: 'id',
                label: 'name',
                children: 'classes'
            },
            schoolBase: {
                period: []
            },
            dateOpt: {
                disabledDate(date) {
                    return date && date.valueOf() < Date.now() - 86400000
                }
            },
            dateOpt1: {
                disabledDate(date) {
                    let d = _this.evaluationInfo.startTime ? _this.evaluationInfo.startTime : Date.now()
                    return d && d > date.valueOf() + 86400000
                }
            },
            schoolTree: [],
            privateTree: [],
            schoolClassList: [],
            createType: 'manualPaper',
            startTime: '',
            endTime: '',
            isLoading: false,
            ruleValidate: {
                name: [
                    { required: true, message: this.$t('learnActivity.createEv.errTips1'), trigger: 'change' }
                ],
                'type.id': [
                    { required: true, message: this.$t('learnActivity.createEv.errTips2'), trigger: 'change' }
                ],
                source: [
                    { required: true, message: this.$t('learnActivity.createEv.errTips3'), trigger: 'change' }
                ],
                'type': [
                    { required: true, message: this.$t('learnActivity.createEv.errTips4'), trigger: 'change' }
                ],
                'examType.id': [
                    { required: true, message: this.$t('learnActivity.createEv.errTips5'), trigger: 'change' }
                ],
                targets: [
                    { required: true, message: this.$t('learnActivity.createEv.errTips6'), type: 'array', trigger: 'change' }
                ],
                classes: [
                    { required: true, message: this.$t('learnActivity.createEv.errTips6'), type: 'array', trigger: 'change' }
                ],
                publish: [
                    { required: true, message: this.$t('learnActivity.createEv.errTips7'), trigger: 'change' }
                ],
                startTime: [
                    { required: true, type: 'number', message: this.$t('learnActivity.createEv.errTips8'), trigger: 'change' }
                ],
                endTime: [
                    { required: true, type: 'number', message: this.$t('learnActivity.createEv.errTips9'), trigger: 'change' }
                ]
            },
            activeTab: 'manualPaper',
            evaluationInfo: {
                name: '',
                targets: [],
                classes: [],
                scope: '',
                type: '',  //测试类别
                source: '',
                publish: '0',
                examType: {}, //测试类型
                startTime: undefined,
                endTime: undefined,
                paperInfo: [],
                papers: []
            },
            mode: '',
            selectBefore: [],
            stuList: [],
            showBack: false,
            allTargets: []
        }
    },
    methods: {
        //查询发布对象数据结构
        findTargetData() {
            let params = {
                code: this.$store.state.userInfo.TEAMModelId,
                schoolId: this.$store.state.userInfo.schoolCode
            }
            this.$api.courseMgmt.findAllByTeahcer(params).then(
                res => {
                    if (res.obj) {
                        this.allTargets = []
                        this.allTargets.push(...res.obj)
                    } else {
                        this.$Message.error('API error!')
                    }
                },
                err => {
                    this.$Message.error('API error!')
                }
            )
        },
        /**vuescroll回到顶部 */
        handleBackToTop() {
            this.$refs['paper-preview'].scrollTo(
                {
                    y: '0'
                },
                300
            )
        },
        /**
         * 判断是否显示回到顶部按钮
         * @param vertical
         * @param horizontal
         * @param nativeEvent
         */
        checkBackTop(vertical, horizontal, nativeEvent) {
            if (vertical.scrollTop > 100) {
                this.showBack = true
            } else {
                this.showBack = false
            }
        },
        publishChange(data) {
            if (data == 0) {
                this.startTime = new Date()
                this.evaluationInfo.startTime = Date.now()
            }
        },
        //重置课程类型
        resetCourse() {
            this.evaluationInfo.targets = []
            this.evaluationInfo.classes = []
        },
        visibleChange(status) {
            if (status) {
                this.selectBefore = this._.cloneDeep(this.evaluationInfo.targets)
            }
        },
        treeChange(data) {
            //1、处理班级类型和课程单选效果
            if (this.selectBefore.length) {
                let curCus = new Set()
                let classType = new Set()
                data.forEach(item => {
                    if (this.evaluationInfo.scope == 'school') {
                        curCus.add(item[1])
                        classType.add(item[0])
                    } else {
                        curCus.add(item[0])
                    }
                })
                // 检查班级类型是否唯一
                if (classType.size > 1) {
                    let originType = this.selectBefore[0][0]
                    let filterData = data.filter(item => {
                        return item[0] != originType
                    })
                    this.selectBefore = filterData
                    this.evaluationInfo.targets = filterData
                    data = JSON.parse(JSON.stringify(filterData))
                    curCus.clear()
                    data.forEach(item => {
                        curCus.add(item[1])
                    })
                }
                // 检查课程是否唯一
                if (curCus.size > 1) {
                    let originCus = this.evaluationInfo.scope == 'school' ? this.selectBefore[0][1] : this.selectBefore[0][0]
                    let filterData = data.filter(item => {
                        let d = this.evaluationInfo.scope == 'school' ? item[1] : item[0]
                        return d != originCus
                    })
                    this.selectBefore = filterData
                    this.evaluationInfo.targets = filterData
                }
            } else {
                this.selectBefore = data
            }

            // 2、设置发布对象
            //个人课程
            if (this.evaluationInfo.scope == 'private') {
                this.evaluationInfo.stuLists = this.evaluationInfo.targets.map(item => {
                    return item[1]
                })
                this.evaluationInfo.classes = []
            }
            //学校课程教学班
            else if (this.evaluationInfo.scope == 'school' && this.evaluationInfo.targets.length && this.evaluationInfo.targets[0][0] == 'stulist') {
                this.evaluationInfo.stuLists = this.evaluationInfo.targets.map(item => {
                    return item[2]
                })
                this.evaluationInfo.classes = []
            }
            // 学校课程行政班
            else {
                this.evaluationInfo.classes = this.evaluationInfo.targets.map(item => {
                    return item[2]
                })
                this.evaluationInfo.stuLists = []
            }

            //3、设置评测“学科”
            this.evaluationInfo.subjects = []
            if (this.evaluationInfo.targets.length) {
                let cus = this.allTargets.find(item => {
                    let cusId = this.evaluationInfo.scope == 'school' ? this.evaluationInfo.targets[0][1] : this.evaluationInfo.targets[0][0]
                    return item.id == cusId
                })
                if (cus) {
                    this.evaluationInfo.subjects.push({
                        id: cus.id,
                        name: cus.name
                    })
                }
            }
        },
        /*
         * 返回上一级
         */
        confirmToManage() {
            if (this.mode == 'private') {
                this.$router.push({
                    name: 'privateEvaluation'
                })
            } else {
                this.$router.push({
                    name: 'schoolEvaluation'
                })
            }
        },
        /**
         * 处理挑选试卷事件
         * @param data
         */
        selectPaper(data) {
            let simplePaper = data
            this.$Modal.confirm({
                title: this.$t('learnActivity.createEv.stPaperTitle'),
                content: `${this.$t('learnActivity.createEv.stPaperContent')}${data.name}?`,
                onOk: async () => {
                    let fullPaper = await this.$evTools.getFullPaper(simplePaper)
                    this.comfirmSelectPaper(simplePaper, fullPaper)
                }
            })
        },
        comfirmSelectPaper(simplePaper, fullPaper) {
            fullPaper.examId = ''
            fullPaper.examScope = this.mode
            fullPaper.examCode = this.$store.state.userInfo.schoolCode
            this.evaluationInfo.paperInfo[0] = fullPaper
            this.evaluationInfo.papers[0] = simplePaper
            this.goToPreview()
        },

        /**
         * 将日期控件时间格式转成时间戳
         * @param value
         * @param date
         */
        getDate(value, flag) {
            if (value.indexOf('00:00') > 0) {
                value = value.replace('00:00', '23:59:59')
            }
            if (flag == 0) {
                this.startTime = value
                this.evaluationInfo.startTime = new Date(value).getTime()
                if (this.evaluationInfo.startTime >= this.evaluationInfo.endTime) {
                    this.endTime = undefined
                    this.evaluationInfo.endTime = undefined
                }
            } else if (flag == 1) {
                this.endTime = value
                this.evaluationInfo.endTime = new Date(value).getTime()
            }
        },
        goToPreview() {
            this.activeTab = 'preview'
        },
        consData() {
            console.log('evaluationInfo', this.evaluationInfo)
        },
        async saveEvaluation() {
            //表单验证
            let flag = true
            this.$refs['evaForm'].validate((valid) => {
                if (!valid) {
                    this.$Message.warning(this.$t('learnActivity.createEv.formWarning'))
                    flag = false
                }
            })
            if (!flag) {
                return
            }
            //检查试卷是否添加
            if (this.evaluationInfo.papers.length < 1) {
                this.$Message.warning({
                    content: this.$t('learnActivity.createEv.paperWarning'),
                    duration: 2
                })
                flag = false
            }
            if (!flag) {
                return
            }
            //通过验证，保存评测

            let apiPapers = this.getPaperInfo()
            //线下阅卷需要处理答题卡数据 
            let sheetIds = []
            if (this.evaluationInfo.source == '2') {
                sheetIds = apiPapers.map(item => {
                    return {
                        sheetId: item.sheet,
                        paperId: item.id,
                        code: item.code.replace('Paper-',''),
                        scope: item.scope
                    }
                })
                console.log(JSON.stringify(sheetIds))
                sheetIds = sheetIds.filter(item => {
                    return item.sheetId
                })
                console.log('答题卡id：', sheetIds)
            }
            this.isLoading = true
            let requestData = {
                pk: 'Exam',
                id: this.evaluationInfo.id || null,
                code: this.$store.state.userInfo.TEAMModelId,
                school: this.$store.state.userInfo.schoolCode,
                name: this.evaluationInfo.name,
                creatorId: this.$store.state.userInfo.TEAMModelId,
                type: this.evaluationInfo.type,
                subjects: this.evaluationInfo.subjects,
                papers: apiPapers,
                examType: this.evaluationInfo.examType,
                year: new Date().getFullYear(),
                source: this.evaluationInfo.source,
                classes: this.evaluationInfo.classes,
                stuLists: this.evaluationInfo.stuLists,
                targets: this.evaluationInfo.targets,
                startTime: this.evaluationInfo.publish == 0 ? -1 : this.evaluationInfo.startTime, //立即发布由后端获取时间
                endTime: this.evaluationInfo.endTime,
                scope: this.evaluationInfo.scope,
                createDate: Math.round(new Date()),
                owner: 'teacher' //后面新增字段
            }

            this.$api.learnActivity.SaveExamInfo(requestData).then(
                res => {
                    if (res.error) {
                        this.$Message.error('API ERROR!')
                        this.isLoading = false
                        return
                    }
                    //发布成功需要备份试卷数据
                    let examId = res.exam.id
                    let privateSas = {}
                    if (this.$store.state.user.userProfile) {
                        let blobInfo = this.$store.state.user.userProfile
                        privateSas.sas = '?' + blobInfo.blob_sas
                        privateSas.url = blobInfo.blob_uri.slice(0, blobInfo.blob_uri.lastIndexOf(this.$store.state.userInfo.TEAMModelId) - 1)
                        privateSas.name = this.$store.state.userInfo.TEAMModelId
                    }

                    let schoolSas = {}
                    if (this.$store.state.userInfo.hasSchool) {
                        schoolSas = {
                            sas: '?' + this.$store.state.user.schoolProfile.blob_sas,
                            url: this.$store.state.user.schoolProfile.blob_uri.slice(0, this.$store.state.user.schoolProfile.blob_uri.lastIndexOf(this.$store.state.userInfo.schoolCode) - 1),
                            name: this.$store.state.userInfo.schoolCode
                        }
                    }
                    //校本课程复制到学校容器 个人课程复制到个人容器
                    let targetBlob = undefined
                    if (this.evaluationInfo.scope == 'school') {
                        targetBlob = new BlobTool(schoolSas.url, schoolSas.name, schoolSas.sas, 'school')
                    } else {
                        targetBlob = new BlobTool(privateSas.url, privateSas.name, privateSas.sas, 'private')
                    }
                    let privateBlob = new BlobTool(privateSas.url, privateSas.name, privateSas.sas, 'private')
                    let schoolBlob = undefined
                    let targetFolder = 'exam/' + examId + '/paper/'
                    let count = 0
                    requestData.papers.forEach(async (item, index) => {
                        if (item.blob.indexOf('/exam/') == 0) {
                            if (++count == (requestData.papers.length)) {
                                this.$Message.success(this.$t('learnActivity.createEv.publishOk'))
                                this.isLoading = false
                                let route = this.mode + 'Evaluation'
                                this.$router.push({
                                    name: route
                                })
                            }
                            return
                        }
                        // 挑选的是校本试卷
                        if (item.scope == 'school') {
                            if (!schoolBlob) schoolBlob = new BlobTool(schoolSas.url, schoolSas.name, schoolSas.sas, 'school')
                            targetBlob.copyFolder(targetFolder + this.evaluationInfo.subjects[index].id + '/', item.blob.substring(1), schoolBlob).then().finally(
                                () => {
                                    if (++count == requestData.papers.length) {
                                        this.$Message.success(this.$t('learnActivity.createEv.publishOk'))
                                        this.isLoading = false
                                        let route = this.mode + 'Evaluation'
                                        this.$router.push({
                                            name: route
                                        })
                                    }
                                }
                            )
                        }
                        //挑选的是个人试卷
                        else if (item.scope == 'private') {
                            if (!privateBlob) privateBlob = new BlobTool(privateSas.url, privateSas.name, privateSas.sas, 'private')
                            targetBlob.copyFolder(targetFolder + this.evaluationInfo.subjects[index].id + '/', item.blob.substring(1), privateBlob).then().finally(
                                () => {
                                    if (++count == requestData.papers.length) {
                                        this.$Message.success(this.$t('learnActivity.createEv.publishOk'))
                                        this.isLoading = false
                                        let route = this.mode + 'Evaluation'
                                        this.$router.push({
                                            name: route
                                        })
                                    }
                                }
                            )
                        }
                    })
                    //处理答题卡 
                    if (sheetIds.length) {
                        sheetIds.forEach(async sheetItem => {
                            try {
                                //这里校本评测只能选校本试卷，所以参数直接写学校
                                let params = {
                                    id: sheetItem.sheetId,
                                    code: sheetItem.code,
                                    scope: sheetItem.scope
                                }
                                //查询答题卡数据
                                let sheetData = await this.$api.evaluation.findSheet(params)
                                if (sheetData.config) {
                                    sheetData.config.id = null //清空答题卡重新创建
                                    //更新答题卡数据
                                    let updParams = {
                                        sheet: sheetData.config,
                                        examId: examId,
                                        owner: 'teacher',
                                        paperId: sheetItem.paperId
                                    }
                                    let updRes = await this.$api.evaluation.upsertSheet(updParams)
                                    console.log('答题卡操作结果', updRes)
                                }
                            } catch (e) {
                                this.$Message.error('答题卡处理失败')
                            }
                        })
                    }
                },
                err => {
                    this.isLoading = false
                    this.$Message.error('API ERROR!')
                }
            )
        },
        //拼接API需要的paper数据
        getPaperInfo() {
            let data = this.evaluationInfo.papers
            let rule = this.evaluationInfo.paperInfo
            if (data) {
                let paperDto = []
                for (let i = 0; i < data.length; i++) {
                    if (data[i].blob.indexOf('/exam/') == 0) {
                        paperDto.push(data[i])
                    } else {
                        let paper = {}
                        paper.id = data[i].id
                        paper.code = data[i].code
                        paper.name = data[i].name
                        paper.blob = data[i].blob
                        paper.scope = data[i].scope
                        paper.sheet = data[i].sheet
                        paper.multipleRule = rule[i].multipleRule
                        paper.answers = []
                        paper.point = []
                        paper.knowledge = []
                        paper.field = []
                        paper.type = []//后面新增字段， 保存每个题目类型
                        for (let k = 0; k < rule[i].slides.length; k++) {
                            if (rule[i].slides[k].type !== 'compose') {
                                paper.answers.push(rule[i].slides[k].scoring.ans ? rule[i].slides[k].scoring.ans : [])
                                paper.point.push(rule[i].slides[k].scoring.score)
                                paper.knowledge.push(rule[i].slides[k].scoring.knowledge ? rule[i].slides[k].scoring.knowledge : [])
                                paper.field.push(rule[i].slides[k].scoring.field ? rule[i].slides[k].scoring.field : [])
                                paper.type.push(rule[i].slides[k].type) //后面新增字段， 保存每个题目类型
                            }
                        }
                        paperDto.push(paper)
                    }
                }
                return paperDto
            } else {
                return []
            }
        }
    },
    created() {
        // 处理默认时间
        this.startTime = new Date()
        this.evaluationInfo.startTime = new Date().getTime()
        this.endTime = new Date(new Date(new Date().toLocaleDateString()).getTime() + 2 * 24 * 60 * 60 * 1000 - 1)
        this.evaluationInfo.endTime = new Date(new Date().toLocaleDateString()).getTime() + 2 * 24 * 60 * 60 * 1000 - 1

        this.$store.dispatch('user/getSchoolProfile').then(
            res => {
                this.schoolBase = res.school_base
                this.schoolClassList = res.school_classes
            }
        )
        //判断创建个人还是校本评测
        if (this.$route.name == 'createSchoolEva') {
            this.mode = 'school'
        } else {
            this.mode = 'private'
        }
        this.evaluationInfo.scope = this.$store.state.userInfo.hasSchool ? 'school' : 'private'
        //编辑评测逻辑
        let routerData = this.$route.params.evaluationInfo
        if (routerData !== undefined) {
            this.isEdit = true
            this.startTime = new Date(routerData.startTime)
            this.endTime = new Date(routerData.endTime)
            routerData.paperInfo = []
            for (let i = 0; i < routerData.papers.length; i++) {
                let paper = this._.cloneDeep(routerData.papers[i])
                routerData.paperInfo.push(paper)
                routerData.paperInfo[i].subjectId = routerData.subjects[i].id
                routerData.paperInfo[i].subjectName = routerData.subjects[i].name
            }
            this.evaluationInfo = routerData
            this.activeTab = 'preview'
        }
        this.findTargetData()
    },
    computed: {
        cascaderClass() {
            return this.evaluationInfo.scope == 'school' ? 'one-hidden-check-box' : ''
        },
        targetData() {
            let nodes = []
            if (this.evaluationInfo.scope == 'school') {
                nodes = [
                    {
                        id: 'class',
                        name: this.$t('cusMgt.listType1'),
                        classes: []
                    },
                    {
                        id: 'stulist',
                        name: this.$t('cusMgt.listType2'),
                        classes: []
                    }
                ]
                let schoolCus = this.allTargets.filter(item => {
                    return item.scope == this.evaluationInfo.scope
                })
                schoolCus.forEach(item => {
                    let c = item.classes.filter(i => {
                        return i.type == 'class'
                    })
                    let s = item.classes.filter(i => {
                        return i.type == 'stuList'
                    })
                    if (c && c.length) {
                        nodes[0].classes.push({
                            id: item.id,
                            name: item.name,
                            classes: c
                        })
                    }
                    if (s && s.length) {
                        nodes[1].classes.push({
                            id: item.id,
                            name: item.name,
                            classes: s
                        })
                    }
                })
            } else {
                nodes = this.allTargets.filter(item => {
                    return item.scope == this.evaluationInfo.scope
                })
            }
            return nodes
        }
    },
    beforeRouteLeave(to, from, next) {
        if (to.name == 'answerSheet') {
            from.meta.isKeep = true
        } else {
            from.meta.isKeep = false
        }
        next()
    }
}
</script>
<style scoped lang="less">
@import "./CreatePrivEva.less";
</style>
<style lang="less">
.one-hidden-check-box {
    .el-cascader-menu:nth-child(1) .el-checkbox {
        display: none;
    }
}
.teacher-preview-container .paper-main-wrap {
    padding: 0px;
    margin-top: 0px;
}
.evaluation-attr-wrap .ivu-form .ivu-form-item-label {
    color: var(--second-text-color);
}

.evaluation-question-main .ivu-tabs-tab-active {
    // background-color: #404040 !important;
    font-weight: 600;
}

.evaluation-question-main .ivu-tabs .ivu-tabs-content-animated {
    height: 100%;
    margin-bottom: 10px;
}

.evaluation-question-main .ivu-tabs-bar {
    border-color: #404040;
    margin-bottom: 0px;
    border-bottom: none;
}
.evaluation-question-main .ivu-tabs.ivu-tabs-card .ivu-tabs-bar .ivu-tabs-tab {
    /* border: none;
    background-color: #303030;
    color: white; */
    margin-right: 2px;
}
</style> 