yuedu.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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">
  12. {{item}}
  13. <view class="swiper-item" :class="'swiper-item' + index" style="height: 300rpx;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. .swiper-item {
  81. height: 200px;
  82. }
  83. </style>