龚焕茏
2024-06-13 c280abf6e11d79b4b1a57c0a92b069b9b7e52aab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<template>
    <div style="background-color: #FFFFFF; padding-top: 50px;min-height: 900px;">
        <el-row class="do-exam-title" style="background-color: #F5F5DC">
            <el-col :span="24">
                <span :key="item.itemOrder" v-for="item in answer.answerItems">
                    <el-tag :type="questionDoRightTag(item.doRight)" class="do-exam-title-tag"
                        @click="goAnchor('#question-' + item.itemOrder)">{{ item.itemOrder }}</el-tag>
                </span>
            </el-col>
        </el-row>
        <el-row class="do-exam-title-hidden">
            <el-col :span="24">
                <span :key="item.itemOrder" v-for="item in answer.answerItems">
                    <el-tag class="do-exam-title-tag">{{ item.itemOrder }}</el-tag>
                </span>
            </el-col>
        </el-row>
        <el-container class="app-item-contain">
            <el-header class="align-center">
                <h1>{{ form.name }}</h1>
                <div>
                    <span class="question-title-padding">试卷得分:{{ answer.score }}</span>
                    <span class="question-title-padding">试卷耗时:{{ formatSeconds(answer.doTime) }}</span>
                </div>
            </el-header>
            <el-main>
                <el-form :model="form" ref="form" v-loading="formLoading" label-width="100px">
                    <el-row :key="index" v-for="(titleItem, index) in form.titleItems">
                        <h3>{{ titleItem.name }}</h3>
                        <el-card class="exampaper-item-box" v-if="titleItem.questionItems.length !== 0">
                            <el-form-item :key="questionItem.itemOrder" :label="questionItem.itemOrder + '.'"
                                v-for="questionItem in titleItem.questionItems" class="exam-question-item"
                                label-width="50px" :id="'question-' + questionItem.itemOrder">
                                <QuestionAnswerShow :qType="questionItem.questionType" :question="questionItem"
                                    :answer="answer.answerItems[questionItem.itemOrder - 1]" />
                            </el-form-item>
                        </el-card>
                    </el-row>
                </el-form>
            </el-main>
        </el-container>
    </div>
</template>
 
<script>
import { mapState, mapGetters } from 'vuex'
import QuestionAnswerShow from './components/QuestionAnswerShow'
import examPaperAnswerApi from '@/api/examPaperAnswer'
export default {
    components: { QuestionAnswerShow },
    data() {
        return {
            form: {},
            formLoading: false,
            answer: {
                id: null,
                score: 0,
                doTime: 0,
                answerItems: [],
                doRight: false
            }
        }
    },
    created() {
        let id = this.$route.query.id
        let _this = this
        if (id && parseInt(id) !== 0) {
            _this.formLoading = true
            examPaperAnswerApi.read(id).then(re => {
                _this.form = re.data.paper
                _this.answer = re.data.answer
                _this.formLoading = false
            })
        }
    },
    methods: {
        formatSeconds(theTime) {
            let theTime1 = 0
            let theTime2 = 0
            if (theTime > 60) {
                theTime1 = parseInt(theTime / 60)
                theTime = parseInt(theTime % 60)
                if (theTime1 > 60) {
                    theTime2 = parseInt(theTime1 / 60)
                    theTime1 = parseInt(theTime1 % 60)
                }
            }
            let result = '' + parseInt(theTime) + '秒'
            if (theTime1 > 0) {
                result = '' + parseInt(theTime1) + '分' + result
            }
            if (theTime2 > 0) {
                result = '' + parseInt(theTime2) + '小时' + result
            }
            return result
        },
        questionDoRightTag(status) {
            return this.enumFormat(this.doRightTag, status)
        },
        goAnchor(selector) {
            this.$el.querySelector(selector).scrollIntoView({ behavior: 'instant', block: 'center', inline: 'nearest' })
        }
    },
    computed: {
        ...mapGetters('enumItem', ['enumFormat']),
        ...mapState('enumItem', {
            doRightTag: state => state.exam.question.answer.doRightTag
        })
    }
}
</script>
 
<style lang="scss" scoped>
.align-center {
    text-align: center
}
 
.exam-question-item {
    padding: 10px;
 
    .el-form-item__label {
        font-size: 15px !important;
    }
}
 
.question-title-padding {
    padding-left: 25px;
    padding-right: 25px;
}
</style>