xiangpei
2024-10-31 b0edc0c7a4cb8a0063a56b436a63931904f179c3
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
<template>
  <div class="sheet-container w-full h-full">
    <el-scrollbar>
      <el-collapse v-model="activeNames">
        <template v-for="item, itemIndex in examDetail">
          <el-collapse-item :title="item.title" :name="item.questionType">
            <div class="sheet-list grid grid-cols-5 gap-4 justify-items-center">
              <div class="sheet-item cursor-pointer flex justify-center items-center"
                v-for="question, index in item.questionList" @click="sheetClick(item.questionType, index)"
                :class="itemClass(question,item.questionType, index)">
                {{ index + 1 }}
              </div>
            </div>
          </el-collapse-item>
        </template>
      </el-collapse>
    </el-scrollbar>
  </div>
</template>
 
<script setup>
import { ref } from 'vue';
import { storeToRefs } from 'pinia';
import { useGradeStore } from '@/store/index.js';
const gradeStore = useGradeStore();
 
const { examDetail, currentType, currentIndex, examInfo } = storeToRefs(gradeStore);
 
const activeNames = ref(examDetail.value.map(item => item.questionType));
 
const concatQuestion = (navbar, titleList) => {
  if (Array.isArray(titleList) && titleList.length > 0) {
    let tempIndex = 0;
    titleList.forEach((title) => {
      title.questionList.forEach((question) => {
        question.isRight = navbar[tempIndex].right;
        tempIndex++;
      });
    })
  }
 
}
 
concatQuestion(examInfo.value.navbar, examDetail.value);
console.log(examDetail.value);
 
const itemClass = (question,type,index) => {
  return {
    right: question.isRight === true,
    wrong: question.isRight === false,
    active: currentType.value === type && currentIndex.value === index
  };
};
 
const sheetClick = (type, index) => {
  currentType.value = type;
  currentIndex.value = index;
};
 
 
 
</script>
 
<style lang="scss" scoped>
.sheet-list {
  width: 97%;
}
 
.sheet-item {
  width: 35px;
  height: 35px;
  border: 1px solid #DCDFE6;
  background-color: #fff;
  color: #374151;
}
 
.active {
  border-color: #3680fa;
}
 
.right {
  background-color: #67C23A !important;
  color: #fff !important;
}
 
.wrong {
  background-color: #F56C6C !important;
  color: #fff !important;
}
</style>