yuedu.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. {{item}}
  13. <view class="swiper-item" :class="'swiper-item' + index" style="background-color: #ccc;">
  14. <template v-if="item.stTypeId == 1">
  15. <!-- 单选 -->
  16. <danxuan :question="item" :key="item.stId"></danxuan>
  17. </template>
  18. <template v-if="item.stTypeId == 2">
  19. <!-- 多选 -->
  20. <duoxuan :question="item" :key="item.stId"></duoxuan>
  21. </template>
  22. <template v-if="item.stTypeId == 3">
  23. <!-- 判断 -->
  24. <panduan :question="item" :key="item.stId"></panduan>
  25. </template>
  26. <template v-if="item.stTypeId == 4">
  27. <!-- 填空 -->
  28. <tiankong :question="item" :key="item.stId"></tiankong>
  29. </template>
  30. <template v-if="item.stTypeId == 5">
  31. <!-- 简答 -->
  32. <jianda :question="item" :key="item.stId"></jianda>
  33. </template>
  34. </view>
  35. </swiper-item>
  36. </swiper>
  37. </view>
  38. </view>
  39. </template>
  40. <script setup>
  41. import {
  42. reactive,
  43. watch,
  44. ref
  45. } from 'vue';
  46. import danxuan from "@/components/questions/danxuan.vue";
  47. import duoxuan from "@/components/questions/duoxuan.vue";
  48. import tiankong from "@/components/questions/tiankong.vue";
  49. import panduan from "@/components/questions/panduan.vue";
  50. import jianda from "@/components/questions/jianda.vue";
  51. const props = defineProps({
  52. question: {
  53. type: Object,
  54. },
  55. showError: {
  56. type: Boolean,
  57. default: false
  58. }
  59. })
  60. const data = reactive({
  61. content: []
  62. })
  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. }, {
  73. immediate: true
  74. })
  75. function onSwitchChange(e) {
  76. console.log('eeee', e)
  77. }
  78. </script>
  79. <style lang="scss">
  80. .yuedu-option-box{
  81. height: calc(100vh - 500rpx);display: flex;flex-direction: column;
  82. .swiper-box{flex: 1;}
  83. .swiper-item-content{overflow-y: auto;}
  84. }
  85. </style>