<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 }}. </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>
|