yuedu.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view v-if="question" class="phone-yuedu-box">
  3. <view class="phone-shiti-question">
  4. <view class="question-num">{{question.onlyNum}}、</view>
  5. <!-- 题干区域 -->
  6. <!-- <rich-text :nodes="question.name"></rich-text> -->
  7. </view>
  8. <!-- 选项区域 -->
  9. <view class="yuedu-option-box">
  10. <swiper class="swiper-box" @change="onSwitchChange" :current="swiperDotIndex">
  11. <swiper-item v-for="(item,index) in data.content" :key="index" class="swiper-item-content">
  12. <view class="swiper-item" :class="'swiper-item' + index" style="background-color: #ccc;">
  13. <template v-if="item.type == 'danxuan'">
  14. <!-- 单选 -->
  15. <danxuan :question="item" :key="item.stId"></danxuan>
  16. </template>
  17. <template v-if="item.type == 'duoxuan'">
  18. <!-- 多选 -->
  19. <duoxuan :question="item" :key="item.stId"></duoxuan>
  20. </template>
  21. <template v-if="item.type == 'panduan'">
  22. <!-- 判断 -->
  23. <panduan :question="item" :key="item.stId"></panduan>
  24. </template>
  25. <template v-if="item.type == 'tiankong'">
  26. <!-- 填空 -->
  27. <tiankong :question="item" :key="item.stId"></tiankong>
  28. </template>
  29. <template v-if="item.type == 'jianda'">
  30. <!-- 简答 -->
  31. <jianda :question="item" :key="item.stId"></jianda>
  32. </template>
  33. </view>
  34. </swiper-item>
  35. </swiper>
  36. </view>
  37. </view>
  38. </template>
  39. <script setup>
  40. import {
  41. reactive,
  42. watch,
  43. ref
  44. } from 'vue';
  45. import danxuan from "@/components/questions/danxuan.vue";
  46. import duoxuan from "@/components/questions/duoxuan.vue";
  47. import tiankong from "@/components/questions/tiankong.vue";
  48. import panduan from "@/components/questions/panduan.vue";
  49. import jianda from "@/components/questions/jianda.vue";
  50. const props = defineProps({
  51. question: {
  52. type: Object,
  53. },
  54. showError: {
  55. type: Boolean,
  56. default: false
  57. }
  58. })
  59. const data = reactive({
  60. content: []
  61. })
  62. const Emits = defineEmits(['yudu-change'])
  63. const swiperDotIndex = ref(0);
  64. watch(() => props.question, (question) => {
  65. const danxuanlist = question.danxuan.forEach(item => item.type = 'danxuan')
  66. const duoxuanlist = question.duoxuan.forEach(item => item.type = 'duoxuan')
  67. const panduanlist = question.panduan.forEach(item => item.type = 'panduan')
  68. const tiankonglist = question.tiankong.forEach(item => item.type = 'tiankong')
  69. const jiandalist = question.jianda.forEach(item => item.type = 'jianda')
  70. data.content = [...question.danxuan, ...question.duoxuan, ...question.panduan, ...question.tiankong, ...
  71. question.jianda
  72. ];
  73. data.content.map((item,index) => {
  74. item.onlyNum = index+1;
  75. return item
  76. })
  77. Emits('yudu-change', data.content[0])
  78. }, {
  79. immediate: true
  80. })
  81. function onSwitchChange(e) {
  82. console.log('eeee', e.detail,data.content[e.detail.current])
  83. Emits('yudu-change', data.content[e.detail.current])
  84. }
  85. </script>
  86. <style lang="scss">
  87. .yuedu-option-box{
  88. height: calc(100vh - 500rpx);display: flex;flex-direction: column;
  89. .swiper-box{flex: 1;}
  90. .swiper-item-content{overflow-y: auto;}
  91. }
  92. </style>