xuruiqian
2025-02-25 e85ab165147c37b571ea67ce6f6ae9ae55a96070
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<template>
    <div class="option-content">
        <div class="option-show" >
            <el-radio-group style="margin: 20px;"
                v-model="mobilequestion.paper[mobilequestion.questionIndex].userAnswer"
                v-if="mobilequestion.type == '单选题'" @change="singleChange">
                <el-radio
                    v-for="(item, index) in mobilequestion.paper[mobilequestion.questionIndex].options.sort((a, b) => a.sequenceno - b.sequenceno)"
                    :label="item.qkey" size="large">
                    <template #default>
                        <div class="radio-div">
                            <span>{{ item.qkey }}</span>
                            <WangEditorShow :content="item.qvalue" />
                            <!-- <div v-html="item.qvalue" class="radio-content"></div> -->
                        </div>
                    </template>
                </el-radio>
            </el-radio-group>
            <el-radio-group style="margin: 20px;  display: inline-block;"
                v-model="mobilequestion.paper[mobilequestion.questionIndex].userAnswer"
                v-if="mobilequestion.type == '判断题'" @change="judgeChange">
                <el-radio label="T" size="large">正确</el-radio>
                <el-radio style="margin-left: 20px;" label="F" size="large">错误</el-radio>
            </el-radio-group>
            <el-checkbox-group style="margin: 20px;"
                v-model="mobilequestion.paper[mobilequestion.questionIndex].userAnswer"
                v-if="mobilequestion.type == '多选题'" @change="multipleChange">
                <el-checkbox
                    v-for="(item, index) in mobilequestion.paper[mobilequestion.questionIndex].options.sort((a, b) => a.sequenceno - b.sequenceno)"
                    :label="item.qkey" size="large">
                    <template #default>
                        <div class="radio-div">
                            <span>{{ item.qkey }}</span>
                            <WangEditorShow :content="item.qvalue" />
                        </div>
                    </template>
                </el-checkbox>
            </el-checkbox-group>
        </div>
    </div>
</template>
 
<script>
import * as icon from '@element-plus/icons-vue'
import { getCurrentInstance, onBeforeUnmount, onMounted, reactive, toRefs, ref } from "vue";
import { useBasicInfoStore } from "../../../store/basicInfo"
import { useMobileQurstionStore } from "../../../store/mobilequestion"
import WangEditorShow from './wangeditorshow.vue';
 
 
export default {
    name: "option",
    components: { WangEditorShow },
    setup() {
        let { proxy } = getCurrentInstance();
        const useStore = useBasicInfoStore()
        const mobilequestion = useMobileQurstionStore()
        const state = reactive({
          
        });
 
        onMounted(() => {
            Init();
        });
        onBeforeUnmount(() => {
 
        });
 
 
        const Init = () => {
        };
 
        const singleChange = (val) => {
            mobilequestion.paper[mobilequestion.questionIndex].userAnswer = val
            if (val == mobilequestion.paper[mobilequestion.questionIndex].answers[0].qkey) {
                mobilequestion.paper[mobilequestion.questionIndex].userStatus = "true"
            } else {
                mobilequestion.paper[mobilequestion.questionIndex].userStatus = "false"
            }
        }
 
        const judgeChange = (val) => {
            mobilequestion.paper[mobilequestion.questionIndex].userAnswer = val
            if (val == mobilequestion.paper[mobilequestion.questionIndex].answers[0].qkey) {
                mobilequestion.paper[mobilequestion.questionIndex].userStatus = "true"
            } else {
                mobilequestion.paper[mobilequestion.questionIndex].userStatus = "false"
            }
        }
 
        const multipleChange = (val) => {
            mobilequestion.paper[mobilequestion.questionIndex].userAnswer = val.sort()
            let answerArr = []
            let answerKey = mobilequestion.paper[mobilequestion.questionIndex].answers.sort((a, b) => a.sequenceno - b.sequenceno)
            for (let i = 0; i < answerKey.length; i++) {
                answerArr.push(answerKey[i].qkey)
            }
            if (JSON.stringify(answerArr) == JSON.stringify(val.sort())) {
                mobilequestion.paper[mobilequestion.questionIndex].userStatus = "true"
            } else {
                mobilequestion.paper[mobilequestion.questionIndex].userStatus = "false"
            }
        }
 
 
        return {
            ...toRefs(state),
            icon,
            mobilequestion,
            singleChange,
            judgeChange,
            multipleChange
        }
    },
}
</script>
 
<style scoped lang="scss">
.center {
    display: flex;
    flex-direction: column;
    align-items: center;
    //justify-content: center;
}
 
.option-content {
    @extend .center;
    background-color: #f5f5f5;
    overflow: auto;
    width: 100%;
}
 
.option-show {
    width: 95vw;
    // height: 300px;
    overflow: auto;
    border-radius: 10px;
    background-color: #fff;
 
    //padding: 30px;
    ::v-deep .el-radio-group {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: flex-start;
    }
 
    ::v-deep .el-radio.el-radio--large {
        height: auto;
        margin: 0px;
    }
 
    ::v-deep .el-checkbox-group {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: flex-start;
        margin: 10px;
    }
 
    ::v-deep .el-checkbox.el-checkbox--large {
        height: auto;
        margin: 0px;
    }
}
 
.radio-div {
    display: flex;
    justify-content: flex-start;
    align-items: center;
}
 
.radio-content {
    // text-overflow: ellipsis;
    white-space: normal;
    line-height: 18px;
    // vertical-align: middle;
    // display: inline-block;
    margin-left: 10px;
}
</style>