From 02b9931c5e3a54d69d4d20a9dc6aad141fc35141 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期四, 15 八月 2024 11:37:14 +0800
Subject: [PATCH] 恢复举手,隐藏举手顶部显示

---
 src/views/exam/components/answer-main/answer-multiple/index.vue |   71 ++++++++++++-----------------------
 1 files changed, 25 insertions(+), 46 deletions(-)

diff --git a/src/views/exam/components/answer-main/answer-multiple/index.vue b/src/views/exam/components/answer-main/answer-multiple/index.vue
index b8a570b..2ba7860 100644
--- a/src/views/exam/components/answer-main/answer-multiple/index.vue
+++ b/src/views/exam/components/answer-main/answer-multiple/index.vue
@@ -1,13 +1,14 @@
+<!-- 澶氶�夐 -->
 <template>
   <div class="answer-container w-full h-full">
     <el-scrollbar>
-      <ExamInfo class="mb-5"></ExamInfo>
+      <ExamInfo class="mb-5" :questionIndex="currentIndex" :activeQuestion="activeQuestion"></ExamInfo>
 
       <div class="answer-content">
-        <div class="answer-item flex" v-for="item, index in examInfo.answerList" @click="answerClick(item)"
+        <div class="answer-item flex" v-for="item, index in activeQuestion.questionItemList" @click="answerClick(item)"
           :class="answerState(item)">
-          <div class="answer-icon flex flex-col justify-center items-center flex-shrink-0">{{ item.type }}</div>
-          <div class="answer-text text-gray-700">{{ item.text }}</div>
+          <div class="answer-icon flex flex-col justify-center items-center flex-shrink-0">{{ item.prefix }}</div>
+          <div class="answer-text text-gray-700" v-html="item.content"></div>
         </div>
       </div>
 
@@ -17,62 +18,39 @@
 
 <script setup>
 import { ref } from 'vue';
+import { storeToRefs } from 'pinia';
 import ExamInfo from '@/components/ExamInfo/index.vue';
+import { useExamStore } from '@/store/index.js';
 
-const examInfo = ref({
-  qId: 1,
-  answerList: [
-    {
-      type: 'A',
-      text: '娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯璇曟祴璇�',
-      isActive: false
-    },
-    {
-      type: 'B',
-      text: '娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯璇曟祴璇�',
-      isActive: false
-    },
-    {
-      type: 'C',
-      text: '娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯璇曟祴璇�',
-      isActive: false
-    },
-    {
-      type: 'D',
-      text: '娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯璇曟祴璇�',
-      isActive: false
-    },
-    {
-      type: 'E',
-      text: '娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯璇曟祴璇�',
-      isActive: false
-    },
-    {
-      type: 'F',
-      text: '娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯娴嬭瘯璇曟祴璇�',
-      isActive: false
-    },
-  ]
-});
+const examStore = useExamStore();
 
-const activeIndex = ref(null);
+const { currentType, currentIndex } = storeToRefs(examStore);
+
+const activeQuestion = ref(examStore.getActiveQuestion);
 
 const answerClick = (item) => {
-  if(item) {
-    resetAnswer();
-    item.isActive = true
+  if (item) {
+    item.isActive = !item.isActive;
+    const answerList = filterAnswer();
+    examStore.setQuestionAnswerList(currentType.value, currentIndex.value, answerList);
   }
 };
 
 const answerState = (item) => {
+  if(Array.isArray(activeQuestion.value.answerList) && activeQuestion.value.answerList.includes(item.prefix)) {
+    item.isActive = true;
+  }
   return {
     active: item.isActive
   };
+};
+
+const filterAnswer = () => {
+  return activeQuestion.value.questionItemList.filter(item => item.isActive).map(item => item.prefix);
 }
 
-const resetAnswer = () => {
-  examInfo.value.answerList.forEach(item => item.isActive = false);
-}
+
+
 
 </script>
 
@@ -114,6 +92,7 @@
 
 .active {
   border-color: #409EFF !important;
+
   .answer-icon {
     color: #ffffff !important;
     border-color: #409EFF !important;

--
Gitblit v1.8.0