ZhangXianQiang
2024-06-19 4756ebe5cd7f236eac6d45dbe7a609f6a8f14d68
fix(考试):修改单选取消选择
1个文件已修改
26 ■■■■■ 已修改文件
src/views/exam/components/answer-main/answer-single/index.vue 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/exam/components/answer-main/answer-single/index.vue
@@ -17,20 +17,25 @@
<script setup>
import { ref } from 'vue';
import {storeToRefs} from 'pinia';
import { storeToRefs } from 'pinia';
import ExamInfo from '@/components/ExamInfo/index.vue';
import {useExamStore} from '@/store/index.js';
import { useExamStore } from '@/store/index.js';
const examStore = useExamStore();
const {currentType,currentIndex} = storeToRefs(examStore);
const { currentType, currentIndex } = storeToRefs(examStore);
const activeQuestion = ref(examStore.getActiveQuestion);
const answerClick = (item) => {
  if(item) {
    resetAnswer();
    item.isActive = true;
    examStore.setQuestionAnswer(currentType.value, currentIndex.value, item.prefix);
  if (item) {
    if (item.isActive) {
      item.isActive = !item.isActive;
    } else {
      resetAnswer();
      item.isActive = true;
    }
    const answerList = filterAnswer();
    examStore.setQuestionAnswer(currentType.value, currentIndex.value, answerList.join(','));
  }
};
@@ -38,10 +43,14 @@
  return {
    active: item.isActive
  };
}
};
const resetAnswer = () => {
  activeQuestion.value.items.forEach(item => item.isActive = false);
};
const filterAnswer = () => {
  return activeQuestion.value.items.filter(item => item.isActive);
}
@@ -85,6 +94,7 @@
.active {
  border-color: #409EFF !important;
  .answer-icon {
    color: #ffffff !important;
    border-color: #409EFF !important;