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
<template>
    <div class="answer-content">
        <div class="answer-show" v-if="mobilequestion.type == '填空题'">
            <div style="width:100%;overflow: auto;">
                <div class="blank-list"
                    v-for="(item, index) in mobilequestion.paper[mobilequestion.questionIndex].answers" :key="index">
                    <span>{{ index + 1 }}.&nbsp;</span><el-input style="width:calc(100% - 2vw);height:8vw;"
                        v-if="mobilequestion.paper[mobilequestion.questionIndex].userAnswer"
                        v-model="mobilequestion.paper[mobilequestion.questionIndex].userAnswer[index].value"
                        @change="inputChange(index)" />
                </div>
            </div>
        </div>
        <div class="answer-show" v-if="mobilequestion.type == '名词解释'
            || mobilequestion.type == '简答题'
            || mobilequestion.type == '论述题'
            || mobilequestion.type == '分析题'
            || mobilequestion.type == '案例分析题'">
            <el-input :autosize="{ minRows: 5, maxRows: 10 }" type="textarea"
                v-if="mobilequestion.paper[mobilequestion.questionIndex].userAnswer"
                v-model="mobilequestion.paper[mobilequestion.questionIndex].userAnswer[0].value"
                @change="textareaChange()" />
        </div>
    </div>
</template>
 
<script>
import * as icon from '@element-plus/icons-vue'
import { getCurrentInstance, onBeforeUnmount, onMounted, reactive, toRefs } from "vue";
import { useBasicInfoStore } from "../../../store/basicInfo"
import { useMobileQurstionStore } from "../../../store/mobilequestion"
 
export default {
    name: "question",
    components: {},
    setup() {
        let { proxy } = getCurrentInstance();
        const useStore = useBasicInfoStore()
        const mobilequestion = useMobileQurstionStore()
        const state = reactive({
            radio: '',
            checkList: [],
            judge: '',
            textarea: '',
            inputList: []
        });
 
        onMounted(() => {
            Init();
        });
        onBeforeUnmount(() => {
 
        });
 
 
        const Init = () => {
            if (mobilequestion.paper[mobilequestion.questionIndex].userAnswer) {
                state.inputList = mobilequestion.paper[mobilequestion.questionIndex].userAnswer
            } else {
                let arr = []
                for (let i = 0; i < mobilequestion.paper[mobilequestion.questionIndex].answers.length; i++) {
                    arr.push({ value: '' })
                }
                mobilequestion.paper[mobilequestion.questionIndex].userAnswer = arr
                state.inputList = arr
            }
 
        };
 
        const inputChange = (item, index) => {
            mobilequestion.paper[mobilequestion.questionIndex].answers = mobilequestion.paper[mobilequestion.questionIndex].answers.sort((a, b) => a.sequenceno - b.sequenceno)
            let status = true
            let empty = true
            for (let i = 0; i < state.inputList.length; i++) {
                if (state.inputList[i].value.replace(/\s+/g, "").toString()) {
                    empty = false
                }
            }
            if (empty == true) {
                return;
            }
 
            for (let i = 0; i < mobilequestion.paper[mobilequestion.questionIndex].answers.length; i++) {
                if (mobilequestion.paper[mobilequestion.questionIndex].answers[i].qkey.replace(/\s+/g, "") != state.inputList[i].value.replace(/\s+/g, "")) {
                    status = false
                }
            }
 
            if (status == false) {
                mobilequestion.paper[mobilequestion.questionIndex].userStatus = "false"
            } else {
                mobilequestion.paper[mobilequestion.questionIndex].userStatus = "true"
            }
 
        }
 
        const textareaChange = () => {
            let arr = mobilequestion.paper[mobilequestion.questionIndex].answers[0].qkey.split("#")
            for (let i = 0; i < arr.length; i++) {
                if (mobilequestion.paper[mobilequestion.questionIndex].userAnswer[0].value.indexOf(arr[i]) == -1) {
                    mobilequestion.paper[mobilequestion.questionIndex].userStatus = "false"
                    return
                }
            }
            mobilequestion.paper[mobilequestion.questionIndex].userStatus = "true"
        }
 
 
 
        return {
            ...toRefs(state),
            icon,
            mobilequestion,
            inputChange,
            textareaChange
        }
    },
}
</script>
 
<style scoped lang="scss">
.center {
    display: flex;
    flex-direction: column;
    align-items: center;
    //justify-content: center;
}
 
.answer-content {
    @extend .center;
    background-color: #f5f5f5;
    overflow: auto;
    width: 100%;
}
 
.answer-show {
    overflow: auto;
    width: 87vw;
    background-color: #fff;
    padding: 4vw;
    border-radius: 10px;
    display: flex;
    justify-content: center;
 
 
    .blank-list {
        width: 100%;
        overflow: auto;
        margin: 2vw 0px;
        display: flex;
        justify-content: space-between;
        line-height: 8vw;
    }
}
</style>