yuedu.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.stTypeId == 1">
  14. <!-- 单选 -->
  15. <danxuan :question="item" :key="item.stId"></danxuan>
  16. </template>
  17. <template v-if="item.stTypeId == 2">
  18. <!-- 多选 -->
  19. <duoxuan :question="item" :key="item.stId"></duoxuan>
  20. </template>
  21. <template v-if="item.stTypeId == 3">
  22. <!-- 判断 -->
  23. <panduan :question="item" :key="item.stId"></panduan>
  24. </template>
  25. <template v-if="item.stTypeId == 4">
  26. <!-- 填空 -->
  27. <tiankong :question="item" :key="item.stId"></tiankong>
  28. </template>
  29. <template v-if="item.stTypeId == 5">
  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. data.content = [...question.danxuan, ...question.duoxuan, ...question.panduan, ...question.tiankong, ...
  66. question.jianda
  67. ];
  68. data.content.map((item,index) => {
  69. item.onlyNum = index+1;
  70. return item
  71. })
  72. Emits('yudu-change', data.content[0])
  73. }, {
  74. immediate: true
  75. })
  76. function onSwitchChange(e) {
  77. console.log('eeee', e.detail,data.content[e.detail.current])
  78. Emits('yudu-change', data.content[e.detail.current])
  79. }
  80. </script>
  81. <style lang="scss">
  82. .yuedu-option-box{
  83. height: calc(100vh - 500rpx);display: flex;flex-direction: column;
  84. .swiper-box{flex: 1;}
  85. .swiper-item-content{overflow-y: auto;}
  86. }
  87. </style>