ques.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="ques-content">
  3. <view class="ques-content-tit" v-show="openCommentStatus!=1">问答题</view>
  4. <view v-for="(item,index) in quesList" :key="index">
  5. <view class="ques-title">
  6. <text>{{index + 1}}.</text>
  7. <view class="ques-type" v-show="item.type == 1 || item.type == 2">
  8. {{item.type == 1 ? '单选' : item.type == 2 ? '多选' : ''}}
  9. </view>
  10. <text>{{item.title}}</text>
  11. </view>
  12. <view :class="isAnswer(item,option.name) ?'ques-option ques-option-active':'ques-option'"
  13. v-for="(option,idx) in item.questionOption" :key="idx" @click="handleAnswer(item,option)">
  14. <view>
  15. {{numberToLetter(idx)}}.
  16. </view>
  17. <view>{{option.name}}</view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. props: ['quesList','openCommentStatus'],
  25. data() {
  26. return {
  27. }
  28. },
  29. computed: {
  30. isAnswer() {
  31. return (item, name) => {
  32. if (item.type == 1) {
  33. return item.answer == name
  34. } else if (item.type == 2) {
  35. const array = item.answer.split(',')
  36. return array.some(i => i == name)
  37. } else {
  38. return false
  39. }
  40. }
  41. }
  42. },
  43. methods: {
  44. numberToLetter(num) {
  45. // 将数字转换为字母的 ASCII 码
  46. let letterCode = num + 65;
  47. // 将 ASCII 码转换为大写字母
  48. let letter = String.fromCharCode(letterCode);
  49. return letter;
  50. },
  51. handleAnswer(item, option) {
  52. const param = {
  53. item,
  54. option
  55. }
  56. this.$emit("handleAnswer", param)
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang="scss" scoped>
  62. @mixin u-flex($flexD, $alignI, $justifyC) {
  63. display: flex;
  64. flex-direction: $flexD;
  65. align-items: $alignI;
  66. justify-content: $justifyC;
  67. }
  68. .ques-content {
  69. background-color: #fff;
  70. padding: 24rpx 32rpx 116rpx 32rpx;
  71. box-sizing: border-box;
  72. font-family: PingFang SC, PingFang SC;
  73. font-weight: 400;
  74. font-size: 28rpx;
  75. color: #222222;
  76. }
  77. .ques-content-tit {
  78. font-family: PingFang SC, PingFang SC;
  79. font-weight: 600;
  80. font-size: 36rpx;
  81. color: #222222;
  82. }
  83. .ques-title {
  84. margin: 48rpx 0 34rpx 0;
  85. font-weight: 500;
  86. font-size: 32rpx;
  87. white-space: normal;
  88. }
  89. .ques-type {
  90. flex-shrink: 0;
  91. min-width: 72rpx;
  92. min-height: 40rpx;
  93. padding: 0 12rpx;
  94. margin: 0 12rpx;
  95. box-sizing: border-box;
  96. background: #FF5C03;
  97. border-radius: 8rpx 8rpx 8rpx 8rpx;
  98. line-height: 40rpx;
  99. text-align: center;
  100. font-family: PingFang SC, PingFang SC;
  101. font-weight: 400;
  102. font-size: 24rpx;
  103. color: #FFFFFF;
  104. display: inline-block;
  105. }
  106. .ques-option {
  107. min-height: 88rpx;
  108. padding: 24rpx 32rpx;
  109. box-sizing: border-box;
  110. margin-bottom: 24rpx;
  111. background: #F5F7FA;
  112. border-radius: 16rpx 16rpx 16rpx 16rpx;
  113. display: flex;
  114. align-items: center;
  115. &-active {
  116. color: #FF5C03 !important;
  117. background: #FCF0E7 !important;
  118. }
  119. }
  120. </style>